Get in touch

9io.ai / Blog

AGENTS.md vs CLAUDE.md: which file each coding agent reads

AGENTS.md vs CLAUDE.md as of 20 October 2026: what Claude Code, Codex, Cursor, Copilot and Gemini CLI read, which file wins, and a template.

Key takeaways

  • Since 18 September 2026, Claude Code 2.1.277 reads AGENTS.md in folders that have no CLAUDE.md.
  • When both files exist, Claude Code reads only CLAUDE.md by default, so start CLAUDE.md with @AGENTS.md.
  • A personal CLAUDE.local.md also switches the AGENTS.md fallback off for the developer who adds it.
  • Codex stops adding AGENTS.md files at 32 KiB by default, and Anthropic suggests under 200 lines per file.
  • Zed’s agent loads only the first instruction file it finds, so a leftover .cursorrules hides AGENTS.md.

AGENTS.md vs CLAUDE.md now comes down to which file wins in each tool. Claude Code 2.1.277, released on 18 September 2026, reads AGENTS.md in a folder that has no CLAUDE.md, and by default still reads only CLAUDE.md when both exist.12 Codex, Cursor, GitHub Copilot, Amp and Zed’s agent all read AGENTS.md, and Gemini CLI reads it once you name it in its settings. For a repository with both files, the fix is one line. Keep the shared instructions in AGENTS.md and start CLAUDE.md with @AGENTS.md.

A personal CLAUDE.local.md switches Claude Code’s fallback off for whoever adds one, and the setting that loads both files only works from user or managed settings. A third-party count from 24 September found a CLAUDE.md beside the AGENTS.md in 161 of 283 popular repositories that ship one.3

This post covers the fix, Claude Code’s rules, a compatibility table for seven agents, what to put in the file, a template and a checklist. Sources are vendor documentation and changelogs dated on or before 20 October 2026, and we haven’t run tests of our own.

The one-line fix for repositories with both files

Make AGENTS.md the file every tool shares, and give Claude Code a CLAUDE.md that imports it.

@AGENTS.md

## Claude Code only
- Use plan mode before changing anything under `db/migrations/`.

Anthropic documents this pattern. Claude reads the imported file first, then the rest of CLAUDE.md. Relative paths resolve from the importing file, imports can nest four hops deep, and an @path inside backticks or a code block isn’t imported. The import never makes Claude read AGENTS.md twice, and it works on versions and providers that can’t load AGENTS.md directly.2 Keep the Claude-only lines short, because Cursor applies a root CLAUDE.md to every conversation as well.4

A symlink, ln -s AGENTS.md CLAUDE.md, works when Claude needs nothing extra, with two constraints that Anthropic lists. Claude’s Edit and Write tools won’t write through a symlink. On Windows, creating one needs Administrator rights or Developer Mode, and Git checks a committed symlink out as a plain text file unless core.symlinks is enabled, so that clone gets a one-line CLAUDE.md holding a path.2 Git’s own docs confirm the plain-file checkout.5 If anyone on the team or in CI uses Windows, use the import.

Monorepos need one more step. Anthropic’s docs describe Claude loading a subfolder’s AGENTS.md only when no CLAUDE.md counts, and a root CLAUDE.md with the import counts.2 Either add a CLAUDE.md containing @AGENTS.md beside each nested AGENTS.md, or delete CLAUDE.md and move the Claude-only lines into .claude/rules/, which doesn’t count. The second route relies on the fallback, so every machine needs a version that supports it on your provider.

How Claude Code reads AGENTS.md since version 2.1.277

Thariq Shihipar announced the change for the Claude Code team on 18 September, as quoted by Simon Willison. From version 2.1.277, when a folder has no CLAUDE.md, “Claude will check for and use AGENTS.md”.61 Anthropic’s docs list which files switch that fallback off.2

  • Counted, so AGENTS.md is skipped: CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in the working directory or any folder above it.
  • Not counted, and loaded alongside AGENTS.md: your ~/.claude/CLAUDE.md, your organisation’s managed CLAUDE.md and .claude/rules/ files.
  • Never read: AGENTS.local.md, AGENTS.override.md and anything under .agents/.

CLAUDE.local.md is meant for personal, gitignored notes, but Anthropic warns that adding one to a project that relies on AGENTS.md stops Claude reading AGENTS.md for that developer. To keep one, Anthropic suggests the claude-md-and-agents-md setting below.

With the fallback active, Claude reads every AGENTS.md from the working directory upwards at the start of a session. It reads a subfolder’s AGENTS.md when it opens a file there, unless that subfolder has a CLAUDE.md of its own.2

