Skip to content
Kamran Code

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
  1. What is AGENTS.md?
  2. How each tool reads it
  3. Codex
  4. Cursor
  5. Claude Code
  6. The one-line fix
  7. What belongs in the file
  8. Guidance, not enforcement
  9. What the three tools are used for
  10. Further reading

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.

  1. One shared rulebook: AGENTS.md
  2. Codex reads it natively
  3. Cursor reads it too
  4. CLAUDE.md imports it with @AGENTS.md
One file holds the rules. Each tool reaches it a different way.
One repo, three AI agents, one rulebook (2-minute video)
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 hasClaude Code reads
AGENTS.md, and no CLAUDE.md in the working directory or aboveAGENTS.md
AGENTS.md and a CLAUDE.mdthe CLAUDE.md files only
a CLAUDE.md that imports AGENTS.mdCLAUDE.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

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.

  • #agents-md
  • #claude-code
  • #cursor
  • #codex
  • #ai-coding-agents
  • #claude-md
  • #developer-workflow

Kamran Khan

I build AI-powered applications, full-stack platforms and business software — across full-stack development, business systems, automation and production AI.

About Kamran →

Keep reading

  • AI Agents12 min read

    AGENTS.md, Skills or MCP: What Each One Is Actually For

    AGENTS.md, Agent Skills and MCP are not rival layers. They differ by when they load, what they cost in context and whether anything enforces them. A source-checked decision table and a worked example.

    • #agents-md
    • #agent-skills
    • #mcp
    • #claude-code
  • AI Agents12 min read

    Harness Engineering, Explained: What It Adds to Prompts and Context

    Prompt, context and harness engineering are three scopes of one job. A dated, source-checked timeline of who said what, where the sources disagree, and a way to decide which fix an agent mistake needs.

    • #harness-engineering
    • #context-engineering
    • #prompt-engineering
    • #ai-agents
  • AI Agents5 min read

    AI Scored 42/42 at the IMO. Who Marked It?

    Several AI systems report perfect IMO 2026 scores. Which were marked by the organisers, which by AI agents, and how one setting moved a score by 14 marks.

    • #imo-2026
    • #ai-benchmarks
    • #ai-evaluation
    • #claude

Turn an AI idea into working software.

From retrieval and agents to document intelligence, I build AI systems that plug into real business data and workflows.