agents-md
The agents-md skill revolutionizes how development teams manage agent documentation as projects scale, making it easy to maintain clarity and coherence in `AGENTS.md` files. By automatically generating a structured `AGENTS.md` from organized fragments, this skill solves the common problem of static, unmanageable documentation, enhancing collaboration across engineering, design, and project management teams. Use cases include seamlessly updating project specifications as code evolves, optimizing workflows by integrating documentation with version control systems, and facilitating quick onboarding through streamlined, contextually relevant information. The output is hierarchically organized, ensuring that all agent contexts remain current, composable, and readily shareable, which significantly improves project efficiency and productivity.
Spec
agents-md
We need an elegant and scalable vibe coding solution.
The Problem
Your project grows, but your AGENTS.md doesn't scale:
project/
βββ AGENTS.md β single file, static name, impossible to sustain
βββ docs/
βββ api/
The Solution
Split context into organized fragments, then compose:
project/
βββ AGENTS.md β auto-generated
βββ docs/
β βββ overview.agents.md β parsed
βββ api/
β βββ AGENTS.md β auto-generated
β βββ endpoints.agents.md β parsed
βββ agents-md/
β βββ epics/
β βββ epic-one.md β parsed
β βββ epic-two.md β parsed
One command builds them all:
npx agents-md compose
Compose canonical AGENTS.md from sustainable and elegant file structures. Keep agent context current, composable, and shareable with your human docs. Abstract-context-as-code is what we aim to achieve.
Quick Start
- Initialize:
npx agents-md init(creates rootAGENTS.mdif missing) - Update fragment files in any of these path formats:
**/agents-md/**/*.md**/*.agents.md**/<customised-directories>/*.md**/*.<customised-file-formats>
- Compose:
npx agents-md compose
Generated files are owned by agents-md. Don't handβedit AGENTS.md β edit source fragments instead.
To have multiple AGENTS.md files for dynamic location-based context, simply add an empty AGENTS.md file in any target directory and rerun bun agents-md compose.
Git Integration
Keep your AGENTS.md files automatically up-to-date with a pre-commit hook:
npx agents-md setup:compose-before-commit
The setup command works with any git repository, regardless of language (JavaScript, Python, Go, Rust, etc.):
What it does:
- Creates a git hook in
.git/hooks/pre-commit - Makes it executable automatically
- Runs
npx agents-md composeand stages AGENTS.md files before each commit
Performance tip: For faster commits, install agents-md globally:
npm install -g agents-md
This avoids npx downloading the package on every commit.
To regenerate the hook (after updating agents-md):
npx agents-md setup:compose-before-commit
To bypass temporarily (not recommended):
git commit --no-verify
Why agents-md?
Common pain points today:
- Single, static
AGENTS.mdper directory; no native "imports" or multiβfile composition. - No globβbased includes in
AGENTS.mditself; no spec for dynamic content (e.g., JSDoc or config extraction). - Some tools don't read
AGENTS.md; - Existing options like Ruler assume
.ruler/and don't curate dynamic content outside of those directories.
agents-md fixes them all
- Inputs (fragment files): Accept all Markdown files in
**/agents-md/**/*.mdand**/*.agents.md. Meanwhile, all file paths are configurable. - Outputs (
AGENTS.mdtarget files): OneAGENTS.mdper target directory (nearestβwins by default) with deterministic ordering and source annotations. - Routing: Markdown directives map fragments to targets.
- Interop: Optional
CLAUDE.mdcan import@AGENTS.mdfor tools that don't readAGENTS.md.
CLI
agents-md init- Initialize agents-md in this project; creates root
AGENTS.mdif missing (usecomposeif already initialized).
- Initialize agents-md in this project; creates root
agents-md compose- Build outputs from fragments.
agents-md report [--json]- Show outputs, sizes (k chars), token estimates, and warnings (use
--jsonfor CI).
- Show outputs, sizes (k chars), token estimates, and warnings (use
agents-md watch [--verbose]- Rebuild on changes silently; use
--verboseto log rebuilds.
- Rebuild on changes silently; use
agents-md setup:compose-before-commit- Setup pre-commit hook to auto-compose AGENTS.md files before each commit (works with any codebase: Node.js, Python, Go, etc.).
agents-md help|version
Exit codes: 0 success, 1 generic error, 2 invalid config, 4 limit violation.
Configuration
Use agents-md.config.ts (or .js/.mjs) at repo root. Defaults are zeroβconfig; customize only as needed. See full schema in docs/design.md.
Key options
| Option | Type | Default | Purpose |
| --- | --- | --- | --- |
| include | string[] | ['**/agents-md/**/*.md','**/*.agents.md'] | Fragment discovery globs |
| exclude | string[] | ['**/node_modules/**','**/.git/**'] | Ignore patterns |
| includeFiles | (ctx) => boolean | undefined | Advanced perβfile filter |
| defaultTarget | 'nearest'|'root' | 'nearest' | Fallback routing behavior |
| annotateSources | boolean | true | Wrap fragments with <!-- source: ... priority=n --> / <!-- /source: ... --> comments |
| truncate | { atChars, strategy } | undefined | Trim oversized outputs |
| limits | { warn/max source/output } | undefined | Size limits and warnings |
Markdown Directives
- Target routing
<!-- agents-md: target=nearest --><!-- agents-md: target=root --><!-- agents-md: target=../docs -->(relative dir)
-
Imports

