Claude Code project setup

AGENTS.md examples and best practices

Write AGENTS.md in free-form Markdown at the repository root. List the build and test commands and where to run them. There is no required schema. A web app or Python project can keep those instructions in one file. In a monorepo, the closest AGENTS.md wins when a package rule conflicts with the root file.

Last updated · Published

By CWYN · Published · Official AGENTS.md format (as of )

1. Copy the AGENTS.md starter template

Save this starter as AGENTS.md. Replace the brackets with commands you have run and paths a new teammate can open. The headings follow the common sections in the official format. Keep the ones your project needs.

AGENTS.md · 19 lines
# [Project name]

## Project overview
[What does this repository produce? Where does the relevant code live?]

## Setup, build and test commands
Run from `[working directory]`.
- Install dependencies with `[setup command]`.
- Build with `[build command]`.
- Run the tests with `[test command]`.

## Code style
- Follow the convention in `[reference file]` when changing [kind of code].

## Testing
- When changing [behavior], add a case to `[test path]` that checks [expected result].

## Security
- Keep [sensitive data] out of [logs, fixtures or other shared output].

Use the free AGENTS.md generator to write rules for when Codex should plan an edit or ask for approval. Paste those rules below your project commands.

2. Three filled-in AGENTS.md examples

These examples describe three fictional repositories. Each shows a decision an agent would otherwise have to guess.

Web app example

# Workshop board
The public calendar shows how many seats are left in each class.
- From the repository root, run `npm ci` and `npm run build`.
- Edit seat calculations in `src/seats.ts`. A cancellation releases one seat.
- Add a case for a full class reopening in `test/seats.test.ts`. Run `npm test`.
- Use invented attendee names in fixtures.

Python scripts example

# Parcel scan reports
Summarize a CSV of parcel scans by tracking ID.
- From the root, try `python -m scans.summarize tests/fixtures/scans.csv`.
- Keep tracking IDs as strings so that leading zeroes survive the export.
- Test a leading-zero ID in `tests/test_summary.py`.
- Run `python -m unittest discover -s tests` from the root.

Monorepo package example

AGENTS.md at the repository root

# Field notes workspace
The editor and parser share one workspace.
- Install dependencies from the root with `pnpm install`.
- By default, run the whole test suite from the root with `pnpm test`.

packages/parser/AGENTS.md

# Field notes parser
- For parser-only changes, run `pnpm --filter @fieldnotes/parser test` from the root.
- Preserve blank lines inside quoted notes.
- Put a sample note in `packages/parser/test/fixtures/` for each new parsing case.

For an edit to packages/parser/src/read.ts, use the parser test command. When instructions conflict, the AGENTS.md closest to the edited file wins. AGENTS.md guidance for monorepos (as of ).

3. AGENTS.md best practices

  • Write for a teammate making a first change. Leave the project introduction in README.md and use AGENTS.md for build steps, tests and conventions.
  • Give the exact command and its working directory. In the Python example, a contributor can run the report against a fixture before editing the parser.
  • Put shared rules at the root. Add a package file where the commands or conventions change. An explicit instruction from the user in chat takes precedence over either file.
  • Treat the file as living documentation. Update a command when you rename the script it calls, and remove rules for code you have retired.

AGENTS.md contents, precedence and maintenance (as of ).

4. AGENTS.md vs skills

Use AGENTS.md for always-on project context. A single Markdown file can hold the facts that apply across tasks in a repository or package. The parser's test command belongs here because contributors need it whenever they change the parser. Official AGENTS.md format (as of ).

Use a skill for a narrow, repeating procedure. An Anthropic Agent Skill is a folder containing SKILL.md. At startup Claude loads only each skill's name and description. It reads the body when the skill becomes relevant, then reads additional files as needed. A checklist for publishing a parser release belongs in a skill. Anthropic’s skill authoring guidance (as of ).

For tool-specific loading rules, see CLAUDE.md vs AGENTS.md.

5. AGENTS.md FAQ

Which headings are required?

None. Standard Markdown is enough. A scripts repository can put its run command first, even if a web app starts with build instructions.

Can a monorepo package override the root file?

Yes. The closest AGENTS.md takes precedence for the file being edited. An explicit user prompt in chat overrides conflicting instructions in those files.

Will the agent run the tests I list?

The official FAQ says the agent will attempt to run relevant programmatic checks and fix failures before finishing. List the checks you use for that change.

Where do CLAUDE.md and SKILL.md fit?

For a Claude Code project file, see the CLAUDE.md template and examples. For steps Claude should read when a task calls for them, put the procedure in a skill folder's SKILL.md.

FAQ sources include the official AGENTS.md FAQ (as of ) and Anthropic’s skill authoring guidance (as of ).

Next steps

Build your own AGENTS.md

Use the free AI instruction builder to generate one universal instructions file you can also paste into AGENTS.md.

Build a full-length AGENTS.md offline

If you want an offline starting point for a development project, AI Instruction Builder Pro ($14.95) includes a developer preset for a full-length AGENTS.md.