Course contents
AGENTS.md best practices: one file that works in seven tools
On this page
What AGENTS.md is
AGENTS.md is a plain Markdown file of instructions for coding agents, with no required fields or frontmatter. The agents.md site describes it as "a README for agents" and lists support across many tools. It's stewarded by the Agentic AI Foundation under the Linux Foundation.
All seven tools in this course read it, though not all the same way:
| Tool | Reads AGENTS.md? | Notes |
|---|---|---|
| Codex | Yes, natively | Root to working directory; AGENTS.override.md per folder; 32 KiB cap |
| Cursor | Yes | Root and nested; nested files apply to work in that folder |
| GitHub Copilot | Yes | Anywhere in the repo; the nearest file takes precedence |
| Claude Code | Yes, v2.1.277+ | By default only when there's no CLAUDE.md; otherwise import it |
| Devin Desktop | Yes | Always-on; also AGENT.md and AGENTS.local.md |
| Cline | Yes | Project root, plus ~/.agents/AGENTS.md globally |
| Antigravity CLI | Yes | Start folder up to repo root; cumulative with GEMINI.md |
What to put in it
Write for a capable new teammate who has never seen the repo and will not ask questions.
# <Project name>
One or two sentences on what this repo is.
## Setup and commands
- Install: `pnpm install`
- Dev server: `pnpm dev`
- Test everything: `pnpm test`; one file: `pnpm vitest run <path>`
- Lint and types: `pnpm lint && pnpm typecheck`
## Layout
- `apps/web/`: Next.js 16 app (App Router)
- `packages/db/`: Prisma schema and data helpers
- `packages/ui/`: shared components
## Conventions
- TypeScript strict. No `any` at package boundaries.
- Database access only through `packages/db`.
## Boundaries
- Don't edit generated files in `packages/db/generated/`. Run `pnpm db:generate`.
- Don't upgrade dependencies unless the task asks.
- Ask before running migrations or anything that deletes data.
## Before you finish
- Run the tests for the files you changed and paste the result.
- Keep the diff limited to the request.
## Skills
- For code reviews, use the `nextjs-code-review` skill.
- For new tests, use the `playwright-test-writer` skill.
The last section matters more than it looks. Agents don't always use skills on their own; in Vercel's evals, an explicit instruction to use a skill raised its trigger rate to over 95% and the pass rate from 53% to 79% (Vercel).
What to keep out
- Tool-specific instructions. "Use plan mode" means nothing to Codex. Put Claude-only notes in
CLAUDE.md, Cursor-only ones in a Cursor rule. - Long procedures. Release checklists and review rubrics are skills.
- Secrets and internal URLs you wouldn't put in a public README.
- Everything else in your README. Link to docs instead of pasting them.
Nested files and precedence
Large repos can put an AGENTS.md in each package. The agents.md guidance is simple: the closest file wins, and explicit chat prompts override everything. In practice, tools differ:
- Codex concatenates one file per folder from the root to where you started. Later (deeper) files win. It never reads sibling folders.
- Cursor applies nested files when working on files in that folder, combined with parents.
- Copilot uses the nearest
AGENTS.md. - Claude Code, when it is reading
AGENTS.mdat all, loads a subfolder's file on demand when it opens a file there and that folder has noCLAUDE.md. - Devin reads from the workspace root down to the folder it's working in.
- Antigravity CLI reads from the start folder up to the root, never down into subfolders.
One file, many tools: the bridge pattern
Most multi-tool teams settle on this:
AGENTS.md # the source of truth
CLAUDE.md # contains: @AGENTS.md (plus Claude-only notes)
.github/copilot-instructions.md # optional; Copilot reads AGENTS.md anyway
- Claude Code reads
AGENTS.mdthrough the import. - Copilot, Cursor, Codex, Devin and Cline read
AGENTS.mddirectly. - For Antigravity CLI, don't also put the same content in
GEMINI.md; it would load twice.
supabase/supabase uses exactly this: its CLAUDE.md is the single line @AGENTS.md.
Appending without clobbering
Tools and installers increasingly add sections to AGENTS.md. Next.js, for example, can manage a docs index block there (Next.js AI agents guide). The presets.dev CLI appends each stack between markers:
<!-- presets.dev:nextjs:start -->
...
<!-- presets.dev:nextjs:end -->
Markers make re-runs safe and let you remove a section cleanly later. When you edit by hand, stay outside other tools' marked blocks so their updates don't overwrite your text.
Common mistakes
- A
CLAUDE.local.mdthat hidesAGENTS.mdfrom Claude Code. Import@AGENTS.mdin it, or change the setting. - Duplicating
AGENTS.mdintoGEMINI.md. Antigravity loads both. - One huge root file in a monorepo. Split by package, and watch Codex's 32 KiB combined limit.
- Stale commands. If
pnpm testwas renamed, the agent will keep running the old one. ReviewAGENTS.mdin PRs that change scripts.
Recap
AGENTS.mdis plain Markdown that all seven tools read in some form.- Include commands, layout, conventions, boundaries, a "before you finish" list and skill pointers.
- Nesting differs: Codex walks down to your folder; Antigravity only looks up.
- Bridge Claude Code with
@AGENTS.md; don't duplicate intoGEMINI.md.
Next step
Move on to skills: Anatomy of a skill.