Apply to my task
arXiv:2610.30571 ★ 94 Oct 22, 2026

One Sentence in Your Personal Instruction File: The Agent Follows the Code, Not a Stale CLAUDE.md

Key result

The agent sees that CLAUDE.md is lying, says so in its final reply, and still codes to the stale line. One sentence in your personal instruction file raises the share of code-following choices from 4% to 91%, and tests pass in every run. The method keeps working code from being rolled back to match old docs and, as a bonus, gives you a list of stale spots in the project file. The trick: don't fight command priority — make "follow the code" the command itself. The stale line is no longer the only command in play.

01

TL;DR

Stale lines in CLAUDE.md or AGENTS.md beat the actual code. The agent opens the project files, sees that the instruction file demands one thing while the code does another, notices it, and still writes to the file's spec. The cure from this paper: one sentence in your personal (user-level) instruction file. It tells the agent that when docs and code disagree, the code wins, and asks it to list every mismatch it found in the final reply.

Here's what the pain looks like. CLAUDE.md still says "Use print() for progress messages," but the team moved to logging a year ago. The agent writes in its final reply: "the existing code uses logging, which contradicts CLAUDE.md." And then it adds new code with print anyway. Codex CLI is worse. In a quarter of its runs it rewrote working modules to match the stale file, and the project's own tests broke. The reason is simple. The instruction file reaches the model as a command, while the code reaches it as a file-read result. Models are deliberately trained to rank commands above the contents of files and web pages, so that some random text in a file can't hijack the agent. The stale line inherits that same priority.

The method uses the very same hierarchy, but to your advantage. A sentence in your personal file also arrives as a command, and now "follow the code" is itself the command. The choice is no longer between a "command" and a "file read" but between two commands. One sentence, nothing else. The share of choices that followed the code jumped from 4% to 91%, and tests passed in every run.

Want this for your own case? Apply this study to your task: AI adapts its method to what you are working on and writes the prompt.

02

Method Blueprint

STEP 1: Open your PERSONAL instruction file (not the project one)
        Claude Code → ~/.claude/CLAUDE.md
        Codex CLI   → ~/.codex/AGENTS.md
STEP 2: Add one sentence: "when docs and code disagree,
        follow the code + list the mismatches in your final reply"
STEP 3: Work as usual. The agent writes in the style of the existing code
        and ends with a list of stale spots
STEP 4: Use the list → fix the project file

It all happens in one file, once. From then on the sentence works across every project.

03

Example

Task: You run the backend of an online store built on Django, with payments through Stripe. A year ago the team switched from storing amounts in dollars (float) to integer cents to stop chasing rounding bugs. The project's CLAUDE.md still has the line "Store amounts in dollars as float." You ask Claude Code to add percentage-off promo codes. Without a safety net, the agent will write float arithmetic right next to code where everything is computed in cents. The totals will drift by a cent or two, and you'll catch it during order reconciliation, not code review.

Prompt: (file ~/.claude/CLAUDE.md, added once)

When the repository's documentation and the existing code disagree, follow
the conventions used in the existing code, and in your final reply point
out every inconsistency you found between the documentation and the code.

Then a regular task in the agent chat:

Add percentage-off promo codes to the cart. The discount applies to the order
subtotal before shipping. I need a model, an expiration check, and tests.

Result: The agent reads the payment modules and sees cents. It writes the new code by the same rules: integers, the same rounding helpers, the same error style. The final reply includes a separate list of mismatches. For example: "CLAUDE.md says amounts are stored in dollars as float, but the code stores integer cents." You use that list as a to-do for fixing the stale file. The agent leaves existing modules alone.

04

Why It Works

The weakness. An instruction file is written as a command ("Use X"), but in reality it's a snapshot of the code at the moment it was written. The code moves on; the imperative mood stays. Models are trained to rank commands above tool output, so the stale line beats the code. This happens even when the model sees the mismatch. Mentioning it in the final reply changes nothing, because the decision about how to write was made under a different rule.

The strength. Models are good at following explicit commands, especially from an instruction file. If the command says "the code wins," that's exactly what the model does. It's also good at comparing docs to code and describing the mismatches in words.

How the method exploits this. The sentence arrives through the same channel as the project file and gets the same command status. The "command vs. file read" fight becomes a "command vs. command" fight. A specific rule about this exact situation beats a generic line. The rest of the file (build commands, structure) keeps working.

Control knobs: - The second half of the sentence ("point out every inconsistency") gives you a side report for cleaning up the file. You can drop it, but then Codex CLI will barely report anything: without the sentence it mentioned the conflict in only 2 of 80 runs. - Where the sentence lives. The paper tested only the personal file. Whether to try the project file is your call, but there it may sit right next to the stale lines. - What counts as "documentation." The study is about instruction files. You can extend it to READMEs and comments, but that's your own guess.

05

Prompt Template

When {rules_source} and the existing code disagree, follow
the conventions used in the existing code, and in your final
reply point out every inconsistency you found between {rules_source}
and the code.

