# AGENTS.md examples and best practices

Canonical: https://cwyn.com/pages/claude-code-guide-agents-md-examples.html
Last updated: 2026-11-30T17:44:46-05:00

Claude Code project setup

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 November 30, 2026 · Published November 22, 2026

By CWYN · Published Nov 22, 2026 · [Official AGENTS.md format](https://agents.md/) (as of Nov 22, 2026)

## 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](https://cwyn.com/tools/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](https://agents.md/) (as of Nov 22, 2026).

## 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](https://agents.md/) (as of Nov 22, 2026).

## 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](https://agents.md/) (as of Nov 22, 2026).

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](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices) (as of Nov 22, 2026).

For tool-specific loading rules, see [CLAUDE.md vs AGENTS.md](https://cwyn.com/pages/claude-code-guide-claude-md-vs-agents-md.html).

## 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](https://cwyn.com/pages/claude-code-guide-claude-md-template.html). 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](https://agents.md/) (as of Nov 22, 2026) and [Anthropic’s skill authoring guidance](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices) (as of Nov 22, 2026).

## Next steps

- [All 34 Claude Code guides](https://cwyn.com/guides/claude-code/)
- [Claude Code setup walkthrough](https://cwyn.com/setup/claude-code/)
- [Free AI instruction builder](https://cwyn.com/build/ai-instructions/)

Estimate the cost of project instructions

[Free AI cost calculator](https://cwyn.com/score/ai-cost-calculator/?tool=claude)

When you include AGENTS.md in a Claude Code prompt, count its tokens with the rest of the session’s input for your monthly API estimate.

[AI Instruction Builder Pro ($14.95)](https://cwyn.com/pages/pack-ai-instruction-builder-pro.html)

Use the developer preset to build a full-length AGENTS.md offline.

### Build your own AGENTS.md

[Use the free AI instruction builder](https://cwyn.com/build/ai-instructions/) to generate one universal instructions file you can also paste into AGENTS.md.

## Email me the starter template

Get the editable starter as AGENTS.md.txt and a prompt for checking it. Save the starter as AGENTS.md in your repository.

Email address

Email me this file. Also send up to 4 short follow-up emails with tips and one related CWYN product. Unsubscribe any time. [Privacy policy](https://cwyn.com/pages/privacy.html)

### Build a full-length AGENTS.md offline

If you want an offline starting point for a development project, [AI Instruction Builder Pro ($14.95)](https://cwyn.com/pages/pack-ai-instruction-builder-pro.html) includes a developer preset for a full-length AGENTS.md.

AI Instruction Builder Pro $14.95

Build a full-length AGENTS.md, longer ChatGPT instructions and files for seven other targets offline, including a dedicated Grok Bot description. Nine offline presets include the General professional default and the developer ready set. Includes six role add-ons, a printable trait report and a self-test guide.
