Instruction precedence
Which source a coding agent obeys when its instruction file (AGENTS.md, CLAUDE.md) and the existing code disagree. By default the file wins; one sentence in the user-level instruction file can give the code precedence.
Coding agents read two sources before they write: the project's instruction file and the code itself. When the file goes stale, the two disagree, for example the file asks for print while the code uses logging. Instruction precedence is the rule that settles which one the agent follows.
A study submitted on 22 October 2026 built 40 Python projects with exactly that conflict and ran Claude Code and Codex CLI 320 times. Without a precedence rule, 90.1% of the agents' choices (649 of 720) followed the stale file. Claude Code pointed out the conflict in 79 of 80 runs and still followed the file. Codex CLI rewrote the existing code to match the file in 20 of 80 runs, and the project's own tests then failed in 17 of them.
The authors attribute this to how the two sources arrive: the instruction file reaches the model as an instruction, and the code as tool output, “which models are trained to rank lower”.
One sentence in the user-level instruction file fixed most of it. It tells the agent that when documentation and existing code disagree, it should follow the conventions in the code and point out each inconsistency. Code-following rose from 4.2% to 91.4%, the rewrites stopped, and the test pass rate went from 89.4% to 100%. The limits: Python only, two agents, one unattended run per project, and conflict reporting judged by a model.
Instruction files are common and rarely explained: 26.3% of 22,854 active, popular GitHub repositories ship one (59.6% of the most-starred), and 74.0% of their directives give no reason.
Agents can read the code, so a stale AGENTS.md does no harm.
They read it, then follow the file: instructions outrank tool output.
Put AGENTS.md and CLAUDE.md behind code review, and add the precedence sentence to the user-level instruction file.
When you choose a coding agent, ask whether code precedence is built in or left to each developer's config.
Sources
- Xu & Wu, Stale Instruction Files Override the Code in Coding Agents: A One-Sentence Fix (arXiv 2610.30571v1) · 22 Oct 2026
- Zarzycki, What Open-Source Projects Tell Their Coding Agents: A Census of AGENTS.md and CLAUDE.md (arXiv 2610.31715) · 22 Oct 2026
- QuinRiva/loom PR #460, “Agents can read the code” rule · 26 Oct 2026