agents-md-generator — Claude Code skill for tidy AGENTS.md files
Writes and trims AGENTS.md at the repo root and in nested modules. Useful when agent instructions have grown bloated or contradict each other.
npx skills add MADTeacher/mad-agents-skills --skill agents-md-generator -a claude-codeWhat agents-md-generator does
The skill walks the agent through discovery first: find the git root, then look for toolchain markers such as package.json, go.mod, pyproject.toml, Cargo.toml, pom.xml. From there it decides whether a nested AGENTS.md is warranted at all. A directory qualifies only if it has its own build manifest or stands as a deployable unit, and only if it adds commands, docs or deployment notes the parent scope lacks. A file that just repeats the root rules does not get created.
Output is two shapes: a root file capped at 60 lines and a module file at 40. Each holds a one-sentence purpose, the package manager, non-standard commands and links to docs. Style guides and CI policy stay out — the skill points at existing documentation instead of copying it.
Commands are never invented. They come from package scripts, a Makefile, CI config or the README. When nothing verifies a command, the file gets a pointer to an existing source instead. The skill also carries over security, secrets and deployment warnings from an existing AGENTS.md, and checks that no <...> placeholders survive. It will not spin up hidden agent directories; if there is no local skill folder, skills are referenced by name. All it needs is an agent with read and write access — script execution is optional.
What it helps with
- write a root AGENTS.md from scratch for a new repo
- split a bloated AGENTS.md into root and module files
- strip contradictory or outdated instructions from agent context
- add an AGENTS.md for a new package or service in a monorepo
- move style guides and CI policy into docs, leaving links behind
Example prompts for the agent
- Generate an AGENTS.md for the repository root
- Trim AGENTS.md and replace long sections with links to docs
- Add a nested AGENTS.md for the apps/api package
How to install agents-md-generator
1Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill agents-md-generator -a claude-code2Manually: put the files in place
~/.claude/skills/agents-md-generator/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/agents-md-generator/
1Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill agents-md-generator -a codex2Manually: put the files in place
.agents/skills/agents-md-generator/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill agents-md-generator -a cursor2Manually: put the files in place
.cursor/skills/agents-md-generator/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install MADTeacher/mad-agents-skills agents-md-generator2Manually: put the files in place
.github/skills/agents-md-generator/SKILL.md1Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill agents-md-generator -a gemini-cli2Platform CLI
gemini skills install https://github.com/MADTeacher/mad-agents-skills --path agents-md-generatorManually: put the files in place
.devin/skills/agents-md-generator/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add MADTeacher/mad-agents-skills --skill agents-md-generator -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about agents-md-generator
How do I install agents-md-generator in Claude?
Run npx skills add MADTeacher/mad-agents-skills --skill agents-md-generator -a claude-code. The skill lands at ~/.claude/skills/agents-md-generator/SKILL.md.
What does agents-md-generator do?
It creates, updates, repairs, trims and splits AGENTS.md files at the repo root and in nested modules. Root files stay under 60 lines, module files under 40.
Where does it get the commands it writes into AGENTS.md?
From package scripts, a Makefile, CI configuration or the README. If a command cannot be verified, the skill points to an existing file rather than guessing.
Source text
SKILL.md · MIT
--- name: agents-md-generator description: 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. compatibility: Filesystem-based coding agents with read/write access. Script execution optional. metadata: author: Stanislav [MADTeacher] Chernyshev version: "2.0" --- # 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 <existing file>” - 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: 1. **If local skill directory detected** ``` See: <detected-skill-root>/<skill-name>/SKILL.md ``` 2. **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.
© Stanislav [MADTeacher] Chernyshev · MIT · MADTeacher/mad-agents-skills