--- topic: compile source_keys: - context7-microsoft-apm --- ## Compile ```bash apm compile # fails on skill/agent-only packages — see Gotchas apm compile --clean # zero-write sanity check; use for skill/agent-only packages apm compile --clean --dry-run # pure preview, no writes ``` Compiles `.apm/instructions/` + `.apm/agents/*.agent.md` primitives into consumer-side context files (AGENTS.md/CLAUDE.md CONTEXT files) for the deployment target, per the `compilation:` block in `apm.yml`. This is the consumer/deployment side — it is NOT the producer of `plugin.json`/`marketplace.json`; that's `apm pack`'s job (below). Run `apm compile` after any change to `.apm/instructions/`/`.apm/agents/` content or to `compilation:`/`targets:` in `apm.yml`. ## Pack ```bash apm pack --dry-run # resolve and print; do not write apm pack --offline # cached refs only apm pack --include-prerelease # allow pre-release tags apm pack -v # per-entry resolution detail apm pack --marketplace=claude --json # JSON output for CI pipelines ``` Bundles a producer package into a distributable artifact. Default to `--dry-run -v` first when packing something for the first time or after a dependency change — resolution errors surface before anything is written. ### `.mcp.json` merge mechanics `apm pack` reads a package's root-level `.mcp.json` directly — no `dependencies.mcp` entry in `apm.yml` is needed for simple passthrough. Behavior is content-aware: - An empty `.mcp.json` (`{"mcpServers": {}}`) is NOT included in the packed output at all. - A populated one gets its `mcpServers` content merged directly into the compiled `plugin.json`, but only for the `claude` target. - The `copilot` target's compiled `plugin.json` OMITS `mcpServers` entirely — it isn't part of Copilot's plugin manifest schema. `dependencies.mcp` in `apm.yml` is for a different purpose — declaring a remote MCP-server package as an APM dependency — not local `.mcp.json` passthrough. ### `includes: auto` and the packed bundle `includes: auto` does NOT sweep generic root-level passthrough files (README.md, docs/, sources.md, config files, etc.) into the `apm pack` distribution bundle (`build/-`) — only `.apm/` primitives, the compiled `plugin.json`, and the content-aware `.mcp.json` handling above make it into that bundle. This does not affect Claude Code's own plugin loading, which reads a plugin's working directory directly via its `source:` path in `marketplace.json`, not the `apm pack` bundle — but it matters for anyone relying on the packed bundle for distribution via `apm install`. Run `apm audit` after compile/pack, not before — audit scans deployed/compiled output, not the source `apm.yml` manifest. Plain `apm audit` is not the CI-equivalent pass (that is `apm audit --ci`, which checks strictly more); see `references/audit.md`. ## Publish ```bash apm publish --package acme/my-skill --dry-run -v apm publish --package acme/my-skill ``` Publishes a producer package (root containing `apm.yml`, `.apm/`, and optionally a `registries:` block) to a registry. Always dry-run with `-v` first — publishing is not trivially reversible once a version tag is claimed on a registry. Publishing to a named registry requires `apm experimental enable registries` to have already run — see `SKILL.md`'s Gotchas for the precondition and its silent-no-op failure mode. ## Run ```bash apm run