Track lessons
CodexOpenCodeCursorIntermediate4 min

AGENTS.md vs CLAUDE.md vs Cursor Rules: One Source of Truth

Teams now use several coding agents, and duplicated instruction files quickly disagree. AGENTS.md can hold shared repository guidance while thin tool-specific files keep only behavior unique to each agent.

When to use

  • Use the same commands and constraints across multiple coding agents.
  • Prevent copied instruction files from drifting.
  • Keep scoped or tool-only features in their native configuration.

Example

Codex, OpenCode and Cursor share commands and safety rules from AGENTS.md; CLAUDE.md imports that source and adds one Claude-only review skill.

TL;DR

Write rules once in AGENTS.md; make CLAUDE.md import it.

bash
echo '@AGENTS.md' > CLAUDE.md

Steps

  1. 1

    Put shared rules in AGENTS.md

    Start with commands and durable repository constraints that should remain identical regardless of which supported agent performs the work.

    AGENTS.md
    # Agent instructions
    
    ## Commands
    - Install: `npm ci`
    - Test: `npm test`
    
    ## Rules
    - Never edit src/gen/.
    - Add a test for every bug fix.
  2. 2

    Point Claude Code at it

    Keep CLAUDE.md thin: import the shared source, then add only behavior that applies specifically to Claude Code.

    CLAUDE.md
    @AGENTS.md
    
    ## Claude-only
    - Use the review-diff skill before finishing.
  3. 3

    Keep Cursor rules for scoping only

    Use .mdc files for glob-specific rules, not for repeating AGENTS.md.

  4. 4

    Personal defaults

    Keep preferences that should not affect teammates in each tool's personal instructions directory rather than committing them to the repository.

    paths
    ~/.codex/AGENTS.md     # Codex, all projects
    ~/.claude/CLAUDE.md    # Claude Code, all projects

Gotchas

  • Two copies of the same rule will drift; delete duplicates.
  • Nested AGENTS.md files override parent ones for that folder.
  • Tool-specific features (skills, subagents, Bugbot) stay in their own files.

Cheat sheet

AGENTS.mdCodex, OpenCode, Cursor
CLAUDE.md + @AGENTS.mdClaude Code
.cursor/rules/*.mdcCursor scoped rules
.cursor/BUGBOT.mdCursor Bugbot reviews

Related

Sources

Reviewing agent output? CodeCrab reviews pull requests locally with your own AI tools.