CLAUDE.md vs AGENTS.md: What Claude Code Actually Reads
Quick answer: CLAUDE.md is Claude Code’s instruction file. AGENTS.md is the shared file that Codex, Cursor and GitHub Copilot’s agents read. Since v2.1.277 (September 18, 2026), Claude Code also reads AGENTS.md, but by default only when there is no CLAUDE.md or CLAUDE.local.md in your working directory or any directory above it. To keep one source of truth, write AGENTS.md and put a one-line @AGENTS.md import in CLAUDE.md.
Most repositories that use more than one coding agent end up with two or three instruction files saying nearly the same thing, slowly drifting apart. The fix is to know exactly which file each tool loads, in what order, and which one wins. All of that changed for Claude Code two weeks ago, so a lot of what you will read elsewhere is now stale.
The correction: Claude Code reads AGENTS.md now, with a catch
Plenty of guides still say Claude Code ignores AGENTS.md and that you need a symlink or a SessionStart hook to make it pay attention. That stopped being true with v2.1.277, which the Claude Code changelog dates to September 18, 2026: “in a project with no CLAUDE.md, Claude Code reads AGENTS.md instead.” Version 2.1.281 (September 23) extended that to Amazon Bedrock, Google Vertex AI, Microsoft Foundry, LLM gateways and sessions with telemetry disabled.
The catch is in the word instead. According to the official memory docs, three files count as “you already have a CLAUDE.md”: CLAUDE.md, .claude/CLAUDE.md and CLAUDE.local.md, in your working directory or any directory above it. If any of them exists, Claude reads your CLAUDE.md files and skips AGENTS.md entirely.
CLAUDE.local.md counts. In a repo that relies on AGENTS.md, creating a personal, gitignored CLAUDE.local.md for your sandbox URLs silently stops Claude from reading the team’s AGENTS.md for you. Your ~/.claude/CLAUDE.md, an organization’s managed CLAUDE.md and .claude/rules/ files do not count, and keep loading alongside AGENTS.md. Verified against code.claude.com/docs/en/memory on October 2, 2026.The behavior is controlled by a setting called Project instructions in /config, with four values. The default is claude-md-or-agents-md, which is the “one or the other” rule above. We cover all four further down.
Which file does each agent read?
Each row below comes from that tool’s own documentation, not from a compatibility chart. Where the docs are silent, the table says so rather than guessing.
| Agent | Its own file | Reads AGENTS.md? | Nested files |
|---|---|---|---|
| Claude Code | CLAUDE.md, CLAUDE.local.md, ~/.claude/CLAUDE.md, .claude/rules/ | Yes, from v2.1.277, when no CLAUDE.md/CLAUDE.local.md exists (default setting) | Loaded on demand when Claude reads files in that folder |
| Codex | AGENTS.md, AGENTS.override.md, ~/.codex/AGENTS.md | It is the native format | One file per directory, from the project root down to your current directory |
| Cursor | .cursor/rules/*.mdc, User Rules, Team Rules | Yes, root and subdirectories | Nested AGENTS.md combines with parents; the more specific one wins |
| GitHub Copilot | .github/copilot-instructions.md, .github/instructions/*.instructions.md | Yes, for agents; the nearest AGENTS.md takes precedence | Also accepts a single root CLAUDE.md or GEMINI.md as an alternative |
| Gemini CLI | GEMINI.md, ~/.gemini/GEMINI.md | Only if you add it to context.fileName in settings.json | Scans a folder and its ancestors when a tool touches it |
Two details in that table are easy to miss. Codex never reads CLAUDE.md unless you add it to project_doc_fallback_filenames in ~/.codex/config.toml, and it stops adding files once their combined size reaches project_doc_max_bytes, 32 KiB by default. Claude Code, for its part, does not read AGENTS.override.md, AGENTS.local.md, or anything under an .agents/ directory, so Codex overrides stay Codex-only.
Precedence explainer
Tick the files that exist in your repo and pick the Claude Code setting. Assumes you launch each agent from the repo root, then work on a file in packages/web/.
How Claude Code orders its instruction files
Claude Code loads instruction files from four scopes, broadest first. Nothing overrides anything: every file found is concatenated into context, and later text simply reads as more specific.
| Scope | Location | Shared with |
|---|---|---|
| Managed policy | /Library/Application Support/ClaudeCode/CLAUDE.md (macOS), /etc/claude-code/CLAUDE.md (Linux, WSL) | Everyone on the machine; can’t be excluded |
| User | ~/.claude/CLAUDE.md | Just you, all projects |
| Project | ./CLAUDE.md or ./.claude/CLAUDE.md | The team, via git |
| Local | ./CLAUDE.local.md | Just you, this project; add it to .gitignore |
Within the directory tree, Claude Code walks from your working directory up to the filesystem root and loads every CLAUDE.md and CLAUDE.local.md it finds, ordered root first. Start a session in foo/bar/ and foo/CLAUDE.md lands in context before foo/bar/CLAUDE.md. In each directory, CLAUDE.local.md comes after CLAUDE.md, so your personal notes are the last thing Claude reads at that level.
Files below your working directory behave differently. A packages/web/CLAUDE.md doesn’t load at launch; it’s pulled in the first time Claude reads a file in packages/web/. That’s why a monorepo with per-package instructions can look like it’s ignoring them in the first few turns.
Because everything is concatenated, contradictions are your problem. The docs are blunt about it: if two instructions conflict, “Claude may pick one arbitrarily.” They also suggest keeping each file under 200 lines, and Claude Code skips any single file over 4 MiB.
For instructions that only matter to some files, use .claude/rules/. A rule file with paths frontmatter loads only when Claude reads a matching file:
---
paths:
- "src/components/**/*.tsx"
- "src/styles/**/*.css"
---
# UI rules
- Colors come from tokens in src/styles/tokens.css. No raw hex.
The Project instructions setting
Open /config in a session and look for Project instructions. If it isn’t there, your session can’t load AGENTS.md at all: you’re on a version before 2.1.277, you disabled the built-in agents-md plugin, or it’s your first session right after upgrading.
| Value | What Claude reads |
|---|---|
claude-md-or-agents-md | Your CLAUDE.md files, or AGENTS.md when no CLAUDE.md/CLAUDE.local.md exists at or above the working directory. The default. |
claude-md-and-agents-md | Both. In each directory, CLAUDE.md files first, then AGENTS.md. An AGENTS.md already pulled in by an import or symlink isn’t read twice. |
claude-md | CLAUDE.md files only. |
managed-only | Only the managed CLAUDE.md and auto memory at launch. A subdirectory’s CLAUDE.md and path-scoped rules still load when Claude reads files there. |
You can also set it in a settings file, under the built-in plugin’s ID. Claude Code honors this in ~/.claude/settings.json, a --settings file or managed settings, and ignores it in project and local settings, so you can’t force it on teammates from the repo:
{
"pluginConfigs": {
"agents-md@builtin": {
"options": { "instructionFiles": "claude-md-and-agents-md" }
}
}
}
@imports: how one file pulls in another
Both CLAUDE.md and an AGENTS.md that Claude reads directly can import other files with @path. Imported files are expanded into context at launch, next to the file that references them.
See @README.md for the project overview and @package.json for scripts.
# Design system
@docs/DESIGN.md
# Personal, shared across worktrees
@~/.claude/my-project-instructions.md
The rules, from the docs:
- Relative paths resolve from the file containing the import, not from your working directory.
- Imports can nest, up to four hops deep.
- An
@pathinside backticks or a fenced code block is left alone, which is how you mention a path without importing it. - Paths with spaces need a backslash before each space. A quoted path isn’t imported at all.
- The first time a project file imports something outside the working directory, Claude Code asks you to approve it. Decline, and those imports stay off.
One thing imports don’t do is save context. An imported file loads at launch just like the file that imports it, so splitting a 600-line CLAUDE.md into six imports helps you, not the model.
Keeping one source of truth
If your team uses Claude Code alongside Codex, Cursor or Copilot, make AGENTS.md the canonical file, because it’s the one all of them read. Then pick one of three ways to hand it to Claude Code.
Option 1: AGENTS.md alone
On v2.1.277 or later with the default setting, this just works, as long as nobody adds a CLAUDE.md or CLAUDE.local.md. It’s the most fragile option for exactly that reason.
Option 2: CLAUDE.md that imports AGENTS.md (recommended)
@AGENTS.md
## Claude Code only
Use plan mode for changes under src/billing/.
Claude reads the imported file first, then the Claude-specific lines below it. This works in every session, including ones that can’t load AGENTS.md directly, and the docs confirm the import never causes a second copy under any Project instructions value. Personal CLAUDE.local.md files are safe here, since you aren’t relying on the fallback.
Option 3: a symlink
ln -s AGENTS.md CLAUDE.md
Fine if you have nothing Claude-specific to add, with two caveats from the docs. Claude’s Edit and Write tools refuse to write through a symlink, so it gets redirected to edit AGENTS.md. And on Windows, Git checks out a committed symlink as a plain text file unless core.symlinks is enabled, leaving that teammate with a one-line CLAUDE.md that says AGENTS.md. If anyone on the team uses Windows, use the import.
If you set up a workaround before September, the docs say what to do with it. Keep an @AGENTS.md import. Replace a sentence like “read AGENTS.md first” with a real import, because a sentence only works if Claude decides to open the file. Delete a SessionStart hook that prints AGENTS.md, or you’ll load it twice.
What to put in it for UI work
The general advice in the docs applies: facts Claude should hold in every session, like build commands, conventions, project layout and “always do X” rules. Multi-step procedures belong in a skill; folder-specific rules belong in .claude/rules/.
For front-end work, the instruction file’s most useful job is to stop the agent from inventing a design system. Without one in context, a model falls back to the median of its training data, which is how you get the same indigo three-card page from every tool. A short UI section that points at real values does more than a page of adjectives:
# AGENTS.md
## Commands
- pnpm dev / pnpm test / pnpm lint
## UI
- Design tokens live in DESIGN.md and src/styles/tokens.css. Read DESIGN.md before
writing or restyling any component.
- Never use a raw hex, px font size or spacing value that isn't a token.
- Type scale: use the --step-* custom properties only.
- Body text must meet 4.5:1 contrast against its background.
- Reuse components from src/components/ui before creating new ones.
Note that this example asks the agent to read DESIGN.md rather than importing it. A full token file can run to hundreds of lines, and an @DESIGN.md import would load all of it into every session, including the ones where you’re fixing a database migration. Our guide to writing a DESIGN.md for AI coding agents covers what goes in that file and how to keep it compact enough to import if you’d rather. In Claude Code, a design-system skill with paths set to your UI files is the tidier middle ground.
Getting the actual values is the tedious part. Typing a palette, a type scale and a spacing scale into Markdown by hand, from DevTools, one computed style at a time, is where most teams give up and leave the agent to guess.
Skip the transcription. CSS DNA, a browser extension for inspecting CSS, reads any page’s colors, fonts, type scale and spacing on-device. The ranked palette and font readout are free; the AI DESIGN.md brief and tokens.json export are Pro, $5/mo after a 7-day trial. Add CSS DNA to Chrome (free).
How to check what actually loaded
Don’t trust the file tree; ask each tool.
- In Claude Code, run
/contextand look under Memory files, or/memoryto list and open every file. WhenAGENTS.mdloads through the fallback, an interactive session prints a line likeno CLAUDE.md found; AGENTS.md loaded: /home/you/repo/AGENTS.md. - For Codex, its docs suggest
codex --ask-for-approval never "Summarize the current instructions."from the repo root; it should echo global and project guidance in precedence order. - In Gemini CLI,
/memory showprints the full concatenated context; the footer shows how many context files loaded.
If Claude Code isn’t picking up your AGENTS.md, the docs give this checklist, in order:
- Look for a
CLAUDE.md,.claude/CLAUDE.mdorCLAUDE.local.mdin your working directory or any parent, other than~/.claude/CLAUDE.md. One of those wins under the default setting. - Run
claude --versionand confirm 2.1.277 or later (2.1.281 or later on Bedrock, Vertex AI, Foundry or with telemetry off). - Open
/configand check Project instructions isn’tclaude-mdormanaged-only.
One debugging gotcha: the InstructionsLoaded hook, handy for logging which files load and why, doesn’t fire for an AGENTS.md read through the setting. It does fire for one that a CLAUDE.md imports or symlinks to.
Frequently asked questions
Does Claude Code read AGENTS.md?
Yes, from v2.1.277 (September 18, 2026). With the default claude-md-or-agents-md setting it reads AGENTS.md only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working directory or above it. Set Project instructions to claude-md-and-agents-md in /config to read both.
What happens if a repo has both CLAUDE.md and AGENTS.md?
By default, Claude Code reads the CLAUDE.md files and ignores AGENTS.md. Codex and Cursor do the reverse: they read AGENTS.md and don’t mention CLAUDE.md. The clean fix is an @AGENTS.md import at the top of CLAUDE.md, so both tools see the same instructions.
Should I symlink CLAUDE.md to AGENTS.md?
Only if nobody on the team uses Windows and you have nothing Claude-specific to add. Git on Windows checks out a symlink as a text file unless core.symlinks is enabled, and Claude’s Edit tool won’t write through a symlink. An @AGENTS.md import avoids both problems.
Why did adding CLAUDE.local.md break my AGENTS.md?
Because CLAUDE.local.md counts as having a CLAUDE.md under the default setting, so Claude stops reading AGENTS.md. Either add a CLAUDE.md containing @AGENTS.md, or set Project instructions to claude-md-and-agents-md in your user settings.
How long should CLAUDE.md be?
Anthropic’s docs suggest under 200 lines per file, since longer files cost context and reduce adherence. Imports don’t help with that, because imported files also load at launch. Move folder-specific rules to .claude/rules/ with paths frontmatter, and procedures to skills.
Does Gemini CLI read AGENTS.md?
Not by default. Gemini CLI reads GEMINI.md files. Add "context": { "fileName": ["AGENTS.md", "GEMINI.md"] } to its settings.json and it will read AGENTS.md too.
Give your agent real design values
Pull the palette, fonts and spacing from any site in your browser, then hand them to Claude Code, Codex or Cursor as tokens instead of guesses.
Add CSS DNA to Chrome (free)Free: element CSS, eyedropper, ranked palette. Pro, $5/mo after a 7-day trial: exports, DESIGN.md, CSS audit. No account.