Files
Holocron/plugins/kyberforge/docs/research/docs/microsoft-apm/prompt-primitive-schema.md
T
Defame1297andClaude Opus 5.5 5ca2056046 docs(research): refresh apm reference set to 0.39.3 (#265)
Add lockfile-and-compatibility, approvals-and-executables and
migration-0-28-to-0-39 topics; update installation, cli-reference, the
prompt, hooks and instructions topics for 0.39.x behaviour; label the
remaining 0.28.0 observations by version. Sources: the v0.39.3 source,
CHANGELOG and docs; Context7 was unavailable.

Refs #265

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
2026-12-01 21:46:06 +00:00

8.2 KiB
Raw Blame History

topic, source_keys
topic source_keys
prompt-primitive-schema
context7-microsoft-apm
apm-github-repo
apm-docs-author-prompts
apm-docs-llms-full
apm-v0-39-3-source
apm-v0-39-3-changelog

Per-target output, key survival and the doc inconsistencies are in prompt-target-mapping.md and prompt-gotchas.md.

Version note. This file was first verified on apm 0.28.0. The Claude key set changed in 0.39.0; the section "Claude command keys in 0.39.x" below is the current behaviour, read from the v0.39.3 source. In 0.28.0 the shared set was five keys: description, input, allowed-tools, model, argument-hint, where input is consumed into arguments: on Claude. Every other key was dropped on every Claude-family target.

Claude command keys in 0.39.x

  • Shared keys, kept on every Claude-family target: description, allowed-tools (alias allowedTools), model, argument-hint (alias argumentHint), input.

  • Claude-native keys, kept only when the target is claude:

    • when_to_use, disable-model-invocation, user-invocable, disallowed-tools, effort;
    • context, agent, background, shell.

    Cursor, OpenCode, Windsurf and the other targets that reuse the command transformer still drop them.

  • arguments: an authored arguments is kept verbatim only on Claude, and only when the file has no input key at all. An input key always wins, even when it is empty or every name in it was rejected.

  • hooks: withheld on purpose. The command is deployed without its hooks, and install warns frontmatter hooks withheld. apm does not yet run command hooks through its executable-approval gate.

  • Other keys: still dropped. The dropped-keys message is now an info line shown only with --verbose, no longer an always-on warning.

  • Consequence: a prompt with disable-model-invocation: true deploys with that key to .claude/commands/<name>.md on 0.39.0 and later. 0.28.0 silently stripped it.

File location, naming, and frontmatter

.apm/prompts/*.prompt.md (also discovered at the package root). Filename minus the .prompt.md suffix becomes the prompt's identity — used verbatim as the Copilot filename and, after transformation, as the Claude command name. No required-extension ambiguity: it is genuinely .prompt.md, confirmed both in docs and in APM's own PromptIntegrator.find_prompt_files (*.prompt.md) and CommandIntegrator.find_prompt_files (same glob).

There is no single closed frontmatter schema — APM's P1 "no invented primitive frontmatter" principle applies here too, so a prompt author writes whatever keys their primary target needs and APM passes or drops per-target. Keys seen in APM's own docs/examples:

Field Purpose
description Shown in Copilot's prompt picker / used for discovery
input List of parameter names (simple list, or list of {name: description} objects) referenced in body as ${input:name}
allowed-tools (or allowedTools) Tool allowlist for the prompt's execution
argument-hint (or argumentHint) Human-readable hint for expected arguments
model Model override when the prompt runs
author, mcp, parameters Cursor/other-target-specific metadata — not preserved by the shared Claude/Cursor command transformer (see below)

Workflow-prompt-only keys (Copilot App / Copilot Workflows, not Copilot CLI): name, interval (manual/hourly/daily/weekly), schedule_hour (0–23 UTC), schedule_day (0–6, weekly only), mode (interactive/plan), reasoning_effort. These are flat top-level keys on the same .prompt.md file, consumed only by the Copilot App scheduler integration — irrelevant to Claude Code / Copilot CLI compilation and should not be treated as universal prompt schema.

Compile-time mapping: verbatim for Copilot, real reconstruction for Claude

Copilot CLI target — verbatim copy. PrimitiveMapping("prompts", ".prompt.md", "github_prompt") on the copilot target profile carries no output_compare flag, and PromptIntegrator.copy_prompt() reads the source file and writes it out unchanged (only markdown link targets get rewritten) via copy_prompt: "Copy prompt file verbatim with link resolution.". Every frontmatter key — including author, mcp, parameters — survives. Filename is untouched (get_target_filename returns source_file.name, "no -apm suffix").

Claude Code target — real reconstruction into a slash command, with field-dropping. There is no prompts: key at all in Claude's TargetProfile.primitives dict; instead prompts route through the shared CommandIntegrator, which transforms .prompt.md → Claude custom slash command markdown. CommandIntegrator._transform_prompt_to_command():

  • Strips the .prompt.md suffix from the filename to derive command_name.
  • Builds an entirely new frontmatter object containing only the preserved keys. In 0.28.0 these were description, allowed-tools (alias allowedTools), model and argument-hint (alias argumentHint). From 0.39.0 the claude target also keeps the Claude-native keys listed above.
  • Maps APM's input: list to Claude's arguments: list, and synthesizes argument-hint from it if not already set.
  • Rewrites body placeholders ${input:name} / ${{input:name}} to Claude's native $name syntax via regex substitution.
  • Computes dropped_keys = source_frontmatter_keys - preserved_keys and surfaces it as an install-time diagnostic warning — so author, mcp, parameters, and any other non-listed key are silently dropped from the compiled output but not silently dropped from the user's awareness (a warning fires).
  • Cursor reuses this exact same transformer (claude_command format_id) — same preserved-key set, same drops.

Compile-time file placement

Target Output path Transform
Copilot CLI .github/prompts/<name>.prompt.md Verbatim byte copy (links resolved)
Claude Code .claude/commands/<name>.md Reconstructed. In 0.28.0 only description/allowed-tools/model/argument-hint/arguments survive; from 0.39.0 the Claude-native keys survive too. input: → arguments:; ${input:x} → $x

Invocation surface differs correspondingly: Copilot exposes it via the prompts picker UI (select by name); Claude exposes it as /<name> <args> (same pattern Cursor, OpenCode, Gemini CLI, and Windsurf's workflows menu use for their own compiled copies).

Validation constraints and gotchas

  • Input-name validation is real, not just documentation. _extract_input_names() enforces [A-Za-z][\w-]{0,63} on every name pulled from input:; anything that fails is dropped from arguments: and reported as a warning listing up to 5 rejected names (input: rejected N invalid name(s) ... ). A malformed input: entry does not fail the install — it silently loses that one argument.
  • Filename-derived identity is security-checked. integrate_commands_for_target calls validate_path_segments(base_name, context="command filename") specifically to reject a package shipping a .prompt.md file with a manipulated relative name (e.g. ../../evil.prompt.md) that would otherwise escape the target commands directory.
  • The dropped-key message is the only signal a Claude-only author gets that Cursor-specific frontmatter (author, mcp, parameters) never reached the deployed file. There is no error, no hard failure, and no config flag to preserve those keys. The preserved-key lists are fixed in code (_PRESERVED_COMMAND_KEYS, and _CLAUDE_NATIVE_COMMAND_KEYS from 0.39.0); a package cannot configure them. From 0.39.0 the message appears only with --verbose.
  • No dedicated Prompt/PromptPrimitive validation class exists in apm_cli/models/validation.py or apm_cli/primitives/models.py — same gap pattern documented for the agent primitive. apm.yml's type: prompts package-content-type ("Commands/prompts only, no instructions or skills") is validated at the package-type-detection level, not the individual-prompt level.
  • Slash commands and prompts share one source directory and one glob (.apm/prompts/*.prompt.md) — there is no separate .apm/commands/ primitive; "command" is purely a per-target compiled name for the same source file, not a distinct authoring primitive.