What AGENTS.md is
AGENTS.md is a plain Markdown file at the root of a repository that tells a coding agent how to work in it: which commands build and test the code, where things live, which rules the team follows, and what the agent must not touch. There is no schema and no required heading. Any agent that supports the format reads it at the start of a session, before it reads a single line of your code.
The idea is a split of audiences. The README is written for people: what the project is, how to get it running, who to ask. AGENTS.md is written for an agent that has the patience to follow exact instructions but none of the tacit knowledge a new hire picks up in their first week. A sentence like "we never store money as a float" is obvious to everyone on the team and invisible to an agent until somebody writes it down.
The format appeared in 2025 as a vendor-neutral convention, so that a repository would not need one file per tool. In December 2025 it became one of the founding projects of the Agentic AI Foundation, a Linux Foundation project, alongside Anthropic's Model Context Protocol and Block's goose. The agents.md site says it is used by over 60,000 open-source projects and is now stewarded by the foundation.
Which agents read it
The list on agents.md is long and growing: OpenAI Codex, GitHub Copilot's coding agent, Cursor, Google's Jules and Gemini CLI, Devin and Windsurf, Amp, Factory, Aider, goose, Zed, Warp, JetBrains Junie and others. The practical consequence is that one well-kept file serves every developer on the team, whichever agent they prefer.
Claude Code has its own file, CLAUDE.md, and recent versions read AGENTS.md as well. According to the Claude Code memory docs, Claude reads AGENTS.md when the repository has no CLAUDE.md, and reads only CLAUDE.md when both exist. A CLAUDE.md that holds the single line @AGENTS.md imports the shared file, so both tools see the same rules and Claude-only lines can sit below the import. CLAUDE.md in a team repository covers the combinations in detail.
What to put in it
Write down what an agent cannot work out from the code and what it gets wrong without being told. Seven kinds of content earn their place:
| Section | What it holds | Example line |
|---|---|---|
| Commands | Install, run, test, lint, format, typecheck, with exact flags, including how to run one test | pnpm --filter api test -- -t "renewal" |
| Structure | Where each kind of code lives, and which folders are generated | "HTTP handlers in src/http/; no business logic there" |
| Project rules | Conventions a linter cannot check | "Money is integer cents; never a float" |
| Tests | What a change must be tested with, and when a task counts as done | "A bug fix starts with a failing test" |
| Boundaries | Folders not to touch, commands not to run, when to stop and ask | "Do not edit applied migrations; add a new one" |
| Handoff | Branch and commit names, what the pull request description says, which checks pass first | "Before handoff: pnpm typecheck && pnpm lint && pnpm test" |
| Links | Architecture notes, decision records, specs: the details stay there | "Why queues and not cron: docs/adr/0007.md" |
Commands go first, because they are what an agent uses most and gets wrong most expensively. A test command that runs the whole suite when the agent wanted one file costs minutes and tokens on every attempt. A handoff line that differs from what CI runs teaches the agent to declare work done that CI will reject.
An example file
Here is a complete file for a fictional subscriptions service. It is about forty lines, and every line is either a command, a location or a rule that was broken at least once.
# subscriptions: plans, renewals and invoices (TypeScript, PostgreSQL)
## Commands
- Install: `pnpm install`
- Run locally: `docker compose up -d db && pnpm dev`
- All tests: `pnpm test`
- One file: `pnpm vitest run src/renewals/schedule.test.ts`
- One test by name: `pnpm vitest run -t "renews on the last day of a short month"`
- Before handoff (same as CI): `pnpm typecheck && pnpm lint && pnpm test`
## Structure
- `src/http/`: routes and request validation only
- `src/renewals/`, `src/invoices/`: business logic
- `src/db/`: queries and repositories; nothing else talks to the database
- `migrations/`: SQL migrations, applied in order
- `docs/architecture.md`, `docs/adr/`: read before changing a module boundary
- `specs/`: one spec per feature; read the one your task names
## Rules
- Money is integer cents (`bigint`); never `number` with decimals.
- Renewal dates are computed in the customer's time zone (`customer.tz`),
then stored in UTC. A renewal on the 31st falls on the month's last day.
- Every call to the payment provider carries an idempotency key.
- Errors are thrown as `DomainError` from `src/errors.ts`, not bare `Error`.
- A new public endpoint gets a contract test in `tests/contract/`.
## Tests
- A bug fix starts with a test that fails without the fix.
- External HTTP is mocked with `msw`; tests never call the real provider.
- Do not delete, skip or loosen an existing test to make a change pass.
## Boundaries
- Do not edit files in `migrations/` that are already on `main`.
- Do not touch `infra/` or `.github/workflows/`.
- No new dependency without saying why in the pull request.
- Changing a public API or the database schema: stop and propose a plan first.
## Handoff
- Branch: `feat/<ticket>-short-name`
- Pull request: link the spec, list the acceptance criteria covered,
say how you verified the change.
Notice what is missing: no history of the project, no description of the team, no generic advice such as "write readable code". The templates for seven stacks follow the same shape.
Monorepos and nested files
A monorepo with a TypeScript frontend, a Go service and a Python data job cannot share one set of commands. AGENTS.md handles this with nested files: each package or service can have its own AGENTS.md, and the agents.md site says the nearest file in the directory tree to the file being edited takes precedence. An explicit instruction in the chat overrides them all.
Three habits keep nested files from contradicting each other:
- Put shared rules at the root, and only there. Branch names, the handoff checklist and cross-package boundaries belong in the root file.
- Keep a nested file about its own folder. Its commands, its structure, its local rules.
- State an override in words. If the Go service uses a different branch prefix, write "Differs from the root: branches start with
svc/". An agent that sees two silent, conflicting rules may follow either.
Tools do not all merge files the same way. Claude Code, for example, concatenates the files it loads rather than replacing one with another, so a contradiction between the root and a subfolder stays visible to the model as two rules. Writing overrides explicitly works everywhere.
Common mistakes
- A copy of the README. The agent already reads the README if it needs to. Duplicated text drifts apart, and the agent gets two versions of the truth.
- Too long. Every line is read at the start of every session and competes for the model's attention with the task. If a person cannot read the file in two or three minutes, move the detail into
docs/and link to it. See context engineering for why more is not better. - Vague. "Handle dates carefully" changes nothing. "Renewal dates are computed in the customer's time zone, stored in UTC" changes the code an agent writes.
- Rules a tool should enforce. Indentation, import order and quote style belong to the formatter and the linter, which never forget. A line in AGENTS.md is a request; a failing check is a fact.
- Never updated. A command renamed six months ago, a folder that no longer exists: the agent follows them faithfully and fails. Stale instructions are worse than none.
Keeping it true
AGENTS.md is not written once. It grows from real mistakes and shrinks when a tool takes over a rule. A loop that works:
- Notice the mistakeAn agent does something wrong, or a reviewer writes the same remark on a second pull request.
- Find the missing pieceWas a rule missing, a command wrong, a piece of knowledge buried in somebody's head?
- Prefer a checkIf a linter rule, a test or a hook can catch it, add that. Otherwise write one concrete line in AGENTS.md, or a page in the knowledge base with a link.
- Change it through reviewEdit the file in a pull request like code, so the team sees and agrees with every new rule.
Give the file an owner, one or two people who review changes to it and prune it every month or so. Without one, rules accumulate "just in case" and nobody removes the ones a linter now enforces.
Questions
What is the difference between AGENTS.md and CLAUDE.md?
They serve the same purpose. AGENTS.md is the shared, vendor-neutral file; CLAUDE.md is Claude Code's own. Recent Claude Code versions read AGENTS.md when there is no CLAUDE.md. If you need both, keep the shared rules in AGENTS.md and put @AGENTS.md at the top of CLAUDE.md, with Claude-only lines below it.
How long should AGENTS.md be?
There is no hard limit in the format. A useful test is whether a person can read it in two or three minutes. Claude Code's docs suggest keeping each CLAUDE.md under 200 lines, and the same reasoning applies: longer files cost context and are followed less reliably.
Where does the file go?
At the repository root, committed to git. In a monorepo, add nested files in packages or services whose commands and rules differ from the root.
We have a good README. Do we still need AGENTS.md?
Yes. A README explains the project to people. AGENTS.md gives an agent exact commands, boundaries and rules it would otherwise guess, and it is the file the agent is guaranteed to read.
Take your team there, step by step
A 13-week pilot on one team: a baseline, a harness built around your process, real backlog tasks through the whole cycle, and the numbers before and after.