hackerdb

Home / Guides / How to write an AGENTS.md that coding agents actually follow

How to write an AGENTS.md that coding agents actually follow

A project instruction file is loaded in every session, so every wasted line costs you attention and every wrong command costs you time. Short, true and specific wins.

Published 2026-12-02. By hackerdb.

The five sections

  1. Commands. Install, run, test (including how to run one test), lint, build. Run each yourself from a clean checkout. A wrong command is worse than none.
  2. Layout. Three to six lines on where things live and which folders are generated or off limits.
  3. Conventions. The rules that are not obvious from the code: error handling style, how to validate input, what must have a test.
  4. Definition of done. What must be true before the agent says it is finished (tests pass, lint clean, docs updated).
  5. Hard limits. Things the agent must never do without asking: delete outside the repo, push, deploy, touch secrets, move money.

What to leave out

Keep it small

Aim for under about 100 lines. If you need more, move procedures into skills that load only when relevant: see how to write a SKILL.md that triggers reliably.

Treat it as code

Review changes to the file in pull requests. It steers an agent that can run commands, so a malicious edit matters. Scan it for hidden characters and risky commands with agentscan.

The Coding Agent Skills and AGENTS.md Kit includes ten starter templates (web app, Python service, Rust CLI, Solidity, Solana, data pipeline, mobile, monorepo, docs site, Terraform).