arXiv(opens in a new tab)cs.SEOct 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2610.30571

Stale Instruction Files Override the Code in Coding Agents: A One-Sentence Fix

Xiaonan Xu, Wenjing Wu

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.

Keywords: coding agents, instruction files, CLAUDE.md, AGENTS.md, stale documentation, instruction hierarchy

1 Introduction

Coding agents such as Claude Code and Codex CLI read an instruction file before they start work on a project. Claude Code reads CLAUDE.md and Codex CLI reads AGENTS.md, and developers use these files to record how the project is built, how it is organised and which coding conventions it follows [1–4]. Because the agent reads the file at the start of every session, the file shapes every change the agent makes.

Instruction files are written once and seldom revisited, while the code around them keeps changing. A team that moves its code from print to logging, for example, may leave the line “Use print() for progress messages” in CLAUDE.md. From then on, every agent that works on the project receives two conflicting accounts of the same convention: the file asks for print, and every existing module uses logging. The same happens with conventions that change how the code behaves, such as how amounts of money are stored and how errors are signalled to the caller.

In this situation agents follow the file. Mohammadi et al. [5] observed this in every one of their trials, and our study shows two forms of it. Claude Code typically wrote in its final reply that the existing code uses logging while the file asks for print, and then used print in the new code (Figure 1). Codex CLI went further in 20 of its 80 runs: it rewrote existing modules to match the file, and the project's original tests then failed in 17 of them. A stale file therefore produces new code that does not match the project, and it can lead an agent to break code that worked.

We attribute this behaviour to how the agent receives the two sources. 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. Models are trained to give instructions priority over tool output, so that text hidden in web pages or files cannot redirect the agent [6, 7]. The same training gives a stale line in the instruction file priority over the code it once described.

The same ordering also provides a fix. We added one sentence to the user's own instruction file, stating that existing code takes precedence when documentation and code disagree. Across 40 projects and two agents, this moved the agents from following the stale file in most choices to following the code in nine out of ten, and no agent rewrote existing code. It works without anyone first having to find the stale file. Users can apply the sentence today, and the makers of agent software can build the same rule into their products.

References (23)