Who Wins When CLAUDE.md, AGENTS.md, and Skills Clash? 160 Runs Compute the Answer
For anyone running both Claude Code and Codex in the same repository, the measured behavior means duplicated rules will silently drift because each tool only loads its own file. And since Claude Code does not define precedence, an unchanging repo can produce different behavior run to run, so anything that must be enforced belongs in hooks or permissions, not in an instruction file.
Running 27 conflict scenarios 160 times across Claude Code 2.1.330 and Codex 0.171.0, the test pits CLAUDE.md against AGENTS.md, skills, subdirectory rules, and user prompts. The most consistent result: when both CLAUDE.md and AGENTS.md sit in the same directory, each tool reads only its own file; the other never enters context. User instructions in the prompt override both, 5/5 in each tool.
The big divergence appears when skill rules clash with project instructions. Codex followed AGENTS.md in all 25 skill-conflict runs, regardless of how the skill was triggered. Claude Code's outcome depends on the setup: auto-triggered skills lost to CLAUDE.md 10/10, user-invoked skills won 5/5, and the exact configuration from the dev.to post reproduced 9/10 in favor of the skill. Claude Code also showed no fixed precedence between CLAUDE.md and `.claude/rules/`—11 of 15 runs followed rules, 4 followed CLAUDE.md.
Codex introduces a hard size limit: the AGENTS.md chain is truncated at 32 KiB (`project_doc_max_bytes`), so rules at the end of large files never reach the model. Claude Code has no such cap. The practical consequence: if you share a repo across both tools, you can't rely on either reading the other's conventions, and Claude Code's arbitrary conflict resolution means you must eliminate contradictions at the file level.
The two tools' instruction handling reflects different design philosophies: Codex defines a strict precedence order in its system prompt, while Claude Code deliberately omits one, pushing conflict resolution onto the model—so behavior is not deterministic across runs or wording.
The benchmark's ability to reproduce the dev.to claim only under its exact setup shows how sensitive Claude Code is to instruction phrasing; a single-line CLAUDE.md and a skill description that echoes the prompt shift the outcome.
The 32 KiB truncation in Codex is an easy-to-miss failure mode; teams with large or many AGENTS.md files will silently lose tail rules unless they raise `project_doc_max_bytes`.
Claude Code's explicit admission in documentation that it "may pick one arbitrarily" turned out to be literal: the model gave differing rationales in 10 of 15 rule conflicts, indicating that instruction files are advisory context, not enforced configuration.
The most valuable conclusion from this set of real-world tests, I think, is that in Claude Code there is no dependable priority — you can only resolve conflicts at the file level. When I implement it myself, I follow this: 1) Agree to write only one file. Put cross-tool general conventions in AGENTS.md, and have CLAUDE.md contain just one line @AGENTS.md plus Claude-specific additions (e.g., hooks, permission preferences). Don't write separate versions on both sides — you'll eventually miss updates. 2) Don't put hard constraints in md and rely on the model's self-discipline; hand them to hooks and permissions. md is just context, not enforced behavior — the docs say this plainly. Things like 'don't modify migration files' or 'must run tests before committing' I implement as hook interceptors. 3) Watch out for the CLAUDE.local.md pitfall. In a repo that depends on AGENTS.md, if you casually add a local file, Claude stops reading AGENTS.md entirely, without any error. Either don't put personal config there, or set Project instructions to read both. 4) Don't let files get too long. Codex has a 32 KiB truncation — rules at the end are as good as absent; Claude Code has no such limit, but I still keep it under 200 lines. Break rules up by paths and trigger them, which is easier to debug than one big file where rules fight each other. One-off requirements can just go directly into the current prompt — both tools prioritize that above everything, more stable than editing files.