AGENTS.md vs CLAUDE.md vs .cursorrules: Which Spec Should Your Repo Use?
A practical breakdown of how Codex, Claude Code, Cursor, and GitHub Copilot read repository instruction files—and how to keep one source of truth without drift.
Teams adopting AI coding tools quickly run into file sprawl: one engineer creates .cursorrules, another runs Claude Code /init to generate CLAUDE.md, and a third adds AGENTS.md for Codex or OpenCode. Within a few weeks, the three files contradict each other on test commands, lint flags, and folder conventions.
Side-by-Side Comparison of Repository Instruction Specs
| File | Primary Readers | Nesting & Discovery | Unique Features |
|---|---|---|---|
AGENTS.md | OpenAI Codex, OpenCode, Jules, Cursor, Copilot | Root + nested subdirectory overrides | Vendor-neutral open Markdown convention |
CLAUDE.md | Claude Code CLI & IDE extensions | Root, parent directories, local overrides | Supports @path/to/file.md recursive imports |
.cursorrules / .cursor/rules/*.mdc | Cursor Agent & Tab Composer | Root or scoped glob frontmatter in .mdc | File-pattern auto-attachment in Cursor |
.github/copilot-instructions.md | GitHub Copilot Chat & Coding Agent | Fixed .github/ path | Native GitHub PR & IDE integration |
Why AGENTS.md Is Winning as the Shared Baseline
AGENTS.md has emerged as the lowest-friction baseline because it is plain Markdown with zero proprietary frontmatter. Even if your team primarily uses Claude Code or Cursor today, contributors using Codex, OpenCode, or automated CI coding agents immediately pick up AGENTS.md without duplicating project setup steps.
Where CLAUDE.md Still Matters
Claude Code specifically reads CLAUDE.md and expands @import lines (such as @docs/api-contracts.md or @package.json) automatically. If your team relies heavily on Claude Code alongside other tools, duplicating the same 120 lines across both files causes prompt drift. Instead, use one of two clean patterns:
Pattern A: Single Source in AGENTS.md + Thin CLAUDE.md Wrapper
Put your stack, commands, directory layout, and boundaries in AGENTS.md, then make CLAUDE.md a 3-line pointer plus Claude-specific rules:
@AGENTS.md
## Claude Code Specifics
- Prefer targeted test files over full suite runs during iteration.
- Never commit changes directly to main; open a feature branch first. Pattern B: Generate Targeted Exports from One Config
If your repository policy prohibits symlinks or cross-file imports (for example, strict CI templates or Windows setups), maintain one structured configuration and generate synchronized exports with the AGENTS.md Generator.
What Never Belongs in Any Instruction File
- Full codebase file trees: Agents already have fast directory listing and search tools. Listing 80 filenames goes stale immediately and wastes context tokens on every turn.
- Generic coding clichés: Phrases like "write clean, modular code" or "follow best practices" have zero verification value. Replace them with concrete commands like
npx astro checkorpytest -q. - Secrets or internal URLs with tokens: Instruction files are committed to Git and passed straight into model context. Always audit for accidental
sk-*,ghp_*, or private key blocks before pushing.
Practical Recommendation
Start every new repository with a sub-100-line AGENTS.md covering four blocks: exact commands, top-level folders, non-obvious invariants, and hard "never do this" guardrails. Add a minimal CLAUDE.md importing @AGENTS.md only if Claude Code needs custom workflow rules.