AGENTS.md: One Rulebook for Cursor, Claude Code and Codex
Cursor, Claude Code and Codex read different instruction files. How AGENTS.md gives them one shared rulebook, and the Claude Code gotcha to avoid.
- Author
- Kamran Khan
- Published
- Reading time
- 7 min read
On this page
If you use more than one AI coding tool on the same repository, you have probably met the problem: each tool wants its own instruction file. Cursor has its rules folder, Claude Code has CLAUDE.md, and Codex has AGENTS.md. Three files, written at different times, quietly drift apart, and then the agents start to disagree about how the project works.
This is what I found when I checked each tool's own documentation: how the three read instructions, the one gotcha in Claude Code, and a setup where they all follow the same rules.
- One shared rulebook: AGENTS.md
- Codex reads it natively
- Cursor reads it too
- CLAUDE.md imports it with @AGENTS.md
Transcript
You use Cursor, Claude Code and Codex on the same repo. Each one wants its own rulebook. Here's how developers get them to share one. Developers describe a rough split. Cursor for reading and editing in the editor. Claude Code for multi-file work in the terminal. Codex for background tasks, and as a second reviewer. The catch is that each tool reads different instructions. Cursor has a rules folder. Claude Code has CLAUDE.md. Codex has AGENTS.md. Three rulebooks drift apart, and the agents start to disagree. The fix is already a standard. In December twenty twenty-five, OpenAI donated AGENTS.md to the Linux Foundation, alongside Anthropic's MCP. The foundation says over sixty thousand projects use it. Codex reads it natively. It starts at the repo root and walks down to your folder, and the closest file wins. Cursor reads it too, as a plain markdown alternative to its rules. Claude Code has one gotcha. With no CLAUDE.md, it reads AGENTS.md. But if both files exist, it reads only CLAUDE.md. The fix is one line. Put at AGENTS.md inside CLAUDE.md, and Claude Code loads both. Keep the file short and practical. Build and test commands. Code conventions. Folders agents must not touch. Codex stops reading at thirty-two kilobytes by default. It's guidance, not enforcement, so use hooks for hard rules. Then let a second agent review the first one's work. Developers say it catches what the first one missed. One file. Three tools. One set of rules. Follow for more developer workflows.
What is AGENTS.md?
AGENTS.md is a plain markdown file at the root of a repository that tells AI coding agents how the project works. It is meant to be the README for agents: the commands to build and test, the conventions to follow, the places not to touch.
It is also an open standard. In December 2025 the Linux Foundation announced the Agentic AI Foundation, with Anthropic, Block and OpenAI as founding contributors. Three projects were contributed: Anthropic's Model Context Protocol, Block's goose, and OpenAI's AGENTS.md. The Linux Foundation's announcement says AGENTS.md has been adopted by more than 60,000 open source projects and agent frameworks. That is the foundation's own figure, so treat it as a claim from the organisers rather than an independent count.
How each tool reads it
Codex
Codex builds its instruction chain once per run. At the global level it reads AGENTS.override.md from its home directory if that exists, otherwise AGENTS.md. Then it starts at the project root, usually the Git root, and walks down to the directory you are working in. In each directory it takes at most one file, checking AGENTS.override.md first, then AGENTS.md, then any fallback names you have configured.
The files are joined from the root downwards, so the ones nearest your work come last and win. Codex stops adding files once the combined size reaches 32 KiB by default (project_doc_max_bytes), which is a good reason to keep the file short.
Cursor
Cursor supports AGENTS.md as a simple alternative to .cursor/rules. It is plain markdown with no frontmatter, so there is no metadata controlling when it applies. It works at the project root and in subdirectories: nested files combine with their parents, and the more specific instructions take precedence.
One detail from Cursor's documentation is easy to miss: plain .md files placed inside .cursor/rules are ignored. If you want plain markdown, AGENTS.md is the way to get it.
Claude Code
Claude Code is the careful one. Its documentation sets out exactly what it reads by default:
| Your repository has | Claude Code reads |
|---|---|
AGENTS.md, and no CLAUDE.md in the working directory or above | AGENTS.md |
AGENTS.md and a CLAUDE.md | the CLAUDE.md files only |
a CLAUDE.md that imports AGENTS.md | CLAUDE.md, with AGENTS.md included through the import |
The first row is recent. Until September 2026 the documented workaround was to create a CLAUDE.md that imports AGENTS.md. On 18 September 2026 Claude Code team member Thariq Shihipar announced that, from version 2.1.277, Claude falls back to AGENTS.md when a folder has no CLAUDE.md.
The one-line fix
Import AGENTS.md from inside CLAUDE.md with Claude Code's @ import syntax:
@AGENTS.md
## Claude Code only
- Use plan mode before large changes.Now AGENTS.md is the single source of truth. Claude Code loads it through the import, Codex reads it natively and Cursor reads it as its alternative to .cursor/rules. Anything that really is specific to one tool goes in that tool's own file underneath. This site's repository is set up the same way: its CLAUDE.md starts with @AGENTS.md.
What belongs in the file
Keep it short and practical. The things worth writing down:
- The exact commands to build, test and lint the project.
- Code conventions that are not obvious from the code.
- Folders and files the agent must not touch.
- Where the facts live, such as the folder that holds content or configuration.
Because Codex stops reading at 32 KiB by default, and because every extra line competes for the model's attention, a file that fits on a page works better than one that tries to say everything.
Guidance, not enforcement
An instruction file is context the model weighs, not enforced configuration. Claude Code's documentation says so directly: to block an action regardless of what the model decides, use a PreToolUse hook instead. The same split applies to the other tools. Put preferences and conventions in AGENTS.md, and put anything that must never happen into a mechanism the agent cannot talk its way past.
What the three tools are used for
People who run several tools on one repository describe a rough split: Cursor for reading and editing in the editor with inline diffs, Claude Code for multi-file work in the terminal, and Codex for background tasks, sometimes also as a second reviewer of another agent's work. These are practitioner reports from comparison articles rather than measurements, and the boundaries are blurring as each tool adds the others' features, so treat them as defaults, not rules. What does not change is the benefit of one shared rulebook: whichever agent wrote the code, it followed the same conventions.
Further reading
- Linux Foundation, announcement of the Agentic AI Foundation: the December 2025 formation and the three contributed projects.
- Claude Code documentation, How Claude remembers your project: the table of what Claude reads, the
@import and the hook advice. - Cursor documentation, Rules: how
AGENTS.mdrelates to.cursor/rules. - Codex documentation, AGENTS.md: discovery order, overrides and the 32 KiB limit.
- Simon Willison, Claude Code now supports AGENTS.md: the 18 September 2026 announcement.
- My own article, What Is a Harness Engineer?, explains why the environment around the model matters more than any single prompt.
Frequently asked questions
What is AGENTS.md?
A plain markdown file in a repository that tells AI coding agents how the project works: build and test commands, code conventions and folders they must not touch. It is an open format, now governed under the Linux Foundation's Agentic AI Foundation.
Does Claude Code read AGENTS.md?
Yes, but only when there is no CLAUDE.md in the working directory or above it. If both files exist, Claude Code reads the CLAUDE.md files only. To get both, put @AGENTS.md at the top of CLAUDE.md so it is imported.
Does Cursor read AGENTS.md?
Yes. Cursor's documentation describes AGENTS.md as a simple alternative to .cursor/rules: plain markdown with no frontmatter, working at the project root and in subdirectories, where nested files combine and the more specific one takes precedence.
How does Codex use AGENTS.md?
Codex builds its instructions once per run. It reads a global file in its home directory, then walks from the project root down to your current folder, reading at most one file per directory and concatenating them root first, so files closer to your work override earlier ones. It stops at 32 KiB by default.
Can AGENTS.md force an agent to follow a rule?
No. Instruction files are context the model weighs, not enforced configuration. For rules that must never be broken, use a mechanism the agent cannot talk its way past, such as a Claude Code PreToolUse hook.