Guide

AGENTS.md: Which Coding CLIs Actually Read It

The question under every AGENTS.md thread is not how to write one. It is whether the tool you use actually reads it, and what happens when a repository has both AGENTS.md and CLAUDE.md. So we installed all three major terminal agents on the same day — Claude Code v2.1.260, Codex CLI v0.153.2, OpenCode v1.18.27 — and looked, per tool, at what each one ships. The short answer is that all three read AGENTS.md and only one of them treats CLAUDE.md as a first-class file.

By DK, Editor  ·  Last verified: 2026-09-04  · Claude Code v2.1.260 · Codex CLI v0.153.2 · OpenCode v1.18.27 — all three installed and inspected 2026-09-04  ·  How we test

Before you start

  • Nothing to install to read this page
  • To reproduce it: npm install -g @anthropic-ai/claude-code opencode-ai @openai/codex

Steps

  1. 01

    What AGENTS.md is trying to be

    AGENTS.md is a plain Markdown file at the root of a repository that carries the context a coding agent needs and a README does not: how to run the build, which commands verify a change, the conventions that are not obvious from the code. The pitch is that it is tool-neutral — one file, read by whichever agent a developer happens to use, instead of a different proprietary file per vendor. OpenCode states the rationale in its own shipped prompt text: README.md files are for humans, and AGENTS.md complements them with the detailed context coding agents need. The interesting question is how much of that neutrality is real, which is the rest of this page.

  2. 02

    Codex CLI: AGENTS.md is the native format, with real precedence rules

    Codex does not merely tolerate AGENTS.md — its behaviour around the file is spelled out inside its own system prompt, which is about as first-class as support gets. Four rules ship in the v0.153.2 binary. The scope of an AGENTS.md file is the entire directory tree rooted at the folder containing it. More deeply nested AGENTS.md files take precedence when instructions conflict. For every file in a patch, the agent must obey any AGENTS.md whose scope covers that file. And direct system, developer or user instructions take precedence over AGENTS.md. There is also a practical note worth knowing: the AGENTS.md at the repository root and in directories from the working directory up to the root are already included with the developer message, so Codex does not re-read them — but when it works in a subdirectory or outside the working directory it checks for additional applicable files.

    repo/AGENTS.md                 # applies to the whole tree
    repo/packages/api/AGENTS.md    # wins inside packages/api on conflict
    repo/packages/web/AGENTS.md    # wins inside packages/web on conflict
  3. 03

    OpenCode: AGENTS.md out of the box, and the list is configurable

    OpenCode reads AGENTS.md out of the box and treats it as one entry in a list you control. Its own shipped config reference shows "instructions": ["AGENTS.md", "docs/style.md"] — AGENTS.md is the file the config documents first, and the mechanism is general, so you can point OpenCode at additional files without renaming anything. Its shipped prompt text tells the agent that files named AGENTS.md usually carry the project’s background, structure, coding styles and preferences and should be used to understand the project, that it should look at AGENTS.md files in subdirectories for more detail about specific parts, and that if it changes anything an AGENTS.md describes it must update that file to keep it current.

    // opencode.json
    {
      "instructions": ["AGENTS.md", "docs/style.md"]
    }
  4. 04

    Claude Code: reads both, but CLAUDE.md is the one it is built around

    Claude Code v2.1.260 ships a string describing its own behaviour as hardcoding CLAUDE.md and AGENTS.md discovery, so an AGENTS.md repository is not invisible to it. But the weighting is not subtle: CLAUDE.md appears roughly two hundred times across the binary — its own commands, its onboarding flow, its memory tooling and its context-cost guidance are all built on it — while AGENTS.md appears a handful of times, mostly in the codebase-survey and config-import paths that look for whatever instruction files a repository already has. In practice: put your rules in AGENTS.md and Claude Code will read them; put them in CLAUDE.md and every other feature that touches project memory, from /init to /memory to per-directory scoping, works on them too.

  5. 05

    What to actually do when a repository has both

    Pick one as the source of truth and make the other a pointer, rather than maintaining two files that drift. If your team is mostly on Codex or OpenCode, AGENTS.md is the natural home and a one-line CLAUDE.md that says "see AGENTS.md" costs nothing. If your team is mostly on Claude Code, the reverse. What you should not do is duplicate the content: both files are resident in context for the tools that read them, so two copies of the same rules is double the cost per turn and guarantees that one of them will eventually be wrong. Codex ships an explicit precedence rule for nested AGENTS.md files, but no rule about AGENTS.md versus CLAUDE.md, because that is not a conflict the format anticipates.

    # CLAUDE.md — one line is enough when AGENTS.md is the source of truth
    Project conventions live in AGENTS.md at the repository root. Read that file.

Reference

Support, per tool, on named versions

All three CLIs were installed with npm on 2026-09-04 and inspected the same day. "Native" means the tool ships behaviour or configuration built around that file; "read" means it looks for the file but is not built around it.

