axsDocs
Guides

CLAUDE.md vs AGENTS.md: one file for all coding agents

CLAUDE.md is Claude Code's instruction file, AGENTS.md the open format Codex, Cursor and others read. How to keep one file for every agent, and its limits.

CLAUDE.md is Claude Code's own instruction file. AGENTS.md is an open Markdown format that Codex, Cursor, Gemini CLI, GitHub Copilot's coding agent and many other agents read. To keep one file for all of them, write your rules in AGENTS.md: current Claude Code reads it when the repo has no CLAUDE.md, and otherwise a CLAUDE.md with the line @AGENTS.md pulls it in.

What each tool reads

ToolMain instruction filesSource
Claude CodeCLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, ~/.claude/CLAUDE.md, .claude/rules/*.md, and AGENTS.mdClaude Code memory
CodexAGENTS.override.md or AGENTS.md in ~/.codex and in each directory from the project root downCodex AGENTS.md
Cursor.mdc files in .cursor/rules, AGENTS.md, User Rules, Team RulesCursor rules

AGENTS.md

AGENTS.md is "a simple, open format for guiding coding agents", now stewarded by the Agentic AI Foundation under the Linux Foundation. It is plain Markdown with no required fields. In a monorepo you can put one in each package; the nearest file to the edited code takes precedence.

Codex walks from the project root (usually the git root) to your current directory and takes at most one file per directory. Files closer to where you work come later in the prompt, so they override earlier guidance. The combined size stops at project_doc_max_bytes, 32 KiB by default.

Cursor reads AGENTS.md in the project root and in subdirectories. Nested files are combined with their parents, and the more specific one wins.

CLAUDE.md

Claude Code loads CLAUDE.md and CLAUDE.local.md from your working directory and every directory above it, and subdirectory files on demand. All of them are concatenated, not overridden. It also supports:

  • @path imports, up to four hops deep,
  • path-scoped rules in .claude/rules/,
  • a managed CLAUDE.md for every user on a machine,
  • auto memory, notes Claude writes itself.

How Claude Code handles AGENTS.md

Since v2.1.277, Claude Code reads AGENTS.md directly, with this default:

Your repo hasClaude reads
AGENTS.md, no CLAUDE.md or CLAUDE.local.mdAGENTS.md
AGENTS.md and a CLAUDE.md or CLAUDE.local.mdOnly the CLAUDE.md files
A CLAUDE.md that imports @AGENTS.mdCLAUDE.md, with AGENTS.md included

Watch the second row: adding a personal CLAUDE.local.md stops Claude from reading AGENTS.md for you. The Project instructions setting claude-md-and-agents-md makes Claude read both.

Cursor rules

Project rules in .cursor/rules must be .mdc files. A plain .md file there is ignored, because it has no frontmatter. The frontmatter has description, globs and alwaysApply, which give four modes: Always Apply, Apply Intelligently (by description), Apply to Specific Files (by glob) and Apply Manually (when you @-mention it). Rules apply in the order Team Rules, Project Rules, User Rules.

AGENTS.md is the simpler alternative: no metadata, no globs, one file.

One file for every agent

For most repos this setup is enough:

  1. Put shared rules in AGENTS.md: build and test commands, code style, layout, things to never do.
  2. If you need Claude specific notes, add a CLAUDE.md that starts with @AGENTS.md and puts the extra notes below it:
@AGENTS.md

## Claude Code
- Run the tests before you say a change is done.
  1. Keep .cursor/rules only for rules that need globs, for example rules that apply only to *.test.ts.

The Claude Code docs also allow a CLAUDE.md symlinked to AGENTS.md, but recommend the import if anyone on the team uses Windows, where git may check a symlink out as a plain text file.

This is free, reviewed in git and read by every agent. If you work in one repo and the rules change rarely, stop here.

Where files stop working

Instruction files hold what you write in them. They do not cover:

  • Lessons from chat. A correction stays in that session unless someone edits the file.
  • Knowledge beyond one repo. Servers, accounts and deploy steps have no natural home in a single repo.
  • Rules that must hold. A line in AGENTS.md is guidance. The agent can still ignore it.
  • Size. Anthropic suggests under 200 lines per CLAUDE.md; Codex stops at 32 KiB by default.

axs brain covers these for Claude Code, Codex and Cursor at once. Its hooks push the matching memories into each session, the agent saves lessons when you correct it, and rules can block a command or ask first, from hooks the agent cannot skip. Your existing CLAUDE.md, AGENTS.md, .cursor/rules and .cursorrules can be imported, one memory per rule or fact, and the files stay as they are.

axs login
axs install claude
axs install codex
axs install cursor

See Connect your agents and Plans and billing (from €12 a month, 14 days free).

FAQ

Does Claude Code read AGENTS.md?

Yes, since v2.1.277, when there is no CLAUDE.md or CLAUDE.local.md in your working directory or above it. With a CLAUDE.md, add @AGENTS.md to it.

Does Cursor read AGENTS.md?

Yes, in the project root and in subdirectories. Nested files are combined with their parents.

Should I use .mdc or .md in .cursor/rules?

.mdc. Cursor ignores plain .md files in .cursor/rules because they have no frontmatter.

Can one AGENTS.md replace CLAUDE.md and Cursor rules?

For shared project rules, yes. Keep a CLAUDE.md only for an import plus Claude specific notes, and .cursor/rules only for rules that need globs.

What about team memory beyond the repo?

Files in one repo cannot hold it. See Claude Code team memory and Shared memory for AI coding agents.

For each agent in depth: Codex memory and Share Cursor rules across repos.

On this page