1. The Silent Regression Problem: Prompts Are Production Code
Engineering teams treat Python and TypeScript modules with strict discipline—unit tests, static type checking, and required CI status checks before merge. Yet the files that actually steer how Claude Code reasons, selects tools, and delegates to subagents—CLAUDE.md, .claude/commands/, and MCP server JSON schemas—routinely land on main with zero automated verification.
When you tweak a rule in CLAUDE.md or rename a parameter in an MCP tool description, traditional CI passes 100% green while agent reliability quietly collapses across four failure modes:
- Instruction Override & Policy Drift: Adding a "be concise" directive or new repo convention inadvertently overrides an earlier safety constraint, causing the agent to skip test verification or bypass pre-commit checks.
- MCP Tool-Selection Confusion: Renaming an MCP tool field or expanding a docstring causes Claude Code to misroute calls to
Bashinstead of your structured MCP server, breaking deterministic guardrails. - Subagent Handoff Breakage: Updating a slash command in
.claude/commands/alters the structured brief passed to subagents, silently dropping required context or output schemas. - Token Efficiency Bloat: An innocent 400-token addition to
CLAUDE.mdor a verbose MCP schema inflates every turn's prompt cache and triggers unnecessary tool-call loops—doubling API spend without changing a single line of application code.
CLAUDE.md, slash commands, MCP tool schemas, and subagent trajectories—at $0.00 per PR run.
2. Architecture: Offline $0.00 Trajectory Evals & CI Gates
Running live LLM calls on every pull request is slow, non-deterministic, and expensive. claude-code-eval separates offline deterministic trajectory verification from optional live-model sampling, using recorded JSONL fixtures and a local mock MCP/tool harness to validate every PR in seconds:
Instead of guessing whether a prompt edit improved or broke your workflow, the CI runner evaluates every trajectory fixture against hard invariants: expected tool-call sequences, valid MCP argument schemas, forbidden command patterns, and token-budget ceilings.
3. Four Core Primitives of claude-code-eval
1. Offline $0.00 Trajectory Replay
Every benchmark suite lives as versioned JSONL trajectory fixtures under evals/suites/. During offline replay, claude-code-eval injects your updated CLAUDE.md, slash commands, and MCP tool definitions into a deterministic local harness. It verifies schema bindings, rule precedence, forbidden tool patterns, and replay assertions with zero external network calls—costing literally $0.00 per CI run.
2. pass@k & Token Efficiency Scoring
Single-run anecdotes hide flakiness. When running stochastic or multi-seed suites, claude-code-eval computes pass@1 and pass@k across N trials alongside a Token Efficiency Ratio (comparing input/output token deltas against the main baseline). A PR that maintains accuracy while burning 35% more tokens is flagged immediately before merge.
3. --min-pass-rate CI Gates
In GitHub Actions, claude-code-eval acts as a hard status check. Passing --min-pass-rate 0.95 and --max-token-regression 1.15 guarantees that no prompt, MCP schema, or subagent change can merge if reliability drops below 95% or token overhead spikes above 15%.
4. Cryptographic SHA-256 Evaluation Receipts
Passing CI should leave an immutable audit trail. Every successful run writes a canonical JSON receipt (eval-receipt.json) containing the commit SHA, SHA-256 hashes of CLAUDE.md and MCP schemas, per-suite pass@k scores, token efficiency metrics, and a top-level receipt_sha256 digest.
4. Wiring claude-code-eval in GitHub Actions
Add a dedicated workflow file at .github/workflows/claude-eval.yml so every PR touching agent configuration files automatically runs the offline benchmark gate:
name: Claude Code Eval Gate
on:
pull_request:
paths:
- "CLAUDE.md"
- ".claude/**"
- "mcp/**"
- "evals/**"
jobs:
offline-trajectory-eval:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install claude-code-eval
run: pip install claude-code-eval
- name: Run Offline $0.00 Trajectory Suite & Enforce Gate
run: |
claude-code-eval run \
--suite evals/suites/core-workflows.jsonl \
--mode offline \
--k 3 \
--min-pass-rate 0.95 \
--max-token-regression 1.15 \
--receipt-out artifacts/eval-receipt.json
- name: Upload SHA-256 Evaluation Receipt
if: always()
uses: actions/upload-artifact@v4
with:
name: claude-eval-receipt
path: artifacts/eval-receipt.json
5. Inside the Evaluator: pass@k, Token Efficiency & SHA-256 Receipts
Below is the core deterministic scoring and receipt-generation logic in Python. Given trajectory outcomes, it computes unbiased pass@k, validates the --min-pass-rate threshold, checks token efficiency against baseline, and seals the result with a canonical SHA-256 digest:
import hashlib
import json
import math
import sys
from pathlib import Path
def compute_pass_at_k(n: int, c: int, k: int) -> float:
"""Unbiased estimator for pass@k given n samples and c passing runs."""
if n - c < k:
return 1.0
return 1.0 - math.comb(n - c, k) / math.comb(n, k)
def evaluate_suite_and_emit_receipt(
results: list[dict],
config_paths: list[Path],
k: int = 3,
min_pass_rate: float = 0.95,
receipt_path: Path = Path("artifacts/eval-receipt.json"),
) -> int:
total_cases = len(results)
passed_cases = sum(1 for r in results if r["passed"])
pass_rate = passed_cases / total_cases if total_cases else 0.0
pass_at_k_scores = [
compute_pass_at_k(r["n_trials"], r["n_passed"], k) for r in results
]
mean_pass_at_k = sum(pass_at_k_scores) / len(pass_at_k_scores) if pass_at_k_scores else 0.0
total_tokens = sum(r["tokens_used"] for r in results)
baseline_tokens = sum(r["baseline_tokens"] for r in results)
token_ratio = total_tokens / baseline_tokens if baseline_tokens else 1.0
input_hashes = {
str(p): hashlib.sha256(p.read_bytes()).hexdigest()
for p in sorted(config_paths)
if p.exists()
}
payload = {
"mode": "offline",
"cost_usd": 0.00,
"total_cases": total_cases,
"passed_cases": passed_cases,
"pass_rate": round(pass_rate, 4),
f"pass@{k}": round(mean_pass_at_k, 4),
"token_efficiency_ratio": round(token_ratio, 4),
"input_hashes": input_hashes,
"gate_passed": pass_rate >= min_pass_rate,
}
canonical = json.dumps(payload, sort_keys=True, separators=(",", ":")).encode("utf-8")
payload["receipt_sha256"] = hashlib.sha256(canonical).hexdigest()
receipt_path.parent.mkdir(parents=True, exist_ok=True)
receipt_path.write_text(json.dumps(payload, indent=2) + "\n", encoding="utf-8")
return 0 if payload["gate_passed"] else 1
if __name__ == "__main__":
sample_results = [
{"id": "mcp-schema-route", "n_trials": 3, "n_passed": 3, "passed": True, "tokens_used": 1420, "baseline_tokens": 1500},
{"id": "subagent-brief-gate", "n_trials": 3, "n_passed": 3, "passed": True, "tokens_used": 1890, "baseline_tokens": 1950},
]
exit_code = evaluate_suite_and_emit_receipt(
sample_results,
[Path("CLAUDE.md")],
)
sys.exit(exit_code)
6. Comparison: Unverified Prompt Edits vs. claude-code-eval
| Evaluation Dimension | Unverified CLAUDE.md & MCP Edits |
Benni-OS/claude-code-eval |
|---|---|---|
| PR Verification Cost | Manual spot-checks or expensive ad-hoc runs | $0.00 offline deterministic trajectory replay |
| Reliability Metric | "Looks good to me" vibes on one prompt | Quantified pass@1 and pass@k across suites |
| Token & Cost Drift | Discovered weeks later on API invoice | Token Efficiency Ratio checked on every PR |
| Merge Enforcement | Broken rules and MCP schemas land on main |
Hard --min-pass-rate gate in GitHub Actions |
| Auditability | No proof of which prompt version passed | Immutable SHA-256 evaluation receipt JSON |
Stop Merging Blind Prompt & MCP Changes
Deploy Benni-OS/claude-code-eval to benchmark CLAUDE.md, .claude/commands/, and MCP tool schemas at $0.00 in GitHub Actions with pass@k gates and SHA-256 receipts.
Frequently Asked Questions
CLAUDE.md rules, .claude/commands/ workflows, and MCP tool JSON schemas act as executable control-plane code for your coding agent. Standard unit tests and linters never parse prompt instructions or tool descriptions, so a subtle wording conflict or renamed parameter silently causes tool-selection drift, skipped safety gates, or 2× token bloat in production.claude-code-eval records and replays deterministic JSONL trajectory fixtures—capturing prompt state, tool call sequences, MCP payloads, and expected repository diffs—using a local mock runtime. In CI, it validates rule compliance, tool-call ordering, schema invariants, and token efficiency without making live LLM API calls, keeping PR checks at $0.00.pass@k measures the probability that at least one of k sampled agent trajectories satisfies every deterministic assertion (tests passing, expected tool sequence, and budget ceiling). Setting --min-pass-rate 0.95 in GitHub Actions blocks any pull request that drops agent reliability below 95%.CLAUDE.md and MCP schema inputs, pass@k metrics, token efficiency delta, and a deterministic SHA-256 digest. Teams can archive or verify receipts to prove a merged prompt or MCP change passed its exact evaluation gate.