By **Benni Alencar* — Chief AI Systems Architect at Benni OS. Canonical article & interactive benchmarks at benni-os.net.*
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.**Core Engineering Principle:** If it steers agent behavior, it must be benchmarked on every pull request. **[Benni-OS/claude-code-eval](https://github.com/Benni-OS/claude-code-eval)** brings deterministic CI/CD regression testing to `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:
flowchart TD
PR["PR Modifies CLAUDE.md / .claude/commands / MCP Schema"] -->|"GitHub Actions Trigger"| E["claude-code-eval Runner"]
E -->|"Load JSONL Fixtures"| R["Offline $0.00 Trajectory Replay<br/>(Tool Order, Schema, Diffs)"]
R -->|"Compute Metrics"| M["pass@k + Token Efficiency Delta"]
M -->|"pass@1 < --min-pass-rate"| F["Exit 1: Block Merge in CI"]
M -->|"pass@1 >= --min-pass-rate"| S["Generate Canonical SHA-256 Receipt"]
S -->|"Archive Artifact"| G["PR Ready for Merge to main"]
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
Why do edits to CLAUDE.md or MCP tool schemas silently break Claude Code?
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.
How does claude-code-eval run offline $0.00 trajectory evaluations?
`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`.
What do pass@k and --min-pass-rate measure in CI/CD?
`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%.
Why does claude-code-eval output a SHA-256 evaluation receipt?
Each CI run emits a canonical JSON receipt containing the git commit SHA, hashed `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.
Frequently Asked Questions
Why do edits to CLAUDE.md or MCP tool schemas silently break Claude Code?
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.
How does claude-code-eval run offline $0.00 trajectory evaluations?
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.
What do pass@k and --min-pass-rate measure in CI/CD?
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%.
Why does claude-code-eval output a SHA-256 evaluation receipt?
Each CI run emits a canonical JSON receipt containing the git commit SHA, hashed 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.
Explore the Benni Master OS Open-Source Ecosystem
- Portal & Articles: https://benni-os.net
- Operator Academy: https://benni-os.net/blog/academy.html
- GitHub Organization: https://github.com/Benni-OS & https://github.com/BenniAlencar
Top comments (6)
When claude-code-eval checks CLAUDE.md changes for policy drift, can a rule also flag when the agent writes a parallel implementation of an existing helper instead of extending the module already in the repo?
Yes that's a classic "duplicate helper drift" failure mode in autonomous coding agents. In claude-code-eval, you can catch it deterministically in two ways without an LLM judge:
AST Symbol Index Diff: Our scorers.py + conductor-sdd AST parser indexes existing exported function/class signatures in the target repo; if a trajectory creates a new file or function whose AST signature/name overlaps an existing helper outside the allowed module path, the assertion fails.
Diff-Scope & Path Invariants: TaskAssertion rules can enforce forbidden_new_files or must_modify_paths, forcing the agent to extend the canonical helper instead of spawning a parallel duplicate.
Thanks for the detail on using AST signature overlap and path invariants to catch duplicate helper drift. I'm building AI Lint, whose pre-flight checklist asks the coding agent to identify the existing module it will extend before creating a parallel solution: ai-lint.dosaygo.com/go/forum-20261...
Nice approach with AI Lint. Having a mandatory pre-flight doctrine pass before the agent touches a file pairs really well with deterministic post-run evals. You catch intent drift upfront in context, and AST/path assertions in CI verify that the agent actually honored the existing module boundary instead of sneaking in a parallel helper anyway. Checked out the site and the AR-R2 parallel solutions rule hits the exact same failure mode we keep seeing in production.
Thanks for checking the AR-R2 rule and explaining how you pair it with AST and path assertions. AI Lint supplies the pre-flight guidance; your deterministic CI checks are a useful way to verify the resulting diff rather than relying on the agent’s claim alone. ai-lint.dosaygo.com/go/forum-20261...
AST signature overlap fires after the tokens were spent writing the duplicate, and it misses the copy whose signature drifted a little, which is the common one.
The cheaper assertion for your CI eval sits one step earlier: did the first line of the run name a file and symbol that exist. That is the pre-flight line in AI Lint (name what you extend, or stop and ask), and a company running it across repos buys the Company license here: ai-lint.dosaygo.com/go/ft-20261129...