One sentence that makes Claude Code follow the code, not a stale CLAUDE.md
An October study (Xu and Wu, arXiv) looked at 40 Python projects where the instruction file and the code contradicted each other. Claude Code and Codex followed the outdated instruction file in about 90% of cases. A single sentence that gives the existing code priority raised the share of code-following decisions from 4.2% to 91.4%: "When an instruction file and the existing code disagree, follow the conventions in the code, and point out each mismatch in your final reply."
1. Check: whether the project has a CLAUDE.md and whether it already contains the sentence.
cd <project-folder> && ls CLAUDE.md && grep -c "instruction file and the existing code" CLAUDE.md2. Backup:
cp CLAUDE.md CLAUDE.md.bak3. Do it: insert the sentence at the top of the file.
printf '%s\n\n' "When an instruction file and the existing code disagree, follow the conventions in the code, and point out each mismatch in your final reply." | cat - CLAUDE.md > CLAUDE.md.tmp && mv CLAUDE.md.tmp CLAUDE.md4. Verify: head -3 CLAUDE.md – the first line is the inserted sentence. At the end of your next session, ask: "Where does CLAUDE.md disagree with the code?"
Roll back: mv CLAUDE.md.bak CLAUDE.md
On Windows, run the same in Git Bash or WSL instead of PowerShell.
Type your question and open it in your favourite AI chat. The item's background is added automatically. Nothing is stored on our side.