Claude Code & Context Engineering

AGENTS.md vs CLAUDE.md: What Goes Where When You Use More Than One AI Coding Tool

21 November 2026 · Updated 28 November 2026 · 11 min read · by Yang Kai

AGENTS.md or CLAUDE.md? A practical split for multi-tool builders — what belongs in each file, what to share, and a minimal pair you can copy today.

Table inside: Decision table and minimal AGENTS.md + CLAUDE.md pair

Contents
  1. Criterion 1: who reads it
  2. Criterion 2: loading behaviour and precedence
  3. Criterion 3: Claude Code support, as of November 2026
  4. Criterion 4: features on top
  5. Criterion 5: maintenance and drift
  6. The decision table
  7. A minimal pair you can copy
  8. Commands
  9. Boundaries
  10. Done means
  11. Claude Code workflow
  12. Where skills and hooks fit
  13. When to skip one of the files
  14. The verdict, by use case

The failure looks like this: a second AI tool opens your repo, works confidently for an hour, and ignores every convention you set — because those conventions live in a file it never reads. One tool, one file is fine. The moment a second agent, a teammate’s different setup, or an automated reviewer enters the repo, you need a shared layer and a tool-specific layer, and a rule for deciding which is which.

This comparison gives that rule. It scores the two files criterion by criterion, covers the loading change that landed in Claude Code in late 2026, and ends with the exact split and a minimal pair to copy. The mechanics are checked against Anthropic’s and OpenAI’s documentation and the agents.md format as of November 2026.

In a hurry? Shared rules go in AGENTS.md; Claude-only behaviour goes in CLAUDE.md; and since September 2026 Claude Code itself reads AGENTS.md when no CLAUDE.md is present. The full verdict:

Criterion AGENTS.md CLAUDE.md Winner
Who reads it Codex, Cursor, Copilot, Gemini CLI, Windsurf, Devin, and 20+ more tools Claude Code AGENTS.md
Format rules Plain Markdown, no required sections Plain Markdown, plus Claude-only extras Tie
Loading depth Nested files; nearest to the edit wins Four scopes, concatenated; subdirectory files load on demand CLAUDE.md
Extra features None — portability is the point @path imports, .claude/rules/, CLAUDE.local.md CLAUDE.md
Maintenance One file every tool shares Drifts if it duplicates the shared file AGENTS.md
Best role The shared working agreement The thin Claude Code layer on top —

Criterion 1: who reads it

AGENTS.md is the open format, stewarded by the Agentic AI Foundation and used by 60,000+ open-source projects according to the agents.md site. Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Devin, Zed, Aider, and more read it natively. CLAUDE.md is read by exactly one tool: Claude Code.

That asymmetry decides the default. A rule in AGENTS.md is a rule every agent in the repo can follow; a rule in CLAUDE.md is a rule one agent follows and the rest never see.

Winner: AGENTS.md — it is the only file in the pair with an audience larger than one tool.

Criterion 2: loading behaviour and precedence

Both formats support nesting, but they assemble files differently.

With AGENTS.md, the convention is simple: the file closest to the code being edited takes precedence, and an explicit instruction in your prompt overrides every file. Codex implements it by walking from the project root down to your working directory and concatenating what it finds, so closer files land later in the prompt and win where they conflict. Codex also reads a personal ~/.codex/AGENTS.md, and an AGENTS.override.md beats the plain file in the same directory.

Claude Code loads CLAUDE.md from four scopes — managed policy, your user file at ~/.claude/CLAUDE.md, the project file, and CLAUDE.local.md — concatenated from the root down, with the file closest to your work read last. Files in subdirectories load on demand, when the agent reads files there. Anthropic’s docs add a warning that matters for both formats: these files are context, not enforced configuration. They guide the model; hooks and permissions are what enforce.

Winner: CLAUDE.md — the scope stack and on-demand subdirectory loading give you finer control. But you only feel the difference in large repos; for most projects the AGENTS.md nearest-wins rule is enough.

Criterion 3: Claude Code support, as of November 2026

This is the criterion that changed, and older comparisons get it wrong. Until recently, Claude Code ignored AGENTS.md entirely, and the standard advice was a symlink or a CLAUDE.md that imports it.

Since Claude Code version 2.1.277 (18 September 2026), Claude Code reads AGENTS.md directly — as a fallback. The default rule, from Anthropic’s memory documentation:

The behaviour is configurable under Project instructions in /config: the default mode above, a mode that loads both files, a CLAUDE.md-only mode, and a managed-only mode. Two traps deserve bold type. First, a personal CLAUDE.local.md counts as a CLAUDE.md — add one for a private preference and the team’s AGENTS.md silently stops loading; the fix is the load-both mode. Second, the fallback is not yet available on Bedrock, Vertex, or Foundry deployments, and sessions that cannot fetch feature flags (telemetry disabled, for instance) cannot use it either. In those setups, the @AGENTS.md import line is still the reliable route.

Winner: AGENTS.md — a repo can now run on the shared file alone and Claude Code will follow it, with the caveats above. CLAUDE.md remains the file Claude Code reads first when it exists.

Criterion 4: features on top

CLAUDE.md carries machinery AGENTS.md deliberately lacks:

AGENTS.md offers none of this, on purpose: every feature a format adds is a feature another tool cannot read. Its only structural trick is nesting.

Winner: CLAUDE.md — if Claude Code is your main tool, imports and path-scoped rules are real capability, and they belong in the Claude layer where they cannot confuse other agents.

Criterion 5: maintenance and drift

