What the research says about writing a CLAUDE.md

A CLAUDE.md changes what a coding agent does. The stud­ies I read say it doesn’t change how many tasks the agent solves.

I keep one repo for the setup my agents run in. This week I wanted to add a line to its CLAUDE.md saying the project’s goal is to imple­ment the most robust and recent tech­niques for build­ing AI harnesses. First I went look­ing for what has been mea­sured about these files.

Three studies, one answer

StudyWhat they ranWhat they found
Gloaguen et al., ETH Zurich (preprint, latest version 29 September 2026)300 SWE-bench Lite tasks, plus 138 tasks from 12 smaller Python repos whose developers wrote their own context files. Four agents, Claude Code with Sonnet 4.5 among themNo general improvement in task success, and over 20% more inference cost
Khatri (preprint, July 2026)Claude Code and Codex on 17 tasks from 3 repos whose AGENTS.md files rated Good or Excellent, 288 runs scored against hidden testsNo measurable change in correctness, bounded to within 10–15 points
Lulla et al. (workshop paper, January 2026)Codex only, 124 merged pull requests from 10 repos, with and without the repo’s AGENTS.mdMedian runtime 28.6% lower, output tokens 16.6% lower, similar completion

They dis­agree on cost, from 20% more to 17% fewer tokens. They agree that the file doesn’t decide whether the task gets solved. Khatri’s look at the fail­ures explains why: “agents fail on imple­men­ta­tion skill — fea­ture design, pat­tern selec­tion, exact wiring — not miss­ing repos­i­tory knowl­edge that a con­text file could supply.”

Two details from the ETH paper. Files writ­ten by the repo’s own devel­op­ers beat LLM-generated ones by 7 points, and they helped three of the four agents. The fourth was Claude Code. The paper also soft­ened between versions. In February the abstract said con­text files “tend to reduce task suc­cess rates”. By June it said they do “not gen­er­ally improve” them. If you have seen “AGENTS.md makes agents worse”, that is the first ver­sion talking.

The agent follows it, and pays for it

The flat results don’t come from agents ignor­ing the file. When a con­text file men­tioned uv, agents used it 1.6 times per task. When it didn’t, fewer than 0.01 times. With a developer-written file they took 3.34 more steps on average. With a gen­er­ated file, GPT-5.2 spent 22% more rea­son­ing tokens.

A line in a CLAUDE.md isn’t free even when it’s harm­less, because the agent acts on it. Anthropic’s test for each line, “Would remov­ing this cause Claude to make mis­takes?”, reads dif­fer­ently once you know that.

Where a file earns its lines

The same paper con­cludes that the files are “useful for spec­i­fy­ing non-standard coding prac­tices”. That matches the one big effect I found. Vercel tested agents on Next.js 16 APIs that aren’t in the models’ train­ing data:

It’s a vendor’s own eval with no sta­tis­tics, but the direc­tion makes sense: a file helps with what the agent can’t get from the repo or from training.

When the ETH team deleted every Markdown file and docs/ folder from the repos, the gen­er­ated con­text files started to help, by 2.7% on average. A gen­er­ated file only pays where noth­ing else doc­u­ments the repo.

The overview doesn’t help

Eight of the 12 developer-written files in the ETH bench­mark had a code­base overview. The ver­dict: “con­text files, even developer-provided ones, are not effec­tive at pro­vid­ing a repos­i­tory overview.” The agent finds its way around the repo anyway. A one-line pointer to the README does the job of a tour of every folder.

Fewer instructions, the important ones first

IFScale, a 2025 bench­mark, gave 20 models a report to write under as many as 500 key­word instruc­tions at once. Accuracy, by number of instruc­tions, with the Claude models run with­out thinking:

Model50100250500
o3 (high)99.698.297.862.8
gemini-2.5-pro-preview99.698.484.868.9
claude-sonnet-498.094.477.242.9
claude-opus-410094.667.944.6

The rea­son­ing models held near-perfect through 150 or more instruc­tions, then fell. Claude Sonnet 4 declined steadily from the start. Models mostly dropped instruc­tions out­right rather than half-following them, and favoured the ones that came first.

These are 2025 models, noth­ing from the Claude 4.5 or 5 gen­er­a­tion, on a syn­thetic writ­ing task rather than agents in a code­base, and the paper gives no line count for a CLAUDE.md. The “150–200 instruc­tions” and “under 300 lines” you will see quoted come from a prac­ti­tioner blog’s read­ing of this paper.

Wording mat­ters too. In the Vercel eval, “You MUST invoke the skill” did worse than “Explore project first, then invoke skill”.

What nobody has tested: the purpose line

No study I found tests a pur­pose or mis­sion state­ment: whether “use the most recent tech­niques” or “write high-quality code” helps, does noth­ing, or sends the agent off doing more than it was asked. There is only opin­ion, and it points one way. Anthropic’s context-engineering post names “vague, high-level guid­ance that fails to give the LLM con­crete sig­nals for desired out­puts or falsely assumes shared con­text” as one of two fail­ure modes.

So I didn’t write the mis­sion line. “Most recent” and “most robust” pull against each other, since a new tech­nique is the least proven one, and an agent left to weigh the two will lean toward what­ever suits the task in front of it. The stud­ies say it would follow the line. Here is what went in instead:

CLAUDE.md

It is the harness Stan’s agents run in: every Claude Code session on the Mac and, through hermes/, the agents on the box. Keep it current with the field, and adopt a technique once it has been measured to work here. Until then a new technique is undecided work, so it goes in docs/roadmap.md with a line on how we would test it.

The second half is the kind of line the evi­dence sup­ports: con­crete, spe­cific to this repo, checkable. The first half is untested. I kept it because it gives the reason for the rule, which Anthropic’s prompt­ing guide recommends.

How I write one now

My own global CLAUDE.md, the one that loads into every ses­sion, is 368 lines. It’s next.

What this doesn’t cover