← Back to all posts Claude Code and Codex load different rule files from the same folder ~/ home-directory file workspace/ · git root · 14,864 B engagements/ · 15,855 B project/ · nested .git · 17,770 B ← both agents launched here walks up, no git boundary Claude Code loads 55,986 bytes every parent directory, imports expanded Codex loads 24,150 bytes nested git root down · 32 KiB cap never fired 30,058 bytes unread by Codex 54% of the rulebook · nothing warned me Byte counts measured on one workspace, 2026-09-14. Directory names are generic; the numbers are unmodified.

CLAUDE.md and AGENTS.md: One Rulebook All Three Agents Read

Sep 14, 2026 · AI & Building

Every guide about CLAUDE.md and AGENTS.md gives the same advice, and it's good advice: keep one main file, and make the others thin shims that import it. Anthropic's own docs say this: “Claude Code reads CLAUDE.md, not AGENTS.md. If your repository already uses AGENTS.md for other coding agents, create a CLAUDE.md that imports it.” I follow it. My root CLAUDE.md is three lines long and the first one is an import.

That fixed the filenames, which is the part most guides cover. The three tools also disagree on which directories to collect those files from, so two agents launched in the same folder can end up with very different rulebooks, and the one with fewer rules has no idea. I found this by counting the bytes each tool loads from the same folder.

Quick answer: from a single working directory three levels deep in my workspace, Claude Code loaded 55,986 bytes of instructions and Codex loaded 24,150. The missing 30,058 bytes (54% of the rulebook) sat above a nested repository's own Git root, and Codex starts its search at the Git root. Nothing warned me. The Codex chain finished with 8,618 bytes to spare, so the well-known 32 KiB cap never came into it.

The Three Loaders Disagree About Where “The Project” Starts

All of these rules are in the docs, and I'd read all three before I built the layout that broke. The trouble shows up when you put them side by side, which no vendor's docs do.

ToolReadsWhich directories it collects fromSize behaviour
Claude Code CLAUDE.md, CLAUDE.local.md “your current working directory and every directory above it.” No Git boundary appears in the rule. Subdirectory files load on demand when it reads files there Loads a file up to 4 MiB in full, skips larger. Advises under 200 lines for adherence
Codex AGENTS.override.md, then AGENTS.md, then your configured fallbacks “Starting from the Git root down to your current directory.” A nested .git becomes the ceiling “stops adding files once the combined size reaches the limit defined by project_doc_max_bytes (32 KiB by default)”
Gemini CLI GEMINI.md by default; context.fileName accepts another name or a list, including AGENTS.md Home-directory file, then configured workspace directories, then “that directory and its ancestors up to a trusted root” No published byte cap; concatenates general to specific, deepest last

In the middle column, Claude Code walks up past every repository edge, and Codex walks down from the nearest one. In a flat, single-repo project they happen to pick the same files, which is why almost nobody notices. Put one .git inside another and they pick different files.

The Measurement: 55,986 Against 24,150

My workspace is a root repository with nine sibling repositories inside it, one per area of work, and one of those has a repository of its own nested a level deeper. I set it up that way for reasons that have nothing to do with agents: separate histories and separate commits per area. It's also a common layout. Any monorepo with vendored submodules looks like this.

I launched from the deepest directory and counted what each tool's documented rule would collect. I've made the directory names generic, but the byte counts are exact.

CLAUDE CODE: cwd upward, across git boundaries, imports expanded ~/.claude/CLAUDE.md 7,497 workspace/CLAUDE.md + import 176 + 14,688 workspace/engagements/CLAUDE.md + import 485 + 15,370 workspace/engagements/project/CLAUDE.md 280 + 17,490 ------------------------------------------------- TOTAL 55,986 bytes (743 lines) CODEX: git root downward, no imports ~/.codex/AGENTS.md 6,660 workspace/engagements/project/AGENTS.md 17,490 ------------------------------------------------- TOTAL 24,150 bytes (316 lines) cap 32,768, headroom remaining: 8,618 UNREAD BY CODEX 30,058 bytes

