Composition
Build AGENTS.md from multiple fragment files. Useful for monorepos where each package contributes instructions.
Fragment Patterns
AgentMD discovers fragments matching:
**/agents-md/**/*.md— Files in agents-md directories**/*.agents.md— Suffixed markdown files
Directives
Use <!-- agents-md: key=value --> in fragments:
| Directive | Description |
|---|---|
target=nearest | Compose into AGENTS.md in the fragment's directory (default) |
target=root | Compose into root AGENTS.md |
target=path | Compose into a specific path |
priority=N | Ordering (higher = earlier in output) |
Example Structure
repo/
├── agents-md/
│ ├── build.agents.md # target=root, priority=10
│ └── testing.agents.md # target=root, priority=5
├── packages/
│ └── core/
│ └── agents-md/
│ └── core.agents.md # target=nearest
└── AGENTS.md # GeneratedCLI
agentmd compose .
# Composed 2 AGENTS.md file(s)Generated files include source annotations:
<!-- Generated by AgentMD compose. Do not edit directly. -->
<!-- source: agents-md/build.agents.md -->
## Build
...
<!-- /source: agents-md/build.agents.md -->