AGENTS.md across coding agents: who reads it, which file wins, and where it gets skipped
Codex, Claude Code, Gemini CLI and GitHub Copilot all say they support AGENTS.md, but they find it, merge it and override it in different ways. Here's what each one actually loads, per the official docs.
AGENTS.md is about as low-tech as an agent standard gets. It's a Markdown file in your repo that tells coding agents how to build and test your project and what to leave alone. The official site calls it "a README for agents," says it's used by over 60,000 open-source projects, and notes that it's now stewarded by the Agentic AI Foundation under the Linux Foundation. There are no required fields. You write headings and sentences, and the agent reads them.
The catch shows up when your team doesn't all use the same tool. The format is shared, but the loading rules aren't. Each agent decides for itself which files to look for, in what order, how much to read, and what happens when two files disagree. One person on Codex and another on Claude Code can open the same repo and start with different instructions without either of them noticing. This post walks through what Codex, Claude Code, Gemini CLI and GitHub Copilot do with AGENTS.md, using their own docs as of November 29, 2026.
What the format itself promises
The agents.md site makes two rules that matter. For monorepos, you put another AGENTS.md inside each package, and "the closest one takes precedence." The site says OpenAI's main repo had 88 of them at the time of writing. And when instructions conflict, "the closest AGENTS.md to the edited file wins; explicit user chat prompts override everything."
Everything past that is up to the tool. The spec doesn't say whether files get merged or replaced, how big they can be, or what an agent should do if you also have a vendor-specific file sitting next to it. That's where the four tools split.
Codex: one file per directory, merged top down, capped at 32 KiB
OpenAI documents the most explicit algorithm in its AGENTS.md guide for Codex. Codex builds an instruction chain once when a run starts. First it looks in your Codex home directory (~/.codex unless you set CODEX_HOME) and uses AGENTS.override.md if it exists, otherwise AGENTS.md. Then it starts at the project root, usually the Git root, and walks down to your current working directory. In each directory along that path it checks AGENTS.override.md, then AGENTS.md, then any names you listed in project_doc_fallback_filenames, and takes at most one file per directory.
Those files get concatenated from the root down, joined with blank lines. Codex doesn't resolve conflicts itself. Files closer to where you're working just land later in the prompt, so their guidance wins by position. Empty files are skipped, and Codex stops adding files once the combined size hits project_doc_max_bytes, which defaults to 32 KiB.
That cap is the part people trip on. If your root AGENTS.md is a long essay, the nested file for the package you're actually editing is the one most likely to get cut, because it comes last. Keep the root file short and push package-specific detail down into the package. The override file is handy too. OpenAI's example drops an AGENTS.override.md into services/payments/ so that directory uses make test-payments instead of npm test. Just remember that inside that directory, the override replaces the regular AGENTS.md instead of adding to it.
Claude Code: reads AGENTS.md only if you don't have a CLAUDE.md
Claude Code has its own file, CLAUDE.md, and its memory docs now cover reading AGENTS.md directly. That needs Claude Code v2.1.277 or later. The default rule is either/or. Claude reads your AGENTS.md only when there's no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working directory or anywhere above it. If any of those exist, Claude reads the CLAUDE.md files and skips AGENTS.md entirely.
There's a nasty little trap in that rule. CLAUDE.local.md is the file Anthropic suggests for personal, gitignored preferences. Create one in a repo that relies on AGENTS.md and you've quietly turned off AGENTS.md for yourself. The docs call this out and point to the fix: set Project instructions to claude-md-and-agents-md in /config. With that setting, each directory's CLAUDE.md files load first and its AGENTS.md after them, and Claude Code skips an AGENTS.md it already loaded, so nothing gets read twice. Your user-level ~/.claude/CLAUDE.md and your org's managed CLAUDE.md don't count toward the either/or check, so those keep loading alongside AGENTS.md.
The bigger compatibility gap is in what Claude doesn't read at all. The docs list AGENTS.local.md, AGENTS.override.md and anything under a .agents/ directory as not read. So that payments override from the Codex example is invisible to Claude Code. If half your team uses each tool, the payments service runs make test-payments for the Codex people and plain npm test for the Claude people.
The oldest workaround still works fine. A CLAUDE.md containing just @AGENTS.md imports the file, and Anthropic says keeping that import never makes Claude read AGENTS.md twice under any setting. Imports can nest up to four hops deep. It's also the only route in sessions that can't load AGENTS.md directly, such as older versions or a setup where the built-in AGENTS.md plugin is disabled. One thing to delete, though: if you once wrote a SessionStart hook that prints AGENTS.md into the session, the docs say to remove it, because now you'd get a second copy in context.
Gemini CLI: you have to ask for it by name
Gemini CLI uses GEMINI.md by default and won't pick up AGENTS.md until you tell it to. You do that with the context.fileName setting in settings.json, which takes a single name or a list. The docs' own example is ["AGENTS.md", "CONTEXT.md", "GEMINI.md"].
{
"context": {
"fileName": ["AGENTS.md", "GEMINI.md"]
}
}
Its loading model is also the most generous of the four. It reads a global ~/.gemini/GEMINI.md, then context files in your workspace directories and their parents, then just-in-time files whenever a tool touches a file or directory, scanning that directory and its ancestors up to a trusted root. It concatenates everything it finds and sends it with every prompt. There's no documented one-file-per-directory rule or byte cap like Codex has. That makes /memory show worth running now and then, since it prints the exact combined context the model is getting. If you edit files mid-session, /memory reload re-scans them.
GitHub Copilot: nearest file wins, but precedence depends on the surface
GitHub's repository instructions docs say you can put AGENTS.md files anywhere in the repo, and when Copilot is working, the nearest one in the directory tree takes precedence. As an alternative it accepts a single CLAUDE.md or GEMINI.md at the repo root. These sit next to Copilot's own formats, .github/copilot-instructions.md for repo-wide rules and .github/instructions/*.instructions.md files with applyTo globs for specific paths.
How those combine depends on where you're using Copilot. The custom instructions overview says most clients, including Copilot CLI, VS Code and Visual Studio, combine the applicable files without a general precedence order. Copilot Chat on GitHub.com does rank them: personal instructions first, then repository instructions (path-specific, then repo-wide, then agent files like AGENTS.md), then organization instructions. The same page says agent instructions aren't supported by every Copilot feature yet. So "it's in AGENTS.md" doesn't guarantee every Copilot surface saw it.
One detail matters for anyone thinking about security. GitHub says that when Copilot reviews a pull request, it reads instructions, agent instructions and skills from the head branch, the one with the changes, not the base branch. In practice that means a PR can edit AGENTS.md and the edited version shapes the review of that same PR. Look at instruction-file diffs in PRs with the same suspicion you'd give a CI config change. Our prompt injection post covers why text an agent reads as instructions deserves that.
A setup that behaves the same everywhere
If you want one repo that gives every one of these tools the same starting point, the docs line up well enough. Make AGENTS.md the real source, keep the root one short, and put package-specific rules in nested AGENTS.md files instead of AGENTS.override.md, since Claude Code doesn't read overrides. For Claude Code users, either have no CLAUDE.md at all or make it a one-line @AGENTS.md import plus anything truly Claude-only. Tell anyone who adds a CLAUDE.local.md to switch Project instructions to claude-md-and-agents-md. Gemini CLI users add AGENTS.md to context.fileName. Copilot needs nothing extra beyond checking that the feature you rely on actually supports agent instructions.
Size is worth watching. Codex stops at 32 KiB combined. Anthropic suggests keeping each CLAUDE.md under 200 lines and notes that imports help you organize but don't make a file cheaper, since imported files load in full. Gemini sends everything with every prompt. Every line in AGENTS.md costs tokens on every turn, so this is the same budgeting problem as counting tokens before you send. Long procedures that only matter now and then fit better in skills, which load on demand.
And don't put rules in AGENTS.md that you need enforced. Anthropic is blunt about this: CLAUDE.md files are context, not enforced configuration, and if you need to block an action regardless of what Claude decides, use a PreToolUse hook. GitHub's overview warns that Copilot may not follow custom instructions the same way every time. Use AGENTS.md for how to work in the repo, like the test command or the folder nobody should touch. Hard limits like "never push to main" or "no network in tests" go in hooks, sandbox settings and branch protection.