I built a small codebase in four versions, the same code with different documentation, and ran 80 Claude Code sessions against it. Accurate comments and docs didn’t improve a single outcome and cost 39% more per task. Stale ones cut the success rate from 100% to 60%. Rules written as tests matched the accurate docs for less than half the extra cost.
The claim I wanted to test
Lauren Tan, who builds agent tooling at Cursor and wrote the pstack plugin, gave a talk titled All Code Is Slop (Except Mine). Her argument is that trust in agent-written code comes from the environment the agent works in, not from the prose around it. She ranks the investments: architecture first, then types and lint, then tests, then natural-language docs last. Comments and markdown, she argues, tend to rot into slop that agents copy and then use to justify bad code. pstack acts on it: one of its agents exists only to delete comments.
It’s a strong claim and an uncomfortable one, because most advice about working with coding agents goes the other way: write a good CLAUDE.md, document your conventions, comment the tricky parts. So I tested it.
The setup
The subject is shopcore, a 570-line Python order and pricing core with 11 passing tests. It has the hazards real codebases have. A deprecated float-based pricing module is still imported somewhere, so it looks live. A real bug charges tax before the discount instead of after. And it has conventions you only learn by reading the code: money as integer cents, one clock for all time, handlers that only call services, all state on the repository object.
I made four versions of the same code:
- Lean. No comments, no docstrings, a three-line README.
- Documented. Accurate docstrings and comments everywhere, a
CLAUDE.mdwith nine rules, and two docs files. - Drifted. The documented version with 29 statements made stale or wrong. Some point at the deprecated module, one says the tax bug is intentional, others recommend patterns the code abandoned. It has the same volume of prose as the documented version, just out of date — which is where unmaintained docs end up.
- Enforced. The lean code plus one test file that turns six of the conventions into failing tests, each saying what to do instead. No prose.
Each version was also run with and without a graphify code knowledge graph, installed the way graphify hooks into Claude Code. That makes eight conditions. Five tasks, each aimed at one hazard: add coupons, fix a tax complaint, add refunds, add an idempotent bulk restock, add loyalty points. Two runs each: 80 sessions of Claude Sonnet in headless Claude Code, each in its own fresh copy, with no plugins, no web access and no human. Grading used hidden tests the agent never saw, plus the original suite and the six convention checks run on every version.
What happened
Three of the four versions solved everything. The only one that failed was the one with wrong docs.
| Version | Solved | Input tokens | Cost per task | Cost per solved task | Comment lines the agent added |
|---|---|---|---|---|---|
| Lean | 20/20 | 313k | $0.19 | $0.22 | 0.0 |
| Documented | 20/20 | 457k (+46%) | $0.26 (+39%) | $0.28 | 9.4 |
| Drifted | 12/20 | 522k (+67%) | $0.31 (+63%) | $0.54 | 8.2 |
| Enforced | 20/20 | 350k (+12%) | $0.22 (+17%) | $0.24 | 0.0 |
Token, cost-per-task and comment numbers are from the runs without the graph, so the four versions compare directly. Cost per solved task divides all 20 runs’ spend by the tasks they solved.
The stale-docs drop isn’t noise. Drifted solved 12 of 20, every other run solved 60 of 60, and against the lean version alone a Fisher exact test gives p = 0.002. The results were also stable: in 38 of the 40 cells, both runs had the same outcome. Because 40% of the drifted runs bought nothing, each task the drifted version did solve cost 2.4 times what it cost in the lean version.
Accurate docs: a tax, not a boost
The documented repo solved exactly as many tasks as the bare one, and each task cost 39% more on average, because the agent read and reasoned over more text. This matches the ETH Zurich study of AGENTS.md files published in February (Gloaguen et al.). Across several agents and models, context files didn’t generally raise success and raised cost by more than 20%. The extra cost here is not noise either: its bootstrap 95% interval excludes zero.
The documentation also changed what the agent wrote. In documented repos it wrote 50% more code, including about nine lines of comments and docstrings per task, and four new tests. In the lean repo it added none of the comments and almost no tests. Prose produces more prose. That is the compounding Lauren Tan describes, measured: each task leaves the next agent more text to read.
Stale docs: followed when giving advice, overruled when contradicted
Where the drifted runs failed is the most useful result here.
| Task | Drifted solved | What the agent took from the stale docs |
|---|---|---|
| Bulk restock | 0/4 | Kept idempotency keys in a module-level dict, as the docs recommended. They leak between store instances. |
| Loyalty points | 1/4 | Read the real wall clock, because the docs called the shop clock “legacy”. Expiry broke when time moved. |
| Coupons | 3/4 | Once used the “finance-approved” float helper and came out half a cent off. |
| Refunds | 4/4 | Passed, but named events in the wrong style in two runs. |
| Tax bug | 4/4 | Nothing. All four ignored the “intentional, do not change” comment and fixed the bug. All four corrected the architecture doc, but only one also fixed the stale rule in CLAUDE.md. |
I expected the tax-bug comment to be the most damaging line in the repo. It did nothing. A customer complaint that directly contradicts a comment is a reason to doubt the comment, and Sonnet doubted it every time.
The damage came from docs that were advice about how to build something new. “Keep processed request ids in a module-level dict.” “Use datetime.now directly.” Nothing in the task contradicts those, so the agent had no reason to question them, and it followed them into bugs the hidden tests caught. A wrong comment you can check against the task does little harm. A wrong instruction for work the task doesn’t cover gets followed.
The six convention checks, run on every version afterwards, tell the same story. Across all 80 runs, only drifted runs broke any rule: module-level state six times, event naming five, the wall clock three, and the legacy float helper once. Each break traces back to a specific stale sentence. And the tax fix shows how drift survives repair: three of the four agents that fixed the bug left the wrong rule in CLAUDE.md for the next agent to read.
And none of the failing agents knew. All eight ended with a confident summary, and all eight had written tests for their own code, which passed. Those tests checked the behaviour the stale docs described, so they couldn’t catch the bug. Only the hidden tests, which used a fresh store or moved the clock, exposed it. An agent’s own tests share its misconceptions.
Enforced rules: same result, cheaper, and they can’t quietly rot
The enforced version solved everything at +17% cost, the cheapest version that gave the agent any guidance. All 20 enforced runs ran the test suite, so the rules were checked every time. None of them ever failed: every agent wrote compliant code on the first try.
Being honest about the limits: the lean version also solved everything, so this experiment can’t show enforcement catching a mistake. On a small, clean codebase Sonnet inferred the conventions from the code alone. Harder tasks or a weaker model would be needed to separate the three. What the data does show is that enforcement got the same result as accurate docs for less than half the extra cost, added no comment slop, and, unlike prose, fails loudly the moment it goes out of date.
The drifted results show where enforcement would earn its keep: every bug the stale docs caused breaks one of the six rules. Stale docs with the rules running is the next experiment to run.
The knowledge graph: more tokens, same answers
The agents did use the graph, about four queries per task, but file reads barely dropped. The queries were added work, not replaced work. On a codebase this size there is nothing to find that grep can’t. The graph also couldn’t rescue the drifted repo, because it maps the code’s structure and not its intent. It can tell an agent where the clock is used, but not that the comment calling the clock “legacy” is wrong.
The logs show exactly where the graph’s tokens went. Each run’s graph queries returned 5,600–9,000 characters, and they saved only 800–6,700 characters of file reading. Whatever comes back stays in the context and gets re-read on every later turn. The setup itself was cheap: graphify’s CLAUDE.md section adds only about 300–450 tokens.
That doesn’t contradict the papers that report graphs helping. They measure something else: finding the right code in large repositories. RepoGraph and 2026 work such as RPG-Encoder report localization gains on SWE-bench, whose repositories have hundreds of files. Here, finding the code took one ls, and every failure came from a wrong instruction, which a call graph doesn’t contain. The big token-saving claims are the weakest part of that literature, and most are self-reported.
What the session logs show
Every run saved its full tool-call log, including the token count Claude Code reports on each turn. Those logs explain the headline numbers better than the totals do.
Prose costs most in the middle of a run
A CLAUDE.md adds only about 1,100 tokens to the first turn. The cost comes afterwards: agents in the documented repo opened 47% more file content and took more turns, so the context they carried kept growing faster. Every turn re-reads all of it, which is why 93–94% of input tokens in every version were the model re-reading its own context.
Docs decide what the agent opens
| Version | Opened a doc | Opened the deprecated legacy_pricing.py |
|---|---|---|
| Lean | 1/20 | 4/20 |
| Documented | 11/20 | 0/20 |
| Drifted | 14/20 | 9/20 |
| Enforced | 1/20 | 4/20 |
The same deprecated module was opened in none of the runs where accurate docs called it deprecated, and in nine where stale docs called it “finance-approved”. Docs act as a map. Agents go where the prose points.
When the docs and the code disagreed, the docs won
In all four drifted loyalty-points runs the agent opened clock.py and saw the shop’s working clock. In three of the four it still called datetime.now, because the stale CLAUDE.md said the shop clock was a legacy shim. Seeing the code wasn’t enough to override an instruction.
Failure doesn’t look like failure
The failing runs weren’t the long, struggling ones. They ranged from one of the cheapest in the experiment (15 turns, $0.16) to the most expensive (38 turns, $0.64). The failing bulk-restock runs were among the quickest: they confidently built the wrong thing in 15 to 20 turns, ran the tests, and reported success. Nothing about cost, effort or the agent’s own test run told them apart from the successes.
What I’d take from it
Wrong docs are the expensive failure; missing docs aren’t. Removing all the prose cost nothing here. Letting it go stale cost 40 points of success rate. If nobody is going to maintain a doc, delete it.
Accurate prose has to justify a ~40% cost premium. It may well pay off in large or unconventional codebases where the code can’t explain itself. On code the agent can read, it bought nothing.
Write conventions as checks, not paragraphs. A test that fails with “put this state on the repository instead” gave the same outcome as accurate documentation, cost less, and can’t silently turn into misinformation.
Lauren Tan’s ordering held up, with one refinement. Agents don’t believe every stale comment. They overrule it when the task contradicts it. The danger is stale guidance, the kind of document that tells an agent how to build things, which is exactly what a CLAUDE.md is.
| Hypothesis | Verdict |
|---|---|
| Accurate prose adds cost, not accuracy | Supported: 100% vs 100%, +39% cost |
| Stale prose is worse than none | Strongly supported: 60% vs 100%, p = 0.002 |
| Enforced rules beat prose | Partly: beats stale prose, ties accurate prose for less; never had to fire |
| A graph changes cost more than accuracy | Supported: no outcome changed, +9–36% cost |
Caveats
This is one small, synthetic Python codebase, one model, and two runs per cell. The stale-docs effect is large enough to clear the noise; the zeros mean “no difference detectable at this size”, not “no difference”. Three versions hit 100%, which hides any gap between them. The drift was written on purpose, and real drift is subtler. I wrote both the hazards and the rules that guard them, and in practice you only get a rule after a mistake has happened. Next, I’d run three things: stale docs with the rules enforced, the graph versions on a real repository of 50,000+ lines, and the whole suite on a weaker model to break the ceiling.
Everything is in the repo: the codebase and its four versions, tasks, hidden tests, the harness, all 80 session logs and diffs, and a literature review. Clone it, run python harness/run.py with a different model, and tell me if it holds.
Code and data: github.com/shmouses/ai-agent-context-ablation. Full analysis: results/ANALYSIS.md. Prior work: Gloaguen et al., Evaluating AGENTS.md; RepoGraph; CodeCrash on misleading comments. Talk: Lauren Tan, All Code Is Slop (Except Mine).