The existing schema doc covered only Claude and Copilot and called missing description and empty content errors when apm 0.28.0 only warns. Rewrite it with the applyTo grammar and add per-target compile/install mapping and a gotchas doc (unquoted globs, install-vs-compile discovery, dedup and overwrite behaviour), all verified against the apm 0.28.0 binary. Refs: #148 Co-Authored-By: Claude Code <[email protected]> Claude-Session: https://claude.ai/code/session_01KkT7RSDwDbmrM9T34b6sTi
7.8 KiB
topic, source_keys
| topic | source_keys | |||||
|---|---|---|---|---|---|---|
| instructions-target-mapping |
|
What each target receives from an instruction file, at install time (native per-file deploy) and at compile time (folded into a root context file). Verified against apm 0.28.0 source and throwaway installs unless marked otherwise. Field syntax of the source file is in instructions-primitive-schema.md.
Two separate output paths
apm install writes native files, one per instruction, into each target's own rules directory. apm compile writes root context files (CLAUDE.md, AGENTS.md, GEMINI.md) that concatenate instruction bodies. The two overlap, which is why compile has a dedup rule (below). A skill author should treat install as the primary path for Claude Code and Copilot, and compile as the path for targets that have no native instructions directory.
Install-time mapping
| Target | Deployed path | Transform |
|---|---|---|
| copilot | .github/instructions/<n>.instructions.md |
Verbatim copy, frontmatter untouched |
| copilot, user scope | ~/.copilot/copilot-instructions.md |
All bodies concatenated into one file, frontmatter stripped, provenance markers added |
| claude | .claude/rules/<n>.md |
applyTo becomes a paths: list; description dropped; no frontmatter at all when there is no applyTo |
| cursor | .cursor/rules/<n>.mdc |
applyTo becomes globs: (scalar for one pattern, list for several); description kept, auto-generated from the first body sentence when missing; no alwaysApply is written; not deployed at user scope |
| windsurf | .windsurf/rules/<n>.md |
trigger: glob plus globs:, or trigger: always_on when unscoped; description dropped; not deployed at user scope |
| kiro | .kiro/steering/<n>.md |
inclusion: fileMatch plus fileMatchPattern, or inclusion: always when unscoped; description dropped |
| antigravity | .agents/rules/<n>.md |
trigger: glob plus globs, or no frontmatter when unscoped; not deployed at user scope |
| grok-build | .grok/rules/<n>.instructions.md |
Verbatim copy; keeps the .instructions.md name |
| codex, gemini, opencode, agent-skills, openclaw, hermes, grok-cloud, copilot-cowork, copilot-app | none | No instructions mapping; these targets receive instructions only through compile |
Rename rule: the source suffix .instructions.md is replaced by the target's extension (.md, .mdc) except for Copilot and Grok, which keep the full suffix.
Ownership and overwrite
The rule-directory targets (cursor, claude, windsurf, kiro, antigravity) are treated as APM-owned per file: install overwrites an existing hand-authored file with the same deployed name without a prompt (verified: a hand-written .claude/rules/u.md was replaced). Copilot behaves differently: an existing unmanaged file is skipped with the message "local files exist, not managed by APM" and needs apm install --force to overwrite. A name collision with a hand-authored rule in .claude/rules/ is therefore silent data loss, so authors should not reuse stems of existing hand-written rules.
Removing or renaming a source instruction makes the next install delete the previously deployed file ("Cleaned N stale files"), and apm audit --ci passes after a clean install.
Install with explicit targets: in apm.yml creates the target directories (.claude/, .github/) if they do not exist.
Per-target field survival
| Field | Claude | Copilot | Cursor | Windsurf | Kiro | Antigravity | Compiled root file |
|---|---|---|---|---|---|---|---|
applyTo |
as paths |
kept verbatim | as globs |
as globs |
as fileMatchPattern |
as globs |
used for grouping only |
description |
dropped | kept (verbatim file) | kept | dropped | dropped | dropped | dropped |
author, version |
dropped | kept only because the file is verbatim | dropped | dropped | dropped | dropped | dropped |
Consequence for authors: a description is useful only for Copilot and Cursor. For Claude Code the first line or heading of the body is the only descriptive text that survives, so the body must be self-explanatory.
Native format facts from the downstream tools
Claude Code: .claude/rules/*.md is found recursively. paths is the only field read; it accepts a YAML list or a comma-separated string. Other fields are ignored with no error. Rules without paths load unconditionally at launch; path-scoped rules load when matching files are read. Invalid frontmatter YAML is ignored and the rule loads without paths. Brace expansion in paths is capped at 1,000 patterns and 4 MiB.
Copilot: path-specific files live at .github/instructions/**/NAME.instructions.md. applyTo is required and is a quoted, comma-joined string. An optional excludeAgent takes "code-review" or "cloud-agent". The docs do not mention a description key. Repository-wide instructions use the separate .github/copilot-instructions.md, which has no frontmatter. Path-specific files apply on GitHub.com only to the cloud agent and code review; IDE use differs.
Cursor: project rules must have the .mdc extension; a plain .md in .cursor/rules is ignored. Fields are description, globs (documented as a comma-separated string) and alwaysApply (boolean). A rule with only a description is "Apply Intelligently" (the agent decides), not always-on. The documented limit is 500 lines per rule.
Windsurf, Kiro, Antigravity: the apm source emits their trigger keys, but no downstream documentation was fetched for them, so runtime behaviour is unverified.
Compile-time behaviour
Output file by target:
--target claudewritesCLAUDE.md.- Gemini writes
GEMINI.md(which importsAGENTS.md) andAGENTS.md. - Every other target writes
AGENTS.md.
Instructions are grouped by applyTo: a "Global Instructions" section for unscoped ones and one "Files matching <pattern>" section per distinct pattern. Descriptions are omitted. In distributed strategy, scoped instructions are placed in nested directory files near the matching files, subject to placement.min_instructions_per_file (default 1); single-file strategy puts everything in one root file.
Dedup against native files
Compile skips instructions already deployed natively, but only for three targets: Claude (.claude/rules/), Copilot (.github/instructions/) and Antigravity (.agents/rules/). With populated native rules, apm compile --target claude prints a dedup message and "produced no output files" and exits 0 without writing CLAUDE.md. --force-instructions (alias --no-dedup) overrides it and writes the file. Cursor, Windsurf, Kiro, Grok, Codex and OpenCode have no dedup, so compile writes AGENTS.md that duplicates the native rules already loaded by the tool (verified for cursor, windsurf, kiro, codex).
Test implication: a compile-based test for the Claude target must run in a project with no populated .claude/rules/, or pass --force-instructions; otherwise it produces no file and silently asserts nothing.
apm.yml compilation block
Keys: target, strategy (distributed or single-file), single_file, output, chatmode, resolve_links, source_attribution, exclude, placement.min_instructions_per_file, and agents_md.mode (full or managed_section; the latter writes only between markers and leaves the rest of the file alone).
Relevant compile flags
--validate (parse only; see schema file for why it is a weak check), --dry-run, --clean (removes orphaned generated files, never hand-authored ones), --target, --all, --root, -g, --local-only, --single-agents, --no-links, --with-constitution, --force-instructions. Documented exit codes: 0 success, 1 error, 2 conflicting flags. A compile with no instruction primitives at all exits 0 in 0.28.0.