AGENTS.md vs CLAUDE.md is a question every team hits once it uses more than one AI coding agent. Codex wants an AGENTS.md. Claude Code wants a CLAUDE.md. GitHub Copilot reads AGENTS.md too, but in its own way. Write both by hand and they drift apart within a week.
The repository behind this website runs on a single AGENTS.md, and both Claude Code and Codex work from it every day. In this guide I explain what each file is, how each agent finds it, the setup I recommend for sharing one set of rules, and what I learned when my own AGENTS.md grew far past the size limits. Everything here was checked against the official Claude Code memory docs and the Codex AGENTS.md docs in November 2026.
AGENTS.md vs CLAUDE.md: the short answer
Both files do the same job. They are plain Markdown files in your repository that tell an AI coding agent how your project works: which commands to run, which rules to follow and what it must never do. Think of them as a README written for an agent instead of a person.
The difference is who reads them. AGENTS.md is an open format that many tools agreed on. CLAUDE.md is Claude Code's own file, and Claude Code gives it priority.
| AGENTS.md | CLAUDE.md | |
|---|---|---|
| What it is | Open format shared by many agents | Claude Code's own instruction file |
| Read by | Codex, GitHub Copilot's coding agent, Cursor, Gemini CLI and others | Claude Code |
| Where it lives | Repo root, plus optional files in subfolders | Repo root or .claude/, plus your home folder and subfolders |
| Imports other files | No | Yes, with @path, up to four hops deep |
| Size guidance | Codex reads up to 32 KiB by default | Target under 200 lines per file |
So the honest answer to "which one should I write?" is: write AGENTS.md for your rules, and add a tiny CLAUDE.md only if you need one. I explain when you need it below.
How each coding agent finds its instructions
The rules for finding these files are different for every agent, and that is where most of the confusion comes from. Here is how the three agents I use actually load them.
Codex
Codex builds its instructions from several files. It first checks your Codex home folder (~/.codex) for a global AGENTS.override.md or AGENTS.md. Then it walks from the project root down to the folder you are working in, and picks up at most one file per folder: AGENTS.override.md if it exists, otherwise AGENTS.md.
It joins these files from top to bottom, so a file closer to your code comes later and wins when two rules disagree. It stops adding files once the total reaches 32 KiB, which is the default value of the project_doc_max_bytes setting. If your rules are longer, you can raise it in ~/.codex/config.toml:
# ~/.codex/config.toml
project_doc_max_bytes = 65536
Codex can also read other file names through the project_doc_fallback_filenames setting, but I would not rely on that for team rules. A setting on your laptop does nothing for the next person who clones the repo.
Claude Code
Claude Code loads CLAUDE.md from several places: your home folder (~/.claude/CLAUDE.md), the project (./CLAUDE.md or ./.claude/CLAUDE.md), a personal CLAUDE.local.md, and rule files in .claude/rules/. CLAUDE.md files in subfolders load when Claude starts working in that folder.
Since version 2.1.277, Claude Code also reads AGENTS.md, but with a catch. By default it reads AGENTS.md only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working folder or any folder above it. You can change this with the Project instructions setting in /config. The value claude-md-and-agents-md loads both files, but it is a personal setting, so it does not travel with the repository either.

