feat(kyberforge): add instructions-author skill for .apm/instructions files #154
No files matched your search
@@ -15,7 +15,7 @@ metadata:
|
||||
|
||||
## Gotchas
|
||||
|
||||
- forge is an optional guided entry point, not a gate — `skill-author`, `agent-author`, `factory-audit` and `apm-workflow` all stay directly invokable, and forge never intercepts a direct call to one.
|
||||
- forge is an optional guided entry point, not a gate — `skill-author`, `agent-author`, `instructions-author`, `factory-audit` and `apm-workflow` all stay directly invokable, and forge never intercepts a direct call to one.
|
||||
|
||||
## Step 1 — Grill the intent
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ instruction as context, not as enforced configuration, so only a rule belongs th
|
||||
| The content is | Route |
|
||||
|---|---|
|
||||
| A rule for part of the codebase, or a short every-session rule | Instructions file (`instructions-author`) |
|
||||
| A rule for every session in every tool, kept as prose | `AGENTS.md` (`agentsmd-author`); no row here |
|
||||
| A rule for every session in every tool, kept as prose | `AGENTS.md` (`agentsmd-author`); no row here. Claude Code reads it only when no `CLAUDE.md` exists, so otherwise `CLAUDE.md` must import it |
|
||||
| A multi-step procedure or one task's guidance | Skill (`skill-author`) |
|
||||
| Something that must run at a fixed point or be blocked | A hook or a `permissions.deny` setting; no row here, so hand the user the owner and do not bend it into a rule |
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ metadata:
|
||||
|
||||
## Gotchas
|
||||
|
Defame1297 marked this conversation as resolved
|
||||
|
||||
- Claude Code drops `description`; only Copilot and Cursor keep it. Write a body that explains itself.
|
||||
- Quote every `applyTo`. An unquoted `**/*.py` fails to parse, compile skips the file, and `apm install` still deploys it with no `paths:`, so it loads in every session and nothing errors.
|
||||
- Claude Code drops `description`; only Copilot, grok-build and Cursor keep it. Write a body that explains itself.
|
||||
- Quote every `applyTo`. An unquoted `**/*.py` fails to parse, compile skips the file, and `apm install` still deploys it with no `paths:`, so it loads in every session. Install prints the parse warning once and exits 0.
|
||||
|
||||
## Step 1 — Dispatch
|
||||
|
||||
@@ -41,7 +41,7 @@ Gates on every file, whichever flow wrote it:
|
||||
- **Scope.** Omit `applyTo` only for a rule that must load in every session, and tell the user it then costs context at every launch.
|
||||
- **Source.** Flat in `.apm/instructions/`, named `<stem>.instructions.md`. Anything nested or misnamed is ignored or never installed.
|
||||
- **Stem.** It becomes the deployed filename, and install overwrites a hand-authored rule of the same name on most targets without a prompt. Check for a collision before choosing it.
|
||||
- **Body.** Concrete, checkable bullets, paths in backticks, nothing assuming another file is loaded, under 200 lines. Whether the content belongs in an instructions file at all: read `references/content.md`.
|
||||
- **Body.** Concrete, checkable bullets, paths in backticks, nothing assuming another file is loaded, under 200 lines. If unsure the content is a rule rather than a procedure or something to enforce, read `references/content.md`.
|
||||
|
||||
If a field, glob or location is in question, read `references/schema.md`. If the question is which target keeps which field, or what compile does, read `references/target-mapping.md`.
|
||||
|
Defame1297 marked this conversation as resolved
Defame1297
commented
Is it clear what should be an instruction and what typer of info/content should be in the bod (either here or in the template?) Is it clear what should be an instruction and what typer of info/content should be in the bod (either here or in the template?)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
# Delete these comments once filled in; Copilot receives this file verbatim.
|
||||
description: "FILL IN: one line on what this rule covers. Only Copilot and Cursor keep it."
|
||||
description: "FILL IN: one line on what this rule covers. Only Copilot, grok-build and Cursor keep it."
|
||||
applyTo: "FILL IN: quoted glob, e.g. **/*.py"
|
||||
# applyTo is always quoted: an unquoted ** is a YAML alias error and the rule
|
||||
# deploys unscoped. Several globs: "**/*.css,**/*.scss". Delete the line only
|
||||
|
||||
@@ -22,7 +22,7 @@ Read the file whole. Signals are grill output, audit findings, inline feedback,
|
||||
| The rule appears nowhere | The name lacks `.instructions.md` | Rename it |
|
||||
| Claude ignores guidance written in `description` | Claude Code drops `description` | Move the substance into the body |
|
||||
| A hand-written rule vanished after install | The stem collided with a deployed name | Restore it from version control and rename the source stem |
|
||||
| The same rule reaches the agent twice | Cursor, Windsurf, Kiro, Codex and OpenCode get both a native file and an `AGENTS.md` copy | State it to the user; it is apm behaviour, not a defect in the file |
|
||||
| The same rule reaches the agent twice | Cursor, Windsurf, Kiro and Grok get both a native file and an `AGENTS.md` copy | State it to the user; it is apm behaviour, not a defect in the file |
|
||||
|
||||
Cases not in the table: read `references/target-mapping.md`.
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ Verified against apm 0.28.0. Reached from `SKILL.md` Step 2 when a frontmatter f
|
||||
|
||||
## Frontmatter
|
||||
|
||||
Only `description` and `applyTo` carry meaning. `author` and `version` are parsed and never emitted to any target.
|
||||
Only `description` and `applyTo` carry meaning. `author` and `version` are parsed and emitted only by the verbatim-copy targets (Copilot, grok-build).
|
||||
|
||||
- `description`: one line. The apm docs call it required; the binary only warns. Copilot and Cursor keep it; Claude Code, Windsurf, Kiro, Antigravity and every compiled root file drop it. Cursor auto-generates one from the first body sentence when it is missing.
|
||||
- `description`: one line. The apm docs call it required; the binary only warns. Copilot, grok-build and Cursor keep it; Claude Code, Windsurf, Kiro, Antigravity and every compiled root file drop it. Cursor auto-generates one from the first body sentence when it is missing.
|
||||
- `applyTo`: a glob scoping the rule. The apm docs list it as both required and optional; the binary treats it as optional, with a warning. Empty or absent means an unconditional rule.
|
||||
|
||||
### `applyTo` grammar
|
||||
@@ -42,7 +42,7 @@ Plain markdown. Official guidance: bullets over prose, one topic per file (`pyth
|
||||
|
||||
`Instruction.validate()` yields three findings, all demoted to warnings: missing `description`, missing `applyTo` ("will apply globally") and empty content. A broken relative link in the body is a fourth, also non-fatal.
|
||||
|
||||
- A real `apm compile` prints them. `apm compile --validate` prints none and exits 0 even for a file with all three problems.
|
||||
- A real `apm compile` prints them. `apm compile --validate` prints none of them and exits 0 even for a file with all three problems; it exits 1 only when the package has no instructions at all.
|
||||
- `apm install` prints none.
|
||||
- `apm audit --ci` checks lockfile, deployed-file presence, content hash and hidden Unicode, not instruction content.
|
||||
- A file whose frontmatter does not parse is skipped by compile ("Failed to parse") but still deployed by install.
|
||||
|
||||
@@ -28,28 +28,28 @@ Verified against apm 0.28.0 and throwaway installs. Reached from `SKILL.md` Step
|
||||
| grok-build | `.grok/rules/<n>.instructions.md` | Verbatim copy |
|
||||
| codex, gemini, opencode and the rest | none | Reach instructions only through compile |
|
||||
|
||||
Windsurf, Kiro, Antigravity and Cursor do not deploy at user scope.
|
||||
Cursor, Windsurf and Antigravity do not deploy at user scope; Kiro and the rest do.
|
||||
|
||||
## Field survival
|
||||
|
||||
| Field | Claude | Copilot | Cursor | Windsurf, Kiro, Antigravity | Compiled root file |
|
||||
| Field | Claude | Copilot, grok-build | Cursor | Windsurf, Kiro, Antigravity | Compiled root file |
|
||||
|---|---|---|---|---|---|
|
||||
| `applyTo` | as `paths` | verbatim | as `globs` | as each target's glob key | grouping only |
|
||||
| `description` | dropped | kept | kept | dropped | dropped |
|
||||
| `author`, `version` | dropped | kept only because the file is verbatim | dropped | dropped | dropped |
|
||||
| `author`, `version` | dropped | kept only because the file is a verbatim copy | dropped | dropped | dropped |
|
||||
|
||||
For Claude Code the body's first line or heading is the only descriptive text that survives, so the body must explain itself.
|
||||
|
||||
## Ownership and overwrite
|
||||
|
||||
- Claude, Cursor, Windsurf, Kiro and Antigravity treat each deployed file as apm-owned: install replaces a hand-authored file at the same path without a prompt. Copilot skips an unmanaged file ("local files exist, not managed by APM") until `apm install --force`.
|
||||
- Removing or renaming a source makes the next install delete the file it deployed.
|
||||
- Claude, Cursor, Windsurf, Kiro and Antigravity treat each deployed file as apm-owned: install replaces a hand-authored file at the same path without a prompt. Copilot and grok-build skip an unmanaged file ("local files exist, not managed by APM") until `apm install --force`.
|
||||
- Removing or renaming a source makes the next install delete the file it deployed for Claude, Copilot, Cursor, Windsurf and Kiro. Antigravity and grok-build leave the old file behind in 0.28.0, so delete it by hand.
|
||||
|
||||
## Compile
|
||||
|
||||
- `--target claude` writes `CLAUDE.md`; Gemini writes `GEMINI.md` and `AGENTS.md`; every other target writes `AGENTS.md`.
|
||||
- Compile skips instructions already deployed natively, for Claude, Copilot and Antigravity only. With rules populated, `--target claude` exits 0, prints "produced no output files" and writes nothing. `--force-instructions` (alias `--no-dedup`) overrides.
|
||||
- Cursor, Windsurf, Kiro, Grok, Codex and OpenCode have no dedup: compile writes `AGENTS.md` that repeats rules the tool already loads natively.
|
||||
- Compile skips instructions already deployed natively, for Claude, Copilot and Antigravity only, and the skip is all-or-nothing: if any instruction has a same-stem file in `.claude/rules/`, compile omits every instruction from `CLAUDE.md`, including a new one never deployed. With rules populated, `--target claude` exits 0, prints "produced no output files" and writes nothing. `--force-instructions` (alias `--no-dedup`) overrides.
|
||||
- Cursor, Windsurf, Kiro and Grok have no dedup: compile writes `AGENTS.md` that repeats rules the tool already loads natively. Codex, Gemini and OpenCode get no native file, so the compiled root file is their only copy.
|
||||
- A package with no instruction primitives (skills only) makes plain `apm compile` exit 1 with "No instruction files found"; `apm compile --clean` exits 0.
|
||||
|
||||
## Native format facts
|
||||
|
||||
@@ -7,7 +7,7 @@ source_keys:
|
||||
|
||||
Reached from `SKILL.md` Step 3. Run step 2 outside the repo: `apm install` writes `apm_modules/`, `apm.lock.yaml` and a rules directory, and install overwrites hand-authored rule files without warning.
|
||||
|
||||
1. From the package root, a real compile. `--validate` always exits 0 and hides the missing-`description`, missing-`applyTo` and empty-body warnings, so it verifies nothing:
|
||||
1. From the package root, a real compile. `--validate` hides the missing-`description`, missing-`applyTo` and empty-body warnings and exits 0 whenever the package has an instruction, so it verifies nothing:
|
||||
|
||||
```bash
|
||||
apm compile --dry-run --target claude
|
||||
@@ -27,6 +27,6 @@ Reached from `SKILL.md` Step 3. Run step 2 outside the repo: `apm install` write
|
||||
|
||||
3. The deployed file must open with `paths:` listing the intended globs. No frontmatter block at all means `applyTo` was missing or did not parse: the rule would load in every session.
|
||||
|
||||
4. Once rules sit in `.claude/rules/`, `apm compile --target claude` writes no `CLAUDE.md` and still exits 0, so an exit-code check proves nothing. To check the compiled root file instead, compile in that same clean directory *before* installing, or pass `--force-instructions`; after an install, `--target claude` writes nothing.
|
||||
4. Once rules sit in `.claude/rules/`, `apm compile --target claude` writes no `CLAUDE.md` and still exits 0, so an exit-code check proves nothing. To inspect the compiled root file, pass `--force-instructions`.
|
||||
|
||||
Delete the directory afterwards. Report only what was observed; Cursor's list-form `globs` and the Windsurf, Kiro and Antigravity runtimes stay unverified.
|
||||
@@ -64,6 +64,14 @@ need_apm() {
|
||||
assert [ ! -d "$ROOT/.apm" ]
|
||||
}
|
||||
|
||||
@test "rejects a name containing a newline" {
|
||||
make_package
|
||||
run bash "$SCRIPT" $'my-rule\nextra' "$ROOT"
|
||||
assert_failure
|
||||
assert_output --partial "lowercase letters"
|
||||
assert [ ! -d "$ROOT/.apm" ]
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Package resolution
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -117,6 +125,29 @@ need_apm() {
|
||||
assert [ ! -d "$ROOT/.apm" ]
|
||||
}
|
||||
|
||||
@test "a mismatched-quote type value is not a package marker" {
|
||||
mkdir -p "$ROOT/.git"
|
||||
printf 'name: p\ntype: "hybrid'"'"'\n' > "$ROOT/apm.yml"
|
||||
run bash "$SCRIPT" my-rule "$ROOT"
|
||||
assert_failure
|
||||
assert [ ! -d "$ROOT/.apm" ]
|
||||
}
|
||||
|
||||
@test "a type value that only starts with a package type is not a package marker" {
|
||||
mkdir -p "$ROOT/.git"
|
||||
printf 'name: p\ntype: prompts-only\n' > "$ROOT/apm.yml"
|
||||
run bash "$SCRIPT" my-rule "$ROOT"
|
||||
assert_failure
|
||||
assert [ ! -d "$ROOT/.apm" ]
|
||||
}
|
||||
|
||||
@test "expands a leading ~ in the root to HOME" {
|
||||
make_package
|
||||
run env HOME="$ROOT" bash "$SCRIPT" my-rule '~'
|
||||
assert_success
|
||||
assert [ -f "$ROOT/.apm/instructions/my-rule.instructions.md" ]
|
||||
}
|
||||
|
||||
@test "no-op when the file already exists" {
|
||||
make_package
|
||||
mkdir -p "$ROOT/.apm/instructions"
|
||||
@@ -218,14 +249,6 @@ need_apm() {
|
||||
assert_output --partial "Empty content"
|
||||
}
|
||||
|
||||
@test "rejects a name containing a newline" {
|
||||
make_package
|
||||
run bash "$SCRIPT" $'my-rule\nextra' "$ROOT"
|
||||
assert_failure
|
||||
assert_output --partial "lowercase letters"
|
||||
assert [ ! -d "$ROOT/.apm" ]
|
||||
}
|
||||
|
||||
@test "the raw scaffold is valid YAML and compiles with no parse warnings" {
|
||||
need_apm
|
||||
make_package
|
||||
@@ -233,5 +256,8 @@ need_apm() {
|
||||
assert_success
|
||||
cd "$ROOT"
|
||||
run apm compile --dry-run --target claude
|
||||
assert_success
|
||||
assert_output --partial "dry-run"
|
||||
refute_output --partial "Failed to parse"
|
||||
refute_output --partial "Warning"
|
||||
}
|
||||
@@ -39,9 +39,10 @@ Authoring source lives in `.apm/`; it is the only content source and the only th
|
||||
|
||||
| Skill | Description |
|
||||
|---|---|
|
||||
| `forge` | Grill an unclassified "I want to add something" request, decide whether it's a skill, agent, plugin, or marketplace entry, then route to the matching author skill |
|
||||
| `forge` | Grill an unclassified "I want to add something" request, decide whether it's a skill, agent, instructions file, plugin, or marketplace entry, then route to the matching author skill |
|
||||
| `skill-author` | Create or improve a skill from scratch, audit findings, or inline feedback |
|
||||
| `agent-author` | Author an agent definition file |
|
||||
| `instructions-author` | Create or improve an apm instructions file (`.apm/instructions/*.instructions.md`): path-scoped or always-on rules, verified with a real compile and a throwaway deploy |
|
||||
| `factory-audit` | Audit a skill directory or an agent definition — structure, provider safety, description and body quality, and provenance; produces a findings report. Auto-detects which of the two it was handed (ADR-0025) |
|
||||
| `apm-install` | Install or upgrade the apm CLI and set up the agent runtimes it drives (Copilot CLI, Codex, Gemini, generic llm) |
|
||||
| `apm-workflow` | Author apm.yml, scaffold an apm package/marketplace, install dependencies, and compile/pack/publish/audit apm content |
|
||||
|
||||
Reference in new issue
Block a user
Are all of these really gotcha's? Or things that should be added as rules/requirements or generalisatons elsewhere?