/cc-authoring:apm-plugin-distribution-pathsfrom cc-authoring
Canonical authoring layout for an APM (microsoft/apm) package, plus the decision matrix for whether you need a `marketplace:` block. Use when: (1) you've run `apm init` and are unsure where SKILL.md / agent .md / command .md files belong (answer: under `.apm/`, NOT at repo root); (2) you've authored CC-native files at `commands/agents/skills/` at repo root and wonder if that's "right" (it works as fallback layout #3 "Claude plugin", but it's not the canonical authoring path); (3) you're trying to choose between the three layouts APM recognizes (one-skill repo, multi-primitive `.apm/`, Claude plugin); (4) `apm targets` fails with "No such command" in CLI 0.12.1 (subcommand doesn't exist); (5) `apm validate` fails with "No such command" in CLI 0.12.1 (use APM's packaging command in dry-run mode instead); (6) wondering whether `apm compile -t claude` will generate output for a hand-authored CC-native plugin (it won't; it's a no-op for layout #3); (7) wondering if you need a `marketplace:` block in apm.yml (you don't, for a single-plugin repo). Covers the canonical `.apm/` source layout, the source-to-plugin remap table, the three-layout choice, and the four distribution paths.
Trending skills
7-day visitors to each skill page
Ships in cc-authoring. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A common confusion when packaging a Claude Code plugin with APM is "where do
my files go?" and "do I need a marketplace: block?" The answers are both
non-obvious and easy to get wrong:
.apm/ (source) — not at repo root. The root
commands/agents/skills/ paths are build output (deployed copies),
not the canonical authoring location.apm install owner/repo works against bare apm.yml + .apm/ content.This skill captures the canonical layout, the alternatives APM tolerates, and the four distribution paths.
You've run apm init on a repo, authored a SKILL.md and a slash command,
and you don't know whether they go at:
skills/<name>/SKILL.md and commands/<name>.md (root).apm/skills/<name>/SKILL.md and .apm/commands/<name>.md.claude/skills/<name>/SKILL.md and .claude/commands/<name>.mdplugins/<name>/skills/<name>/SKILL.md (under a marketplace pluginRoot)All four "work" in the sense that something installs, but only one is canonical and gets the full benefit of APM's multi-target compile.
Any of these point here:
.apm/skills/<name>/SKILL.md
but you've put them at root skills/<name>/SKILL.md because that's the
Claude Code plugin layout. Both work; only one is canonical.apm-marketplace-authoring-gotchas skill and
it implies every APM-published plugin needs a marketplace block. (It
doesn't — that skill is about authoring a marketplace, not about a
single plugin.)apm targets exits 2 with Error: No such command 'targets' (despite
the dependencies guide referencing the command — it's not shipped in 0.12.1).apm validate exits 2 with Error: No such command 'validate'.
Validation is folded into APM's packaging command run with --dry-run.apm compile -t claude --dry-run exits 0 with [x] No APM content found to compile — confirms you have no .apm/ source content (only deployed
copies at root). For canonical authoring, the message should disappear.From the official anatomy doc:
apm.ymlis yourpackage.json..apm/is yoursrc/.apm_modules/is yournode_modules/. Output under.github/,.claude/,.cursor/, etc. is yourdist/— generated, tool-specific, not the source of truth.
Source under .apm/. Tool-specific dirs (.claude/, .github/, etc.)
are build output. That single rule resolves most layout confusion.
Per the official getting-started guide:
| # | Layout | When to use |
|---|---|---|
| 1 | One skill — SKILL.md at root + optional agents//assets//scripts/ | Single-skill repo, no other primitives |
| 2 | Multiple primitives — .apm/skills/, .apm/agents/, .apm/instructions/, .apm/commands/ | Canonical for any package shipping > 1 primitive |
| 3 | Claude plugin — existing plugin.json at repo root with commands/agents/skills/ siblings | Pre-existing CC plugin you want APM to consume as-is without restructuring |
Layout 3 is a consumption fallback, not a recommended authoring path. APM "can consume it directly without restructuring" — that wording is the giveaway. Use it only if migrating an existing CC plugin and you don't want the multi-target benefit.
.apm/ source → plugin-bundle remapAPM's packaging step reads from .apm/ and emits a plugin bundle under
build/<name>-<version>/. The remap table:
.apm/ source path | Plugin output path |
|---|---|
.apm/agents/<name>.agent.md | agents/<name>.agent.md |
.apm/skills/<name>/SKILL.md | skills/<name>/SKILL.md |
.apm/prompts/<name>.prompt.md | commands/<name>.md (suffix stripped) |
.apm/prompts/<name>.md | commands/<name>.md |
.apm/instructions/<name>.instructions.md | instructions/<name>.instructions.md |
.apm/hooks/*.json | hooks.json (merged) |
.apm/commands/<name>.md | commands/<name>.md |
Two notable conventions:
.agent.md suffix under .apm/agents/. A bare
<name>.md doesn't get picked up the same way..apm/commands/*.md
(preserved as-is) or .apm/prompts/*.md (any .prompt.md suffix is
stripped on output). Prefer .apm/commands/ for Claude-Code-flavored
slash commands; prefer .apm/prompts/ for portable prompt-style content
that consumers might invoke as Copilot prompts..apm/)If you currently have a CC-native repo at root and want to move to canonical APM authoring:
# 1. Create the .apm tree
mkdir -p .apm/skills .apm/agents .apm/commands
# 2. Move skills as-is (directory layout preserved)
git mv skills/* .apm/skills/
# 3. Move and rename agents (.md → .agent.md)
for f in agents/*.md; do
base=$(basename "$f" .md)
git mv "$f" ".apm/agents/${base}.agent.md"
done
rmdir agents
# 4. Move commands as-is
git mv commands/* .apm/commands/
rmdir commands
# 5. Optionally remove plugin.json (APM's packaging step synthesizes it from apm.yml)
git rm .claude-plugin/plugin.json
rmdir .claude-plugin
# 6. Verify
# (run APM's packaging step in --dry-run mode here) → exit 0; should now list all primitives from .apm/
apm install --dry-run # would deploy to .claude/, .github/, etc.
After migration, the deployed copies under .claude/ (or .github/, etc.)
are build output. They can be:
microsoft/apm itself does
(dogfooding) — useful for repos where the in-repo agent also consumes
the deployed copy. Source is still authoritative; deployed is byte-identical.Once your source is canonical, here's how others consume it:
| Path | Consumer command | Requires |
|---|---|---|
| APM Package (canonical) | apm install owner/repo | apm.yml + .apm/ source ✓ default |
| Marketplace Plugin | apm install owner/repo/plugins/<name> | Content under ./plugins/<name>/ (multi-plugin repos) |
CC /plugin marketplace add | /plugin marketplace add owner/repo | marketplace: block in apm.yml so APM's packaging step emits marketplace.json |
| Manual install | git clone + copy | Just the file layout |
The first row is what apm init aims at. Add a marketplace: block only if
your audience is non-APM CC users who'd use /plugin marketplace add, or if
you host multiple plugins in one repo.
Real subcommands (verified by apm --help):
apm init # Scaffold apm.yml
apm install # Resolve deps + deploy local .apm/ content
apm compile [-t <target>] # Translate .apm/* sources to native formats
# APM's packaging step, optional --dry-run # Validate schema + build plugin bundle
# APM's marketplace-check command # Runs git ls-remote (often fails for local-only)
apm policy
apm preview
Non-existent in 0.12.1 (referenced in older docs/skills):
apm targets — auto-detection runs during install/compile/pack.
To preview compile output, use apm compile -t <target> --dry-run.apm validate — schema validation is APM's packaging step run with --dry-run.apm.yml (matches apm init -y)name: <package-name>
version: 1.0.0
description: <one line>
author: <handle> # or {name, url} object form
dependencies:
apm: [] # plugins THIS package consumes
mcp: []
includes: auto # walks .apm/ tree and deploys what it finds
scripts: {}
The includes: auto field is what makes apm install walk .apm/ and
deploy locally-authored primitives. Setting includes: [] (or omitting)
disables local-content deployment.
After authoring at .apm/skills/<name>/SKILL.md and friends:
# (run APM's packaging step with --dry-run) # Schema validation; exit 0
apm install --dry-run # Preview deployment; exit 0
apm compile -t claude --dry-run # Should now show content (not the
# "No APM content found" message
# you'd see for layout 3)
Then test the consumer flow from a different directory:
cd /tmp/test-consumer
echo 'name: test
version: 0.0.1
dependencies:
apm:
- owner/repo' > apm.yml
apm install --dry-run # Should resolve your package
If APM's packaging step (with --dry-run) lists fewer primitives than expected after
migration, check that agent files use .agent.md (not bare .md) and that
commands moved to .apm/commands/ (not the deployed commands/ at root).
The reference example is microsoft/apm-sample-package, which uses
layout 2:
apm-sample-package/
├── apm.yml
└── .apm/
├── prompts/
│ ├── design-review.prompt.md
│ └── accessibility-audit.prompt.md
├── instructions/
│ └── design-standards.instructions.md
├── agents/
│ └── design-reviewer.agent.md
└── skills/
└── style-checker/SKILL.md
Consumers apm install microsoft/apm-sample-package#v1.0.0 and the deploy
step writes:
.apm/skills/style-checker/SKILL.md → .claude/skills/style-checker/SKILL.md.apm/agents/design-reviewer.agent.md → .claude/agents/design-reviewer.agent.md.apm/prompts/design-review.prompt.md → .claude/commands/design-review.mdapm.lock.yaml should be tracked (committed) for reproducibility,
not gitignored. apm_modules/ should be gitignored. build/ (where
APM's packaging step writes) should also be gitignored.microsoft/apm repo itself dogfoods layout 2 — .apm/skills/python-architecture/SKILL.md
is the source; .github/skills/python-architecture/SKILL.md is the
deployed copy that the in-repo Copilot agent loads. Use this as a real
reference.marketplace: block and dependencies: block can coexist — your repo
can both consume other plugins AND be a marketplace. They're orthogonal.apm targets /
apm validate as first-class subcommands; re-verify with apm --help.pluginRoot
rewriting, prettier conflicts, husky/markdownlint MD040, etc.), see the
complementary skill apm-marketplace-authoring-gotchas.commands/agents/skills/ at root) is the canonical
APM authoring layout. It isn't — it's layout 3, the "I already have a
Claude plugin" fallback. Layout 2 (.apm/) is the source-of-truth path
and the only one that works for multi-target compile..apm/ + .github/ side-by-side)apm-marketplace-authoring-gotchasWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cajias/claude-skills --plugin cc-authoring16 skills in this plugin
/apm-marketplace-authoring-gotchasEight APM-marketplace-authoring gotchas discovered during real
migrations from hand-authored .claude-plugin/marketplace.json to
APM-managed and from CC-native plugin authoring.
Use when: (1) running APM's packaging step (with or without
`--dry-run`) or its marketplace-check command in a repo with an
`apm.yml`; (2) wiring CI for an APM
marketplace; (3) the CI staleness check (repack, then `git diff
--quiet`) fails despite a clean local; (4) prettier reformats
`marketplace.json` after APM's packer writes it; (5) APM exit code 1 on
local-path-only marketplaces; (6) confused by `packages:` in apm.yml
vs `plugins:` in marketplace.json; (7) commitlint rejects a commit
with `footer-leading-blank` despite no apparent footer; (8) `apm
compile -t claude` exits 0 with zero output and no compiled plugin
appears; (9) husky+lint-staged pre-commit blocks the FIRST marketplace
commit with markdownlint `MD040/fenced-code-language` errors on a
SKILL.md file copied verbatim from `~/.claude/skills/`. The gotchas
form a chain — fixing one usually surfaces the next.
/autoresearch-is-code-metric-optimizerThe `/autoresearch:autoresearch` Claude Code skill is a CODE-METRIC
OPTIMIZER (modify → verify → keep/discard loop). Use when: (1) you are
about to invoke `/autoresearch:autoresearch` to do literature / web
research (it does NOT fetch papers, search the web, or synthesize cited
reports — use `/deep-research` for that); (2) you have a measurable
target (test pass rate, perf delta, p&l, win rate, composite metric)
AND code-or-config that can be modified to hit it — that IS the right
use case, including non-traditional optimization targets like trading
strategy backtest results; (3) you're confused about when to reach for
the BASE skill vs the sub-skills `:reason` (adversarial debate) or
`:probe` (8-persona interrogation) — the base skill is for iterative
optimization with a clear verify function; the sub-skills are for
qualitative investigation when there is no verify function.
/cc-hooks-main-vs-subagentHow a Claude Code PreToolUse/PostToolUse hook can tell whether a tool call
came from the MAIN conversation thread or from a SUBAGENT (Task/Agent tool),
plus the gotchas of testing hooks via headless `claude -p`. Use when:
(1) building a hook that should apply only to the main thread (e.g.
orchestrator-only enforcement that denies Edit/Write in main but allows
subagents) or only to subagents; (2) wondering if hook input contains an
is_subagent / agent indicator — it does, but it's undocumented;
(3) a hook behaves differently than expected under `claude -p` because
CLAUDE_CODE_ENTRYPOINT is sdk-cli there and `env CLAUDE_CODE_ENTRYPOINT=cli`
does NOT survive (the CLI overwrites it); (4) a headless hook test shows
"Claude requested permissions ... but you haven't granted it yet" instead of
the hook's deny reason — the permission gate fires before the hook surfaces;
(5) you need to force the interactive code path in a headless test (use a
--settings file with an env block).
/cc-mid-session-registry-stalenessFix for two Claude Code mid-session staleness traps that fail Workflow runs
instantly (<15ms). Use when: (1) a Workflow agent() call fails with
"agent type '<name>' not found" listing only plugin/built-in agents, even
though .claude/agents/<name>.md exists with valid frontmatter — the agent
registry only loads .claude/agents/ at session START, so agent files created
mid-session are not resolvable via agentType/subagent_type until restart;
(2) re-invoking a saved workflow via Workflow({name}) runs STALE code after
you edited .claude/workflows/<name>.js — name resolution serves a cached
snapshot, so mid-session edits never reach it. Both failures look like your
code is wrong when it's actually registry caching. Fixes: launch via
Workflow({scriptPath: <live file path>}) to bypass the name cache, and
design workflow scripts with a registry-independent persona fallback
(prompt the agent to Read its own .claude/agents/<name>.md and adopt the
role) toggled by an arg like useAgentTypes:false.
/cc-plugin-cache-multi-version-not-recordedFix for Claude Code startup warning `Plugin "<name>" not cached at (not
recorded) — run /plugins to refresh`. Use when: (1) Claude Code prints a
`plugin-cache-miss` warning whose installPath is the literal string
`(not recorded)`; (2) `claude plugin list` shows the plugin as installed
with a valid version, AND
`~/.claude/plugins/installed_plugins.json` has a real `installPath` for
it, yet the warning still fires every session; (3) running `/plugins` or
reinstalling the plugin doesn't clear the warning; (4) the plugin's
cache directory at
`~/.claude/plugins/cache/<marketplace>/<plugin>/` contains TWO (or more)
version subdirectories — typically an old SHA-prefix dir and the
current one — left over from an in-place marketplace SHA bump.
Root cause: the Claude Code cache resolver (`fk8` in the binary) skips
any cache parent whose subdir count `!== 1`, returns null, and the
install-record fallback emits the warning with the hardcoded sentinel
`installPath: "(not recorded)"`. The phrase is NOT a missing config
field — it's a literal string in the error branch. Fix: delete every
stale version subdir under that plugin so exactly one remains (the one
recorded in `installed_plugins.json`).
/cc-pluginroot-directory-source-ignoredFix for the Claude Code startup error `Plugin directory not found at path:
<marketplace_root>/<plugin_name>. Check that the marketplace entry has the
correct path.` when a local `source: "directory"` marketplace uses
`metadata.pluginRoot` to factor a common prefix out of its plugin sources.
Use when: you authored a directory-source marketplace via `claude plugin
marketplace add <local-path>`; marketplace.json pairs
`{"name":"foo","source":"./foo"}` with a top-level
`metadata.pluginRoot: "./plugins"`; the subdirectories exist at
`<root>/plugins/foo` but Claude Code reports them missing at `<root>/foo`,
the `/plugins/` segment silently dropped; you manage the marketplace with
APM (`apm.yml` with `marketplace.metadata.pluginRoot`) whose packaging step
emits a pluginRoot-factored marketplace.json that Claude Code then rejects
at load; or the plugin loads once you change its source to `./plugins/foo`
and remove `pluginRoot`. Covers why the field is schema-accepted and honored
for `git-subdir` sources yet ignored for directory ones (resolved literally
against installLocation as of Claude Code 2.1.158), and what to change at
both the apm.yml and marketplace.json layers.