Skip to content

AGENTS.md: what it is, and an example that works in Codex, Cursor and Claude Code

By the Toolbay team · Checked against the sources below on

AGENTS.md is a plain Markdown file in your repo that tells coding agents how to work on it: the commands, the code style and the rules. The agents.md site calls it "a README for agents". Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf and many others read it, and recent Claude Code versions do too.

One AGENTS.md means one set of rules for every agent on the team, instead of a different file per tool.

Where to put it

  • Put AGENTS.md in the repo root. There is no frontmatter; it is plain Markdown.
  • You can add more AGENTS.md files in subfolders. Agents read the nearest one, so the closest file to the code being edited takes precedence. A direct instruction in the chat overrides all of them.
  • Codex joins the files from the repo root down to the current folder and stops at 32 KiB in total by default (project_doc_max_bytes). Restart Codex after you edit the file.
  • Codex also reads a personal file at ~/.codex/AGENTS.md.

An example you can copy

AGENTS.md
# AGENTS.md

## Setup
- Install: pnpm install
- Dev server: pnpm dev
- Tests: pnpm test
- Types and lint: pnpm typecheck && pnpm lint

## Before you finish a task
- Run the tests, the type check and the lint. All three must pass.
- If you changed behaviour, add or update a test for it.
- Summarise what you changed and anything you could not check.

## Code style
- TypeScript strict mode.
- Single quotes, no semicolons.
- Prefer small pure functions; no new dependencies without asking.

## Boundaries
- Do not edit generated files in src/generated/.
- Do not touch .env files or print secrets.
- Ask before deleting files or changing the database schema.

## Project map
- apps/web: the Next.js site
- packages/core: shared logic, no framework code
- packages/core/AGENTS.md has extra rules for that package

Using it with Claude Code

Claude Code reads AGENTS.md as project instructions when there is no CLAUDE.md in the folder or above it (this needs a recent version). If your repo has both, make CLAUDE.md import AGENTS.md so the rules live in one place, then add anything Claude-specific below it.

CLAUDE.md
@AGENTS.md

## Claude Code
- Use the code-review skill before saying a change is done.

Using it with Cursor

Cursor reads AGENTS.md in the project root and in subfolders, combined with the parent folders, with the more specific file winning. For rules that must apply only to some files, Cursor also has .cursor/rules/*.mdc files with globs; AGENTS.md covers the rest.

What makes an AGENTS.md work

  1. Exact commands. An agent that guesses the test command will often skip the tests.
  2. A definition of done the agent can check itself against.
  3. Boundaries with a reason, so the agent can apply them to cases you did not list.
  4. Short. Every agent loads it for every task; Codex cuts it off at 32 KiB by default.

Questions people ask

AGENTS.md or CLAUDE.md?
Write the shared rules once in AGENTS.md so every agent gets them. If you use Claude Code too, put @AGENTS.md at the top of CLAUDE.md and keep only Claude-specific notes below it.
Does AGENTS.md need frontmatter?
No. It is plain Markdown with any headings you like. The agents.md example uses sections for setup commands and code style.