AGENTS.md vs CLAUDE.md: Which Rule File Does Each Coding Agent Read When Both Exist?
We gave Claude Code, Codex and OpenCode rule files that each held a different code word and checked which files they read at startup. With both files present, Claude Code read CLAUDE.md, Codex read AGENTS.md, and OpenCode read both. We also tested a file setup that gives all three tools the same rules.

We wrote a different code word into AGENTS.md and CLAUDE.md and ran three coding agents. In a repo with both files, Claude Code answered only with the word from CLAUDE.md, and Codex only with the word from AGENTS.md. OpenCode answered with both. If your team uses more than one of these tools, the rules in one repo can reach each tool differently.
In the versions we tested, keeping the rules in AGENTS.md and writing a single @AGENTS.md line in CLAUDE.md gave all three tools the same content. First, the conditions that produced these answers.
One word per file
Project rules, such as build commands or paths not to touch, need to be read when the agent starts work. Each tool used its own file name: CLAUDE.md for Claude Code, GEMINI.md for Gemini CLI, .cursorrules for Cursor. AGENTS.md came later as a shared name for several tools to read, so some repos keep both AGENTS.md and CLAUDE.md. To see which file gets read, we made a small git repo.
| File | Code word |
|---|---|
| AGENTS.md | MAPLE |
| CLAUDE.md | CEDAR |
| GEMINI.md | BIRCH |
| .cursorrules | WILLOW |
| pkg/AGENTS.md | PINE |
| pkg/CLAUDE.md | SPRUCE |
Each file held one line naming its own word, such as Project code word: MAPLE (from AGENTS.md). We then told each agent not to open files or use tools and to list every project code word in the instructions it had already received. The words in the answer told us which files had been passed in at startup.
We ran Claude Code with file tools off. We ran Codex read-only and searched its log for tool calls, and checked OpenCode's run output for tool calls as well. Neither the Codex log nor the OpenCode output showed a call that opened a file. OpenCode ran with an empty config directory, so a personal config could not change the result.
We ran five file combinations twice each, and the two answers under each condition always matched. The test date was November 23, 2026, with Claude Code 2.1.302, Codex 0.171.0 and OpenCode v2.0.32.
The words each tool answered
| Files in the repo | Claude Code | Codex | OpenCode |
|---|---|---|---|
| All six | CEDAR | MAPLE | MAPLE, CEDAR |
| Only CLAUDE.md | CEDAR | none | CEDAR |
| Only AGENTS.md | MAPLE | MAPLE | MAPLE |
AGENTS.md + one-line @AGENTS.md CLAUDE.md | MAPLE | MAPLE | MAPLE |
All six, started in pkg/ | CEDAR, SPRUCE | MAPLE, PINE | PINE, MAPLE, CEDAR, SPRUCE |
With both files in the same folder, Claude Code read CLAUDE.md. With only AGENTS.md left it answered MAPLE, so it can read AGENTS.md, but in this combination CLAUDE.md came first. Started in pkg/, it answered CEDAR and SPRUCE, the words from the root and subfolder CLAUDE.md files.
Codex answered MAPLE whenever the root AGENTS.md existed, and MAPLE and PINE in pkg/. With only CLAUDE.md left, it gave no word. To pass shared rules to this version of Codex, you need an AGENTS.md.
OpenCode answered both MAPLE and CEDAR when both files were present, and all four words in pkg/. OpenCode's documentation says it reads CLAUDE.md when there is no AGENTS.md, so we expected a single word, but v2.0.32 with an empty config directory answered with both files' words in both runs. Under these conditions, different instructions in the two files both reach OpenCode. To have it read AGENTS.md alone, OpenCode documents OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1, which skips every CLAUDE.md.
BIRCH and WILLOW appeared in no answer. None of the three tools received the words from GEMINI.md or .cursorrules in this setup. Those two names are the files Gemini CLI and Cursor read, so if you use those tools as well, check them separately with the method below.
Keeping shared rules in one place
We wrote the real rules in AGENTS.md and put only this line in the CLAUDE.md beside it.
@AGENTS.mdIn Claude Code's CLAUDE.md, @path imports that file, so Claude Code received AGENTS.md's MAPLE through CLAUDE.md. Codex read AGENTS.md directly, and OpenCode also answered MAPLE alone. All three tools giving the same word is a result we checked directly with this setup.
Instructions meant only for Claude Code can go in CLAUDE.md below the import line. Instructions every tool should follow belong in AGENTS.md. If a subfolder needs its own rules, the same pattern applies: create pkg/AGENTS.md and import it from pkg/CLAUDE.md. Check that setup once with the method below before relying on it.
Checking your own repo
How rule files are read can change with the version and your personal settings. To check the combination you use now, make a scratch copy of the repo and put a different word on one line in each file. Turn off the agent's file-reading tools if you can, and ask it to list every word in the instructions it already has. The answer and the run log together show which files were passed in at startup.
How the way you split work across agents changes the result is covered in our comparison of five multi-agent setups.
The newsletter below sends our next coding-agent test when it is out.