CLAUDE.md Ablation: Measure LLM Judge Noise Before Pruning
Ablation deletes agent instruction text only when LLM judge noise sits below the winning margin and a task covered it. Built for CLAUDE.md and AGENTS.md.
Instruction files for coding agents only grow. AGENTS.md, CLAUDE.md and similar rule files pick up a line after every surprise, and nobody removes one, because nobody can tell which lines actually help. This post walks through how one Claude Code plugin tests that by removing text and measuring the effect (an ablation), and the two checks designed to keep that test from deleting text you may need: refuse the result when the grader’s disagreement with itself reaches the winning gap, and never delete text that no test task was meant to use. A lock that fixes the gap in writing before any run keeps the first check honest.
The obvious fix is an A/B test. Run the agent on a task with the full instruction set, run it again with a trimmed set, have an LLM-as-a-judge grade both results, and delete whatever did not move the score. That test has two holes, and both of them can recommend deleting text you may need.
The first hole is the judge. An LLM grader can give different scores to the same diff on re-grade, so that noise has to be measured, not assumed away. If the judge’s disagreement with itself reaches the margin a winner must clear, the comparison is reading noise and calling it a finding.
The second hole is coverage. If no test task is declared to exercise the area a rule governs, the test never gave that rule a chance to help. A score tie on that text says nothing about whether it is needed.
When can an A/B test justify deleting CLAUDE.md text?
An A/B test can justify deleting agent instruction text only when two conditions hold: the judge’s re-grade noise sits strictly below the pre-registered winning margin, and a test task was declared to exercise that text. The earned-context scorer refuses to score when noise reaches the margin, and lists uncovered text as untested instead of deleting it.
What earned-context does: four phases
The work lives in earned-context, a Claude Code plugin with one skill, four subagents and a deterministic orchestrator. The original prompt came from Lauren (@poteto); it became a reusable skill and then this plugin. It runs in four phases:
- Inventory. A claim-auditor subagent lists what the text asserts, checked by
validate_claims.py. - Enforce. An enforcer subagent turns enforceable rules into checks.
prove_check.pyrequires each check to pass on the clean tree, fail on the violation, and not be editable by the agent. - Ablate.
ablate.pyruns the experiment with no LLM in the orchestrator, ideally in CI. A task-miner subagent builds tasks first. - Fix. A failure-analyst subagent reads what went wrong, then the enforcer runs again.
The focus here is phase 3, and specifically the scorer’s refusal rules. Phases 1 and 2 matter because they shrink what is left to ablate: a rule that became a check no longer needs to sit in the context window. The rule-versus-gate distinction is the subject of the agent failures on a team relay, where five of six failures traced to a rule nothing enforced.
The agent under test and the judge are not subagents. Each runs as its own headless claude -p process with settings and MCP isolation, plus transcript checks for leaks. Those checks detect the leak patterns they know about. They are not an operating-system sandbox.
The pre-registered ablation plan and prune rule
An ablation here is a pre-registered plan: conditions, tasks, replicates and a prune rule, written down and hash-locked before any run. The task-miner’s seed output proposed this plan shape (never locked, never run):
conditions: A keep **
B keep CLAUDE.md and docs/domain/**
C keep CLAUDE.md
order: [C, B, A] # smallest text set first
replicates: 3
prune_rule: statistic = median, margin = 2
That is a summary of the plan, not the file format. The order matters. The prune rule in common.py walks from the smallest text set upward, and a larger set only displaces the current winner if it beats it by at least the margin:
# common.py, apply_prune_rule (excerpt; docstring paraphrased as comments)
# Walk from the smallest text set upward. A larger set only displaces
# the current winner if it beats it by at least margin on the chosen statistic.
delta = s[cand] - s[winner]
earns = delta >= rule['margin']
So the default answer is “less text wins.” Extra text has to earn its place by a margin named in advance. Picking the margin after seeing results would let you tune the conclusion, which is why the lock exists.
Each run’s score blends the judge with deterministic probes, which are scripted checks against the agent’s output:
run_score = scale * (judge_weight * judge / scale + probe_weight * probe_frac)
The probes are deterministic, so they do not vary between re-grades. In the seed case, a mined task called refund-credit passed 16 of 16 probes on the base repo and 0 of 16 on the base repo plus its setup patch, and calibrate_probes.py --allow-unlocked reported OK. The setup patch is what breaks the repo so the agent has something to fix. Probes that pass on the solved state and fail on the broken one are measuring the task, not the weather.
Hole one: refusing a result when judge noise reaches the margin
Before trusting any gap, judge.py re-grades a sample of the blinded diffs (20% by default) and writes the repeat scores. score.py reads them and measures how far the judge moved. It weights that movement by the judge’s share of the run score, because a judge that counts for half the score can only move the total by half its own swing:
# score.py (reformatted)
def weighted_judge_noise(sc, grades, repeat):
return max(
(abs(row['score'] - grades[bid]['score']) * sc.get('judge_weight', 0.5)
for bid, row in repeat.items() if bid in grades),
default=0.0,
)
It takes the worst case across the re-graded sample, not the average. If the repeat file is missing, it exits 1; setting the repeat fraction to zero skips this gate entirely. Then it refuses, printing to stderr:
# score.py, main (abridged; the print goes to sys.stderr)
if judge_noise >= rule['margin']:
print(f"judge noise {judge_noise:.2f} >= margin {rule['margin']}: "
"raise probe_weight, tighten the rubric, or pre-register "
"a larger margin in a new experiment")
return 1
The comment in the source puts it plainly: if re-grading the same blinded diff moves the total by about the margin, the rule is reading noise.
A hypothetical to make the numbers concrete, on the default 0 to 10 score scale. With a margin of 2 and the default judge weight of 0.5, a judge that gives one diff 7 and then 3 on re-grade has a raw swing of 4 and a weighted noise of 2.0. That equals the margin, so the scorer exits 1 and recommends nothing. The comparison is strict on purpose. Noise equal to the margin means a winner could exist purely because the judge rolled differently.
The three ways out in the message are the real choices. Raise the probe weight so deterministic checks carry more of the score. Tighten the rubric so the judge has less room to wander. Or start a new experiment with a larger margin. Loosening the margin on the locked plan is not offered.
score.py also exits 1 on ungraded runs, and on leaks unless the plan’s allow_leaks field names the run ids (the docstring asks for a reason, but nothing enforces one).
Hole two: coverage decides what can be deleted
Each task in the plan declares exercises globs: the files it is meant to put to work. After the prune rule picks a winner, the losers are the files in the largest non-pinned condition that the winner did not keep. coverage() splits them:
# common.py, coverage (excerpt; docstring shown as comments)
def coverage(text_files, tasks):
# Untested text was never given a chance to help,
# so the prune rule can't delete it.
globs = [g for t in tasks for g in t.get('exercises', [])]
...
Covered losers go under “Delete (tested by a task and did not earn its context)”. The rest go under “Untested (no task exercises it: NOT deleted; add a task or decide by hand)”. The label says tested; read it as declared to exercise. The delete list is the covered set and nothing else (except when a pinned pre-prune condition, one built from the commit before pruning, wins; then the scorecard says restore instead of delete, see Other guards).
The exercises globs are declared in the pre-registered plan. They are not measured file reads. A task can claim to exercise docs/domain/** and never really lean on it. The declaration moves the decision into the open, where a reviewer can argue with it before the lock, but it is not proof of use.
A related trap showed up in the scorecard. Some files reach the agent’s context without the agent ever opening them, such as auto-loaded instruction files. A later fix partitions unopened files using the leak audit’s auto-load note, and the scorecard now says these files can affect context without an explicit read, so do not interpret them as unused. The auto-load note is an annotation, not runtime proof, and the absence of explicit reads is not evidence of unused context. This changes how the scorecard reports reads; the delete list is still decided by declared coverage only.
Sizing the margin with a pilot before the lock
Picking a margin that merely feels safe fails in both directions. The judge’s noise is unknown until measured, and measuring it inside the locked experiment means the result is already on the table. Suppose you choose 2 and the judge’s weighted re-grade noise comes in at 2.5: the scorer refuses after every replicate has been paid for. Choose 10 and nothing realistic can displace the smallest set, so everything a task covered gets deleted.
pilot.py answers that before the lock. It reuses the same runner, leak checks, blinding, judge and scoring formula on one dedicated pilot task. It requires at least 3 reps, exactly one task and judge repeats above zero. Among other fields, it reports:
spread run-to-run spread on the pilot task
judge_noise weighted re-grade noise
suggested_margin max(spread, judge_noise)
strict_margin_must_exceed judge_noise
Then it prints that this is an observed lower bound only: the final margin must also be strictly greater than judge noise, chosen before locking, and the pilot never prunes or modifies the plan. When judge noise is at least the spread, suggested_margin equals the noise and would itself be refused, so pick something strictly larger. If the plan already has a lock, it refuses outright with PILOT REFUSED: prereg has a lock; margin cannot be tuned after locking.
A lower bound from one task and a few reps is thin. It tells you the floor, not the ceiling. The production gate in score.py stays strict regardless of what the pilot said.
Other guards in the plan
The plan refuses to lock if the judge and the agent share the same configured model name, so the grader is not marking its own homework. It also rejects setup patches that touch the text under test, since a patch that edits CLAUDE.md would contaminate every condition. A later change lets the pre-prune condition pin its own base; if that pinned base wins, the delete list is forced empty and the scorecard emits “restore” instead, because pruning already hurt.
What ran, and what did not
The four subagents each passed one synthetic seed case. The claim-auditor ran 3 times with 100% agreement against gold labels, at 13.0 s and $0.110 per run. The enforcer passed 2 of 2 runs at 20.8 s and $0.183. The task-miner passed 2 of 2 runs at 66.9 s and $0.527. The failure-analyst passed 2 of 2 runs at 19.7 s and $0.095. Those costs are Claude CLI-reported estimates, not invoices. One seed case per agent does not establish broad reliability, and it does not establish the cheapest model or effort setting.
The test suite has 53 pytest cases passing. The pilot mechanics and the scorer gates are tested with fake agents and judges.
No full ablation of a real repository’s instructions has run. In the task-miner session, nothing was locked, no ablation ran, and the repo was untouched. The judge-noise gate has been exercised in tests, not yet on a real judge’s real swing.
On the models: the early commits were co-authored with Claude Opus 5.5. The four subagents were configured and smoke-tested on Claude Fable 5.2 through headless runs. Claude Code 2.1.335 confirmed Fable was selected but exposed no effort setting in its returned JSON or debug output, so the README calls frontmatter effort unverified. The fixes along the way were small: an auth preflight after a real empty-config auth failure, and prompt templates where JSON braces broke str.format.
Also shipped
ablate.pyruns phase 3 with stage hashing, resume and a budget cap.- A CI workflow keeps the unblinding key away from interactive sessions.
matches()no longer strips leading dots, so.githuband.cursorpaths match.- Byte budgets cap the skill at 4,500 bytes and the total at 9,300 bytes.
Frequently asked questions
Why not pick a margin that feels safe?
The judge’s noise is unknown until it is measured, and measuring it inside the locked experiment means the result is already on the table. Suppose you choose 2 and the judge’s weighted re-grade noise comes in at 2.5: the scorer refuses after every replicate has been paid for. Choose 10 and nothing realistic can displace the smallest set, so everything a task covered gets deleted. The pilot.py script measures run spread and judge noise on one task before the plan is locked.
Does an LLM judge score the same diff the same way twice?
Not reliably. Re-grading can move the score, so the scorer measures that movement instead of assuming it away. This post has no measurement from a real judge yet, only tests with fake judges. The judge step re-grades a sample of the same blinded diffs, the scorer weights the movement by the judge’s share of the run score, and keeps the worst case. If that weighted noise reaches the margin, the scorer exits 1 and recommends nothing.
Should instructions that no test task covers be deleted?
No. Each task declares the files it is meant to exercise, and only losing files inside that coverage go on the delete list. Text that no task exercises is listed as untested and is not deleted. These declarations sit in the pre-registered plan, so they are not proof that a task actually read the file.
Use this
- Before trusting any LLM-judged A/B gap, re-grade the same blinded outputs and refuse the result when the weighted re-grade swing is greater than or equal to your winning margin.
- Run a one-task pilot to measure run spread and judge noise, then set the margin strictly above the noise, but not so large that nothing can displace the smallest set, and lock it before the real experiment starts.
- Declare which files each task exercises, delete only losers inside that coverage, and list everything else as untested instead of unused.
The plugin and its scripts are at https://github.com/jeremylongshore/earned-context.