Course contents

AGENTS.md best practices: one file that works in seven tools

intermediate3 min readUpdated
  • Cursor
  • GitHub Copilot
  • Claude Code
  • Windsurf / Devin
  • Cline
  • Codex
  • Antigravity CLI
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:

ToolReads AGENTS.md?Notes
CodexYes, nativelyRoot to working directory; AGENTS.override.md per folder; 32 KiB cap
CursorYesRoot and nested; nested files apply to work in that folder
GitHub CopilotYesAnywhere in the repo; the nearest file takes precedence
Claude CodeYes, v2.1.277+By default only when there's no CLAUDE.md; otherwise import it
Devin DesktopYesAlways-on; also AGENT.md and AGENTS.local.md
ClineYesProject root, plus ~/.agents/AGENTS.md globally
Antigravity CLIYesStart 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.

AGENTS.md template
# <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.md at all, loads a subfolder's file on demand when it opens a file there and that folder has no CLAUDE.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:

Bridge layout
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.md through the import.
  • Copilot, Cursor, Codex, Devin and Cline read AGENTS.md directly.
  • 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.md that hides AGENTS.md from Claude Code. Import @AGENTS.md in it, or change the setting.
  • Duplicating AGENTS.md into GEMINI.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 test was renamed, the agent will keep running the old one. Review AGENTS.md in PRs that change scripts.

Recap

  • AGENTS.md is 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 into GEMINI.md.

Next step

Move on to skills: Anatomy of a skill.