GitHub Copilot and the rest
GitHub Copilot's coding agent reads AGENTS.md files anywhere in the repository, and the nearest one in the folder tree takes precedence. Cursor, Gemini CLI, Aider and many other tools are listed on agents.md as supporting the format. In practice, AGENTS.md is the file that the most tools agree on, which is exactly why it should hold your rules.
The setup I recommend: one AGENTS.md and a thin CLAUDE.md
Keep every shared rule in AGENTS.md. Then, if you need a CLAUDE.md, make its first line an import of AGENTS.md. This is also what the Claude Code docs recommend:
@AGENTS.md
## Claude Code only
- Use plan mode for changes that touch more than three files.
- Run the test suite before you say a task is done.
Claude Code replaces @AGENTS.md with the full file when the session starts, then reads the Claude-only notes below it. Codex and Copilot ignore CLAUDE.md and read AGENTS.md directly. One file to edit, every agent in sync.
When you can skip CLAUDE.md completely
If nobody on the project has a CLAUDE.md, you do not need one. Claude Code falls back to AGENTS.md on its own. That is how my own repository works today: there is no CLAUDE.md, and Claude Code loads AGENTS.md through that fallback.
The trap is that the fallback switches off silently. The moment someone adds a CLAUDE.md, even an almost empty one, Claude Code stops reading AGENTS.md and nothing warns you. Running /init is the most common way this happens, because it generates a starting CLAUDE.md, and by default it does not read your AGENTS.md first. If you run /init, add @AGENTS.md to the top of the file it creates.
Why I use an import instead of a symlink
Many guides suggest making CLAUDE.md a symlink to AGENTS.md. It works on macOS and Linux, but I would avoid it. I work on Windows, where symlinks need Administrator rights or Developer Mode, and Git checks them out as plain text files unless core.symlinks is turned on. The Claude Code docs also note that its Edit and Write tools refuse to write through a symlink. A one-line import has none of these problems.
If you want to start from a clean file, my free AGENTS.md Generator and Checker builds an AGENTS.md for common stacks and a matching CLAUDE.md that imports it. It runs in your browser and uploads nothing.
What I learned from a 321-line AGENTS.md
The AGENTS.md in this website's repository started in July 2026 with a few notes about the build step and the blog pipeline. Today it is 321 lines and about 54 KB. That is well over Claude Code's 200-line guidance and well over the 32 KiB that Codex reads by default. I let it grow because every agent session added "one more note", and almost none of them removed anything.

Here is what that taught me.
Specific rules work, general advice does not
The rules that saved me most often are boring and exact:
- "Rebuild the CSS after any class change." Tailwind is precompiled on this site, and an agent that forgets to rebuild ships a page where the new classes have no styling.
- "Never push without an explicit yes." Pushing to
maindeploys to production, so this one line keeps every agent from going live on its own. - "Keep draft branch names short." A long SEO slug once became a preview branch name, and the preview hostname broke because it was too long for DNS. Nobody would guess that rule, so it has to be written down.
Compare those with a line like "write clean, maintainable code". Every agent already tries to do that, so the line costs context and changes nothing.
History belongs somewhere else
A big part of my file is a record of what happened: which post went live on which day, which bug was fixed in which commit. Agents need some of that context, but not on every task. My plan is to keep AGENTS.md for rules and commands, and move the history into a separate handoff file that an agent reads only when it needs it. If you use Claude Code, the .claude/rules/ folder is another way to split rules that only apply to some files.
Treat it as a public file
AGENTS.md is committed to your repository. My site's repository is mirrored to a public GitHub repo, so anything in that file is public. Never put API keys, tokens, client names or private notes in it. Write where a secret lives ("keys are in Netlify environment variables"), never the secret itself. The checker in my tool flags lines that look like leaked keys for exactly this reason.
Check what your agent actually loaded
Do not assume an agent read your file. In Claude Code, run /context all and look at the list under Memory files. In Codex, ask it to summarize the current instructions, and it should list the files it loaded in order. If a rule is missing, it is usually a file name, a folder or a size limit problem, not the agent ignoring you.
My recommendation
Write one AGENTS.md at the root of your repository with your real commands and your most important rules, and keep it short. Add a CLAUDE.md only when you need Claude-only notes, and make @AGENTS.md its first line. Review the file every few weeks and remove anything that is history rather than a rule. If you are choosing between agents in the first place, my comparison of Claude Code and Codex covers how they differ in daily work.
I build SaaS products with AI coding agents every day, and setting them up so they follow a team's real rules is part of that work. If you want help with your project, get in touch, or see how I build AI SaaS products.