The 30,058 bytes are the workspace root rulebook and the tier above the nested repository: the failure-registry triggers, the naming rules, the single-committer Git convention, and the instruction never to claim something is done without the file that proves it. Claude Code loaded all of it, and Codex, launched from the same folder at the same time, loaded none.

Why the 32 KiB Cap Is the Wrong Thing to Worry About

The cap exists, and it's the number people quote most when they talk about these files. OpenAI's docs say it plainly: Codex “concatenates files from the root down” and “stops adding files once the combined size reaches the limit defined by project_doc_max_bytes (32 KiB by default)”. There is an open issue on the Codex repository reporting that when it kicks in there's no warning in the terminal UI, no log line and nothing in the editor extension. I checked my own config.toml while writing this. I've never set project_doc_max_bytes, so I'm running the 32,768-byte default.

The Codex chain came in at 24,150 bytes with a quarter of the budget left, so the cap never fired. My problem was how far up the tree Codex looks, which I'll call reach. It never looked above the Git root, and a size cap can't catch that.

You fix a length problem by trimming, and that's what most articles about these files tell you to do. If the problem is reach, trimming only shortens the files the agent was already reading, and the ones it can't see stay hidden. I spent a whole session trimming before I thought to measure, and it got me nothing.

The five-second check, before you rewrite anything. If one agent follows a rule and another ignores it, run git rev-parse --show-toplevel from the directory you launch the agent in. If that path is below the file with the rule, a tool that starts at the Git root was never going to read it, and rewording the rule won't change that.

The Import Trick Covers Two Tools Out of Three

The standard fix (one main file, plus shims that import it) works well where it works. Claude Code's import path is relative to the file doing the import, and imports can nest up to four levels deep. Gemini CLI supports the same idea. Both can point at a single AGENTS.md, and mine do. My CLAUDE.md files in two pillars are eleven bytes each: one import line and a newline.

Codex can't do this. I read its instruction-file docs end to end looking for an include directive, because I assumed I'd missed it. The docs cover discovery order, precedence, AGENTS.override.md for temporary global overrides, and configurable project_doc_fallback_filenames. They have no import or include syntax of any kind. A Codex instruction file has to contain its own text.

So with three tools you have two options:

ShapeHow it worksWhat it costs
Canonical AGENTS.md
(use this inside a repo)
AGENTS.md holds every shared rule. CLAUDE.md is one import line plus any Claude-only additions. Gemini CLI either imports it or has AGENTS.md added to context.fileName Nothing, inside one repository. Breaks the moment a rule needs to live above a nested Git root
Mirrored portable block
(use this for home-directory files)
The shared rules live between two marker comments and are copied byte-for-byte into each tool's home file. Tool-specific content goes outside the markers It's a copy, so it will drift. You need a scripted diff that fails loudly

The home-directory files are where the import can't help, because there's no shared repository to hold the main file. Mine use the mirror, and the drift check is one command:

diff <(sed -n '/PORTABLE-START/,/PORTABLE-END/p' ~/.claude/CLAUDE.md) \ <(sed -n '/PORTABLE-START/,/PORTABLE-END/p' ~/.codex/AGENTS.md)

I ran it against both mirrors while writing this page and both returned clean: a 4,886-byte, 720-word, 60-line block, byte-identical across all three home files. The files around it differ (7,497, 6,660 and 6,675 bytes) because each one has settings only its own tool uses.

A symlink is a third option, and Anthropic documents it. On Windows it needs Administrator privileges or Developer Mode, and the docs say the import is the better choice there. A symlink also leaves you nowhere to put tool-specific content, which is usually why you'd want a shim in the first place. I'd use one only when the file is the same for every tool and nobody's on Windows.

The Layout That Works for All Three

I use four rules. The first is the one that fixes the problem above, and it's the one I was missing.

