Agent Engineering / Instructions & Prompting
Write an AGENTS.md for every repository agents work in
- MUST put an
AGENTS.mdat 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). - 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.
- 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).
- MUST write instructions that can be checked (“Run
bun testbefore committing”), not aspirations (“Write good tests”). - MUST NOT put secrets, credentials, internal hostnames or personal data in it. It is committed and read by every tool and contributor.
- 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.
- 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.
- SHOULD, in a monorepo, add an
AGENTS.mdin each subproject for what differs there. Agents use the nearest file in the directory tree, so do not repeat the root file. - SHOULD update it in the same change that alters a command, convention or boundary, and review it when agents repeatedly make the same mistake.
- MAY cite practices from this site by ID (for example “follow [email protected] for CLI output”) instead of restating them.
When to apply
Section titled “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
Section titled “Procedure”- Start from what a new teammate would need on day one, minus what the README already says for humans.
- Run every command you list, from a clean checkout, before committing the file.
- Write the boundaries section from real incidents and near misses.
- Ask an agent to do a small task using only the file; fix whatever it had to guess.
Examples
Section titled “Examples”## ProjectGo 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- 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
Section titled “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
Section titled “Checklist”- Root
AGENTS.mdexists; 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