docs(kyberforge): verify apm prompts primitive against apm 0.28.0

Fold throwaway-install experiments into prompt-gotchas and
prompt-target-mapping. Resolves root-level discovery, manifest type
advisory behaviour, compile ignoring prompts, per-target key survival
and collision/cleanup behaviour, and records where the published docs
disagree with the observed behaviour (Gemini silent drops, same-name
collisions, --force on critical hidden characters).

Refs: #149

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN
This commit is contained in:
Defame1297andClaude Sonnet 5.5 committed 2026-10-15 07:36:44 +00:00
1 parent f5a260e85c
commit 3b3b3028f8
3 files changed
+87 -50

No files matched your search

@@ -6,46 +6,69 @@ source_keys:
- apm-docs-producer-ramp
- apm-docs-cli-run
- apm-docs-cli-compile
- apm-cli-0-28-0-prompt-experiments
---
## What this covers
Constraints that surprise a prompt author, taken from the published apm docs. None of it was exercised against the installed binary. Items marked "doc conflict" have two statements in the docs that disagree and need an experiment before a skill asserts either.
Constraints that surprise a prompt author. Items are marked **observed** when they were reproduced on the installed apm 0.28.0 in a throwaway project with local-path packages, and **doc** when they come only from the published docs. Where an observation disagrees with a doc statement, the observation wins and the disagreement is noted. Claude Code, Cursor and Gemini runtime behaviour on the emitted files was not tested.
## Silent or quiet loss
## Discovery
- Keys outside the preserved set are dropped on every command target except Copilot. The only signal is a diagnostic at install time; there is no failure and no flag to keep them.
- Input names must match `[A-Za-z][\w-]{0,63}`. A non-matching name is rejected with a warning and never reaches the command frontmatter, so that one argument silently disappears while the install succeeds.
- Codex receives nothing. A workflow that must reach Codex has to ship as a skill.
- A package whose `type:` does not cover prompts may deploy none. Doc conflict: the manifest field reference says `type` constrains what `.apm/` may contain, while the spec says it is advisory in v0.1 and consumers must ignore it.
- **Observed:** a root-level `<pkg>/foo.prompt.md` is discovered and deployed alongside `.apm/prompts/`. The `.apm/prompts/` directory is canonical; root-level discovery works but is a backward-compatibility path.
- **Observed:** discovery is non-recursive and case-sensitive. `.apm/prompts/sub/x.prompt.md`, `X.PROMPT.md` and a bare `x.md` are silently ignored with exit 0.
- **Observed:** `apm init` writes only `apm.yml`. It creates no `.apm/` and no `.apm/prompts/`, so the scaffold must create the directory.
- **Observed:** a project's own `.apm/prompts` is deployed by a bare `apm install` in that project, with no dependency needed. Such local prompts are recorded in the lockfile only under `deployments:`, while dependency prompts also appear in `deployed_files` with hashes.
- **Observed:** odd filenames (uppercase, underscores, dots, spaces, a leading dash or dot) deploy as-is with no validation. Whether Claude Code accepts such command names was not tested, so authors should stay with kebab-case.
## Manifest `type:`
**Observed:** `instructions`, `skill`, `prompts` and `hybrid` all deploy prompts identically. Any other value (`agents`, `bogus`) fails the install with exit 1 and the message "Invalid package type ... Valid types are: 'instructions', 'skill', 'hybrid', 'prompts'", and apm.yml is restored. So the value is validated but never constrains deployment, which matches the spec's "advisory" wording and contradicts the manifest reference that says it constrains contents.
## Compile versus install
`apm compile` ignores prompts. It handles instructions and root context files. Prompts are deployed by `apm install`, and parameter binding happens only in `apm run`. Consequences: a prompts-only package compiled for `claude` yields no output; `apm compile --validate` checks primitive frontmatter and structure without writing, but the docs do not say whether it inspects individual prompt files, and no prompt validation class was found in the code reading. Whether a plain `apm compile` fails on a package with no instructions is not addressed for prompts-only packages. Doc conflict: one passage says compile and run both compile prompts and another says prompts are never compiled.
- **Observed:** `apm compile` never reads prompts. Prompts reach commands directories only through `apm install`.
- **Observed:** on a prompts-only package, plain `apm compile`, `--validate` and `--target claude` exit 1 with "No instruction files found in .apm/ directory" while no `.claude/` exists. Once install has created `.claude/`, the same commands exit 0 with "CLAUDE.md not generated" and no output, and `--validate` reports "Validated 0 primitives". `--dry-run` exits 0 either way and writes nothing. The exit code tracks whether `.claude/` exists, not anything about the prompts.
- **Observed:** with one valid instruction present, `apm compile --validate` exits 0 and counts only instructions, even when prompts have malformed YAML, invalid input names or unknown keys. It cannot lint prompts, and the docs' suggestion to use it as a verify step does not cover them.
- **Consequence:** verifying a prompt means a throwaway `apm install` and inspecting the deployed files, not `apm compile`. Any acceptance criterion phrased as "passes `apm compile` for the Claude target" proves nothing about prompts unless it also asserts the installed output.
## Identity and collisions
## Silent or quiet loss
- The base filename is the command name on every target, so it must be valid and unique as a slash command and as a Copilot prompt filename at once.
- Two prompts with the same base name, one under `.apm/prompts/` and one at the package root, collide. The later writer wins on Copilot and the transform fails on Claude and Cursor.
- Root-level `*.prompt.md` discovery is documented both as supported for backward compatibility and as not discovered by install. Doc conflict; prefer `.apm/prompts/` and do not rely on either.
- A virtual package reference ending in `.prompt.md` is classified by extension only.
- Symlinked prompt files are rejected by `apm preview` and `apm run`, and plugin packing flags symlinks under the prompts directory.
- **Observed:** on the Claude family (claude, cursor, opencode, windsurf, grok-build) unsupported keys are dropped with exit 0 and a warning of the form "frontmatter keys not supported for claude commands and were dropped: agent, author, mcp, mode, parameters, tools. Supported keys: allowed-tools, argument-hint, description, input, model". Unknown keys such as `inputs` are dropped the same way. Copilot keeps everything.
- **Observed, disagrees with the docs:** Gemini drops everything except `description` with **no** diagnostic.
- **Observed:** codex, kiro, antigravity and agent-skills deploy nothing, exit 0, with no warning.
- **Observed:** the `input` descriptions in the object and map forms are discarded; only names survive, as `arguments:`.
- **Observed:** invalid input names (`bad name!`, `9lead`) are rejected with a warning and the install succeeds. Duplicate names are neither removed nor warned about, giving `arguments: [dup, dup]`.
- **Observed:** declaring `input:` and also writing a literal `$ARGUMENTS` or `$0` in the body gives both `arguments:` and the literal text, with no conflict diagnostic.
## Ownership, overwrite and cleanup
## Frontmatter and body edge cases
No prompt-specific rule exists; only generic install rules were found. Untracked files already on disk are skipped with a warning unless `--force` is used. Files a package previously deployed and no longer produces are removed on the next install. Narrowing `targets:` removes only unchanged files apm owns, and files placed by hand inside a target directory remain. Uninstall deletes only files recorded in the lockfile `deployed_files` manifest. Local primitives override dependency primitives of the same name and type; the first declared dependency wins between dependencies.
- **Observed:** malformed YAML makes Claude and Gemini skip the file with a "Skipped command ... malformed or over-budget YAML frontmatter" warning and exit 0, so the command is simply missing. Copilot copies the broken file verbatim with no warning.
- **Observed:** a prompt with no frontmatter becomes an empty `{}` frontmatter block on Claude. An empty body deploys frontmatter only on Claude and `prompt = ""` on Gemini. Neither warns.
- **Observed:** `${input:x}` and `${{input:x}}` become `$x` on the Claude family, including for undeclared names. The placeholder form `${input:x:placeholder}` is left untouched. Gemini does not rewrite `${input:...}` at all, and a `$<digit>` anywhere in a Gemini body prepends an "Arguments: {{args}}" line.
## Identity, collisions and ownership
- **Observed:** a pre-existing hand-written `.claude/commands/<name>.md`, `.github/prompts/<name>.prompt.md`, cursor or gemini file is skipped with "files skipped -- local files exist, not managed by APM", exit 0, other prompts still deploy, and `--force` overwrites. This is uniform across the four targets tested, unlike instructions, which overwrote silently on some.
- **Observed:** editing the source and reinstalling redeploys. Hand-editing a deployed file and reinstalling silently overwrites it.
- **Observed:** removing a prompt from the package and reinstalling cleans the stale deployed files on every target tested. A deployed file that was hand-edited first is kept with a "delete manually" message.
- **Observed, disagrees with the docs:** the same base name in the root and in `.apm/prompts/` does not fail. The root copy is processed first and wins; the second is skipped with the misleading "not managed by APM" message, and `--force` lets `.apm/prompts/` win. There is no transform failure and no duplicate diagnostic.
## Security scanning
The install-time scan inspects every primitive for hidden Unicode and blocks critical findings unless forced. `apm compile` and `apm run` do not re-scan, so a hand-edited prompt needs `apm audit`. A proposed audit of deployed prompts decodes only documented prompt fields.
- **Observed:** zero-width space, BOM and NBSP in a prompt are warnings and the file deploys. Tag characters and bidi overrides are critical: the install exits 1, apm.yml is restored and nothing deploys.
- **Observed, disagrees with the docs:** `--force` makes the exit code 0 and prints "Deployed with --force despite critical hidden characters", yet the prompt is still not deployed.
- **Observed:** `apm audit` scans deployed command files, exits 2 on the zero-width warning, and a hand-appended critical character produces a critical finding plus drift. `apm audit --ci` reports `hash-drift`.
## apm run specifics
## Packing
Parameters are interpolated into any `.prompt.md` the script references and are not exported as shell variables. A typo in a script name can fall through to discovery and then to a virtual-package install attempt. The docs do not say what happens when a `${input:...}` placeholder has no `--param`. The `apm run` command is marked experimental. The spec describes script substitution with `{key}` placeholders instead of `${input:name}`; this divergence is unresolved.
- **Observed:** `apm pack --format plugin` maps `.apm/prompts/x.prompt.md` to `commands/x.md`, byte-identical to the source with no transform. Root-level prompts are not packed. Installing that bundle copies files verbatim: Claude gets an untransformed file that still has `input:`, and Copilot gets `.github/commands/` rather than `.github/prompts/`.
- **Observed:** pack refuses a manifest with a local-path dependency, and with neither dependencies, marketplace nor target it exits 1 with "Nothing to pack".
## Documentation inconsistencies to keep out of the skill
## apm run specifics (doc only)
- Whether `apm init` scaffolds `.apm/prompts/`.
- Whether Copilot prompts deploy at user scope.
- The `$name` form used in one example versus `${input:name}` in the prompts page; the transformer rewrite explains it, but the example does not say so.
- `mode` and `mcp` appear in some example frontmatter but are not in the preserved set.
Parameters are interpolated into any `.prompt.md` the script references and are not exported as shell variables. A typo in a script name can fall through to discovery and then a virtual-package install attempt. The docs do not say what happens when a placeholder has no `--param`. `apm run` is marked experimental, and the spec describes `{key}` placeholders where the CLI docs use `${input:name}`. `apm run` and `apm preview` were not exercised.
## Not tested
The experimental targets (hermes, openclaw, copilot-cowork, grok-cloud, copilot-app), because enabling them writes global config. Claude Code, Cursor and Gemini runtime handling of the emitted files.
@@ -5,59 +5,66 @@ source_keys:
- apm-docs-llms-full
- apm-docs-producer-ramp
- apm-github-repo
- apm-cli-0-28-0-prompt-experiments
---
## Scope and confidence
This file maps one `.apm/prompts/<name>.prompt.md` source to what each apm target receives. It combines the published apm docs (the "Author a prompt" page, the full docs dump and the producer guide) with the code-level reading already recorded in `prompt-primitive-schema.md`. Nothing here was verified by running apm 0.28.0; unlike the instructions research there are no install experiments behind it. Doc statements that contradict each other are listed in `prompt-gotchas.md` rather than resolved here.
This file maps one `.apm/prompts/<name>.prompt.md` source to what each apm target receives. The paths and transforms below were **observed** on apm 0.28.0 using local-path packages in a throwaway project, and cross-checked against the published docs and the installer source. Where docs and observation disagree, the observation is used and `prompt-gotchas.md` records the disagreement. Runtime behaviour in the receiving tools was not tested.
## Output per target
| Target | Output path | Form |
|---|---|---|
| copilot | `.github/prompts/<name>.prompt.md` | Verbatim copy, markdown links resolved |
| copilot (also vscode, intellij) | `.github/prompts/<name>.prompt.md` | Byte-identical copy |
| claude | `.claude/commands/<name>.md` | Reconstructed slash command |
| cursor | `.cursor/commands/<name>.md` | Shared command transformer (same as Claude) |
| opencode | `.opencode/commands/<name>.md` | Shared command transformer |
| grok-build | `.grok/commands/<name>.md` | Grok command |
| gemini | `.gemini/commands/<name>.toml` | TOML command, `$ARGUMENTS` becomes `{{args}}` |
| windsurf | `.windsurf/workflows/<name>.md` | Workflow file |
| copilot-app | row in the Copilot App workflows store | Experimental, only for workflow-shaped prompts |
| codex | none | No prompts or commands primitive |
| cursor | `.cursor/commands/<name>.md` | Identical transform to claude; output is byte-identical |
| opencode | `.opencode/commands/<name>.md` | Identical transform |
| grok-build | `.grok/commands/<name>.md` | Identical transform |
| windsurf | `.windsurf/workflows/<name>.md` | Identical transform, workflow directory |
| gemini | `.gemini/commands/<name>.toml` | TOML with `description` and `prompt` only |
| codex, kiro, antigravity, agent-skills | none | Exit 0, no warning |
| hermes, openclaw, copilot-cowork, grok-cloud, copilot-app | none by default | Print that an experimental flag is required; untested |
The published compatibility matrix labels Copilot "Native", the command-style targets "Compiled", and Codex, Kiro and Hermes "Unsupported". The published page lists seven deploying targets and Codex as the only explicit "none"; antigravity is described as compiled in the matrix, while the code reading found no commands primitive for it. Treat antigravity, kiro and any other target as unknown until tested.
At user scope (`apm install -g`) claude, gemini and cursor deploy to their home-directory commands folders and Copilot deploys to the Copilot user prompts directory. This resolves the earlier doc conflict about Copilot user scope.
## Slot terminology
The docs call the source primitive "prompts" and the per-target surface "commands". Claude and Cursor have no `prompts` slot in their target profile, so a package that ships only prompts and is compiled for `claude` produces zero output from `apm compile`. Prompts reach Claude only through `apm install`, which routes them into the commands slot. There is no `.apm/commands/` source directory; "command" is purely the compiled name for the same file.
The docs call the source primitive "prompts" and the per-target surface "commands". Claude has no `prompts` slot in its target profile, so prompts reach it only through `apm install`, which routes them into the commands slot; `apm compile` never touches them. There is no `.apm/commands/` source directory. A package built with `apm pack --format plugin` maps the prompts directory to `commands/` and renames `x.prompt.md` to `x.md` without transforming the contents.
## Claude-family output
For a source with `description`, `input` (`simple`, `named: The named one`, `other`), `allowed-tools`, `model`, `argument-hint` and extra keys, the Claude command file contains only `allowed-tools`, `argument-hint`, `arguments`, `description` and `model`, keys sorted alphabetically, with no trailing newline. `input` is consumed into `arguments:` as names only (object and map forms lose their descriptions), and `argument-hint` is synthesised as `<a> <b>` when absent or kept when given. `argumentHint` and `allowedTools` are accepted as aliases. The five keys visible in the output are therefore `description`, `allowed-tools`, `model`, `argument-hint` and `arguments`, while the five keys an author may write and expect to survive are `description`, `input`, `allowed-tools`, `model` and `argument-hint`.
## Frontmatter survival by target
Five keys are preserved by the cross-tool command transform: `description`, `input`, `allowed-tools`, `model`, `argument-hint`. The published pages list this set as five keys including `input`; the earlier research digest listed four and treated `input` as input to `arguments` only, which is a wording difference rather than a behavioural one.
| Key | Copilot | Claude, Cursor | Other command targets |
| Key | Copilot | Claude family | Gemini |
|---|---|---|---|
| `description` | kept | kept | kept |
| `input` | kept as written | becomes `arguments:`, and `argument-hint` is derived if unset | per-target; not individually documented |
| `allowed-tools` | kept, but Copilot ignores it | honored | not documented |
| `model` | kept | honored | not documented |
| `argument-hint` | kept | kept, or derived from `input` | not documented |
| any other key (`author`, `mcp`, `parameters`) | kept | dropped with an install diagnostic | dropped with an install diagnostic |
| `input` | kept as written | becomes `arguments:` | dropped silently |
| `allowed-tools` | kept (Copilot ignores it) | kept | dropped silently |
| `model` | kept | kept | dropped silently |
| `argument-hint` | kept | kept or synthesised | dropped silently |
| any other key | kept | dropped with a warning naming the keys | dropped silently |
The Copilot copy is a byte copy, so every key survives even where the Copilot runtime ignores it. The VS Code prompt-file format uses `agent`, `tools` and `name` keys that apm does not list as preserved, so a prompt written for Copilot with those keys works on Copilot only.
The VS Code prompt format uses `agent`, `tools` and `name`, which survive on Copilot only.
## Body placeholders
The apm body syntax is `${input:name}`. The transformer rewrites it to the target's native form, for example `$name` on Claude. On Gemini the argument token is `{{args}}`. Copilot receives the text unchanged, and VS Code itself understands `${input:name}` and `${input:name:placeholder}`.
| Syntax in source | Claude family | Gemini | Copilot |
|---|---|---|---|
| `${input:x}` | `$x` | unchanged | unchanged |
| `${{input:x}}` | `$x` | unchanged | unchanged |
| `${input:x:placeholder}` | unchanged | unchanged | unchanged |
| `$ARGUMENTS` | unchanged | `{{args}}` | unchanged |
| `$0`, `$1` | unchanged | unchanged, and an "Arguments: {{args}}" line is prepended | unchanged |
Claude Code's own documentation supports `$ARGUMENTS`, zero-based `$N` and named `$name` from a declared `arguments:` list, so the rewritten output is native to Claude Code.
## Workflow-shaped prompts
Only the top-level keys `interval`, `schedule_hour` and `schedule_day` mark a prompt as a Copilot App workflow. The other workflow keys (`name`, `mode`, `model`, `reasoning_effort`) do not by themselves. A plain prompt pointed at `copilot-app` is a hard error, and workflow-shaped prompts are skipped by the command integrator, so they never appear as slash commands.
Only the top-level keys `interval`, `schedule_hour` and `schedule_day` mark a prompt as a Copilot App workflow, and such prompts are skipped by the command integrator. A plain prompt pointed at `copilot-app` is a hard error. The experimental target was not exercised.
## Invocation
Copilot uses its prompt picker. Claude, Cursor, OpenCode and Gemini use `/<name>` followed by arguments. Windsurf uses the workflows menu. Consumers can also bypass the picker through an `apm.yml` script and `apm run <script> --param key=value`, which compiles the prompt into `.apm/compiled/<name>.txt` and substitutes `${input:name}` before running the shell command.
## Scope
The docs say Copilot prompts, agents, skills, hooks and canvas remain project-scope only, while another passage says user-scope prompts deploy to the Copilot user prompts directory. This is unreconciled and should be tested before the skill makes any user-scope claim.
Copilot uses its prompt picker. Claude, Cursor, OpenCode and Gemini use `/<name>` followed by arguments. Windsurf uses the workflows menu. Consumers can bypass the picker with an `apm.yml` script and `apm run <script> --param key=value`, which compiles to `.apm/compiled/<name>.txt` (doc only, not exercised).
@@ -85,3 +85,10 @@ Note: `releasing.md`'s `--check-clean`/`--check-versions` scope, `apm pack` exit
- **Description:** `apm compile` reference, read for what it does with prompts (ignores them) and what `--validate` checks. Does not address prompts-only packages.
- **Contributing files:** prompt-gotchas.md
- **Status:** `extracted`
## apm-cli-0-28-0-prompt-experiments
- **URL:** https://pypi.org/project/apm-cli/0.28.0/
- **Description:** The installed apm-cli 0.28.0 exercised with local-path throwaway packages in a scratchpad outside the repo: root-level and nested prompt discovery, manifest `type:` values, compile on prompts-only packages, per-target install output and dropped-key warnings, input-name and YAML edge cases, collision, stale-cleanup and hand-edit behaviour, hidden-Unicode scanning and audit, and `apm pack --format plugin`. Source files `command_integrator.py`, `prompt_integrator.py` and `plugin_exporter.py` were read to cross-check. Experimental targets and `apm run` were not exercised.
- **Contributing files:** prompt-target-mapping.md, prompt-gotchas.md
- **Status:** `extracted`