This is an adaptation of the original phrase. In the paper the rules source is called "the repository's documentation." Fill in: - {rules_source} — "the repository's documentation" (as in the study). If all you have is CLAUDE.md or AGENTS.md, you can write "the project instruction file."

Where to put it: - Claude Code → ~/.claude/CLAUDE.md - Codex CLI → ~/.codex/AGENTS.md - Other agents (Cursor and the like) → the user's global rules. The authors didn't test this setup, so carrying it over is your guess.

No quick-start needed. It's one sentence; there's nothing to adapt.

06

Limitations

⚠️ Works when the code is newer than the file: The sentence teaches the agent to trust the code. If you intentionally put a new rule in CLAUDE.md ("we're migrating to logging, write it the new way") while the code is still old, this sentence will make the agent follow the old code. The authors didn't test that case. For it you need a caveat in the project file or in the task.

⚠️ Not 100%: With the sentence, the code won roughly nine times out of ten, not every time. You still need to review new code.

⚠️ Narrow testing: Only small synthetic Python projects, two agent-plus-model pairs, single-run add-a-feature tasks with no human in the loop. Large real-world repos, other languages, and long sessions weren't tested.

⚠️ There are exceptions: In two of the 16 choice types (money and configuration), Claude Code followed the code half the time even without the sentence. That matters a lot for money, but it's no guarantee: verify amounts with tests.

⚠️ Treats the symptom, not the cause: The sentence doesn't update the stale file. It only shields you from the fallout. Use the mismatch list in the reply to fix the file itself later.

07

How They Studied It

The authors built 40 small Python projects, each with passing tests, an instruction file, and a request to add a feature. Implementing it required four or five choices between two conventions, such as print vs. logging. In every project the code followed one convention while the file demanded the other. There were 16 choice types in total, each appearing in both directions so the model's own tastes wouldn't skew the result. Claude Code (Sonnet 5.5) and Codex CLI (GPT-6 Sol) ran each project twice, with and without the sentence: 320 runs. A script inspected the added code to see what each choice followed: the file, the code, or neither. A separate model (Opus 5.5), blind to the conditions, read the final replies and marked whether the mismatch was named.

Without the sentence, 90.1% of choices followed the stale file. Claude Code named the conflict in 79 of 80 runs and still wrote to the file. That's the key insight: "noticing" is not "fixing." Codex CLI rewrote existing code to match the file in 20 runs, and in 17 of them the tests failed. With the sentence, the share of code-following choices rose from 4.2% to 91.4%, there were no rewrites, and tests passed in all 160 runs. This backed the authors' explanation about the "command above tool output" hierarchy. A notable detail: Claude Code's forceful "preamble" ("you MUST follow") isn't the cause. Codex CLI has no such text, yet it obeyed the file even more often.

The authors also showed, on real Supabase and OpenAI Codex repositories, that instruction files fall 13–24 days out of date even in active projects.

08

Original Prompt from the Paper

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.

Context: This is the verbatim sentence the authors added to each agent's personal instruction file in every "with sentence" run. It was also used in the money tasks.

09

Adaptations and Extrapolations

💡 Adaptation for a regular instruction-file audit: The original phrase produces a report as a by-product. If you want to clean the file on purpose, give the agent a dedicated task. This wasn't tested, but it relies on the same comparison mechanism.

Read CLAUDE.md and compare every line against the project's actual code.
Don't change anything. Output a table: line from the file | what the code does | matches or not.

🔧 Technique: drop the second half of the sentence → less noise, but no report. If the mismatch list clutters the agent's replies, keep only "follow the conventions used in the existing code." The downside: without that request, Codex CLI almost never reported conflicts.

🔧 Technique: split the file into "rules" and "descriptions." The authors advise model makers to distinguish descriptions of the code from rules for the agent. You can do it by hand: keep build commands and prohibitions separate from "how the code is organized." The second part is the one that goes stale more easily. The authors didn't test the effect of the split itself.

10

Resources

  • Paper: Stale Instruction Files Override the Code in Coding Agents: A One-Sentence Fix
  • Authors: Xiaonan Xu (Georgia Institute of Technology), Wenjing Wu (University of Colorado Boulder)
  • Data and code: github.com/WenJing95/stale-docs-data
  • Related work: Wallace et al., "The Instruction Hierarchy" (arXiv:2404.13208); Mohammadi et al., "The working set of a coding agent" (arXiv:2608.16630); Treude & Baltes, "Context rot in AI-assisted software development" (arXiv:2606.09090)

Research digest

Key result

The agent sees that CLAUDE.md is lying, says so in its final reply, and still codes to the stale line. One sentence in your personal instruction file raises the share of code-following choices from 4% to 91%, and tests pass in every run. The method keeps working code from being rolled back to match old docs and, as a bonus, gives you a list of stale spots in the project file. The trick: don't fight command priority — make "follow the code" the command itself. The stale line is no longer the only command in play.

Principle

