Claude Code instruction files

CLAUDE.md vs AGENTS.md: which file each tool reads

Codex looks for AGENTS.override.md before AGENTS.md in each directory from the project root to the working directory. Claude Code can read AGENTS.md directly from v2.1.277 onward, but by default prefers CLAUDE.md in the working directory or its parents. Keep shared rules in AGENTS.md and import them with @AGENTS.md in a neighboring CLAUDE.md.

Last updated · Published

By CWYN · Sources checked as of · Not affiliated with Anthropic or OpenAI · Short answer as of Nov 22, 2026 (file discovery sources)

1. Match the file to the tool

Documented instruction discovery, as of November 20, 2026
ToolFiles and precedencePublic source
Claude CodeReads CLAUDE.md. From v2.1.277, it can also read AGENTS.md directly. By default, a CLAUDE.md or CLAUDE.local.md in the working directory or above takes priority over automatic AGENTS.md discovery. The Project instructions setting can change this.Claude Code memory docs
OpenAI CodexReads global instructions, then project instructions from the root to the working directory. Per directory, AGENTS.override.md precedes AGENTS.md, followed by configured fallback names. Deeper guidance overrides earlier guidance. CLAUDE.md needs an explicit fallback configuration to join this discovery order.Codex AGENTS.md docs

The AGENTS.md public spec describes plain Markdown and nearest-file precedence. It lists supporting tools, including Codex, Cursor and Jules. Consult each tool's docs before assuming identical discovery or import behavior.

2. Keep one source of truth

Start with the AGENTS.md examples for web apps, Python scripts and monorepos. Use the free AGENTS.md generator to add your preferences for edits and feedback to the shared file.

Starting a new project file? Copy the CLAUDE.md template and fill in your repository’s commands and paths.

Put shared commands, conventions and paths in AGENTS.md. Where Claude needs a companion file, put this single line in a neighboring CLAUDE.md:

@AGENTS.md

Claude's shared-file instructions support this pattern. Add only Claude-specific rules below it. Relative @path imports resolve from the importing file. An ordinary sentence asking Claude to read another file is not an import. This syntax is Claude's behavior; the AGENTS.md spec does not define a portable import mechanism.

3. Confirm what loaded

In Claude Code, run /context all and inspect Memory files. Use /memory to edit files; its menu can include paths for files that do not yet exist. For nested instructions, read a file in that directory and watch for the terminal's Loaded path. These checks come from Claude's memory troubleshooting docs.

In Codex, start a fresh session in the intended directory and ask it to list its active instruction sources. Expect the global file, repository guidance and any applicable override in order, as described in the Codex verification steps.

4. Check a rule before editing more files

Choose one command already documented by your repository. Ask each tool which command it would run without running it, then compare the answers. Reconcile contradictory instructions in the shared file and repeat in a fresh session. File discovery and following a rule are separate checks.

Once both tools see the same rules, compare Claude Code and Codex CLI for editing, review and hand-off to choose which one handles the next task.

To budget the same project on both tools, compare Claude Code and Codex costs.

Next steps

Write and check your shared instructions

Free AI instruction builder

Check your setup file before testing it in the tool.

Generate instructions for both tools

To generate both AGENTS.md and CLAUDE.md offline from the same answers, use AI Instruction Builder Pro ($14.95).