Copyable starter templates

Use one root template for the shared policy: project purpose, package manager, install command, development command, test command, build command, formatting command, safe edit boundaries, files to avoid, review expectations, and known failure notes.

For React or Vue apps, name the frontend package path, generated build folders, UI test command, and screenshot or accessibility check. For Python services, name the virtual environment command, test runner, migration boundary, and formatting command. For monorepos, keep root AGENTS.md short and place nested AGENTS.md files only where commands or ownership really differ.

For teams, add one security section: no secrets in prompts, no production writes without approval, no migration edits without owner review, and no generated code merge without tests or human diff review.

Should you generate AGENTS.md automatically?

Use automation only to assemble repository facts you have verified: exact commands, scope, forbidden paths, and the definition of done. The browser builder on this page is deterministic and does not inspect your repository or ask a model to invent guidance. Replace every default, run each command, remove redundant rules, and review the result before committing it.

A 2026 AGENTS.md evaluation preprint found that context files generally increased steps and inference cost without a statistically significant accuracy gain; developer-written files performed better than model-generated files in its comparison. A separate repository-mining preprint found configuration smells in 91 of 100 sampled repositories, including redundant lint rules and conflicting instructions. These are bounded studies, not universal laws, but they support keeping the starter concise and repo-specific.

Root vs nested AGENTS.md inheritance

Put repo-wide rules in the root AGENTS.md: install commands, global test commands, style rules, forbidden files, and review expectations. Put package-specific exceptions in a nested AGENTS.md, such as apps/web/AGENTS.md or packages/api/AGENTS.md, when that folder has different commands or risk boundaries.

Nested files should override only what changes. If the web app uses npm test and the API uses pytest, write that difference in the nested file instead of duplicating the whole root policy.

What every template must say

Every useful AGENTS.md should declare the test command, completion standard, allowed edit scope, forbidden files, generated folders, secret policy, and review expectation. These are the controls an agent can actually follow during a coding task.

Avoid vague rules like 'write clean code' unless the repo has a command or reviewer habit that checks the rule. Replace vague style advice with concrete commands, file paths, and approval boundaries.

What not to put in it

Do not paste secrets, access tokens, private customer data, or vague motivational rules. Avoid rules like 'write clean code' unless you explain what command or reviewer checks that rule.

Do not copy the same paragraph into every instruction file. Keep one source of truth and link tool-specific files back to it when possible.

Recommended play

  1. Create a root AGENTS.md first, then add nested files only when a folder has different commands or ownership.
  2. Keep every command copy-pasteable from a clean checkout.
  3. Review AGENTS.md whenever CI, package managers, test commands, or security boundaries change.

AGENTS.md template blocks

Use these blocks as a practical template. Delete anything that is not true for the repo.

AreaWhat to writeExampleKeep it out when
Repo purposeOne sentence on what the project doesNext.js marketing site with a FastAPI admin backendThe repo is private and purpose details reveal sensitive plans
CommandsInstall, dev, test, build, lintnpm run test; npm run buildThe command is stale or only works on one developer machine
Safe boundariesAllowed files, risky files, generated filesDo not edit migrations without approvalThe team has not agreed on ownership yet
Review ruleHow to prove the change is doneShow changed files, test result, and known riskThe rule is only style preference and not checked anywhere
Nested scopePackage-specific commands and boundariesapps/web/AGENTS.md uses npm test; packages/api/AGENTS.md uses pytestThe folder does not actually differ from the root policy

Execution steps

01

Write the root file

Start with the project purpose, commands, safe boundaries, and review expectations.

02

Test every command

Run the listed commands once so the agent does not inherit broken instructions.

03

Add folder-specific notes only when needed

Use nested AGENTS.md files for monorepo packages, generated folders, or high-risk areas with different rules.

04

Add a drift owner

Name the person or team that updates instructions when CI, package managers, or release flow changes.

Common pitfalls

Writing a policy novel

Keep the file practical: commands, boundaries, and review steps beat long philosophy.

Listing commands nobody runs

Only include commands that work from a clean checkout or explain the required setup.

Hiding secrets in instructions

Describe environment variable names and access boundaries, never credential values.

Implementation checklist

  • Explain what the repo does in one sentence.
  • List install, test, build, and lint commands.
  • Name files or folders the agent should not edit without approval.
  • Explain how to verify a completed task.
  • Keep secrets and customer data out of the file.
  • Review the file when CI or package managers change.

Questions this guide answers

What should an AGENTS.md template include?

A useful AGENTS.md template gives Codex copyable repo instructions: project purpose, install command, test command, safe edit boundaries, forbidden files, and review expectations. Start with one root file, then add nested AGENTS.md files only for packages that need different commands, ownership, or safety boundaries.

When should you add a nested AGENTS.md file?

Add a nested AGENTS.md only when a folder genuinely needs different guidance, such as package-specific test commands, generated-file boundaries, ownership rules, or risk limits. Keep the root file for shared repo policy and the nested file for local exceptions.

Who is this AGENTS.md template for?

Developers setting up Codex-compatible agents, team leads standardizing repo instructions, and maintainers cleaning stale agent rules across Node.js, Python, and monorepo layouts.

Should you generate AGENTS.md automatically?

Use a generator only as a starter for repository facts you verify yourself: exact setup and test commands, scope, restricted paths, and completion rules. Do not let a model invent a long repository overview. Run every generated command, delete redundant guidance, and audit the final file before committing it.