--- topic: prompt-gotchas source_keys: - apm-docs-author-prompts - apm-docs-llms-full - apm-docs-producer-ramp - apm-docs-cli-run - apm-docs-cli-compile - apm-cli-0-28-0-prompt-experiments - apm-v0-39-3-source - apm-v0-39-3-changelog - apm-cli-0-39-3-experiments --- ## What this covers Constraints that surprise a prompt author. **Version note:** every **observed** item below was observed on apm 0.28.0 and has not been re-run on 0.39.x. The changes known from the 0.39.3 source and CHANGELOG are listed under "Changed in 0.39.x" at the end. 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. ## Discovery - **Observed:** a root-level `/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 - **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. ## Silent or quiet loss - **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:** a single-key `{name: description}` list item loses its description and only the name survives, as `arguments:`. A multi-key item such as `name:` plus `description:` turns every key into an argument (`arguments: [name, description]`). Found by a clean-context review of `prompt-author`. - **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. ## Frontmatter and body edge cases - **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 `$` anywhere in a Gemini body prepends an "Arguments: {{args}}" line. ## Identity, collisions and ownership - **Observed:** a pre-existing hand-written `.claude/commands/.md`, `.github/prompts/.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 - **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 and apm.yml is restored; the Claude-family command is withheld, but the Copilot and Gemini outputs may still be written. - **Observed, disagrees with the docs:** `--force` makes the exit code 0 and prints "Deployed with --force despite critical hidden characters", yet the Claude-family command is still not deployed. Re-tested later: even without `--force`, a plain install that exits 1 on a tag character still wrote the Copilot byte copy and the Gemini TOML; only the Claude file was withheld. - **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`. ## Packing - **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". ## apm run specifics (doc only) 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. ## Changed in 0.39.x (from source and CHANGELOG, not observed) - On the `claude` target the Claude-native command keys are kept rather than dropped: - `when_to_use`, `disable-model-invocation`, `user-invocable`, `disallowed-tools`, `effort`; - `context`, `agent`, `background`, `shell`. So the 0.28.0 drop list above (which named `agent`) no longer holds for Claude. Cursor, OpenCode, Windsurf and grok-build still drop these keys. See `prompt-primitive-schema.md`. - The dropped-keys message is an info line shown only with `--verbose`, so a default install no longer reports dropped keys at all. - Frontmatter `hooks` on a command is withheld with a warning. - A non-string frontmatter key (for example `1:`) skips that one command with a warning, and the other commands still install. - Hidden-Unicode, collision and stale-cleanup behaviour were not re-checked. 0.38 and 0.39 changed how edited deployed files are kept (see `migration-0-28-to-0-39.md`), so the "hand-edited file is silently overwritten" item above is likely stale. ## Re-run on 0.39.3 (holocron#273) Observed with the repo-pinned apm 0.39.3 in throwaway packages outside the repo. Where this disagrees with the sections above, it wins. - **Claude-native keys.** `disable-model-invocation`, `when_to_use`, `user-invocable` and `effort` reached `.claude/commands/.md`. Cursor and OpenCode dropped them. `author` and `mcp` were dropped everywhere but Copilot. - **Dropped-keys message.** Printed only with `--verbose`, as an info line naming the dropped keys and the target's supported set. A default install says nothing about them. - **`hooks`** in a prompt's frontmatter is withheld on Claude with a `frontmatter hooks withheld` warning, and the command still deploys. - **Kiro now receives prompts**, at `.kiro/prompts/.md` with every frontmatter key stripped and a warning naming them. Codex, Antigravity and agent-skills still deploy nothing, silently. - **Hand-edited deployed files.** Editing `.claude/commands/.md` and reinstalling after a source change makes install exit 1 with `Kept ... it was modified since APM deployed it`, and nothing is committed. Removing the source keeps the edited file with a warning and cleans the others. - **Hidden characters.** A tag character makes install exit 1 with nothing written on any target. `--force` exits 0 and writes the Copilot copy and Gemini TOML, but still withholds the Claude command. A zero-width space warns and deploys. - **Unchanged:** compile ignores prompts; `--validate` counts none; malformed YAML skips the command with a warning; an invalid input name is rejected with a warning and duplicates pass; a hand-written file at a deployed path is skipped until `--force`; `input:` becomes `arguments:`; Gemini keeps `description` and the body, and prepends `Arguments: {{args}}` to a body using `$0`.