Skip to content

Commit 4515f29

Browse files
docs: surface compilation.strategy=distributed default (closes #1447) (#1551)
Add a 'Where compiled context files land' section to the primitives-and-targets concepts page explaining that apm compile defaults to distributed placement (per-directory AGENTS.md/CLAUDE.md driven by applyTo: scopes), and a distributed-layout example to the apm compile reference's Strategy modes section. Default behavior is unchanged. The strategy default and --clean default are deliberately out of scope; flipping them is an RFC. Co-authored-by: danielmeppiel <danielmeppiel@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 68718de commit 4515f29

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Documentation
11+
12+
- Surface the `compilation.strategy: distributed` default in the
13+
concepts ramp and `apm compile` reference so users understand why
14+
`apm compile` may add `AGENTS.md` / `CLAUDE.md` files in
15+
subdirectories driven by `applyTo:` scopes. Adds a new "Where
16+
compiled context files land" section to the primitives-and-targets
17+
page and a distributed-layout example in the compile reference.
18+
Default behavior is unchanged. (closes #1447) -- by @tillig
19+
1020
### Fixed
1121

1222
- Linux standalone `apm` binaries no longer fail git shared-cache clones with shared-library symbol lookup errors caused by PyInstaller dynamic-library paths leaking into child processes. (closes #1534)

docs/src/content/docs/concepts/primitives-and-targets.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,31 @@ How to read a cell:
121121
- `plugins / *` -- APM unpacks the plugin at install time into the primitives in the rows above; routing then follows those rows.
122122
- `MCP servers / *` -- APM writes the harness's standard MCP config. Transitive MCP servers brought in by deep dependencies must be explicitly declared or trusted with `--trust-transitive-mcp` -- effectively `gated` for those, `native` for direct dependencies.
123123

124+
## Where compiled context files land
125+
126+
`apm compile` defaults to **distributed** placement: instead of one
127+
monolithic `AGENTS.md` / `CLAUDE.md` at the repo root, APM writes a
128+
focused target file next to each directory that has matching
129+
instructions. The placement is driven by each instruction's `applyTo:`
130+
glob in its frontmatter. For example, an instruction with
131+
`applyTo: "scripts/**"` lands in `scripts/AGENTS.md` rather than the
132+
root file.
133+
134+
This means a fresh `apm compile` may create new `AGENTS.md` /
135+
`CLAUDE.md` files in subdirectories you did not previously touch.
136+
That is intentional -- it follows the **Minimal Context Principle**
137+
so each agent only loads instructions relevant to the directory it is
138+
working in. If you prefer one combined file at the project root, run
139+
`apm compile --single-agents` (or set `compilation.single_file: true`
140+
in `apm.yml`).
141+
142+
To remove distributed files that are no longer produced (e.g. after
143+
deleting or rescoping an instruction), run `apm compile --clean`.
144+
145+
For the full strategy reference and flag semantics, see
146+
[`apm compile`](/apm/reference/cli/compile/#strategy-modes) and
147+
[manifest schema: `compilation.strategy`](/apm/reference/manifest-schema/).
148+
124149
## Dev-only primitives
125150

126151
Mark a primitive as dev-only when it is useful to the package author but should not ship to consumers: release checklists, internal debugging agents, test-fixture skills, anything tied to your own infrastructure. Author such primitives outside `.apm/` (typically `dev/`) and reference them under `devDependencies` in `apm.yml`. `apm pack` excludes them; `apm install --dev` deploys them locally.

docs/src/content/docs/reference/cli/compile.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,32 @@ There is no `--strategy` flag. Compilation runs in one of two modes:
207207
- **Distributed (default)** -- writes a tree of focused target files
208208
(e.g. `AGENTS.md`, `CLAUDE.md`) next to the code they apply to, plus
209209
per-target subdirectories. This is the recommended mode and follows
210-
the Minimal Context Principle.
210+
the Minimal Context Principle. Set `compilation.strategy:
211+
single-file` (or `compilation.single_file: true`) in `apm.yml` to
212+
opt out.
211213
- **Single-file (`--single-agents`)** -- writes one combined file at
212214
`--output` (default `AGENTS.md`). Use when a harness or workflow
213215
requires a single context file.
214216

217+
### Distributed layout example
218+
219+
For a project with two scoped instructions
220+
(`applyTo: "scripts/**"` and `applyTo: "tests/**"`) plus a generic
221+
one (no `applyTo:`), `apm compile` writes:
222+
223+
```
224+
AGENTS.md # generic instructions only
225+
scripts/AGENTS.md # instructions scoped to scripts/**
226+
tests/AGENTS.md # instructions scoped to tests/**
227+
```
228+
229+
Each agent harness then loads only the file nearest the code it is
230+
working in. If you did not expect new `AGENTS.md` / `CLAUDE.md` files
231+
in subdirectories, this is the distributed default in effect; see
232+
[Where compiled context files land](../../../concepts/primitives-and-targets/#where-compiled-context-files-land)
233+
for the rationale, or pass `--single-agents` for a single-file
234+
output.
235+
215236
## Exit codes
216237

217238
| Code | Meaning |

0 commit comments

Comments
 (0)