The temptation is to copy everything into both files “just in case.” Resist it. GitHub’s analysis of 2,500+ AGENTS.md files and an independent scan of 32 real files (only 7 covered all six good-practice areas) describe files that already struggle to stay complete as single documents.

Two full copies will diverge. One gets the new build command, the other keeps the old one, and now an agent is confidently running a command that no longer exists. A short shared file plus a short tool-specific file is easier to keep true than two long mirrors. Duplication also costs context: as the context budget audit shows, every always-loaded line is rent you pay on every request, and two overlapping files means paying twice for the same instruction.

Winner: AGENTS.md — as the single home for shared rules, with CLAUDE.md kept thin enough that there is almost nothing in it to drift.

The decision table

Use this when you are staring at a rule and cannot decide where it lives.

Instruction AGENTS.md CLAUDE.md Why
Project purpose and audience Yes No True for every tool and human
Build, test, and check commands Yes No Shared fact about the repo
Package manager and Node version Yes No Shared fact, often guessed wrong
“Never edit .env files” Yes No Safety boundary for all agents
Code style that can be linted Yes, briefly No Point to the linter config instead
Definition of done checklist Yes No Same bar for every contributor
“Use the deploy-check skill before shipping” No Yes Names a Claude Code skill
Subagent delegation preferences No Yes Claude Code-specific workflow
Hook behaviour and what to do when blocked No Yes Tied to your settings.json
Path-scoped rules (.claude/rules/) No Yes A Claude Code loading feature
Personal cross-project preferences No Yes (user file) ~/.claude/CLAUDE.md, never the repo
Personal tone for commit messages Either Either Pick one home, never both
Links to long docs Yes, as pointers No Load detail on demand, not by default

The pattern is clear once you see it in a table: facts about the repo go shared, facts about the tool go specific. The writing craft for the shared file — the six areas, the annotated template — is in the AGENTS.md field guide.

A minimal pair you can copy

Here is the smallest setup that works on Astro and Next.js repos. First, the shared file:

<!-- AGENTS.md -->
# Project
Astro content site for builders. Speed and correct frontmatter matter most.

## Commands
- npm run dev / npm run build / npm run check
- Package manager: npm only

## Boundaries
- Never edit .env*, package-lock.json, or published content in src/content/
- Small diffs, one concern per change, read a file before editing it

## Done means
Build passes, no new type errors, summary of what was not tested.

Then the Claude Code layer, which adds only what is specific:

<!-- CLAUDE.md -->
@AGENTS.md

## Claude Code workflow
- For multi-file changes, outline the plan before editing.
- Use the content-schema skill when creating or editing articles.
- If a hook blocks an edit, stop and explain the block — do not work around it.
- Split research and implementation using the pattern in our subagent briefs.

The first line does the gluing. With the @AGENTS.md import, Claude Code loads the shared file on every version and deployment — no reliance on the 2.1.277 fallback, no surprise when someone adds a CLAUDE.local.md. Do not assume layering happens by itself; say it in the file.

Where skills and hooks fit

Skills are neither file. A skill loads on demand for a specific kind of task, which is why it should hold the long, detailed procedure that would bloat both instruction files — the case is built in Claude Code skills, explained. Hooks, meanwhile, are configuration, not prose: they live in settings and enforce boundaries mechanically, as shown in the Claude Code hooks that catch real mistakes.

A useful mental model, extended in agent memory patterns: AGENTS.md says what is true, CLAUDE.md says how Claude Code should work here, skills say how to do a particular job, and hooks stop the known accidents.

When to skip one of the files

Honesty matters here. If you are a solo builder who only uses Claude Code, a single well-kept CLAUDE.md is fine — and as of late 2026, a single AGENTS.md also works, because Claude Code will read it as the fallback. Adding the second file is ceremony until a second tool, a second person, or an automated agent starts touching the repo. The reverse holds too: if your whole team uses other tools and you are the only Claude Code user, keep your CLAUDE.md thin and personal, and put your energy into the shared file.

The verdict, by use case

Do the audit today: list every rule you maintain in two places, pick a single home for each using the table above, and shrink CLAUDE.md to the import line plus tool-specific instructions. Then run the context budget audit to check what the slimmer setup saves you — and read your first CLAUDE.md if the Claude layer itself needs a rebuild.

FAQ

Do I need both files? Only if you use more than one agent tool, or you want Claude Code features (imports, path-scoped rules) alongside a shared file. One tool means one file is enough; the second file earns its keep the day a second tool or teammate arrives.

What belongs only in CLAUDE.md? Anything referencing Claude Code features other tools do not have: skills, hook behaviour, slash-command habits, .claude/rules/, personal preferences. Shared facts — stack, commands, hard rules, definition of done — belong in the shared file.

Will Claude Code read AGENTS.md? Yes, since version 2.1.277 — as a fallback. With no CLAUDE.md or CLAUDE.local.md in the working directory or any parent, Claude Code loads AGENTS.md instead. If a CLAUDE.md exists, it takes over by default; change that under Project instructions in /config, or put an @AGENTS.md import line in CLAUDE.md, which works everywhere including Bedrock, Vertex, and Foundry.

Which file wins if they disagree? For most tools, the file closest to the edited code wins. Inside Claude Code, files are concatenated with the closest read last — and a CLAUDE.md in the chain disables the AGENTS.md fallback entirely. All of which is a long way of saying: disagreement is the failure mode. Keep one source of truth per rule and delete the duplicate.

Category: Claude Code & Context Engineering · Tags: #claude-code #agents-md #claude-md #ai-coding #ai-agents

Next step: this article is part of Claude Code guides, which covers the full topic from first setup to advanced use.

Related guides