AGENTS.md Generator (Root + Nested, Portable)
Goal
Maintain small, high-signal AGENTS.md files:
- Root AGENTS.md — purpose of repository, navigation, universal toolchain, canonical commands, links to docs and skills.
- Nested AGENTS.md — module/package purpose, local commands, module references.
Use progressive disclosure: keep AGENTS.md concise; push details to docs or skills.
Skill location (agent-specific)
- Do NOT assume
.agents/ or any fixed directory exists.
- Skills may live:
- inside the repository (embedded),
- or in an external/global skill library (external).
- If referencing local skills, use only an existing skill root already used by
the project or an existing project path already mentioned by repo docs.
- If no local skill directory exists — reference skills by name only (external).
- Never create hidden agent directories just to store skills.
Resource Routing
Use templates as skeletons, not literal output:
- Read
references/AGENTS_TEMPLATE_ROOT.md only when creating or updating the
root AGENTS.md.
- Read
references/AGENTS_TEMPLATE_MODULE.md only after a directory is
confirmed as a nested module that needs its own AGENTS.md.
- Replace or remove every placeholder. Final
AGENTS.md files must not contain
unresolved <...> template markers.
When to run
Run this skill when:
- AGENTS.md is missing, bloated, contradictory, or outdated.
- AGENTS.md needs to be generated, repaired, trimmed, split, or updated.
- A new package/service/module appears.
- Repository structure changes (monorepo growth or split).
- Teams want consistent agent context across diverse stacks.
Workflow (Deterministic)
1. Discover repository shape
- Identify repository root (git root if available).
- Detect language/tool markers:
package.json, pnpm-workspace.yaml
go.mod, go.work
pyproject.toml
Cargo.toml
pubspec.yaml
pom.xml, build.gradle
- Locate
docs/, README.md, existing AGENTS.md.
2. Detect module boundaries
Create nested AGENTS.md if directory:
- Contains independent build/package manifest
- OR represents deployable/service unit (
apps/, services/, packages/)
- AND adds distinct commands, docs, ownership, deployment notes, or toolchain
guidance compared with parent scope.
Do not create a nested AGENTS.md that only repeats the root instructions.
3. Generate/Update Root AGENTS.md
Constraints:
- Ideal size: ≤ 60 lines
- Must include:
- One-sentence repository purpose
- Primary toolchain/package manager
- Canonical commands (if non-standard)
- Links to docs
- Instruction to read nested AGENTS.md when inside modules
- Optional skill references (adaptive: local or external)
- Preserve verified commands, docs, security/secrets/deployment warnings, and
important local rules from any existing root
AGENTS.md.
4. Generate/Update Nested AGENTS.md
Constraints:
- Ideal size: ≤ 40 lines
- Must include:
- One-sentence module purpose
- Module-specific commands
- Local documentation references
- Optional skill references (adaptive)
- Preserve verified module warnings, ownership, deployment notes, and local
rules from any existing nested
AGENTS.md.
5. Progressive Disclosure Rules
- Do not embed style guides, CI policies, or architecture details.
- Prefer links to existing docs and external or local skills.
- Include only links that exist or are explicitly cited as the source for
commands or policy.
- Replace stale long-form sections with links when an authoritative doc exists.
- Avoid “always/never” rules unless critical for correctness/security.
6. Safety / Correctness Gates
- Never invent commands.
- Infer commands from:
- package scripts
- Makefile
- CI configuration
- README
- If uncertain → write:
“Known commands: see ”
- Preserve critical warnings (security, secrets, deployment).
Output Contract
Create or update only:
<repo_root>/AGENTS.md
<module_dir>/AGENTS.md
Do not create agent configuration folders.
Skill Referencing Strategy
When adding skill references inside AGENTS.md:
If local skill directory detected
See: <detected-skill-root>/<skill-name>/SKILL.md
If no local directory exists
Skill: agents-md-generator (external)
Never assume filesystem paths.
Validation
Before finishing, verify:
- Only root/module
AGENTS.md files were created or updated.
- Final
AGENTS.md files contain no unresolved <...> placeholders.
- Relative documentation links exist or clearly point to a source file for
commands/policy.
- Commands are supported by package scripts, Makefile, CI configuration, or
README. If no command is verified, use
Known commands: see <existing file>.
- Line budgets are respected: root ≤ 60 lines, nested module ≤ 40 lines.
- Nested files exist only for confirmed module boundaries.
- Critical warnings from existing
AGENTS.md files are preserved.
1---2name: agents-md-generator3description: Create, generate, update, repair, trim, or split minimal AGENTS.md files for repository roots and confirmed nested modules using progressive disclosure. Use for missing, bloated, contradictory, or outdated agent instructions, monorepos, services, packages, module context, and portable agent guidance without assuming any fixed agent folder structure.4---56# AGENTS.md Generator (Root + Nested, Portable)78## Goal9Maintain small, high-signal AGENTS.md files:1011- Root AGENTS.md — purpose of repository, navigation, universal toolchain, canonical commands, links to docs and skills.12- Nested AGENTS.md — module/package purpose, local commands, module references.1314Use **progressive disclosure**: keep AGENTS.md concise; push details to docs or skills.1516---1718## Skill location (agent-specific)19- **Do NOT assume `.agents/` or any fixed directory exists.**20- Skills may live:21 - inside the repository (embedded),22 - or in an external/global skill library (external).23- If referencing local skills, use only an existing skill root already used by24 the project or an existing project path already mentioned by repo docs.25- If no local skill directory exists — **reference skills by name only (external)**.26- **Never create hidden agent directories** just to store skills.2728---2930## Resource Routing3132Use templates as skeletons, not literal output:3334- Read `references/AGENTS_TEMPLATE_ROOT.md` only when creating or updating the35 root `AGENTS.md`.36- Read `references/AGENTS_TEMPLATE_MODULE.md` only after a directory is37 confirmed as a nested module that needs its own `AGENTS.md`.38- Replace or remove every placeholder. Final `AGENTS.md` files must not contain39 unresolved `<...>` template markers.4041---4243## When to run44Run this skill when:4546- AGENTS.md is missing, bloated, contradictory, or outdated.47- AGENTS.md needs to be generated, repaired, trimmed, split, or updated.48- A new package/service/module appears.49- Repository structure changes (monorepo growth or split).50- Teams want consistent agent context across diverse stacks.5152---5354## Workflow (Deterministic)5556### 1. Discover repository shape57- Identify repository root (git root if available).58- Detect language/tool markers:59 - `package.json`, `pnpm-workspace.yaml`60 - `go.mod`, `go.work`61 - `pyproject.toml`62 - `Cargo.toml`63 - `pubspec.yaml`64 - `pom.xml`, `build.gradle`65- Locate `docs/`, `README.md`, existing `AGENTS.md`.6667---6869### 2. Detect module boundaries70Create nested AGENTS.md if directory:7172- Contains independent build/package manifest73- OR represents deployable/service unit (`apps/`, `services/`, `packages/`)74- AND adds distinct commands, docs, ownership, deployment notes, or toolchain75 guidance compared with parent scope.7677Do not create a nested `AGENTS.md` that only repeats the root instructions.7879---8081### 3. Generate/Update Root AGENTS.md82Constraints:8384- Ideal size: ≤ 60 lines85- Must include:86 - One-sentence repository purpose87 - Primary toolchain/package manager88 - Canonical commands (if non-standard)89 - Links to docs90 - Instruction to read nested AGENTS.md when inside modules91 - Optional skill references (adaptive: local or external)92- Preserve verified commands, docs, security/secrets/deployment warnings, and93 important local rules from any existing root `AGENTS.md`.9495---9697### 4. Generate/Update Nested AGENTS.md98Constraints:99100- Ideal size: ≤ 40 lines101- Must include:102 - One-sentence module purpose103 - Module-specific commands104 - Local documentation references105 - Optional skill references (adaptive)106- Preserve verified module warnings, ownership, deployment notes, and local107 rules from any existing nested `AGENTS.md`.108109---110111### 5. Progressive Disclosure Rules112- Do not embed style guides, CI policies, or architecture details.113- Prefer links to existing docs and external or local skills.114- Include only links that exist or are explicitly cited as the source for115 commands or policy.116- Replace stale long-form sections with links when an authoritative doc exists.117- Avoid “always/never” rules unless critical for correctness/security.118119---120121### 6. Safety / Correctness Gates122- Never invent commands.123- Infer commands from:124 - package scripts125 - Makefile126 - CI configuration127 - README128- If uncertain → write:129 “Known commands: see <existing file>”130- Preserve critical warnings (security, secrets, deployment).131132---133134## Output Contract135Create or update only:136137- `<repo_root>/AGENTS.md`138- `<module_dir>/AGENTS.md`139140**Do not create agent configuration folders.**141142---143144## Skill Referencing Strategy145146When adding skill references inside AGENTS.md:1471481. **If local skill directory detected**149 ```150 See: <detected-skill-root>/<skill-name>/SKILL.md151 ```1521532. **If no local directory exists**154 ```155 Skill: agents-md-generator (external)156 ```157158Never assume filesystem paths.159160---161162## Validation163164Before finishing, verify:165166- Only root/module `AGENTS.md` files were created or updated.167- Final `AGENTS.md` files contain no unresolved `<...>` placeholders.168- Relative documentation links exist or clearly point to a source file for169 commands/policy.170- Commands are supported by package scripts, Makefile, CI configuration, or171 README. If no command is verified, use `Known commands: see <existing file>`.172- Line budgets are respected: root ≤ 60 lines, nested module ≤ 40 lines.173- Nested files exist only for confirmed module boundaries.174- Critical warnings from existing `AGENTS.md` files are preserved.