---
title: Write an AGENTS.md for every repository agents work in
description: Give coding agents a short, specific, tool-neutral AGENTS.md at the repo root (and per subproject in monorepos) with build, test, conventions and boundaries — the README for agents.
id: BP-0015
domain: D.AGT.INS
type: guideline
roles: [implementer, planner, any]
stage: [plan, build]
status: draft
version: 1.0.0
updated: 2026-11-24
reviewed: 2026-11-24
review_by: 2027-05-24
related: [BP-0016, BP-0017, BP-0007, BP-0005]
sources:
  - { title: AGENTS.md, url: https://agents.md/ }
  - { title: Claude Code docs — How Claude remembers your project (AGENTS.md), url: https://code.claude.com/docs/en/claude-md }
---

## Rules

1. **MUST** put an `AGENTS.md` at the repository root of any repo that coding agents work in. It is the tool-neutral instruction file; keep tool-specific files thin (see [BP-0017](/agent-engineering/instructions-prompting/one-source-of-truth-for-agent-instructions/)).
2. **MUST** include the exact commands to build, test, lint and run the project, as code blocks an agent can copy and run. Agents will run listed test commands and try to fix failures, so list only commands that work.
3. **MUST** state the boundaries: what agents must not change (generated files, vendored code, migrations, secrets), and which actions need a human (deploys, releases, data changes).
4. **MUST** write instructions that can be checked ("Run `bun test` before committing"), not aspirations ("Write good tests").
5. **MUST NOT** put secrets, credentials, internal hostnames or personal data in it. It is committed and read by every tool and contributor.
6. **SHOULD** keep it short — aim for under about 200 lines — and link to longer docs instead of copying them. Every line is loaded into every session.
7. **SHOULD** use these sections, in this order, leaving out any that do not apply: project overview, setup and commands, code style and conventions, testing, security and boundaries, commit and pull-request rules.
8. **SHOULD**, in a monorepo, add an `AGENTS.md` in each subproject for what differs there. Agents use the nearest file in the directory tree, so do not repeat the root file.
9. **SHOULD** update it in the same change that alters a command, convention or boundary, and review it when agents repeatedly make the same mistake.
10. **MAY** cite practices from this site by ID (for example "follow BP-0001@1.0.0 for CLI output") instead of restating them.

## When to apply

Every repository that Claude Code, Codex, Copilot, Cursor, Gemini CLI, Jules, Amp or similar agents touch. The format is plain Markdown with no required fields; it is supported by most coding agents and stewarded by the Agentic AI Foundation under the Linux Foundation.

## Procedure

1. Start from what a new teammate would need on day one, minus what the README already says for humans.
2. Run every command you list, from a clean checkout, before committing the file.
3. Write the boundaries section from real incidents and near misses.
4. Ask an agent to do a small task using only the file; fix whatever it had to guess.

## Examples

```markdown
# AGENTS.md

## Project
Go CLI for electronics inventory. Single binary; no external services.

## Commands
- Build: `make build`
- Test: `make test` (must pass before every commit)
- Lint: `make lint`

## Conventions
- Every command supports `--json` (BP-0001@1.0.0).
- Errors wrap with `fmt.Errorf("…: %w", err)`.

## Boundaries
- Do not edit `internal/gen/` (generated by `make gen`).
- Never commit `.env` or anything under `secrets/`.
- Releases and tags are done by a human.

## Pull requests
- One logical change per PR; title in imperative mood; link the issue.
```

## Anti-patterns

- A copy of the README, or a wall of architecture prose agents must read before the first command.
- Commands that no longer work, so agents "fix" a build that was never broken.
- Vague rules ("be careful with the database").
- Separate, diverging instruction files per tool.

## Checklist

- [ ] Root `AGENTS.md` exists; subproject files only where something differs
- [ ] Every listed command runs from a clean checkout
- [ ] Boundaries and human-only actions stated
- [ ] No secrets or internal details
- [ ] Under about 200 lines; links instead of copies

## References

- [AGENTS.md](https://agents.md/)
- [Claude Code — reading AGENTS.md](https://code.claude.com/docs/en/claude-md)
