$npx -y skills add MADTeacher/mad-agents-skills --skill agents-md-generatorCreate, 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 por
| 1 | # AGENTS.md Generator (Root + Nested, Portable) |
| 2 | |
| 3 | ## Goal |
| 4 | Maintain small, high-signal AGENTS.md files: |
| 5 | |
| 6 | - Root AGENTS.md — purpose of repository, navigation, universal toolchain, canonical commands, links to docs and skills. |
| 7 | - Nested AGENTS.md — module/package purpose, local commands, module references. |
| 8 | |
| 9 | Use **progressive disclosure**: keep AGENTS.md concise; push details to docs or skills. |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | ## Skill location (agent-specific) |
| 14 | - **Do NOT assume `.agents/` or any fixed directory exists.** |
| 15 | - Skills may live: |
| 16 | - inside the repository (embedded), |
| 17 | - or in an external/global skill library (external). |
| 18 | - If referencing local skills, use only an existing skill root already used by |
| 19 | the project or an existing project path already mentioned by repo docs. |
| 20 | - If no local skill directory exists — **reference skills by name only (external)**. |
| 21 | - **Never create hidden agent directories** just to store skills. |
| 22 | |
| 23 | --- |
| 24 | |
| 25 | ## Resource Routing |
| 26 | |
| 27 | Use templates as skeletons, not literal output: |
| 28 | |
| 29 | - Read `references/AGENTS_TEMPLATE_ROOT.md` only when creating or updating the |
| 30 | root `AGENTS.md`. |
| 31 | - Read `references/AGENTS_TEMPLATE_MODULE.md` only after a directory is |
| 32 | confirmed as a nested module that needs its own `AGENTS.md`. |
| 33 | - Replace or remove every placeholder. Final `AGENTS.md` files must not contain |
| 34 | unresolved `<...>` template markers. |
| 35 | |
| 36 | --- |
| 37 | |
| 38 | ## When to run |
| 39 | Run this skill when: |
| 40 | |
| 41 | - AGENTS.md is missing, bloated, contradictory, or outdated. |
| 42 | - AGENTS.md needs to be generated, repaired, trimmed, split, or updated. |
| 43 | - A new package/service/module appears. |
| 44 | - Repository structure changes (monorepo growth or split). |
| 45 | - Teams want consistent agent context across diverse stacks. |
| 46 | |
| 47 | --- |
| 48 | |
| 49 | ## Workflow (Deterministic) |
| 50 | |
| 51 | ### 1. Discover repository shape |
| 52 | - Identify repository root (git root if available). |
| 53 | - Detect language/tool markers: |
| 54 | - `package.json`, `pnpm-workspace.yaml` |
| 55 | - `go.mod`, `go.work` |
| 56 | - `pyproject.toml` |
| 57 | - `Cargo.toml` |
| 58 | - `pubspec.yaml` |
| 59 | - `pom.xml`, `build.gradle` |
| 60 | - Locate `docs/`, `README.md`, existing `AGENTS.md`. |
| 61 | |
| 62 | --- |
| 63 | |
| 64 | ### 2. Detect module boundaries |
| 65 | Create nested AGENTS.md if directory: |
| 66 | |
| 67 | - Contains independent build/package manifest |
| 68 | - OR represents deployable/service unit (`apps/`, `services/`, `packages/`) |
| 69 | - AND adds distinct commands, docs, ownership, deployment notes, or toolchain |
| 70 | guidance compared with parent scope. |
| 71 | |
| 72 | Do not create a nested `AGENTS.md` that only repeats the root instructions. |
| 73 | |
| 74 | --- |
| 75 | |
| 76 | ### 3. Generate/Update Root AGENTS.md |
| 77 | Constraints: |
| 78 | |
| 79 | - Ideal size: ≤ 60 lines |
| 80 | - Must include: |
| 81 | - One-sentence repository purpose |
| 82 | - Primary toolchain/package manager |
| 83 | - Canonical commands (if non-standard) |
| 84 | - Links to docs |
| 85 | - Instruction to read nested AGENTS.md when inside modules |
| 86 | - Optional skill references (adaptive: local or external) |
| 87 | - Preserve verified commands, docs, security/secrets/deployment warnings, and |
| 88 | important local rules from any existing root `AGENTS.md`. |
| 89 | |
| 90 | --- |
| 91 | |
| 92 | ### 4. Generate/Update Nested AGENTS.md |
| 93 | Constraints: |
| 94 | |
| 95 | - Ideal size: ≤ 40 lines |
| 96 | - Must include: |
| 97 | - One-sentence module purpose |
| 98 | - Module-specific commands |
| 99 | - Local documentation references |
| 100 | - Optional skill references (adaptive) |
| 101 | - Preserve verified module warnings, ownership, deployment notes, and local |
| 102 | rules from any existing nested `AGENTS.md`. |
| 103 | |
| 104 | --- |
| 105 | |
| 106 | ### 5. Progressive Disclosure Rules |
| 107 | - Do not embed style guides, CI policies, or architecture details. |
| 108 | - Prefer links to existing docs and external or local skills. |
| 109 | - Include only links that exist or are explicitly cited as the source for |
| 110 | commands or policy. |
| 111 | - Replace stale long-form sections with links when an authoritative doc exists. |
| 112 | - Avoid “always/never” rules unless critical for correctness/security. |
| 113 | |
| 114 | --- |
| 115 | |
| 116 | ### 6. Safety / Correctness Gates |
| 117 | - Never invent commands. |
| 118 | - Infer commands from: |
| 119 | - package scripts |
| 120 | - Makefile |
| 121 | - CI configuration |
| 122 | - README |
| 123 | - If uncertain → write: |
| 124 | “Known commands: see <existing file>” |
| 125 | - Preserve critical warnings (security, secrets, deployment). |
| 126 | |
| 127 | --- |
| 128 | |
| 129 | ## Output Contract |
| 130 | Create or update only: |
| 131 | |
| 132 | - `<repo_root>/AGENTS.md` |
| 133 | - `<module_dir>/AGENTS.md` |
| 134 | |
| 135 | **Do not create agent configuration folders.** |
| 136 | |
| 137 | --- |
| 138 | |
| 139 | ## Skill Referencing Strategy |
| 140 | |
| 141 | When adding skill references inside AGENTS.md: |
| 142 | |
| 143 | 1. **If local skill directory detected** |
| 144 | ``` |
| 145 | See: <detected-skill-root>/<skill-name>/SKILL.md |
| 146 | ``` |
| 147 | |
| 148 | 2. **If no local directory exists** |
| 149 | ``` |
| 150 | Skill: agents-md-generator (external) |
| 151 | ``` |
| 152 | |
| 153 | Never assume filesys |