Claude Code and Codex don't read the same rules
Say Codex deletes a folder your rules say never to touch, or opens a file they say never to open. Often it isn't ignoring you. You wrote the rule in Claude Code's file, and Codex never read it. If you use both agents on the same Mac, some of your rules almost certainly reach only one of them, usually the global ones in your home folder.
Here's who reads what, a one-minute check, and three ways to fix it.
Who reads what
| Claude Code | Codex | |
|---|---|---|
| Your global rules | ~/.claude/CLAUDE.md | ~/.codex/AGENTS.md (or AGENTS.override.md there) |
| A project's rules | CLAUDE.md or .claude/CLAUDE.md in the folder and the folders above it, plus CLAUDE.local.md and .claude/rules/ | AGENTS.md from the project root (usually the git root) down to the folder you're in, one file per folder |
| The other tool's file | A project's AGENTS.md, but by default only when there's no CLAUDE.md or CLAUDE.local.md in the folder or above it (Claude Code 2.1.277 or later) | CLAUDE.md only if you add it to project_doc_fallback_filenames, and only in folders with no AGENTS.md |
| Size limit | Stops adding files once they reach 32 KiB in all (project_doc_max_bytes) |
Sources: Anthropic's memory docs and OpenAI's AGENTS.md docs, both read Nov 18, 2026.
Where rules get lost
Global rules never cross over. Nothing in ~/.claude/CLAUDE.md reaches Codex, and nothing in ~/.codex/AGENTS.md reaches Claude Code. A copy in ~/AGENTS.md doesn't fix it either: Codex reads a project's files from the project root down, so a file in your home folder only counts when Codex works in your home folder itself.
A repo with both files gets two rule sets. Claude Code reads CLAUDE.md and skips AGENTS.md. Codex reads AGENTS.md and skips CLAUDE.md. A rule added to one, in a hurry, is missing from the other.
A long file gets cut. If your instructions add up to more than 32 KiB, Codex stops reading there. Whatever is past that point, it never sees.
Check yours in a minute
In Terminal, this lists the lines in your global Claude Code file that say "never" or "don't" and that your global Codex file doesn't have:
comm -23 \
<(grep -hiE 'never|do not|don.t' ~/.claude/CLAUDE.md 2>/dev/null | sed -E 's/^[[:space:]*-]+//' | sort -u) \
<(grep -hiE 'never|do not|don.t' ~/.codex/AGENTS.md 2>/dev/null | sed -E 's/^[[:space:]*-]+//' | sort -u)Swap the two file names to go the other way. It's a rough text match, so a rule worded differently in each file will show up as missing. Read the list; don't trust the count.
Then, in each repo you work in:
ls CLAUDE.md .claude/CLAUDE.md CLAUDE.local.md AGENTS.md 2>/dev/null; wc -c AGENTS.md 2>/dev/nullIf both CLAUDE.md and AGENTS.md are there, you have two rule sets. If AGENTS.md is over 32,768 bytes, Codex isn't reading all of it.
In Claude Code, /context all lists the instruction files that loaded, under Memory files.
Three ways to fix it
1. One file, imported. Keep a project's rules in AGENTS.md, and make CLAUDE.md a single line that imports it:
@AGENTS.mdClaude Code expands the import, so both agents read the same text. Claude-only notes can go below that line.
2. Global rules, imported. Do the same with your global rules. Keep them in ~/.codex/AGENTS.md, and add this line to ~/.claude/CLAUDE.md:
@~/.codex/AGENTS.md3. Let each tool read both. In Claude Code, open /config and set Project instructions to claude-md-and-agents-md. In Codex, add project_doc_fallback_filenames = ["CLAUDE.md"] to ~/.codex/config.toml. That only helps in folders with no AGENTS.md of their own, so the import above is the cleaner fix.
After any of these, start a fresh session in the repo and ask the agent to quote the rule you care about. If it can't, it isn't reading it.
Give this to your agent
If you'd rather have your agent do the comparison, paste this into Claude Code or Codex from the repo you care about. It asks the agent to read only your instruction files and change nothing. What it reads goes to its provider, like everything an agent reads:
Compare the rules in ~/.claude/CLAUDE.md and ~/.codex/AGENTS.md, and in this repo's CLAUDE.md, .claude/CLAUDE.md and AGENTS.md if they exist. List every rule that appears in only one of them, with the file it's in. Treat rules that say the same thing in different words as the same. Don't change any file. Then write one block I can paste into the other file so both agents get the same rules, and tell me if any file is over 32 KiB.A rule on paper is still a rule on paper
Getting a rule to both agents fixes the most common reason it's broken: the agent never saw it. It doesn't make the rule hold. A written rule depends on the agent reading it, keeping it in mind and putting it above whatever is in front of it.
For the few rules that must hold, like a folder that must never be deleted or a key that must never be read, put the rule where the action happens: Claude Code's and Codex's own sandbox, which the Mac enforces however a command is written, and branch protection on GitHub or GitLab for history you don't want rewritten.
What Excellent does here
Excellent for Mac finds the rules you wrote for Claude Code and Codex, shows which reach only one of them, and on your OK adds them to a file the other reads. With Excellent Pro, it can also remind an agent of your rule, in your words, before it breaks it, and turn your file and folder rules into Claude Code's and Codex's macOS sandbox. The rules doc has the details. The app is almost here.
Citation
Please cite this work as:
Matt Waite, “Claude Code and Codex don't read the same rules”, Excellent Research, November 18, 2026. www.excellent.so/research/claude-code-and-codex-dont-read-the-same-rules
Or use the BibTeX citation:
@article{excellent2026claudecodeandcodexdontreadthesamerules,
author = {Matt Waite},
title = {Claude Code and Codex don't read the same rules},
journal = {Excellent Research},
year = {2026},
url = {https://www.excellent.so/research/claude-code-and-codex-dont-read-the-same-rules}
}
