Guide · updated 2026-11-18 · 8 min read
AGENTS.md vs CLAUDE.md: One Setup for Three Agents
Short answer: AGENTS.md is the shared file that Codex and Cursor read natively, and CLAUDE.md is Claude Code's own file. Put your real instructions in AGENTS.md, then add a two-line CLAUDE.md that starts with @AGENTS.md, and all three tools read the same rules without you maintaining copies.
The rest of this guide is the detail behind that: what each tool actually loads, where the gotchas are, and the exact files I'd commit.
What each tool reads
Claude Code
Claude Code's home file is CLAUDE.md. The memory docs list four scopes, loaded broadest first: a managed policy file, your user file at ~/.claude/CLAUDE.md, the project file at ./CLAUDE.md or ./.claude/CLAUDE.md, and a personal ./CLAUDE.local.md. It walks up the directory tree from where you launched it and concatenates everything it finds. CLAUDE.md files in subdirectories load on demand, when Claude reads files in those folders.
AGENTS.md support is newer. The Claude Code changelog for 2.1.277 says: "in a project with no CLAUDE.md, Claude Code reads AGENTS.md instead; change it under 'Project instructions' in /config." Version 2.1.281 extended that to Bedrock, Vertex AI, Microsoft Foundry, LLM gateways and sessions with telemetry turned off.
The key word is "instead." The moment a repo has a CLAUDE.md, the default behavior loads that file, not AGENTS.md. This is the trap I see most often: someone adds a small CLAUDE.md with one Claude-only note, and their 150-line AGENTS.md quietly stops loading in Claude Code.
Codex
Codex is built around AGENTS.md. Per OpenAI's AGENTS.md guide:
- It first checks your Codex home (
~/.codex, orCODEX_HOME) and usesAGENTS.override.mdif present, otherwiseAGENTS.md. - It then walks from the project root (usually the Git root) down to your current directory. In each folder it takes at most one file:
AGENTS.override.md, thenAGENTS.md, then any names inproject_doc_fallback_filenames. - It joins them root first, so files closer to where you're working come later and win.
- It stops adding files once the combined size hits
project_doc_max_bytes, which defaults to 32 KiB.
Codex does not read CLAUDE.md unless you add it to project_doc_fallback_filenames in ~/.codex/config.toml. That setting lives on each developer's machine, so don't build a team setup that depends on it.
Cursor
Cursor's rules docs describe AGENTS.md as "an alternative to .cursor/rules for straightforward use cases." It supports AGENTS.md in the project root and in subdirectories; a nested one applies when you work on files in that folder, and the more specific file takes precedence.
Cursor's structured rules still live in .cursor/rules as .mdc files with four modes: Always Apply, Apply Intelligently, Apply to Specific Files and Apply Manually. One detail worth knowing: Cursor ignores a plain .md file dropped into .cursor/rules. If you want plain Markdown, the docs say to use AGENTS.md.
Cursor's rules page does not mention CLAUDE.md, so I don't count on Cursor reading it.
The comparison in one table
| Claude Code | Codex | Cursor | |
|---|---|---|---|
| Native file | CLAUDE.md | AGENTS.md | .cursor/rules/*.mdc and AGENTS.md |
| Reads AGENTS.md | Only when no CLAUDE.md exists, or via import | Yes | Yes, root and subfolders |
| Nested files | Yes, loaded on demand | Yes, root to current folder | Yes, more specific wins |
| Personal override | CLAUDE.local.md |
AGENTS.override.md |
User Rules (Customize, then Rules) |
| Imports | @path syntax, up to 4 hops |
No | No |
The @AGENTS.md import
Claude Code's CLAUDE.md supports imports with @path. The memory docs show the exact pattern for repos that already have AGENTS.md:
@AGENTS.md
## Claude Code
Use plan mode for changes under `src/billing/`.
Claude loads the imported file at session start, then appends the rest. Relative paths resolve from the file doing the import, not from your working directory, and imports can nest up to four hops deep.
Because this CLAUDE.md exists, Claude Code uses it instead of the fallback, and the import pulls AGENTS.md in anyway. You get the shared rules plus a place for Claude-only notes.
Why not a symlink?
ln -s AGENTS.md CLAUDE.md also works, and the docs say so, as long as you have no Claude-specific content. Two reasons I still prefer the import:
- Windows. The docs note that creating a symlink on Windows needs Administrator rights or Developer Mode, and recommend the import there. If anyone on the team clones on Windows, the import is the safe default.
- Room to diverge. The day you want a Claude-only line (a hook reminder, a subagent hint, "use plan mode here"), a symlink forces that line into the file Codex and Cursor read too.
Why not just rely on the fallback?
If you will never want Claude-specific instructions, having only AGENTS.md is fine on Claude Code 2.1.277 or later. But it depends on everyone running a recent version and on nobody changing the "Project instructions" option in /config. A committed two-line CLAUDE.md works on older versions and doesn't care what that option is set to.
One setup that works in all three
This is what I commit to a repo that more than one agent touches.
Step 1: Write AGENTS.md at the root
Keep it to the things every agent needs: how to build, how to test, the conventions people actually get wrong, and what not to touch.
# AGENTS.md
## Commands
- Install: `pnpm install`
- Test one file: `pnpm vitest run path/to/file.test.ts`
- Lint before commit: `pnpm lint --fix`
## Conventions
- TypeScript strict mode. No `any` in new code.
- API handlers live in `src/api/`, one file per route.
- Money is integer cents everywhere.
## Don't
- Don't edit files in `src/generated/`; run `pnpm codegen`.
- Don't add dependencies without saying why in the PR.
Anthropic's guidance for CLAUDE.md is to keep each file under 200 lines, because longer files cost context and get followed less reliably. I apply the same limit to AGENTS.md. Codex's 32 KiB cap is far above that, so the line count is the limit that matters.
Step 2: Add a thin CLAUDE.md
@AGENTS.md
## Claude Code only
- Run the test for any file you change before you say you're done.
- For anything touching `src/billing/`, start in plan mode.
If you have nothing Claude-specific yet, the file is just the first line. That's fine.
Step 3: Nest only where a folder is truly different
A monorepo package with its own build commands gets its own packages/web/AGENTS.md. Codex picks it up as it walks down from the root, Cursor applies it to files in that folder, and for Claude Code you add packages/web/CLAUDE.md containing @AGENTS.md. The import path is relative to that CLAUDE.md, so it resolves to the package's own AGENTS.md.
Step 4: Keep personal notes out of the shared files
Use CLAUDE.local.md (gitignored) for Claude Code and AGENTS.override.md in ~/.codex for Codex. Your "I like terse commit messages" preference should not land in the team file.
Step 5: Check what actually loaded
Ask each tool to summarize its instructions in the first message of a session. In Claude Code, /memory lists the CLAUDE.md, CLAUDE.local.md and rules files loaded in the session. If the summary is missing your AGENTS.md rules, the most common cause is a CLAUDE.md without the import line.
Migrating from an existing CLAUDE.md
If CLAUDE.md is where your instructions live today:
- Move the tool-neutral parts (commands, conventions, don'ts) into a new AGENTS.md.
- Leave only Claude-specific lines in CLAUDE.md, under an
@AGENTS.mdfirst line. - Delete anything that duplicates what the code already says. Agents read the code; the instruction file is for what they can't infer.
Claude Code's /init helps in the other direction: per the memory docs, running it in a repo that already has AGENTS.md reads it and folds the relevant parts into the CLAUDE.md it generates. I'd still trim that output down to the import line plus Claude-only notes, so you don't end up with two copies drifting apart.
For what to put in the file in the first place, see How to Write a CLAUDE.md File That Claude Follows; most of it applies to AGENTS.md word for word. If you're still choosing between the tools themselves, Claude Code vs Codex vs Cursor covers that.
Trade-offs to know about
- The import is Claude-only syntax. Codex and Cursor will see
@AGENTS.mdas plain text if they ever read CLAUDE.md. They don't by default, so this rarely matters. - Precedence differs. Codex lets deeper files override earlier ones by order, Cursor says the more specific file wins, and Claude Code concatenates everything. Write nested files as additions, not contradictions, and all three behave the same.
- Cursor's scoped rules have no AGENTS.md equivalent. "Apply to Specific Files" with globs is genuinely useful. If you rely on it, keep those rules in
.cursor/rulesand accept that Codex and Claude Code won't see them, or move them into a nested AGENTS.md in the matching folder.
Bottom line
Write your rules once in AGENTS.md. Commit a CLAUDE.md whose first line is @AGENTS.md, and put Claude-only notes under it. Skip the symlink unless nobody uses Windows and you'll never need Claude-specific lines. That one setup is read by Codex and Cursor natively and by Claude Code on any version, without depending on a /config setting.
If this saved you an afternoon of debugging which file loaded, Agent Shipped sends one practical setup like it twice a week (free, about a 4-minute read).
FAQ
Does Claude Code read AGENTS.md?
Yes, since version 2.1.277, but only as a fallback. If the project has no CLAUDE.md, Claude Code reads AGENTS.md instead; if a CLAUDE.md exists, that is what loads unless it imports AGENTS.md.
Should I symlink CLAUDE.md to AGENTS.md?
It works if you never need Claude-specific notes. Anthropic's docs point Windows users to the @AGENTS.md import instead, because creating symlinks there needs Administrator rights or Developer Mode.
Does Codex read CLAUDE.md?
Not by default. Codex reads AGENTS.override.md and AGENTS.md, plus any extra names you list in project_doc_fallback_filenames in ~/.codex/config.toml.
Do I still need .cursor/rules if I have AGENTS.md?
Not for simple, always-on instructions. Cursor treats AGENTS.md as a plain alternative to Project Rules; keep .cursor/rules for rules that should apply only to certain files or only when relevant.