Write one AGENTS.md that every coding agent reads
Added Updated NewHotCopyable prompt below
Published Last verified Released
Our verdict
The cheapest upgrade to any vibe-coded or agent-built project. AGENTS.md is an open format that many coding agents read, including Codex, Jules, Aider, goose, Cursor, Gemini CLI and Copilot's coding agent. Claude Code reads it when there is no CLAUDE.md in your working directory or above it. Keep it short and universal: Anthropic suggests under 200 lines for a CLAUDE.md, and HumanLayer reports that agents ignore parts of bloated files.
- Who it's for
- Anyone using more than one coding agent, or handing a repo to agents regularly
- Leverage
- Every agent session starts with the same project context
- Effort
- Low
- Date added
What How to Write a Good AGENTS.md does
AGENTS.md is plain Markdown at the repo root, a README for agents with no required fields. The format site suggests a project overview, build and test commands, code style, testing instructions and security notes, plus commit or PR rules. In a monorepo you can add one per package; the closest file to the edited file wins and an explicit chat prompt overrides everything. The format is stewarded by the Agentic AI Foundation under the Linux Foundation. Claude Code (v2.1.277 or later) can read AGENTS.md as project instructions, but only when no CLAUDE.md or CLAUDE.local.md exists in your working directory or above; otherwise it reads your CLAUDE.md files, so import or symlink AGENTS.md. HumanLayer's guide adds: cover what, why and how, keep to universally applicable instructions, point to separate docs for task-specific detail, leave style to linters, and write the file by hand.
How builders use How to Write a Good AGENTS.md
- Create AGENTS.md at the repo root with the install, dev, test and lint commands an agent must run before it says a task is done.
- Use Claude Code with an existing CLAUDE.md? Import AGENTS.md from it with @AGENTS.md, or symlink one to the other (ln -s AGENTS.md CLAUDE.md) so both stay in sync.
- Move task-specific detail into an agent_docs/ folder and list the files with one-line descriptions, so the main file stays short.
- For Aider add read: AGENTS.md to .aider.conf.yml; for Gemini CLI set context.fileName to AGENTS.md in .gemini/settings.json.
- In a monorepo, add a nested AGENTS.md in each package with that package's own commands.
- Edit it whenever an agent makes the same mistake twice, and delete lines that no longer apply.
What to put in, and what to leave out
Combined from the AGENTS.md site, Anthropic's memory docs and HumanLayer's guide (checked 26 Nov 2026).
| Put in | Leave out |
|---|---|
| Exact commands: install, dev, test, typecheck, lint (for example Run npm test before committing) | Vague advice such as Test your changes or Keep files organized |
| A short map of the repo and what each folder is for | Long style guides a linter already enforces |
| Gotchas an agent can't guess: required env vars, generated files, what never to edit | Instructions that only matter for one task, such as how to design a new database table |
| Links to deeper docs with one-line descriptions | Whole documents pasted in |
Which agents read it
- The AGENTS.md site lists, among others: Codex, Jules, Factory, Aider, goose, opencode, Zed, Warp, VS Code, Devin, Junie, Amp, Cursor, RooCode, Gemini CLI, Kilo Code, Windsurf, Augment Code and GitHub Copilot's coding agent.
- Aider and Gemini CLI need one line of config to read it (see above); many others read it by default.
- Claude Code reads CLAUDE.md first; with no CLAUDE.md it reads AGENTS.md. In Settings, Project instructions can be set to claude-md-and-agents-md to load both.
How to Write a Good AGENTS.md: limits and gotchas
- It is guidance, not enforcement. Anthropic's docs say CLAUDE.md and auto memory are context, not enforced configuration. For rules that must hold, use permissions or hooks.
- Length hurts. Anthropic suggests under 200 lines per CLAUDE.md file; HumanLayer says under 300 lines is a general consensus and keeps its own root file under 60. Treat both as rules of thumb.
- Adherence drops as instruction count grows. HumanLayer's claim that models follow roughly 150 to 200 instructions reliably is its own estimate, not a measured guarantee.
- In Claude Code, adding a CLAUDE.local.md to a project that relies on AGENTS.md stops Claude from reading AGENTS.md, unless you change the Project instructions setting. Reading AGENTS.md directly needs Claude Code v2.1.277 or later.
- Auto-generated files tend to be generic. The /init command gives a starting point, but HumanLayer recommends writing the file by hand and editing it.
- It can go stale. A wrong command in AGENTS.md is worse than none, so review it when your build changes.
How to Write a Good AGENTS.md compared with other tools here
- Cursor Rules: Cursor's own rules files, which also support AGENTS.md. Pick rule files when you need Cursor-specific or file-scoped rules on top.
- Claude Code and CLAUDE.md: Claude Code's own instruction file, with imports and path-scoped rules. Pick CLAUDE.md for Claude-specific rules and import AGENTS.md for the shared part.
- Claude Code skills: instructions that load on demand. Move rare, task-specific procedures there instead of the always-on file.
- claude-mem: automatic notes from past sessions injected into the next. Pick it to add learned context, not to replace the file you write on purpose.
- ai-memory: a self-hosted memory server shared across agents. Use it for memory that grows over time, while AGENTS.md stays your stable rulebook.
When to pick How to Write a Good AGENTS.md
- Pick AGENTS.md if you use more than one coding agent, or hand a repo to agents regularly.
- Pick it first, before memory tools or plugins: it costs nothing and every session starts from the same context.
- Add a CLAUDE.md only for rules that are specific to Claude Code, and import AGENTS.md from it.
- Skip long documents inside it. Link to them instead.
Copy this: AGENTS.md starter
# AGENTS.md
## Project
<one paragraph: what this app does and who it is for>
## Map
- app/: <what lives here>
- lib/: <what lives here>
## Commands
- Install: <cmd>
- Dev: <cmd>
- Test: <cmd>
- Typecheck/lint: <cmd>
Run test and typecheck before you say a task is done; fix failures.
## Rules
- Keep diffs small; don't refactor unrelated code.
- Never commit secrets; use env vars.
## More docs (read only if relevant)
- agent_docs/database.md: schema and migrations
- agent_docs/deploy.md: how releases workHow to Write a Good AGENTS.md questions
Are there required fields in AGENTS.md?
No. It is plain Markdown, and you can use any headings.
What happens when instructions conflict?
The closest AGENTS.md to the edited file wins, and an explicit instruction in chat overrides everything.
Does Claude Code read AGENTS.md?
Yes, from v2.1.277, but by default only when there is no CLAUDE.md or CLAUDE.local.md in your working directory or above. Otherwise import it from CLAUDE.md or set Project instructions to load both.
How long should it be?
Short. Anthropic suggests under 200 lines per CLAUDE.md file, and HumanLayer's root file is under 60 lines.
Will the agent run the test commands I list?
The AGENTS.md site says yes if you list them: the agent will try to run relevant checks and fix failures before finishing.
Should I let an agent generate it?
It is fine as a first draft, but edit it by hand, because generated files tend to be generic and HumanLayer recommends against relying on them.
Related discoveries
See the newest picks →- ToolVibe-Coding & Prompt-to-App
Context7: up-to-date docs for A.I. editors
Feeds current, version-specific library docs into your coding assistant, through a CLI skill or an MCP server.
Effort: LowPrompt#MCP#Open source
- SetupVibe-Coding & Prompt-to-App
Cursor Rules and AGENTS.md
Persistent instructions so the A.I. follows your stack every time.
Effort: LowPrompt
Get the best new A.I. picks in your inbox
The best new agent workflows and tools we’ve vetted, with a clear verdict on each. Short, occasional, useful.