CLIAGENTS.mdCLAUDE.mdHow we checked
Codex CLI v0.153.2Native — scope and precedence rules ship in its own system prompt.Barely — appears only in the path that imports config from other agents.Strings in the shipped binary: 58 AGENTS.md occurrences vs 2 for CLAUDE.md.
OpenCode v1.18.27Native — the file its shipped config reference lists first in the instructions array.Read about, not loaded — appears inside prompt text, not as a loader default.The shipped config reference `"instructions": ["AGENTS.md", "docs/style.md"]`, plus AGENTS.md instructions in its prompt text.
Claude Code v2.1.260Read — discovery is hardcoded alongside CLAUDE.md.Native — the whole memory system, /init and /memory are built on it.A binary string stating it hardcodes CLAUDE.md / AGENTS.md discovery; 199 vs 6 occurrences.

Reference

Precedence rules that actually ship (Codex CLI v0.153.2)

Paraphrased from the instruction text inside the v0.153.2 binary. Claude Code and OpenCode do not ship an equivalent written ruleset for AGENTS.md.

RuleConsequence
Scope is the whole subtreeAn AGENTS.md governs every file under the folder that contains it.
Deeper files winOn a conflict, the most deeply nested AGENTS.md is the one that applies.
Per-file obligationFor every file in a patch, the agent must obey any AGENTS.md whose scope covers it.
Direct instructions winA system, developer or user instruction outranks anything in AGENTS.md.
Style rules stay in scopeNaming and structure rules apply only to code inside that file’s scope, unless it says otherwise.

Troubleshooting

I added AGENTS.md and nothing changed
Check the tool before the file. All three CLIs here read it, but a fourth tool may not — and inside a monorepo, placement matters as much as content. Codex scopes an AGENTS.md to the directory tree beneath it, so a file in packages/api will not affect work at the repository root. If you are on Claude Code, /memory lists the memory files actually in play, which is the fastest way to see whether the file was picked up at all.
Different agents behave differently in the same repository
That is usually two files disagreeing rather than two tools disagreeing. If AGENTS.md and CLAUDE.md both exist and have drifted, Codex and OpenCode will follow AGENTS.md while Claude Code has both in context — and whichever it weights, the outcome will not match. Make one file the source of truth and reduce the other to a pointer.
My AGENTS.md is long and the agent still misses things
Length is the problem, not emphasis. Instruction files are resident in context on every turn, so anything an agent could work out for itself — the directory layout, what the package scripts do, generic advice like "write tests" — competes with the handful of lines that carry real information. OpenCode’s own guidance is that good AGENTS.md content is hard-earned context that took reading several files to infer. If a line is not that, delete it.
Nested AGENTS.md files are conflicting with the root one
Under Codex that is defined behaviour, not a bug: more deeply nested files take precedence on conflict, and each file governs its own subtree. Use it deliberately — put universal rules at the root and only the genuinely package-specific ones deeper. If you want a nested file to add rather than override, phrase it as an addition instead of restating the root rule with a different value.

FAQ

Does Claude Code read AGENTS.md?
Yes. Claude Code v2.1.260 ships a string describing its own behaviour as hardcoding CLAUDE.md and AGENTS.md discovery, so a repository standardised on AGENTS.md is not invisible to it. CLAUDE.md is still the file it is built around, though — the memory system, /init, /memory and per-directory scoping are all CLAUDE.md machinery, and CLAUDE.md appears about two hundred times in the binary against a handful for AGENTS.md.
Does Codex CLI use AGENTS.md?
Yes, and more thoroughly than any other CLI we checked. Codex CLI v0.153.2 carries its AGENTS.md rules inside its own system prompt: the scope of a file is the entire directory tree beneath it, more deeply nested files take precedence on conflict, and for every file in a patch the agent must obey any AGENTS.md whose scope covers that file. Direct system, developer or user instructions still outrank the file.
Does OpenCode use AGENTS.md?
Yes, out of the box. In OpenCode v1.18.27 the shipped config reference lists AGENTS.md first in the instructions array — `"instructions": ["AGENTS.md", "docs/style.md"]` — so you can add more instruction files without renaming anything. Its prompt text also tells the agent to look for AGENTS.md files in subdirectories for detail about specific parts of a project, and to update them when it changes something they describe.
AGENTS.md or CLAUDE.md — which should I use?
Pick by which tools your team actually runs, then make the other file a one-line pointer. Codex and OpenCode are built around AGENTS.md; Claude Code is built around CLAUDE.md but reads both. Duplicating the content into both files is the one option to avoid: instruction files sit in context on every turn, so two copies cost double and one of them will drift.
Where does AGENTS.md go in a monorepo?
A root AGENTS.md for the rules that hold everywhere, plus a per-package file only where the conventions genuinely differ. Under Codex the scoping is explicit — a file governs the tree beneath it and a deeper file wins on conflict — so a packages/api/AGENTS.md is the right place for API-only rules and the wrong place for anything the whole repository needs.
Do AGENTS.md files actually help?
It is a fair question and the front page of the search results is arguing about it. What we can say from inspecting the tools rather than from benchmarks: all three major terminal agents read the file, two of them treat it as their native format, and Codex ships a written precedence model for it. What none of that settles is whether a given file helps, and the failure mode we see most often is length — a file padded with things the agent could discover on its own spends context every turn and buries the two or three lines that carry real information.