Instruction Debt in CLAUDE.md and AGENTS.md: Drift and Ballast
Published: 2026-11-28
Instruction Debt in CLAUDE.md and AGENTS.md: Drift and Ballast
If you have a CLAUDE.md or an AGENTS.md in your project, check whether it's up to date. Your agent will rely on it, even when the code says something different.
I call this debt in the agent's instructions, and I see two main kinds of it. The first is drift: the instruction file says one thing and the code says another. The second is ballast: the file is true, and it repeats what the agent can already read in the code. Both build up over time, because the code changes every week and the note stays the way we wrote it.
Drift: the note says 500, the code says 800
Say we have a module that handles shipping. Free shipping starts at 500, and that's written both in the code and in the module's CLAUDE.md. One day the business changes it to 800. Someone updates the code and nobody updates the file.
The next time anyone works on that module with an agent, there are two versions of the same rule: 500 in the note and 800 in the code. The agent adds a new promotion and tests for 500, and the tests pass.
This is what a recent preprint by Xiaonan Xu and Wenjing Wu, Stale Instruction Files Override the Code in Coding Agents: A One-Sentence Fix, measured. They built 40 Python projects where the instruction file asks for one convention and the code uses another, and ran Claude Code and Codex CLI on them, 320 runs in total. Without any extra guidance, 90.1% of the agents' choices followed the stale file. Claude Code pointed out the conflict in 79 of 80 runs and still followed the file.
The authors explain it with how the context is built. In their words, "the agent software places the instruction file in the model's context as an instruction, while the code reaches the model only as the output of a file-reading tool." So the agent sees the difference and treats the file as the rule it was given. The projects in the study are synthetic, and the situation is the same as in the shipping example.
Many of these files were written a while ago. Older models very often saved things you can read from the code, and the same happens when a file comes from /init and nobody goes through it. Every such detail is one more place where the note can drift away from the code.
Ballast: a true note that repeats the code
Even when the file is correct, a copy of the code in it has a cost. Instruction files are loaded at the start of every conversation, so at every task the agent gets extra information it could get from the code itself. That fills the context window, each conversation uses more tokens and costs more, and the space could go to something the task actually needs.
The ETH Zurich paper Evaluating AGENTS.md: Are Repository-Level Context Files Helpful for Coding Agents? by Gloaguen, Mündler-Sasahara, Müller, Raychev and Vechev looks at this from the cost side. They found that "providing context files does not generally improve task success rates, while increasing inference cost by over 20% on average." The result about success rates holds for both LLM-generated and developer-committed files. They also write that "repository overviews, although popular and recommended by model providers, are not helpful", and conclude that context files "should only contain specific additional instructions beyond what is already available in the codebase."
A copy of the code in the file also makes drift more likely. Every line copied from the code is a line someone has to update when the code changes, and from experience I know that updating documentation is the thing that always gets pushed back when time runs short.
So for each line in the file I ask one question: can the agent read this from the code? If it can, it's ballast. The project structure, the stack, the list of endpoints and the test commands usually fall into this group. I wrote more about what an agent can and can't read from code in Keep CLAUDE.md Small.
What stays in the file
What I keep in these files is domain knowledge. We aren't able to read it from the code, and it changes less often than the code does. When the agent knows the business rules of the module, it knows what the module does and what problem it solves, so it's easier for it to work toward the right goal and to check its own work.
The 500 to 800 change was a business change too, so when the requirements change, the instruction files need a look as well.
The shipping example shows how to write such a rule so it doesn't drift. The number lives in the code. The file says where the rule comes from and where the current value is:
## Shipping
- The free shipping threshold is set by the sales team and changes with pricing decisions.
- Source of truth: `FREE_SHIPPING_FROM` in `orders/shipping.ts`. Read the current value there.
When the threshold changes again, nothing in the file goes stale, and the agent still knows that the value is a business decision and where to find it.
Generated files need a reader
We can't ask the agent to generate these files and leave them without anyone reading them. The agent goes back to them every time it works on something, whether it's a new function or a change in an existing one, so whatever is written there becomes its knowledge of the project. Someone who knows the module should go through a generated file line by line, remove the ballast and add the domain knowledge the agent couldn't know.
Paying the debt in the same pull request
Instruction files belong to the code they describe, so they should change in the same pull request as that code. When a change touches a module, the author updates the module's instruction files, or confirms they don't need an update.
Code review covers these files like any other part of the change. The reviewer checks three things:
- whether the change requires an update to the instruction files,
- whether a new entry repeats what is already in the code,
- whether anything in the files now contradicts the code.
The team that owns a module also owns its files for agents. When several people work on one module or service, the module keeps changing, and its documentation has to change with it. If the instruction files sit next to the code, CODEOWNERS can assign them to the same team, so the same people review both.
The Xu and Wu paper also has a cheap safety net for the drift that gets through anyway. They add one sentence to the instruction file:
When a repository's documentation and its existing code disagree, follow the conventions used in the existing code, and in your final reply point out each inconsistency you found between the documentation and the code.
In their study this sentence raised the share of choices that follow the code from 4.2% to 91.4%, and the test pass rate from 89.4% to 100%. The list of inconsistencies in the agent's reply also shows which notes need fixing.
Know the instructions you give your agent
The agent works with the instructions you give it, so it's worth knowing what's in your CLAUDE.md or AGENTS.md and whether it still matches the code. Whenever the code or the requirements change, check whether the files need to change with them, and do it in the same pull request.