Skip to content
stacks

AGENTS.md vs CLAUDE.md: which one to use

Use AGENTS.md for shared coding-agent instructions and CLAUDE.md for Claude-specific notes, with an @AGENTS.md import to keep shared rules in one place.

Published 7 min read

AGENTS.md vs CLAUDE.md is mostly a question of which tool loads your instructions. Use AGENTS.md for shared project guidance. Codex and OpenCode read it, and current Claude Code and Cursor support it too. CLAUDE.md gives you a place for Claude-specific instructions.

For a repository used by several agents, I recommend keeping shared rules in AGENTS.md and adding @AGENTS.md on its own line in CLAUDE.md. That keeps one copy of your project knowledge while leaving room for Claude-only notes. The import also works in Claude Code sessions where direct AGENTS.md support is unavailable.

What's the difference between AGENTS.md and CLAUDE.md?

Both files contain Markdown instructions for a coding agent. The filename tells the tool where to find them; it doesn't give a sentence more authority or make a test command run automatically. Your repository can use either file alone, or use both with an explicit connection between them.

The useful comparison is what each tool loads:

Tool Project instruction file Shared-file approach
Codex AGENTS.md Put shared project guidance here
OpenCode AGENTS.md Read the same shared file
Claude Code CLAUDE.md; current versions also support AGENTS.md under conditions below Import AGENTS.md from CLAUDE.md when keeping both
Cursor AGENTS.md or project rules under .cursor/rules/ Use AGENTS.md directly, with rules for scoped guidance
GitHub Copilot .github/copilot-instructions.md; GitHub also documents AGENTS.md files as agent instructions Check which files your Copilot surface reads

OpenAI's AGENTS.md guide describes Codex's instruction discovery. GitHub's repository instructions guide covers Copilot's files. A filename recognized by one tool doesn't establish what another tool will load.

Shared guidance should describe the repository: how to run a focused test, which directories own which responsibilities, and what a finished change must pass. A package command belongs there even if Claude helped discover it. Someone switching to Codex tomorrow needs that command too. The AGENTS.md example for Codex shows a complete file.

Does Claude Code read AGENTS.md?

Current Claude Code supports AGENTS.md directly, starting with version 2.1.277, subject to session support and instruction settings. By default, a CLAUDE.md or CLAUDE.local.md in the working directory or an ancestor takes precedence. Anthropic's memory documentation explains the conditions.

An explicit import keeps the relationship visible when you retain CLAUDE.md. Place the files beside each other and use this as the wrapper:

CLAUDE.md
@AGENTS.md

## Claude Code

Read .claude/README.md before changing the project's Claude hooks.

The @AGENTS.md line loads the shared file into Claude's context. A sentence asking Claude to read it depends on Claude opening the file. Anthropic documents the import as a supported way to share instructions, including when direct loading is unavailable.

Claude Code's /init can generate a starting CLAUDE.md from a repository. Review that draft, move generally useful project knowledge into AGENTS.md, and keep the import in CLAUDE.md. This is an editing step: generated descriptions still need checking against the code you actually run.

The import is my default because it leaves both filenames as ordinary files and gives Claude-specific notes their own home. You can review a change to shared instructions independently of a change to the Claude setup. A contributor opening CLAUDE.md also sees immediately where the project guidance lives.

A symlink works when both names should expose exactly the same content. In that setup, CLAUDE.md points to AGENTS.md, so editing the target updates what both names show. You give up the separate space for Claude-only notes. Check how your checkout and editing tools handle links before adopting one across a team.

Duplicating the text creates two places to maintain every rule. Suppose you replace a broad test command with a faster single-file command in AGENTS.md. If CLAUDE.md keeps the old command, switching agents changes the workflow. Reviewing both files can catch that, but the import removes the second copy you would otherwise have to review.

An existing repository needs a content merge before it needs a new wrapper. Compare both files, move each shared instruction into AGENTS.md, and resolve contradictory commands. Then replace the duplicated part of CLAUDE.md with the import. Preserve any Claude-specific content below it. Adding an import above an unchanged copy would leave the duplication in place.

Shared instructions also need a clear editing convention. Put a short note near the import saying that project commands belong in AGENTS.md. When a command changes in a pull request, review the corresponding documentation change alongside it. The import keeps copies from drifting; someone still has to keep the shared text accurate.

Where do Cursor rules fit?

Cursor supports AGENTS.md directly for straightforward project instructions. Project rules are .mdc files under .cursor/rules/; they add metadata for deciding when guidance applies. Cursor's rules documentation describes both options. You don't need to copy your whole shared guide into a rule just to use Cursor.

Rules are useful when guidance belongs to a particular part of the repository. For example, your shared file can describe the main test command while a rule explains conventions for frontend components. Keep the general command in AGENTS.md so another agent gets the same starting point.