The Project instructions setting in /config has four values.2

Value What Claude Code reads
claude-md-or-agents-md (default) CLAUDE.md files, or AGENTS.md where no CLAUDE.md counts
claude-md-and-agents-md Both, CLAUDE.md first, without loading an imported or symlinked AGENTS.md twice
claude-md CLAUDE.md files only
managed-only Only the organisation’s managed CLAUDE.md and auto memory at launch

Teams can’t commit this setting. Claude Code reads it from user settings, a --settings file or managed settings, and ignores it in project and local settings files. An administrator who wants one behaviour for everyone sets it in managed settings, under pluginConfigs for cc-plugin-agents-md@builtin.2

Cloud providers followed five days later. The 2.1.277 release notes said the fallback was “not yet on Bedrock, Vertex or Foundry”.7 Version 2.1.281, released on 23 September, extended it to Amazon Bedrock, Google Vertex AI, Microsoft Foundry, LLM gateways and sessions with telemetry disabled.18 On older versions those sessions read CLAUDE.md only, so check the versions pinned in CI images and dev containers.

An interactive session confirms the fallback with a line starting no CLAUDE.md found; AGENTS.md loaded:. From version 2.1.280, /memory and /context also list an AGENTS.md that Claude read directly.2

AGENTS.md vs CLAUDE.md across seven coding agents

This table summarises each vendor’s documentation as of 20 October 2026. “Not documented” means the vendor’s page doesn’t say.

