AGENTS.md Generator
Generate high-quality AGENTS.md files for repository folders. Each file provides coding agents with project-specific context — build commands, testing instructions, code style, structure, and operational boundaries.
What is AGENTS.md
AGENTS.md complements README.md. README is for humans; AGENTS.md is for coding agents.
- Predictable location — Agents look for
AGENTS.mdin the current directory, then walk up the tree - Nested files — Subfolders can have their own
AGENTS.mdthat takes precedence over the root one - Separate from README — Keeps READMEs concise; agent-specific details (exact commands, boundaries, conventions) go here
- NOT the same as
.github/agents/*.agent.md— Those are agent persona definitions (who the agent is).AGENTS.mdis project context (what the agent should know about this code)
Critical Guard: Only Generate If Missing
This is the single most important rule.
NEVER overwrite an existing AGENTS.md.
Before generating for ANY folder:
- If it exists → skip and report:
"AGENTS.md already exists at <path> — skipping" - If it does not exist → proceed with generation
- This check applies to every folder independently
Pertinent Folder Detection
Identify which folders should have an AGENTS.md:
Always generate for:
- Repository root (
/) - Wiki folder (
wiki/) — if generated by deep-wiki (haspackage.jsonwith VitePress)
Generate if they exist:
tests/,src/,lib/,app/,api/- Monorepo packages:
packages/*/,apps/*/,services/*/ - Any folder with its own build manifest:
package.jsonpyproject.tomlCargo.toml*.csproj/*.fsprojgo.modpom.xml/build.gradle
.github/— only if it contains workflows or actions
Always skip:
node_modules/,.git/,dist/,build/,out/,target/vendor/,.venv/,venv/,__pycache__/- Any directory that is generated output or third-party dependencies
The Six Core Areas
Every good AGENTS.md covers these areas, tailored to what actually exists in the folder. Do not invent sections for things the project doesn't have.
a) Build & Run Commands — PUT FIRST
Agents reference these constantly. Use exact commands with flags, not just tool names.
Read these sources to find real commands:
package.json→scriptssectionMakefile→ targetspyproject.toml→[tool.poetry.scripts]or[project.scripts]Cargo.toml→ standard cargo commands- CI configs →
.github/workflows/*.yml,Jenkinsfile,.gitlab-ci.yml
b) Testing Instructions
Include:
- Test framework and how it's configured
- How to run all tests, a single file, a single test
- Expected behavior before commits (e.g., "all tests must pass")
c) Project Structure
Include:
- Key directories and what they contain
- Entry points (e.g.,
src/main.py,src/index.ts) - Where to add new features
d) Code Style & Conventions
One real code example beats three paragraphs of description.
Only include if the repo has evidence of conventions (e.g., commitlint config, PR templates, contributing guides).
f) Boundaries
Use a three-tier system:
Tailor boundaries to the project:
- Backend projects: schema changes, API contracts
- Frontend projects: breaking component APIs, design system changes
- Infrastructure: production configs, IAM permissions
Generation Process
When generating an AGENTS.md for a specific folder:
Step 1: Check existence
If it exists, stop. Report and move to the next folder.
Step 2: Scan the folder
Identify:
- Primary language (Python, TypeScript, Rust, Go, Java, C#)
- Framework (FastAPI, Next.js, Actix, Spring Boot)
- Build tool (npm, cargo, poetry, maven, gradle)
- Test runner (pytest, vitest, cargo test, JUnit)
Step 3: Read config files
Extract real commands and settings from:
package.jsonscriptsMakefile/Justfiletargetspyproject.tomlscripts and tool configsCargo.tomlmetadata.github/workflows/*.ymlbuild/test stepsdocker-compose.ymlservice definitions- Linter configs (
.eslintrc,ruff.toml,rustfmt.toml)
Step 4: Detect conventions
Read 3-5 source files to identify:
- Naming patterns
- Import organization
- Error handling style
- Comment style
- Module structure
Step 5: Compose the AGENTS.md
Use only the sections that apply. If the folder has no tests, omit the testing section. If there's no CI config, omit git workflow.
Step 6: Validate
Before writing the file:
- Every command references a real script, target, or tool
- Every file path references an actual file or directory
- No placeholder text like
<your-project>orTODO - No invented sections for things that don't exist
Template Structure
Omit any section that doesn't apply. A 20-line AGENTS.md with real commands beats a 200-line one with generic filler.
Root vs Nested AGENTS.md
Root AGENTS.md (/AGENTS.md)
Covers the entire project:
- Overall tech stack and architecture
- Global conventions and coding standards
- Dev environment setup
- Repository-wide boundaries
- CI/CD overview
Nested AGENTS.md (e.g., tests/AGENTS.md)
Covers that specific subfolder:
- What this folder does and why it exists
- Folder-specific commands (e.g.,
cd tests && pnpm test) - Folder-specific conventions
- Should NOT repeat root-level content
Wiki AGENTS.md (wiki/AGENTS.md)
ALWAYS check if wiki/AGENTS.md exists before generating — same only-if-missing guard as all other folders. If it exists, skip it.
Use this template (adapt to the actual project):
Fill in the real section names, technologies, and project-specific conventions.
Agents read the nearest AGENTS.md in the directory tree. Nested files take precedence, so they should contain folder-specific details, not global ones.
CLAUDE.md Companion File
Whenever you generate an AGENTS.md in a folder, also generate a CLAUDE.md in the same folder — only if CLAUDE.md does not already exist.
The CLAUDE.md content is always exactly:
This ensures Claude Code (and similar tools that look for CLAUDE.md) are redirected to the authoritative AGENTS.md instructions.
Same guard applies: check if CLAUDE.md exists before writing. If it exists, skip it.
Quality Principles
Anti-Patterns to Avoid
- ❌ "You are a helpful coding assistant" — too vague, describes feelings not actions
- ❌ Generic boilerplate — content that could apply to any project provides no value
- ❌ Invented commands/paths — every command and path must reference something real
- ❌ Duplicating README.md — AGENTS.md complements README, doesn't copy it
- ❌ Including secrets — never put credentials, API keys, or tokens in AGENTS.md
- ❌ Overwriting existing files — if AGENTS.md exists, do not touch it
- ❌ Padding empty sections — if there are no tests, don't write a testing section
- ❌ Describing what agents should "think" or "feel" — describe what they should DO


