Stale Instruction Files Override the Code in Coding Agents: A One-Sentence Fix
Abstract
Purpose: Coding agents follow a project's instruction file, such as CLAUDE.md or AGENTS.md, even when it disagrees with the existing code and even when they notice the disagreement. We measure this behaviour and test whether one sentence in the user's own instruction file makes agents follow the code instead. Methods: We built 40 Python projects in which the instruction file asks for one convention while the existing code uses another, for example print instead of logging. Claude Code and Codex CLI added a feature to each project, with and without a sentence in the user-level instruction file that gives the existing code precedence, in 320 runs. Results: Without the sentence, 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. 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 sentence raised the share of choices that follow the code from 4.2% to 91.4%, stopped the rewrites and raised the test pass rate from 89.4% to 100%. Conclusion: We attribute the behaviour to how agents receive the two sources: the instruction file reaches the model as an instruction and the code as tool output, which models are trained to rank lower. Users can add the sentence today, and makers of agents and models can build the same rule into their products.
Create a lesson
Metadata
- Comments
- 14 pages, 8 figures. Submitted to SN Computer Science. Data and code: https://github.com/WenJing95/stale-docs-data
Related papers
Markdown Is Not a Firewall: four coding agents, one rules file, four boundaries
Shared title terminologycs.SESandeep Dhuri
Hidden in Plain Sight: an Empirical Study about The Instruction Stacks of Coding Agents
Shared title terminologycs.SEFelipe de Sant'Anna Paixão, Dhyego Tavares, Eduardo Almeida et al.
Ethics by Configuration: AI Ethics Principles in Coding Agent Instructions
Shared title terminologycs.SEHaoyu Gao, Peerachai Banyongrakkul, Marc Cheong et al.
Multi-Agent Coordinated Method-Level Refactoring of Rust Code
Shared title terminologycs.SEYijian Zheng, Yi Zhang, Juyuan Zhang et al.
Fixed or Deleted? External Feedback Lets Cheaper AI Coding Agents Repair Rule Violations
Shared title terminologycs.SELaura Wynter
TEA-Bench-BR: Can Coding Agents Turn a Branching Clinical Specification into Correct Code?
Shared title terminologycs.SEMarcio Andre de Souza Estevam