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, first detect an existing skill root already used by the project.
- If no local skill directory exists — reference skills by name only (external).
- Never create hidden agent directories just to store skills.
When to run
Run this skill when:
- AGENTS.md is missing, bloated, contradictory, or outdated.
- 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 differs in stack/toolchain from parent scope
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)
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)
5. Progressive Disclosure Rules
- Do not embed style guides, CI policies, or architecture details.
- Prefer links to:
docs/STYLE_GUIDE.md
docs/ARCHITECTURE.md
- external or local skills
- 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.
1---2name: agents-md-generator-23description: Create or update minimal AGENTS.md files in the repository root and nested module directories using progressive disclosure. Works across heterogeneous projects without assuming any fixed agent folder structure.4---5
6# AGENTS.md Generator (Root + Nested, Portable)
7
8## Goal
9Maintain small, high-signal AGENTS.md files:
10
11- 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.
13
14Use **progressive disclosure**: keep AGENTS.md concise; push details to docs or skills.
15
16---
17
18## 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, first detect an existing skill root already used by the project.
24- If no local skill directory exists — **reference skills by name only (external)**.
25- **Never create hidden agent directories** just to store skills.
26
27---
28
29## When to run
30Run this skill when:
31
32- AGENTS.md is missing, bloated, contradictory, or outdated.
33- A new package/service/module appears.
34- Repository structure changes (monorepo growth or split).
35- Teams want consistent agent context across diverse stacks.
36
37---
38
39## Workflow (Deterministic)
40
41### 1. Discover repository shape
42- Identify repository root (git root if available).
43- Detect language/tool markers:
44 - `package.json`, `pnpm-workspace.yaml`
45 - `go.mod`, `go.work`
46 - `pyproject.toml`
47 - `Cargo.toml`
48 - `pubspec.yaml`
49 - `pom.xml`, `build.gradle`
50- Locate `docs/`, `README.md`, existing `AGENTS.md`.
51
52---
53
54### 2. Detect module boundaries
55Create nested AGENTS.md if directory:
56
57- Contains independent build/package manifest
58- OR represents deployable/service unit (`apps/`, `services/`, `packages/`)
59- AND differs in stack/toolchain from parent scope
60
61---
62
63### 3. Generate/Update Root AGENTS.md
64Constraints:
65
66- Ideal size: ≤ 60 lines
67- Must include:
68 - One-sentence repository purpose
69 - Primary toolchain/package manager
70 - Canonical commands (if non-standard)
71 - Links to docs
72 - Instruction to read nested AGENTS.md when inside modules
73 - Optional skill references (adaptive: local or external)
74
75---
76
77### 4. Generate/Update Nested AGENTS.md
78Constraints:
79
80- Ideal size: ≤ 40 lines
81- Must include:
82 - One-sentence module purpose
83 - Module-specific commands
84 - Local documentation references
85 - Optional skill references (adaptive)
86
87---
88
89### 5. Progressive Disclosure Rules
90- Do not embed style guides, CI policies, or architecture details.
91- Prefer links to:
92 - `docs/STYLE_GUIDE.md`
93 - `docs/ARCHITECTURE.md`
94 - external or local skills
95- Avoid “always/never” rules unless critical for correctness/security.
96
97---
98
99### 6. Safety / Correctness Gates
100- Never invent commands.
101- Infer commands from:
102 - package scripts
103 - Makefile
104 - CI configuration
105 - README
106- If uncertain → write:
107 “Known commands: see <file>”
108- Preserve critical warnings (security, secrets, deployment).
109
110---
111
112## Output Contract
113Create or update only:
114
115- `<repo_root>/AGENTS.md`
116- `<module_dir>/AGENTS.md`
117
118**Do not create agent configuration folders.**
119
120---
121
122## Skill Referencing Strategy
123
124When adding skill references inside AGENTS.md:
125
1261. **If local skill directory detected**
127 ```
128 See: <detected-skill-root>/<skill-name>/SKILL.md
129 ```
130
1312. **If no local directory exists**
132 ```
133 Skill: agents-md-generator (external)
134 ```
135
136Never assume filesystem paths.