|
| 1 | +--- |
| 2 | +title: "AGENTS.md vs CLAUDE.md vs .cursorrules: Which One Should You Use?" |
| 3 | +description: "Three context-file formats, one job. Why AGENTS.md is winning, what each tool actually reads, and the safest setup that works across Claude Code, Cursor, Codex, and Windsurf." |
| 4 | +date: "2026-05-20" |
| 5 | +image: "https://images.unsplash.com/photo-1456513080510-7bf3a84b82f8?w=1200&q=80" |
| 6 | +imageAlt: "Stack of paper documents" |
| 7 | +author: "vibeprompt" |
| 8 | +category: method |
| 9 | +--- |
| 10 | + |
| 11 | +If you've used more than one AI coding tool in the past year, you've hit this: Claude Code wants `CLAUDE.md`. Cursor reads `.cursorrules` (or the newer `.cursor/rules`). Codex CLI looks for `AGENTS.md`. Aider has its own conventions. Now you've got four files in your repo, all saying mostly the same thing, all slightly out of sync. |
| 12 | + |
| 13 | +This article explains what each file actually does, why **AGENTS.md is winning**, and the exact setup that lets one file drive every tool — without maintaining four copies. |
| 14 | + |
| 15 | +## The three formats, side by side |
| 16 | + |
| 17 | +| File | Tool that wrote it | Adopted by | |
| 18 | +|---|---|---| |
| 19 | +| `CLAUDE.md` | Anthropic (Claude Code) | Claude Code only | |
| 20 | +| `.cursorrules` (legacy) / `.cursor/rules/` (current) | Cursor | Cursor, Windsurf (partial) | |
| 21 | +| `AGENTS.md` | OpenAI (Codex), then Linux Foundation | Codex CLI, OpenCode, Aider, Cline, Windsurf, Roo, Cursor (reads it) | |
| 22 | + |
| 23 | +The pattern is unambiguous: `AGENTS.md` has the broadest tool support and is now stewarded by the [Linux Foundation as an open standard](https://agents.md). Every major agent either reads it directly or has a config flag to point at it. |
| 24 | + |
| 25 | +## What each file actually does |
| 26 | + |
| 27 | +All three serve the same purpose: **give an AI coding agent the project-specific context it can't infer from the code alone.** Conventions, stack versions, what-not-to-do rules, build commands. |
| 28 | + |
| 29 | +The differences are mostly cosmetic: |
| 30 | + |
| 31 | +- **`CLAUDE.md`** is plain markdown. Claude Code loads it at session start and treats it as authoritative. |
| 32 | +- **`AGENTS.md`** is the same idea, formalized. The Linux Foundation spec defines section conventions (Project, Stack, Conventions, etc.) so tools can predict structure. |
| 33 | +- **`.cursorrules`** was Cursor's original format — single-file rules with optional path globs. The newer `.cursor/rules/` directory splits rules into files with frontmatter for scoping (`description`, `globs`, `alwaysApply`). |
| 34 | + |
| 35 | +There's no functional difference for 95% of users. They all end up in the model's system prompt. |
| 36 | + |
| 37 | +## Why AGENTS.md is winning |
| 38 | + |
| 39 | +Three reasons: |
| 40 | + |
| 41 | +1. **Vendor-neutral.** `CLAUDE.md` ties you to Anthropic. `.cursorrules` ties you to Cursor. `AGENTS.md` doesn't tie you to anything. |
| 42 | +2. **Standardized structure.** The spec means tools can extract specific sections (e.g. "find the build command") deterministically. |
| 43 | +3. **Tool support snowballed in late 2025.** When Codex CLI shipped AGENTS.md support, OpenCode, Cline, Roo, and Aider followed within weeks. Cursor and Claude Code both now read it. |
| 44 | + |
| 45 | +If you're starting a project today, write `AGENTS.md` and stop there. |
| 46 | + |
| 47 | +## The "one file, all tools" setup |
| 48 | + |
| 49 | +If you already have `CLAUDE.md` (or `.cursorrules`), don't migrate everything to AGENTS.md — that's a recipe for drift. Use one of these three patterns: |
| 50 | + |
| 51 | +### Pattern 1: Symlink |
| 52 | + |
| 53 | +The cleanest option. One file, every tool reads it: |
| 54 | + |
| 55 | +```bash |
| 56 | +# AGENTS.md is the source of truth |
| 57 | +ln -sf AGENTS.md CLAUDE.md |
| 58 | +ln -sf AGENTS.md .cursorrules |
| 59 | +``` |
| 60 | + |
| 61 | +Pros: Zero drift. Edit once, all tools see the change. |
| 62 | +Cons: Symlinks don't always survive zip downloads / Windows / some CI checkouts. |
| 63 | + |
| 64 | +### Pattern 2: Pointer file |
| 65 | + |
| 66 | +If symlinks are off the table, make one canonical file and have the others point to it: |
| 67 | + |
| 68 | +```markdown |
| 69 | +# CLAUDE.md |
| 70 | +READ AGENTS.md FIRST. That is the source of truth. |
| 71 | +``` |
| 72 | + |
| 73 | +Tools that load `CLAUDE.md` will hit the pointer and read `AGENTS.md` next. Works because most agents follow `@file` references and `READ X` instructions. |
| 74 | + |
| 75 | +### Pattern 3: @file include |
| 76 | + |
| 77 | +In a tool that supports it (Claude Code, Cursor, Codex): |
| 78 | + |
| 79 | +```markdown |
| 80 | +# CLAUDE.md |
| 81 | +@AGENTS.md |
| 82 | +``` |
| 83 | + |
| 84 | +Claude Code expands `@AGENTS.md` to the file contents. Same effect as a symlink without filesystem trickery. |
| 85 | + |
| 86 | +## What to put in your AGENTS.md |
| 87 | + |
| 88 | +The Linux Foundation spec recommends these sections. Steal this skeleton: |
| 89 | + |
| 90 | +```markdown |
| 91 | +# AGENTS.md |
| 92 | + |
| 93 | +## Project |
| 94 | +**Name:** [Project] |
| 95 | +**One-line:** [What it does] |
| 96 | +**Stack:** [e.g. Next.js 16, TypeScript, Tailwind v4, Vercel] |
| 97 | + |
| 98 | +## Folder structure |
| 99 | +[Tree of relevant dirs] |
| 100 | + |
| 101 | +## Conventions |
| 102 | +- File names: kebab-case |
| 103 | +- No file exceeds 500 lines |
| 104 | +- Server-only code in lib/, imports "server-only" |
| 105 | + |
| 106 | +## Hard rules |
| 107 | +1. Never overwrite without asking |
| 108 | +2. No new dependencies without explicit request |
| 109 | +3. Every feature needs 3 tests |
| 110 | +4. No-touch list: .env, package-lock.json, next.config.ts |
| 111 | + |
| 112 | +## Build & verify |
| 113 | +- npm run dev |
| 114 | +- npm run typecheck |
| 115 | +- npm run lint |
| 116 | + |
| 117 | +## Session kickoff |
| 118 | +At session start: "Read AGENTS.md, docs/PRD.md, and memory-bank/ before doing anything." |
| 119 | +``` |
| 120 | + |
| 121 | +A full [AGENTS.md template](/templates/AGENTS.md) is on this site under templates. |
| 122 | + |
| 123 | +## Mistakes to avoid |
| 124 | + |
| 125 | +**Don't include the PRD in AGENTS.md.** The PRD changes constantly. AGENTS.md is *rules*, not *scope*. Keep them in separate files (`docs/PRD.md`) and reference the PRD from AGENTS.md. |
| 126 | + |
| 127 | +**Don't write 200 lines.** Models drop attention past the first ~80 lines of a system prompt. Keep AGENTS.md under 100 lines. If you have more to say, link out to longer docs. |
| 128 | + |
| 129 | +**Don't add things "just in case."** Every rule you write is a constraint the model has to track. Be specific about what matters, vague about what doesn't. |
| 130 | + |
| 131 | +**Don't forget to update it.** Stale rules are worse than no rules — they tell the model to do things you no longer want. Touch AGENTS.md in the same commit as breaking convention changes. |
| 132 | + |
| 133 | +## Tooling-specific quirks |
| 134 | + |
| 135 | +A few footguns worth knowing: |
| 136 | + |
| 137 | +- **Cursor** still reads `.cursorrules` for backward compatibility, but the newer `.cursor/rules/` directory is preferred. If both exist, `.cursor/rules/` wins. |
| 138 | +- **Claude Code** has a hierarchy: `~/.claude/CLAUDE.md` (global) → `./CLAUDE.md` (project). Both get loaded. Use the global one for personal preferences, the project one for project-specific. |
| 139 | +- **Codex CLI** supports monorepo `AGENTS.md` files — drop one in each package, Codex picks the closest one to your working directory. |
| 140 | +- **Aider** reads `CONVENTIONS.md` by default. Symlink that to `AGENTS.md` too if you use Aider. |
| 141 | + |
| 142 | +## TL;DR |
| 143 | + |
| 144 | +- Write **AGENTS.md** as your source of truth. |
| 145 | +- Symlink or pointer the others (`CLAUDE.md`, `.cursorrules`) to AGENTS.md. |
| 146 | +- Keep it under 100 lines, rules-only — not scope. |
| 147 | +- Update it in the same commit as breaking convention changes. |
| 148 | + |
| 149 | +This stops the four-files-out-of-sync problem cold. Every tool reads the same content, you edit one place. |
0 commit comments