Tool Files it reads Which wins when several exist Nested files in subfolders Size limit How to check what loaded
Claude Code CLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, .claude/rules/; AGENTS.md as a fallback CLAUDE.md, unless Project instructions says otherwise Yes, on demand Aim for under 200 lines a file; skips a file over 4 MiB /context, /memory, startup line
OpenAI Codex AGENTS.override.md, AGENTS.md, names in project_doc_fallback_filenames One file per folder, override first; files nearer the working directory override Root down to the folder Codex starts in 32 KiB combined by default (project_doc_max_bytes) Ask it to summarise its current instructions
Cursor AGENTS.md, a root CLAUDE.md, .cursor/rules/*.mdc, User and Team Rules Team, then Project, then User Rules; AGENTS.md against CLAUDE.md not documented Yes; the more specific file wins None documented; advises rules under 500 lines Customize lists rules and their status
Copilot cloud agent (was coding agent) copilot-instructions.md, *.instructions.md, AGENTS.md, or one root CLAUDE.md or GEMINI.md All relevant files apply; the nearest AGENTS.md wins Yes None documented; about 1,000 lines a file for code review Not documented; Copilot Chat lists the file under References
Copilot in VS Code Root AGENTS.md (on by default), CLAUDE.md, copilot-instructions.md, *.instructions.md Additive, with “no general precedence order” Experimental, off by default None documented References in each response; Agent Debug Logs
Gemini CLI GEMINI.md; AGENTS.md if listed in context.fileName All files found are joined Yes, loaded when a tool touches that folder None documented /memory show; the footer counts loaded files
Zed agent First match of .rules, .cursorrules, .windsurfrules, .clinerules, .github/copilot-instructions.md, AGENT.md, AGENTS.md, CLAUDE.md, GEMINI.md The first file in that list Not documented Not documented Not documented
Amp AGENTS.md; AGENT.md or CLAUDE.md where a folder has no AGENTS.md AGENTS.md Yes, when Amp reads a file there Not documented Not documented

Sources are each vendor’s documentation, and GitHub’s changelog for the cloud agent’s name.2910411121314151617

Claude Code prefers CLAUDE.md, Amp and Zed prefer AGENTS.md, and Copilot in VS Code combines both, so if the two files disagree, the agents get different instructions. With the import in place, they all read the same text. Zed’s agent stops at its first match, so a forgotten .cursorrules or a stub .github/copilot-instructions.md hides AGENTS.md entirely.16 Codex reads CLAUDE.md only if you list it in project_doc_fallback_filenames, and then only in folders without an AGENTS.md.9

Since 18 June 2026, Gemini CLI no longer serves Google AI Pro and Ultra subscribers or free Gemini Code Assist users, who move to Antigravity CLI. Code Assist Standard and Enterprise customers and paid API keys keep Gemini CLI.18 Antigravity reads AGENTS.md or GEMINI.md in any folder and truncates a rule file over 24,000 bytes.19

How many repositories have both files

Decoding AI, writing on Towards AI on 24 September, measured how often the fallback can fire. It took the top 100 repositories by stars in ten languages from the Github-Ranking project, kept the 815 with a commit in the previous 90 days, and fetched each default branch’s instruction files.3

Of the 815, 283 (34.7%) ship an AGENTS.md. In 161 of those 283 (56.9%), a root CLAUDE.md or a .claude/CLAUDE.md sits beside it, so Claude Code’s default never falls back to AGENTS.md. The other 122 (43.1%) are where version 2.1.277 changed anything. A first pass that checked only the root found 157.3

This is a third-party snapshot of the most-starred projects. The author counted files without running Claude Code and notes that gitignored CLAUDE.local.md files are invisible, which makes 161 a floor. The article doesn’t say whether those CLAUDE.md files import or link to AGENTS.md, and one that does still gives Claude the AGENTS.md content, so 161 counts the repositories where the fallback can’t fire.

How to write AGENTS.md: what belongs in it

Anthropic, OpenAI and the agents.md site agree on the core.

  • Commands the agent can’t guess. Install, build, a single test, the full suite, lint and type checks. All three sources list them.202122
  • A few lines on layout. OpenAI asks for the important directories. Anthropic excludes file-by-file descriptions, and its /doctor check proposes cutting directory layouts Claude can work out, so name the folders that aren’t obvious and skip the tree.21222
  • Conventions that differ from defaults. Anthropic asks for code style rules that differ from defaults, plus branch naming and PR conventions. OpenAI asks for engineering conventions and PR expectations.2221
  • Boundaries. OpenAI lists “constraints and do-not rules”, and its sample file asks for confirmation before new production dependencies are added.219 “Ask before running a migration” goes here. The file is advice, so Anthropic says to block anything that must never happen with a hook or a permission rule.2
  • What done means. OpenAI lists “what done means and how to verify work”. The agents.md FAQ says an agent will try to run the checks the file lists and fix failures before it finishes.2120

Write lines a reviewer can check. Anthropic’s example prefers “Run npm test before committing” to “Test your changes”.2 Keep the file short. OpenAI says a short, accurate AGENTS.md is more useful than a long file of vague rules, and Anthropic suggests under 200 lines. Both, like Cursor, suggest adding a rule when the agent repeats a mistake.21210

What to keep out of AGENTS.md

  • Secrets. The file is committed, and each tool sends it to a model provider in every session. Gemini CLI, for example, sends its context files with every prompt.152 Point the agent to .env.example and keep values out.
  • Long documents the agent can open itself. Anthropic, OpenAI and Cursor all say to link or reference documentation instead of pasting it.222110 In Claude Code an @ import still loads at launch, so write the path in backticks and Claude opens the file when it needs it.2
  • Rules a linter or test already enforces. VS Code says to skip conventions that linters and formatters enforce, OpenAI to reserve formatting and lint checks for CI, and Cursor to use a linter instead of copying a style guide.14910 Keep the lint command in AGENTS.md and the rule in the linter’s config, where it can fail a build.

Cursor rules, copilot-instructions.md and GEMINI.md

Cursor rules vs AGENTS.md

Cursor reads AGENTS.md in the root and in subfolders, so always-on rules can move there.10 Keep .cursor/rules/*.mdc files for rules that need a glob or a manual trigger, which is the extra control Cursor says project rules are for.4 Delete .cursorrules. Cursor calls it legacy, and Zed reads it before AGENTS.md.416 Our post on Cursor alternatives has a fuller checklist for moving rules between tools.

copilot-instructions.md

Copilot reads AGENTS.md too, and it gets every instruction file that applies, so text kept in both is sent twice.11 Move the shared text into AGENTS.md and keep .github/copilot-instructions.md for Copilot-only notes, or delete it, remembering that Zed reads it ahead of AGENTS.md.16 Path-specific .instructions.md files with applyTo globs can stay, since AGENTS.md has no glob scoping.11

GEMINI.md

Move the shared text into AGENTS.md and tell Gemini CLI to read both files in .gemini/settings.json.1523

{ "context": { "fileName": ["AGENTS.md", "GEMINI.md"] } }

With folder trust on, Gemini CLI ignores a project’s .gemini/settings.json until the folder is trusted.24 Antigravity reads both files without a setting.19

An AGENTS.md template to start from

This AGENTS.md example suits a repository with a TypeScript front end and a Python API. Swap in your own commands, and delete any line your agents wouldn’t miss. At 40 lines it sits well inside every limit in the table.

# AGENTS.md

Web app in `apps/web` (Next.js) and API in `services/api` (FastAPI).

## Commands
- Install: `pnpm install` and `uv sync --project services/api`
- Run locally: `pnpm dev`
- Test one file: `pnpm vitest run path/to/file.test.ts`
- API tests: `uv run --project services/api pytest -q`
- Before you finish: `pnpm lint && pnpm typecheck`

## Layout
- Shared UI components live in `packages/ui/`, never inside the app
- API endpoints: `services/api/app/routers/`; schemas: `services/api/app/schemas/`
- `db/migrations/` is generated. Never edit an existing migration.
- `services/api/AGENTS.md` adds API-only rules

## Conventions
- TypeScript strict mode. No `any` without a comment saying why.
- API errors use the helpers in `services/api/app/errors.py`
- Branches are `type/short-description`; one logical change per PR

## Ask before you
- Create or run a database migration
- Add, remove or upgrade a dependency
- Change CI workflows or anything under `infra/`
- Delete a file you didn't create in this task

## Never
- Commit `.env` files or secrets. Add new variables to `.env.example`.
- Skip, disable or loosen a test or lint rule to get a check passing

## Done means
- Lint, type checks and the tests for the code you touched pass
- New behaviour has a test
- The PR description says what changed and how you checked it

## Read when relevant
- Architecture decisions: `docs/adr/`
- API conventions: `docs/api.md`

In a monorepo, give each package a short AGENTS.md with only its own commands and rules. Cursor, Copilot cloud agent and Amp pick it up when they work in that folder, and Codex when you start it there.1011179 For Claude Code, see the monorepo step in the fix above.

Treat AGENTS.md changes as code under review

Agents try to run the checks these files list, so editing one command changes what agents run.20 Anthropic tells teams to treat CLAUDE.md like code, reviewing and pruning it and checking that a change actually shifts Claude’s behaviour.22 We’d put every instruction file through pull request review, the same as CI config.

  • Give the files an owner. List them in CODEOWNERS and require that owner’s review. Our post on agent config files that run code has a CODEOWNERS block for these paths and covers the security side.
  • Run the listed commands in CI. A renamed script then fails a build before an agent follows the stale line.
  • Audit for drift. In Claude Code 2.1.283 or later, /doctor prompt-audit reports references to missing files or commands and contradictions across CLAUDE.md, CLAUDE.local.md and AGENTS.md files. It changes nothing until you ask.2

Checklist for one repository this week

  1. Find every instruction file, subfolders included. Look for AGENTS.md, CLAUDE.md, .claude/CLAUDE.md, GEMINI.md, .cursorrules, .cursor/rules/, .github/copilot-instructions.md and .github/instructions/, and ask developers about gitignored CLAUDE.local.md files.
  2. Merge the shared content into AGENTS.md and delete the duplicates.
  3. Start CLAUDE.md with @AGENTS.md, beside each nested AGENTS.md too, or replace CLAUDE.md with .claude/rules/ once every install runs 2.1.281 or later.
  4. Clear out leftovers. Delete .cursorrules, trim copilot-instructions.md to Copilot-only notes and set context.fileName for Gemini CLI.
  5. Cut the file down to commands, layout pointers, conventions, boundaries and a definition of done, in under 200 lines.
  6. Back hard boundaries with permission rules or hooks.
  7. Check what each tool loaded, using the last column of the table.
  8. Add a code owner and a CI job that runs the commands the file lists.

  1. Anthropic, “Claude Code changelog”, versions 2.1.277 and 2.1.281, https://code.claude.com/docs/en/changelog, and CHANGELOG.md as of 20 October 2026, https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md ↩↩↩

  2. Anthropic, “How Claude remembers your project”, Claude Code docs, https://code.claude.com/docs/en/memory ↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩↩

  3. Decoding AI, “Does Claude Code Read AGENTS.md? We Checked 283 Repos - 161 Say No”, Towards AI, 24 September 2026, https://pub.towardsai.net/does-claude-code-read-your-agents-md-we-checked-283-repos-in-161-it-still-reads-claude-md-cb6199708fc1 ↩↩↩

  4. Cursor help, “Rules”, https://cursor.com/help/customization/rules ↩↩↩↩

  5. Git documentation, “git-config”, entry for core.symlinks, https://git-scm.com/docs/git-config ↩

  6. Simon Willison, “A quote from Thariq Shihipar”, 18 September 2026, https://simonwillison.net/2026/Sep/18/thariq-shihipar/ ↩

  7. Anthropic, claude-code release v2.1.277, 18 September 2026, https://github.com/anthropics/claude-code/releases/tag/v2.1.277 ↩

  8. Anthropic, claude-code release v2.1.281, 23 September 2026, https://github.com/anthropics/claude-code/releases/tag/v2.1.281 ↩

  9. OpenAI, “Custom instructions with AGENTS.md”, Codex docs, https://learn.chatgpt.com/docs/agent-configuration/agents-md ↩↩↩↩↩

  10. Cursor docs, “Rules”, https://cursor.com/docs/rules ↩↩↩↩↩↩

  11. GitHub Docs, “Adding repository custom instructions for GitHub Copilot”, https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions, and “Support for different types of custom instructions”, https://docs.github.com/en/copilot/reference/custom-instructions-support ↩↩↩↩

  12. GitHub Docs, tutorial on custom instructions for Copilot code review, https://docs.github.com/en/copilot/tutorials/customize-code-review ↩

  13. GitHub Changelog, “Copilot cloud agent fields added to usage metrics”, 23 April 2026, https://github.blog/changelog/2026-04-23-copilot-cloud-agent-fields-added-to-usage-metrics/ ↩

  14. Visual Studio Code docs, “Use custom instructions in VS Code”, https://code.visualstudio.com/docs/copilot/customization/custom-instructions ↩↩

  15. Gemini CLI docs, “Provide context with GEMINI.md files”, https://geminicli.com/docs/cli/gemini-md/ ↩↩↩

  16. Zed docs, “Instructions”, https://zed.dev/docs/ai/instructions ↩↩↩↩

  17. Amp docs, “AGENTS.md”, https://ampcode.com/docs/customize/agents-md ↩↩

  18. Google for Developers Blog, “An important update: Transitioning Gemini CLI to Antigravity CLI”, 19 May 2026, https://developers.googleblog.com/an-important-update-transitioning-gemini-cli-to-antigravity-cli ↩

  19. Google Antigravity docs, “Rules”, https://antigravity.google/docs/rules ↩↩

  20. AGENTS.md, https://agents.md/ ↩↩↩

  21. OpenAI, “Best practices”, Codex docs, https://learn.chatgpt.com/docs/learn/best-practices ↩↩↩↩↩↩↩

  22. Anthropic, “Best practices for Claude Code”, Claude Code docs, https://code.claude.com/docs/en/best-practices ↩↩↩↩↩

  23. Gemini CLI docs, “Configuration”, context settings, https://geminicli.com/docs/reference/configuration/ ↩

  24. Gemini CLI docs, “Trusted Folders”, https://geminicli.com/docs/cli/trusted-folders/ ↩

Frequently asked questions

Does Claude Code read AGENTS.md?

Yes, since version 2.1.277 of 18 September 2026, but only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in the working directory or above it. Version 2.1.281, released on 23 September, extended this to Bedrock, Vertex AI and Foundry sessions.

What happens if a repo has both AGENTS.md and CLAUDE.md?

Claude Code reads only CLAUDE.md by default, Amp and Zed pick AGENTS.md, and Copilot in VS Code combines the files it finds. Keep the shared instructions in AGENTS.md and start CLAUDE.md with an @AGENTS.md import so every tool reads the same text.

Should I symlink CLAUDE.md to AGENTS.md?

Only if nobody clones the repository on Windows. Git checks a symlink out as a small text file when core.symlinks is false, and Claude Code’s Edit and Write tools won’t write through a symlink. An @AGENTS.md import avoids both problems.

What should I put in AGENTS.md?

Build, test and lint commands, a few lines on layout, conventions that differ from defaults, actions the agent must ask about first, and what done means. Leave out secrets, long documents the agent can open itself and rules a linter already enforces.

Does Gemini CLI read AGENTS.md?

Not by default. Gemini CLI reads GEMINI.md unless you list AGENTS.md under context.fileName in .gemini/settings.json. Google’s Antigravity, which replaced Gemini CLI for Google AI Pro, Ultra and free Gemini Code Assist users on 18 June 2026, reads AGENTS.md or GEMINI.md.

Cursor rules vs AGENTS.md: which should I use?

Put instructions every agent should follow in AGENTS.md, which Cursor reads in the root and in subfolders. Keep .cursor/rules/*.mdc files for Cursor-only rules that need a glob or a manual trigger, and delete the legacy .cursorrules file.

Work with us

Building something like this?

9io is a small team of senior engineers with a fractional CTO, and we work by the hour. Send us a note about your product. The reply comes from the person who'd do the work.