Get updates
Setup

AGENTS.md vs CLAUDE.md

AGENTS.md is the open, cross-tool instructions file. CLAUDE.md is Claude Code's own. Claude Code now reads AGENTS.md too, but only when no CLAUDE.md is around, and every harness has its own precedence rules.

Checked against official docs on Oct 18, 20268 sourcesNo affiliate links

The setup we recommend

  1. Put shared rules in AGENTS.md at the repo root and commit it.
  2. Only if you need Claude-only rules, add a CLAUDE.md that starts with @AGENTS.md.
  3. Point the tools that don't read AGENTS.md by default at it: Gemini CLI via context.fileName, Aider via read:.
  4. Keep it short. Anthropic suggests under 200 lines per file; Codex stops reading at 32 KiB combined by default.

Who reads what

HarnessReads by defaultAGENTS.md?Precedence and gotchas
Claude CodeCLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, ~/.claude/CLAUDE.mdYes, v2.1.277+, when no CLAUDE.md or CLAUDE.local.md is in the folder or aboveA CLAUDE.local.md counts too and silently switches AGENTS.md off. Setting Project instructions to claude-md-and-agents-md loads both
Codex CLIAGENTS.override.md then AGENTS.md in ~/.codex, then each folder from the git root downNativeOverride files win per folder. Stops at project_doc_max_bytes (32 KiB by default). Extra names via project_doc_fallback_filenames
OpenCode 1AGENTS.md (project), ~/.config/opencode/AGENTS.md (global)NativeFalls back to CLAUDE.md and ~/.claude/CLAUDE.md; first matching file wins. Extra files via instructions in opencode.json
OpenCode 2Global file plus every AGENTS.md from the workspace up to the project rootNativeDoesn't use CLAUDE.md as a fallback. Files are combined, not conflict-resolved
gooseAGENTS.md, then .goosehintsNativeChange the list with CONTEXT_FILE_NAMES, for example '["CLAUDE.md", ".goosehints"]'
Gemini CLIGEMINI.mdOpt-inSet context.fileName in settings.json to a list that includes AGENTS.md
AiderNothing automaticOpt-inLoad any markdown file read-only with --read or read: in .aider.conf.yml

Copy-ready files

AGENTS.md (starter)
# AGENTS.md

## Commands
- Install: `npm ci`
- Test: `npm test` (run after any change in `src/`)
- Lint: `npm run lint`

## Rules
- Small, focused changes. One fix or feature at a time.
- Don't edit generated files in `dist/` or `vendor/`.
- Ask before adding a dependency or touching CI config.

## Layout
- `src/` app code · `tests/` mirrors `src/` · `docs/` user docs
CLAUDE.md (optional, Claude-only extras)
@AGENTS.md

## Claude Code
- Use plan mode before multi-file refactors.
.gemini/settings.json
{
  "context": { "fileName": ["AGENTS.md", "GEMINI.md"] }
}
.aider.conf.yml
read: AGENTS.md
goose: read CLAUDE.md as well (optional)
export CONTEXT_FILE_NAMES='["AGENTS.md", "CLAUDE.md", ".goosehints"]'

Imports and nesting

Claude Code expands @path imports in both CLAUDE.md and AGENTS.md, up to four hops deep. Imports inside code spans are ignored, so write `@README` to mention a file without loading it. Imports don't save context: imported files load at launch too.

Gemini CLI also supports @file.md imports in GEMINI.md. Codex and OpenCode 2 concatenate the files they find along the folder path instead, so put narrower rules in a subfolder's own AGENTS.md.

If you used a workaround before

Anthropic's docs list what to do with older setups now that Claude Code reads AGENTS.md itself: a CLAUDE.md containing @AGENTS.md can stay; a CLAUDE.md that only tells Claude to read AGENTS.md should become an import or be deleted; a symlink is fine; and a SessionStart hook that prints AGENTS.md should go, because it now adds a second copy.

FAQ

Does Claude Code read AGENTS.md?

Yes, from v2.1.277, but by default only when there is no CLAUDE.md, .claude/CLAUDE.md or CLAUDE.local.md in your working folder or above it. To load both, set Project instructions to claude-md-and-agents-md, or import @AGENTS.md from your CLAUDE.md.

Should I use AGENTS.md or CLAUDE.md?

Use AGENTS.md for anything shared. Codex, OpenCode and goose read it natively and Claude Code reads it when there's no CLAUDE.md. Keep CLAUDE.md only for Claude-specific extras, and import AGENTS.md at its top.

How long should AGENTS.md be?

Short. Anthropic suggests under 200 lines per instructions file because longer files reduce adherence, and Codex stops adding files after 32 KiB combined by default.

Does Gemini CLI read AGENTS.md?

Not by default; it reads GEMINI.md. Add AGENTS.md to context.fileName in settings.json.

Sources

  1. Claude Code docs: CLAUDE.md, AGENTS.md and memory · checked Oct 18, 2026
  2. Codex docs: AGENTS.md · checked Oct 18, 2026
  3. OpenCode 1 docs: rules · checked Oct 18, 2026
  4. OpenCode 2 docs: instructions · checked Oct 18, 2026
  5. goose docs: .goosehints and AGENTS.md · checked Oct 18, 2026
  6. Gemini CLI docs: GEMINI.md · checked Oct 18, 2026
  7. Aider docs: coding conventions · checked Oct 18, 2026
  8. AGENTS.md (open format) · checked Oct 18, 2026

Spotted something out of date? Email sternberg@mail.grokbot.com.

Related