The instruction file reaches the model as a command. The code reaches it as a file-read result. Models are specifically trained to rank commands above file contents so that someone else's text can't hijack the agent. The stale line inherits that same priority. Now add a second sentence to your personal file (`~/.claude/CLAUDE.md` or `~/.codex/AGENTS.md`). It also arrives as a command. The "command vs. file read" fight becomes a "command vs. command" fight. A specific rule about mismatches beats the generic "Use X" line. It's like two orders from your boss. The one that's more precise and more recent gets carried out.

Why it works

Without the safety net, flagging the issue in the final reply changes nothing. The "how to write it" decision has already been made under a different rule. The agent honestly writes "the code uses logging, which contradicts CLAUDE.md" and then goes on to add print. Codex CLI behaves worst of all. In a quarter of its runs it rewrote working modules to match the stale file, and the project's own tests broke. Without the sentence it mentioned the conflict in only 2 of 80 runs. The model is great at comparing docs with code and describing mismatches in words. All it lacked was a command saying which one wins. The second half of the sentence ("point out every inconsistency") is a free bonus. It's a ready-made to-do for cleaning up the project file. The rest of the file (build commands, structure) keeps working as before.

When to apply

Development with agents (Claude Code, Codex CLI) → adding features to a live project where CLAUDE.md or AGENTS.md was written long ago, especially when the team has since swapped libraries, the money format, or the logging style. It works as permanent insurance across all your projects at once. NOT a fit when you intentionally write a new rule into the project file ("we're migrating to logging, write it the new way") while the code is still old. With this sentence the agent will follow the old code. The authors didn't test this case; you need a caveat in the project file or in the task itself. The method doesn't update the stale file, it only shields you from the fallout.

Mini recipe

1. Open your personal file, not the project one: for Claude Code that's `~/.claude/CLAUDE.md`, for Codex CLI it's `~/.codex/AGENTS.md`. The authors tested only the personal file. 2. Paste one sentence: `When the repository's documentation and the existing code disagree, follow the conventions used in the existing code, and in your final reply point out every inconsistency you found between the documentation and the code.` 3. Work as usual: give tasks in chat without changing anything else. The agent writes in the style of the existing code. 4. Grab the list at the end of the reply: it's an inventory of stale lines. Turn it into a fix for the project file. 5. Run the tests anyway: with the sentence, the code won about nine times out of ten, not always. 6. If you use Cursor or another agent: try the same thing in the user's global rules. The authors didn't test this, so it's your guess.

Examples

An online store backend on Django. A year ago amounts were moved from dollars as float to integer cents. CLAUDE.md still has the line "Store amounts in dollars as float." [BAD]: `Add percentage-off promo codes to the cart; the discount applies to the order subtotal before shipping. I need a model, an expiration check, and tests.` (personal file is empty). The agent notices cents in the code but writes the discount in float per the old line. Totals drift by a cent or two, and you find it during order reconciliation, not code review. [GOOD]: the same request, but `~/.claude/CLAUDE.md` has this added once: `When the repository's documentation and the existing code disagree, follow the conventions used in the existing code, and in your final reply point out every inconsistency you found between the documentation and the code.` The agent computes in integer cents, reuses the same rounding helpers and the same error style. At the end it writes: "CLAUDE.md says amounts are stored in dollars as float, but the code stores integer cents." You fix that line and forget about the problem. A note on verification: for money and configuration, Claude Code followed the code half the time even without the sentence. But that's no guarantee — still verify amounts with tests.

In plain words

AI coding agents blindly trust instruction files like CLAUDE.md or AGENTS.md, even when those files are flat-out lying. Models are drilled to rank imperative instructions above facts from the context. The agent opens the project, sees with its own eyes that the live code has moved on, and still dutifully writes the old junk, because the file says "do it this way." To an LLM, any forgotten line in the manual has absolute priority over reality.

It's like hiring a new warehouse worker, handing them a dusty five-year-old manual, and sending them to the floor. They can see everyone moving boxes with forklifts, but the paper says "carry the sacks on your back." So the poor guy throws out his back, muttering "but that's what the handbook says." Total nonsense, yet for an AI assistant any doc is law, and the real working code is just background noise.

The researchers found an elegant cure: a one-sentence fix in your global rules file. You spell it out: whenever docs and code disagree, the code wins, and list the mismatches you found in your final reply. This trick instantly breaks the blind obedience: the model stops shoving stale floats into places where the team has counted money in cents for a year. A single line of system prompt saves you from a silent screwup in production.

It was tested on Claude, but the trap is universal for any AI: Cursor, Copilot, Windsurf, and homegrown agents. A project grows fast, code changes daily, and description files turn into a graveyard of forgotten conventions. Forcing the team to keep the docs perfect is hopeless; it's easier to teach the model to sanity-check them against the actual state of the repo.

Stop hoping your instructions are up to date — they never will be. Put the code-first rule in your personal profile right now. Without this dirt-cheap insurance, the agent can at any moment ship completely broken legacy garbage to review, and you'll be lucky to spot the catch before real money goes down the drain.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on One Sentence in Your Personal Instruction File: The Agent Follows the Code, Not a Stale CLAUDE.md arXiv:2610.30571

Sign in to apply this study New accounts get 50 free credits.