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:

DirectiveDescription
target=nearestCompose into AGENTS.md in the fragment's directory (default)
target=rootCompose into root AGENTS.md
target=pathCompose into a specific path
priority=NOrdering (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               # Generated

CLI

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 -->

→ CLI Reference