1. Every nested repository opens its instruction file with an inheritance block. A tool that starts at the Git root can't walk up to the parent rulebook, but you can tell it to open it. Name the parent files by relative path in the first section, before anything else. Tools that already walk up lose nothing, and tools that start at the Git root now get the files they were missing. It's the cheapest fix in this post.

## Governance inheritance: read first This folder is its own git repo. Some agents load parent folders automatically; others start at the nearest git root and will not. Open these yourself before reading on: 1. `../AGENTS.md` - the shared rulebook 2. `../PITFALLS.md` - the failure registry

2. Budget the whole chain. The 32 KiB cap applies to root-to-working-directory concatenation, so watch the total along the deepest path. Keep each chain under about 24 KB and the strictest tool never cuts anything. Claude Code's under-200-lines advice is a target for getting the agent to follow the rules, and it's well below any tool's hard limit.

3. A pointer file holds no rules. If CLAUDE.md is a shim, keep it a shim: an import and, at most, one sentence saying where the rules are. As soon as someone adds a rule to the pointer “just this once,” you have two sources of truth, and two of your three tools can't see one of them. Mine says this in its own text, as a note to the next person as much as to the agent.

4. Conditional content leaves the always-loaded file. Everything above is about reach, making sure the agent sees the right files. A separate question is what belongs in them at all. My answer is only what's true for every task. Anything that only applies in certain cases should sit in its own file behind a trigger, which costs one line in the always-loaded file. Claude Code now has a first-class mechanism for this in path-scoped rules under .claude/rules/, which load only when it touches matching files. I wrote up the portable version, and what to do with corrections you've had to give an agent twice, in Your AGENTS.md Gets Worse Every Time You Fix It.

Running more than one agent in the same repo?

I run a free community for people building data and AI pipelines: warehouse modeling, analytics and AI-assisted workflows.

Join the free AI community →

Frequently Asked Questions

What is the difference between CLAUDE.md and AGENTS.md?
They're the same idea with different filenames, read by different tools. AGENTS.md is the vendor-neutral format, and its spec lists about twenty-five tools that read it, including Codex, Cursor, Aider, Devin, Copilot and VS Code. Claude Code reads CLAUDE.md, and GEMINI.md is Gemini CLI's default. Claude Code's docs say it reads CLAUDE.md and not AGENTS.md, and the AGENTS.md spec never mentions CLAUDE.md. The bigger problem is that each tool has a different rule for which directories it collects files from, so two agents in the same folder can end up with different rulebooks even after you line up the filenames.
How big can an AGENTS.md file be?
Each tool has its own answer. Codex stops adding files once the combined chain hits project_doc_max_bytes, which is 32 KiB by default and can be raised in config.toml. The cap applies to the combined chain, and an open issue says it kicks in with no warning anywhere. Claude Code loads a CLAUDE.md up to 4 MiB in full and skips anything larger. Its docs suggest under 200 lines so the agent follows the rules well. In practice, aim for the 200-line advice and keep any single root-to-working-directory chain well under 32 KiB.
Where should AGENTS.md live in a monorepo or nested repositories?
Put one at each level where the rules differ. The spec says to put another AGENTS.md inside each package. The catch is that a nested repository behaves differently from a nested folder. A subdirectory with its own .git becomes a Git root, and any tool that starts its search there can't see anything above it. Start each nested repository's file with a short block that names the parent files by path and tells the agent to open them.

Related reading: Your AGENTS.md Gets Worse Every Time You Fix It, the companion to this page, about what belongs inside the file once you know which files get read. I Ran Claude Code and Codex Head-to-Head, where the two tools above work the same spec in the same repo and get judged blind. Multi-Model Verification, the same don't-trust-one-pass habit applied to an agent's output. AI as an Operations Layer, about where these agents run. For the hardware they run on, see Blendlogic Tech.

What would make this wrong

Get the build notes

My AI experiments: what worked, what didn’t, and how I set them up. Sent to your inbox.

No spam, unsubscribe anytime · Privacy

More in AI & Building →