The setup we recommend
- Put shared rules in
AGENTS.mdat the repo root and commit it. - Only if you need Claude-only rules, add a
CLAUDE.mdthat starts with@AGENTS.md. - Point the tools that don't read
AGENTS.mdby default at it: Gemini CLI viacontext.fileName, Aider viaread:. - Keep it short. Anthropic suggests under 200 lines per file; Codex stops reading at 32 KiB combined by default.
Who reads what
| Harness | Reads by default | AGENTS.md? | Precedence and gotchas |
|---|---|---|---|
| Claude Code | CLAUDE.md, .claude/CLAUDE.md, CLAUDE.local.md, ~/.claude/CLAUDE.md | Yes, v2.1.277+, when no CLAUDE.md or CLAUDE.local.md is in the folder or above | A CLAUDE.local.md counts too and silently switches AGENTS.md off. Setting Project instructions to claude-md-and-agents-md loads both |
| Codex CLI | AGENTS.override.md then AGENTS.md in ~/.codex, then each folder from the git root down | Native | Override files win per folder. Stops at project_doc_max_bytes (32 KiB by default). Extra names via project_doc_fallback_filenames |
| OpenCode 1 | AGENTS.md (project), ~/.config/opencode/AGENTS.md (global) | Native | Falls back to CLAUDE.md and ~/.claude/CLAUDE.md; first matching file wins. Extra files via instructions in opencode.json |
| OpenCode 2 | Global file plus every AGENTS.md from the workspace up to the project root | Native | Doesn't use CLAUDE.md as a fallback. Files are combined, not conflict-resolved |
| goose | AGENTS.md, then .goosehints | Native | Change the list with CONTEXT_FILE_NAMES, for example '["CLAUDE.md", ".goosehints"]' |
| Gemini CLI | GEMINI.md | Opt-in | Set context.fileName in settings.json to a list that includes AGENTS.md |
| Aider | Nothing automatic | Opt-in | Load any markdown file read-only with --read or read: in .aider.conf.yml |
Copy-ready files
# 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@AGENTS.md
## Claude Code
- Use plan mode before multi-file refactors.{
"context": { "fileName": ["AGENTS.md", "GEMINI.md"] }
}read: AGENTS.mdexport 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.
Get new rigs by email
New job recipes and harness changes, a few times a month. Each one with copy-ready config and dated sources.
Sources
- Claude Code docs: CLAUDE.md, AGENTS.md and memory · checked Oct 18, 2026
- Codex docs: AGENTS.md · checked Oct 18, 2026
- OpenCode 1 docs: rules · checked Oct 18, 2026
- OpenCode 2 docs: instructions · checked Oct 18, 2026
- goose docs: .goosehints and AGENTS.md · checked Oct 18, 2026
- Gemini CLI docs: GEMINI.md · checked Oct 18, 2026
- Aider docs: coding conventions · checked Oct 18, 2026
- AGENTS.md (open format) · checked Oct 18, 2026
Spotted something out of date? Email sternberg@mail.grokbot.com.