AGENTS.md is a plain Markdown file in a repository that tells coding agents how to work there: how to build and test, which conventions to follow, what not to touch. It’s a README written for agents instead of people. Codex, Cursor, GitHub Copilot, Gemini CLI and a couple of dozen other tools read it. CLAUDE.md is the same idea for Claude Code, and the two don’t mix the way you might expect. Claude Code reads AGENTS.md only when the repository has no CLAUDE.md at all. If you have both, your AGENTS.md is silently ignored. The fix is one line: put @AGENTS.md at the top of your CLAUDE.md, or make CLAUDE.md a symlink to it.
Claude Code started reading AGENTS.md on its own in version 2.1.277, and the Hacker News post about it reached 741 points in September. I wanted to know which file wins in my own repositories, so I tested it with fruit. The results are below, along with what Codex, Copilot and Cursor read, and what happened to my own CLAUDE.md when I let it grow from February to November.
What AGENTS.md is#
The format’s home page calls it “a simple, open format for guiding coding agents”. It grew out of work by OpenAI Codex, Amp, Google’s Jules, Cursor and Factory, and it’s now looked after by the Agentic AI Foundation under the Linux Foundation. There’s no schema and no required section. It’s Markdown, and the agent reads all of it.

The site suggests a project overview, build and test commands, code style, testing instructions and security notes, plus anything you’d tell a new teammate on their first day. In a monorepo each package can have its own AGENTS.md, and the nearest one to the file being edited wins. The site mentions that OpenAI’s main repository has 88 of them.
Which file each tool reads#
This is where the confusion comes from. Every tool reads AGENTS.md, but each has its own file too, and the rules for which one wins differ.
| Tool | What it reads | Worth knowing |
|---|---|---|
| Claude Code | CLAUDE.md, .claude/CLAUDE.md and CLAUDE.local.md, from the working directory up. AGENTS.md only when none of those exist anywhere up the tree | /config → Project instructions → claude-md-and-agents-md reads both. AGENTS.override.md and AGENTS.local.md are never read |
| Codex | AGENTS.override.md or AGENTS.md in each directory from the repository root down, plus one in ~/.codex | Combined size capped at 32 KiB (project_doc_max_bytes). Other names only if you list them in project_doc_fallback_filenames |
| GitHub Copilot | .github/copilot-instructions.md, .github/instructions/*.instructions.md, AGENTS.md anywhere in the repository, or a single CLAUDE.md or GEMINI.md at the root | The nearest AGENTS.md takes precedence. Code review reads the instructions from the head branch |
| Cursor | .cursor/rules/*.mdc, and AGENTS.md at the root and in subdirectories | Nested AGENTS.md files combine with their parents. A plain .md in .cursor/rules is ignored |
Two things stand out. Copilot will read a root CLAUDE.md, so a Claude-first repository still gives Copilot something. And Codex’s and Cursor’s docs don’t mention CLAUDE.md at all, so a repository with only a CLAUDE.md gives those two nothing. If more than one agent works in your repository, AGENTS.md is the file they all agree on.
What Claude Code actually does, tested#
The docs lay out the rules clearly enough, but I wanted to see it. I made an empty repository with an AGENTS.md telling the agent to end every reply with PINEAPPLE, then asked Claude Code the capital of France four times, changing one file between runs.
- Only an AGENTS.md: “The capital of France is Paris. PINEAPPLE”. Claude Code found it with no setup.
- Add a CLAUDE.md that asks for BANANA: BANANA, and no PINEAPPLE. The moment a CLAUDE.md exists, AGENTS.md drops out, with no warning.
- Make CLAUDE.md a symlink to AGENTS.md: PINEAPPLE again.
- A real CLAUDE.md that imports AGENTS.md and adds its own rule: “MANGO The capital of France is Paris. PINEAPPLE”. Both files counted.
Step 2 is the trap. A repository that already has a CLAUDE.md gains an AGENTS.md for Codex or Cursor, and from then on Claude Code never sees it. Two of the repositories on my laptop are in exactly that state, as it turns out further down.
A few details from the docs that the test doesn’t show. Your personal ~/.claude/CLAUDE.md doesn’t count as “having a CLAUDE.md”: mine holds a handful of personal working rules, and AGENTS.md still loaded in step 1. Rules in .claude/rules/ don’t count either. But CLAUDE.local.md does, so if you add one to a repository that relies on AGENTS.md, Claude Code stops reading the AGENTS.md for you, and only you. The Project instructions setting in /config can make it read both, but that setting is only read from your user settings or managed settings, never from a project’s settings file. You can’t commit it for your team. The import is the fix that travels with the repository.
My first attempt also loaded nothing at all, not even the AGENTS.md. Claude Code deliberately skips instruction files in folders laid out like a session’s scratch directory, and I’d put the demo repository in one. If you ever need to know what loaded, run with --debug-file /tmp/claude.log and search the log for CLAUDE.md: it lists every file it looked at and why it skipped any.
Symlink or import?#
Both worked in the test. They differ at the edges.
A symlink (ln -s AGENTS.md CLAUDE.md) means one file and nothing to keep in sync. But Claude Code’s Edit and Write tools won’t write through a symlink, so it edits AGENTS.md directly, which is fine. The bigger catch is Windows: creating a symlink there needs Administrator rights or Developer Mode, and git checks a committed symlink out as a one-line text file unless core.symlinks is on. Anyone on that clone gets a CLAUDE.md that says AGENTS.md and nothing else.
An import works everywhere and leaves room for instructions only Claude Code needs:
@AGENTS.md
## Claude Code
- Use plan mode for anything under `src/billing/`.
- Run the `release-notes` skill before tagging a release.Claude Code never reads AGENTS.md twice, whichever setting you use, so the import is safe to leave in place. That’s what I’d use: AGENTS.md as the shared file, and a short CLAUDE.md that imports it and adds the few Claude-specific lines. Codex, Cursor and Copilot read AGENTS.md directly, and Claude Code gets it through the import.
What goes in the file, and what doesn’t#
A good AGENTS.md is short and a bit boring. It holds the things an agent can’t work out by reading code, or would get wrong:
- The exact commands to install, build, test, lint and type-check, including the one that runs a single test.
- A map of the repository: where the API lives, where the shared types are, what’s generated and shouldn’t be edited by hand.
- Conventions that differ from the defaults. If you use tabs, or never use default exports, say so.
- The don’ts: don’t touch migrations that have already shipped, don’t add dependencies without asking.
- How to check the work before calling it done.
What doesn’t belong:
- Procedures. A ten-step release checklist is a skill. Only a skill’s one-line description sits in context; the body loads when it’s used.
- Rules that must never be broken. The Claude Code docs are blunt that CLAUDE.md is “context, not enforced configuration”. If something must be blocked whatever the agent decides, that’s a
PreToolUsehook. - Detail that matters for one corner of the code. Claude Code has
.claude/rules/files with apaths:glob that load only when matching files are touched. For every tool at once, a nested AGENTS.md in that folder does the same job.
On size, the Claude Code docs suggest keeping each CLAUDE.md under 200 lines, because longer files use more context and get followed less closely. Imports help organise a long file but don’t shrink it: an imported file loads in full. Codex stops reading at 32 KiB. Two commands help here. /init writes a starting CLAUDE.md from your codebase, or suggests improvements if you have one. /doctor prompt-audit checks CLAUDE.md, CLAUDE.local.md and AGENTS.md files for instructions that are stale or contradict each other, and proposes edits.
What I found in my own repositories#
I counted the instruction files across the repositories on my laptop: my own projects plus a few I’ve cloned from other people. About fifteen have a CLAUDE.md at the root and four have an AGENTS.md. The median CLAUDE.md is 328 lines. Nine of the fifteen are over the 200-line guidance, and four are over 1,000.
Two of those repositories have both files, and in neither does the CLAUDE.md mention AGENTS.md. So when I run Claude Code there, it never sees 262 lines of instructions in one and 168 in the other. Somebody wrote those for Codex or Cursor, and they’re invisible to the agent I actually use. Neither repository is mine, which is partly the point: you inherit these files with the code.
The longest story is my marketplace app’s repository. Its CLAUDE.md was 261 lines when the repository was first committed in February. Over the next eight and a half months, 106 commits touched it, and 97 of those were feature or bug-fix commits that added a paragraph about whatever had just changed. By 7 November it was 2,123 lines.
On 9 November I cut it to 142 lines: the rules that apply to every task, the commands, and a map. The topic detail moved into 22 files in a docs/claude/ folder, 2,225 lines between them, and the CLAUDE.md points at each one by path, along the lines of “before changing payments, read docs/claude/payments.md”, rather than importing it. That difference matters. An import would have loaded all 2,225 lines into every session anyway, and the point was to load them only when the work needs them.
A starting AGENTS.md#
If you’re writing one from scratch, this is about the right length. Swap in your own commands.
# myapp
A web app (Next.js) and a REST API (Django) in one repository.
## Commands
- Install: `pnpm install` and `uv sync`
- Web dev server: `pnpm dev`; API: `uv run python manage.py runserver`
- Tests: `pnpm test` and `uv run pytest`; one test: `uv run pytest -k name`
- Before finishing: `pnpm lint && pnpm typecheck && uv run pytest`
## Layout
- `web/`: the Next.js app. `api/`: the Django project.
- `web/src/generated/` is generated from the OpenAPI schema. Never edit it by hand;
run `pnpm gen:api` after changing an API serializer.
## Conventions
- TypeScript strict mode, named exports only.
- API errors return `{"detail": "..."}` with a 4xx status, never 200.
## Don't
- Don't edit migrations that are already on `main`; add a new one.
- Don't add a dependency without saying why in the pull request.And the CLAUDE.md next to it, if you use Claude Code:
@AGENTS.md
## Claude Code
- Use plan mode for changes under `api/billing/`.Further reading#
On this site:
- Claude Code settings.local.json vs settings.json, Explained
- Claude Code Worktrees: Running Parallel Agents Without Collisions
- How I Run Claude Code Day to Day, on the setup these files sit in
- Agentic AI Security, on why instruction files are only advice, and what to enforce instead
- MCP vs CLI vs Skills: What Each Costs Your Coding Agent
Elsewhere:
- agents.md, the format’s home page
- How Claude remembers your project, the Claude Code docs on CLAUDE.md, AGENTS.md, imports and rules
- Custom instructions with AGENTS.md in the Codex docs
- Adding repository custom instructions for GitHub Copilot
- Rules in the Cursor docs
