AGENTS.md vs CLAUDE.md: choose one repository instruction path

AGENTS.md vs CLAUDE.md compared: Codex and Claude Code loading rules, nested scope, coexistence, failure states, and a verified migration path.

AGENTS.md vs CLAUDE.md repository review with two engineers mapping root and nested instruction files
Original Neyrotex editorial reconstruction. The root-file choice sets the path that each coding agent follows into service-specific guidance.

Codex counts all discovered project instructions toward that configurable 32 KiB default. Claude Code can read either file family, both families, or only managed instructions, depending on version and the Project instructions setting.

A platform lead does not need a universal winner. The useful choice is the smallest repository contract that every approved host can load, explain, and verify without hiding a rule behind another file.

AGENTS.md vs CLAUDE.md starts with two loader contracts

OpenAI documents a root-to-working-directory walk. Codex reads one non-empty global instruction file, then checks each directory from the project root to the current working directory.

Within each directory, Codex checks AGENTS.override.md before AGENTS.md and configured fallback names. It includes at most one instruction file from that directory, so a nearby override can replace the regular file at the same level.

Anthropic documents a selection rule before the directory walk. Claude Code v2.1.277 or later can read AGENTS.md, but the default mode reads project-path CLAUDE.md files instead when one exists in the working directory or an ancestor.

Source disagreement map: follow the active host

  1. Codex: check the Codex home file, then one instruction file per directory from repository root to working directory.
  2. Claude default: read AGENTS.md only when no project-path CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md takes precedence.
  3. Claude both-mode: read each directory’s CLAUDE.md first and AGENTS.md after it, while skipping a duplicate AGENTS.md already imported or symlinked.
  4. Team check: ask each approved host to list loaded instruction sources before relying on nested scope or precedence.

The two products agree on one useful pattern: broad repository rules belong near the root, and narrow service rules belong near the files they govern. Their discovery details still differ enough to make an untested dual-file setup risky.

Round one: one shared base file

AGENTS.md wins the portability round for a mixed Codex and Claude Code team. Codex treats it as the native project instruction file, while current Claude Code can load it without a wrapper when its setting and version allow that path.

The default Claude behavior contains the catch. A CLAUDE.md, .claude/CLAUDE.md, or CLAUDE.local.md on the active project path suppresses direct AGENTS.md loading unless the user selects both-mode.

A compatibility import gives teams a controlled bridge. Anthropic recommends placing @AGENTS.md in CLAUDE.md when a session cannot load AGENTS.md, when Project instructions is set to CLAUDE.md, or when the team needs Claude-specific lines below the shared import.

Round two: host-specific capabilities

CLAUDE.md wins when the team needs Claude Code’s instruction tooling rather than a cross-host base. Anthropic says InstructionsLoaded hooks fire for CLAUDE.md, while an AGENTS.md loaded through the Project instructions setting does not trigger those hooks.

Additional directories form another boundary. With Claude Code’s additional-directory CLAUDE.md option enabled, those directories can load CLAUDE.md files, but the equivalent AGENTS.md files do not load through that mechanism.

Codex has a different specialization path. AGENTS.override.md takes precedence within a directory, and project_doc_fallback_filenames lets a team add alternate names. The combined project instruction stream stops at project_doc_max_bytes, whose documented default is 32 KiB.

Which file earns the root?

Repository condition Recommended root contract Verification
Codex and current Claude Code AGENTS.md as shared base Codex instruction summary plus Claude /memory or /context
Mixed Claude versions or restricted sessions AGENTS.md plus CLAUDE.md import Confirm the import once and check for duplicate content
Claude Code-only with hooks or path rules CLAUDE.md Inspect InstructionsLoaded events and active rules
Temporary Codex exception in one subtree Nested AGENTS.override.md Start Codex in that subtree and list sources

Round three: nested scope and conflict cost

Nested files save context when they contain rules that matter only below that directory. They also create a debugging cost: the same prompt can receive different instructions when an agent starts from the repository root or a service folder.

OpenAI’s repository-rule guidance recommends consequential, scoped invariants rather than formatting checks. The suggested test uses one change that should trigger the rule, one safe counterexample, and one unrelated change that should stay quiet.

The Codex prompting guide adds an important implementation detail: each discovered instruction file enters model context as its own user-role message in root-to-leaf order. A directory map is therefore a context map, not a documentation index.

Make that map physical during a team review: pin AGENTS.md and CLAUDE.md cards at the repository root, then trace the service folders beneath them. The exercise forces owners to name which file should govern each path before an agent makes a change.

A second verification check can remain factual: hands move from the repository root to a service folder while a terminal displays the loaded filenames and short paths.

AGENTS.md vs CLAUDE.md verification with hands checking loaded filenames at a nested repository path
Original Neyrotex editorial reconstruction. A short loaded-file readout exposes a missing import or an unexpected ancestor before the rule affects code.

Failure states worth testing before consolidation

A CLAUDE.local.md can surprise a developer who expects Claude Code to read the repository’s AGENTS.md. Under the default setting, that local file counts as a project-path CLAUDE.md and changes the selected file family.

An AGENTS.override.md can surprise a Codex user who edits AGENTS.md in the same directory. Codex selects the override first, so the regular file in that directory does not join the instruction stream.

A large instruction tree can lose its tail in Codex after the combined byte limit. Raising the limit may help, but moving specialized rules into the directory where they apply makes the loading path easier to inspect.

Claude’s direct AGENTS.md support also has version and session boundaries. Anthropic documents gaps before v2.1.277, plus older cases where Bedrock or disabled telemetry affected support. Teams with those hosts should keep an import until each approved environment passes the load check.

A migration sequence that preserves working rules

  1. Inventory the active files. List every AGENTS.md, AGENTS.override.md, CLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, import, symlink, and host setting.
  2. Choose the shared base. For a mixed team, move cross-host invariants into root AGENTS.md and keep host-specific guidance in the smallest wrapper that needs it.
  3. Preserve nested ownership. Keep payment, deployment, data, or platform rules beside the code they govern when both loaders can reach them.
  4. Run positive and negative checks. Ask each host to summarize loaded sources from the root and one nested service, then try a rule trigger and an unrelated change.
  5. Remove duplicate delivery. Delete an old hook or wrapper only after the supported sessions show one copy of the intended guidance.

Teams building agent workflows can continue with the OpenAI Agents API production checklist. The OpenAI Terraform governance guide shows how to keep platform rules reviewable, while the GPT-6 Sol versus Luna routing guide applies the same conditional-decision discipline to model selection.

Browse the Neyrotex AI Tech hub for related agent and platform analysis.

Return to the 32 KiB question

The first number still gives the clearest decision rule. If your shared instructions fit inside one concise root contract and both approved hosts can name that file, choose AGENTS.md and add a Claude import only where the loader requires it. Choose CLAUDE.md when Claude-specific loading features are part of the requirement, then keep Codex guidance in its own verified path rather than assuming the filenames are interchangeable.