AGENTS.md vs CLAUDE.md: what differs and which to use
Both files hold the same kind of thing: instructions for a coding agent. AGENTS.md is an open format read by many agents (Codex, Cursor, GitHub Copilot, Gemini CLI and more). CLAUDE.md is Claude Code's own file, with extras like imports and path-scoped rules.
If more than one agent touches your repo, write the shared rules in AGENTS.md and put @AGENTS.md at the top of CLAUDE.md. One copy of the rules, every agent covered.
| AGENTS.md | CLAUDE.md | |
|---|---|---|
| Read by | Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Zed, Aider and others (agents.md list); Claude Code when no CLAUDE.md exists | Claude Code |
| Locations | Repo root and any subfolder; Codex also ~/.codex/AGENTS.md | Managed policy, ~/.claude/CLAUDE.md, ./CLAUDE.md or ./.claude/CLAUDE.md, ./CLAUDE.local.md, subfolders |
| Several files | Nearest file wins; chat instructions override | All files are joined; closer ones are read last |
| Size limit | Codex: 32 KiB total by default | Guidance: under about 200 lines per file |
| Imports | Not part of the format | @path/to/file, up to four levels |
| Per-file rules | Use nested files | .claude/rules/*.md with a paths list |
| Frontmatter | None | None in CLAUDE.md; paths in .claude/rules files |
Use both with one line
@AGENTS.md
## Claude Code only
- Use the code-review skill before you say a change is done.Claude Code's docs give this exact pattern for repos that already have an AGENTS.md. Recent Claude Code versions also read AGENTS.md directly when there is no CLAUDE.md at all.
Choose AGENTS.md if
- Your team uses more than one agent, or might.
- You want the rules to read like a README that people can follow too.
Choose CLAUDE.md if
- Only Claude Code works on the repo.
- You need imports or path-scoped rules to keep the always-loaded part short.
Whichever you choose, the same rules decide whether the agent follows it: exact commands, checkable rules, short files, no contradictions between files.