A rule can also point the agent toward the shared file. That is the approach used by the generated adapter in the demo below. Its alwaysApply: true setting applies the rule to every task, and the rule asks Cursor to read AGENTS.md. This is a direction to read a file; the CLAUDE.md @AGENTS.md line uses Claude's import mechanism.

How do I keep one set of instructions for every agent?

Hand-maintained AGENTS.md plus a small CLAUDE.md wrapper is enough to share project instructions. You can commit those files without adding another tool. Once several repositories need the same setup, generating the surrounding agent files and checking the import can save repeated setup work.

stacks (@steamfield/stacks) writes that arrangement through its agent-ops fragment, a reusable piece of project setup. It writes AGENTS.md for every target, a CLAUDE.md importing it for Claude Code, and a Cursor rule pointing to it when Cursor is selected. The agent setup guide explains the target selection.

The scripted demo creates a Go CLI with Claude Code, Codex and Cursor selected, then inspects the generated files. Its command output was captured from stacks 0.7.0 and excerpted. Playback shows the setup; it doesn't run commands on your computer.

Agent + stacks
Demo

You: Set this Go CLI up for Claude Code, Codex and Cursor.

Agent: I’ll generate all three adapters, then inspect where they point.

●Bash(stacks new go-cli team-cli --agents claude,codex,cursor --sandbox --no-launch)
Created team-cli from go-cli (sandbox).
Fragments: agent-ops, ci-github, git-hooks
Agents: claude, codex, cursor
Git: new repository, nothing committed
Brief: .stacks/BRIEF.md (3289 words)
Output abbreviated
●Bash(find team-cli/AGENTS.md team-cli/CLAUDE.md team-cli/.cursor team-cli/.codex team-cli/.claude -type f | sort)
team-cli/.claude/settings.json
team-cli/.codex/config.toml
team-cli/.codex/hooks.json
team-cli/.cursor/rules/agent-ops.mdc
team-cli/AGENTS.md
team-cli/CLAUDE.md
Output abbreviated

Agent: Each agent gets its own config. AGENTS.md holds the shared project instructions.

●Bash(cat team-cli/CLAUDE.md)
@AGENTS.md
## Claude Code
Output abbreviated
●Bash(cat team-cli/.cursor/rules/agent-ops.mdc)
---
alwaysApply: true
---
# Agent operations
Read `AGENTS.md` for project commands and conventions. `.cursor/hooks.json` wires
`preToolUse` guards for destructive shell commands, secret writes and env-file
Output abbreviated

Agent: CLAUDE.md imports AGENTS.md, and Cursor’s rule points there too. I’ll fill the shared project details in AGENTS.md.

Example agent conversation. Playback can be paused.

One command writes AGENTS.md, a CLAUDE.md that imports it, and a Cursor rule that points to it.

The generated AGENTS.md is a skeleton the agent fills from the built project. stacks doesn't inspect your source to write project knowledge. Its agents-md-filled verify step requires a nonempty file with a Commands section and fails while stacks:fill markers remain. Run the listed commands yourself to confirm they work.

The fragment also adds claude-md-imports-agents. Whenever CLAUDE.md exists, that verify step requires an exact @AGENTS.md line. Removing the import makes the step fail. The composition concepts explain how fragments contribute files and verification steps to a project.

An existing repository can receive the same fragment without replacing its current instruction files. From its root, with the stacks CLI available:

Add agent files to an existing repository
stacks add agent-ops --agents claude,codex,cursor --no-launch

Conflicting versions are parked under .stacks/incoming/ for the agent to merge; your live files keep their contents. The agent reads .stacks/BRIEF.md, merges the instructions, fills the missing project details and runs stacks verify. add itself runs no install or verification steps. The existing-repository guide covers that workflow. On a repository with a manifest already, its existing agent targets are retained, so omit --agents unless it matches them.

The Cursor and OpenCode adapters shipped in 0.7.0 are labeled unproven. Claude Code and Codex have recorded successful project runs. The demo shows the files written for Cursor; it doesn't establish that a Cursor session built the application successfully.

What goes in CLAUDE.md if AGENTS.md has everything?

CLAUDE.md can stay small: the import and any instructions that depend on Claude's own setup. For the generated wrapper, those notes include where the Claude hook documentation lives and where to put path-scoped Claude rules. Shared architecture and verification commands stay in AGENTS.md.

A useful editing test is whether a developer using a different agent needs the information. A warning that database migrations require review belongs in the shared guide. A pointer explaining the project's .claude/ hook setup belongs in the Claude section. If the shared guide grows, link to the detailed repository documentation where that topic is maintained.

Concrete commands make the shared guide easier to use. Write the actual command for running one test file and name the directory it runs from. For a known workaround, record the condition that requires it and when it can be removed. The next person changing that part of the project can update the instruction alongside the code.