Compare commits
19
Commits
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "holocron",
|
||||
"description": "AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.",
|
||||
"version": "0.7.0",
|
||||
"version": "0.5.2",
|
||||
"owner": {
|
||||
"name": "Defame1297",
|
||||
"email": "[email protected]",
|
||||
@@ -11,14 +11,14 @@
|
||||
{
|
||||
"name": "kyberforge",
|
||||
"description": "Skills and agents for creating, maintaining, and managing an apm plugin marketplace for Claude Code and GitHub Copilot.",
|
||||
"version": "2.2.1",
|
||||
"version": "2.1.0",
|
||||
"category": "Developer Tools",
|
||||
"source": "./plugins/kyberforge"
|
||||
},
|
||||
{
|
||||
"name": "bin",
|
||||
"description": "Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.",
|
||||
"version": "3.0.0",
|
||||
"version": "1.1.9",
|
||||
"category": "Utilities",
|
||||
"source": "./plugins/bin"
|
||||
},
|
||||
@@ -36,6 +36,13 @@
|
||||
"category": "Version Control",
|
||||
"source": "./plugins/gitea"
|
||||
},
|
||||
{
|
||||
"name": "onedev",
|
||||
"description": "Skills and agents for working with a OneDev forge through the TOD CLI — the forge's own objects, as distinct from the local git clone.",
|
||||
"version": "0.1.1",
|
||||
"category": "Version Control",
|
||||
"source": "./plugins/onedev"
|
||||
},
|
||||
{
|
||||
"name": "core",
|
||||
"description": "Skills for authoring and auditing a repo's AGENTS.md and the provider adapter files that defer to it.",
|
||||
@@ -43,13 +50,6 @@
|
||||
"category": "Productivity",
|
||||
"source": "./plugins/core"
|
||||
},
|
||||
{
|
||||
"name": "mattpocock",
|
||||
"description": "Matt Pocock's agent skills — planning, grilling, test-first development, triage and bug diagnosis — redistributed from upstream at a pinned release.",
|
||||
"version": "0.4.0",
|
||||
"category": "Productivity",
|
||||
"source": "./plugins/mattpocock"
|
||||
},
|
||||
{
|
||||
"name": "lint",
|
||||
"description": "Skills and agents for configuring and running linters.",
|
||||
|
||||
+35
-18
@@ -27,24 +27,41 @@ repos:
|
||||
stages: ['pre-commit']
|
||||
- id: pretty-format-json
|
||||
stages: ['pre-commit']
|
||||
args: [--autofix, --no-sort-keys]
|
||||
# `--no-sort-keys` is load-bearing. apm OWNS `.claude/settings.json` and its
|
||||
# `.claude/apm-hooks.json` sidecar (ADR-0018, ADR-0019), and
|
||||
# `apm audit --ci` replays the install and diffs the result byte-for-byte.
|
||||
# apm emits insertion order (`matcher` before `hooks`); the formatter's
|
||||
# default sorts keys, rewrites that into a form apm would never produce,
|
||||
# and the `apm-audit-ci` pre-push hook then reports drift on a file with
|
||||
# no git diff (#102, first hit at 2e395a4). Keeping insertion order means
|
||||
# those two files need no exclude. Dropping the flag is caught at pre-push
|
||||
# by `apm-audit-ci` as drift on `.claude/settings.json`.
|
||||
args: [--autofix]
|
||||
# Every generated manifest lives at a KNOWN path, so every alternative is
|
||||
# root-anchored and spells that path out. This was five `(^|/)`
|
||||
# any-depth alternatives plus one `^` root-only one -- a mixture with no
|
||||
# rationale, under which a fixture or vendored tree containing
|
||||
# `.../.claude-plugin/marketplace.json` would have been silently excluded
|
||||
# from formatting while an equivalent
|
||||
# `.../.agents/plugins/marketplace.json` would not. Only the one root
|
||||
# marketplace manifest matches now; anything else is hand-authored and
|
||||
# gets formatted. The twelve per-plugin `plugin.json` alternatives were
|
||||
# dropped with the plugin manifests themselves when native
|
||||
# `claude plugin install` support was removed (ADR-0024) -- apm probes
|
||||
# `apm.yml` and never reached them. The `.agents/plugins/` and
|
||||
# `.github/plugin/` marketplace mirrors went the same way, and their
|
||||
# alternations went with them: `check-useless-excludes` fails on a
|
||||
# pattern that matches no file.
|
||||
#
|
||||
# `.claude-plugin/marketplace.json` is the one remaining exclude. It
|
||||
# round-trips except for non-ASCII: it carries literal em dashes and the
|
||||
# formatter re-escapes them to `\u2014` (`--no-ensure-ascii` would fix that,
|
||||
# but it changes the output for every JSON file). Root-anchored because it
|
||||
# is one known path; `check-useless-excludes` fails on a pattern that
|
||||
# matches no file.
|
||||
exclude: '^\.claude-plugin/marketplace\.json$'
|
||||
# `.claude/settings.json` and its `.claude/apm-hooks.json` ownership
|
||||
# sidecar are the last two alternations, and they are the only ones
|
||||
# here for a reason other than "generated manifest":
|
||||
# apm OWNS that file (ADR-0018, ADR-0019), and
|
||||
# `apm audit --ci` replays the install into a scratch tree and diffs
|
||||
# the result byte-for-byte. `pretty-format-json` sorts object keys
|
||||
# unless `--no-sort-keys` is passed, while apm's hook integrator emits
|
||||
# insertion order (`matcher` before `hooks`, `type` before `command`).
|
||||
# Formatting the file therefore rewrites apm's output into a form apm
|
||||
# would never produce, and the `apm-audit-ci` pre-push hook reports it
|
||||
# as permanent drift on a file with no git diff -- exactly what
|
||||
# happened when the SessionStart hook first landed in 2e395a4.
|
||||
# Re-running `apm install` fixes the file; leaving it in scope here
|
||||
# would re-break it on the very commit that carries the fix. The
|
||||
# sidecar is committed so a fresh clone's install can claim the
|
||||
# settings entry instead of duplicating it (ADR-0019, 2026-09-16
|
||||
# correction), and it is apm output under the same byte-for-byte replay.
|
||||
exclude: '^(\.claude-plugin/marketplace\.json|\.claude/(settings|apm-hooks)\.json)$'
|
||||
- id: check-yaml
|
||||
stages: ['pre-commit']
|
||||
- id: trailing-whitespace
|
||||
@@ -107,7 +124,7 @@ repos:
|
||||
# deployed files to check. Running every plugin package is what
|
||||
# makes lockfile-exists reachable for them at all -- the root-only
|
||||
# invocation audits the root manifest and nothing else.
|
||||
# THAT ARMING NOW HAPPENS: plugins/mattpocock declares real dependencies,
|
||||
# THAT ARMING NOW HAPPENS: plugins/onedev declares a real dependency,
|
||||
# and there is no green state for it -- without a package lockfile
|
||||
# lockfile-exists fails, and with one it passes and arms the other
|
||||
# nine, where drift then demands the dependency's skills be deployed
|
||||
|
||||
@@ -35,7 +35,7 @@ Fall back to raw shell only when no skill covers it.
|
||||
|
||||
## Key documents
|
||||
|
||||
Read `GLOSSARY.md` at the start of every session — it is this repo's domain glossary, and the terms it defines are used unglossed everywhere else. It is not exhaustive: terms it does not carry are defined at their point of use, mostly in `docs/spec/`.
|
||||
Read `CONTEXT.md` at the start of every session — it is this repo's domain glossary, and the terms it defines are used unglossed everywhere else. It is not exhaustive: terms it does not carry are defined at their point of use, mostly in `docs/spec/`.
|
||||
|
||||
Read these on demand:
|
||||
|
||||
@@ -49,17 +49,3 @@ Read these on demand:
|
||||
- `docs/research/ai-coding-factory/ai-coding-factory-principles.md` — factory design rationale; read when implementing, auditing, or reviewing skills or factory structure
|
||||
- `docs/notes/factory-integration-decisions.md` — decisions from the factory integration grill; read when making skill authoring or factory design decisions
|
||||
- Governance rules are always in effect — `core/instructions/governance.md` (agent rules); `docs/research/governance_principles/CONTROLS.md`
|
||||
|
||||
## Agent skills
|
||||
|
||||
### Issue tracker
|
||||
|
||||
Issues and PRs live in Gitea (`Defame1297/holocron`), reached through the `gitea-*` skills. See `docs/agents/issue-tracker.md`.
|
||||
|
||||
### Triage labels
|
||||
|
||||
Default five roles, mapped onto Gitea's `Status/*` and `Reviewed/*` labels. See `docs/agents/triage-labels.md`.
|
||||
|
||||
### Domain docs
|
||||
|
||||
Single-context: `GLOSSARY.md` and `docs/adr/` at the repo root. See `docs/agents/domain.md`.
|
||||
+41
-12
@@ -45,19 +45,35 @@ _Avoid_: agent hygiene
|
||||
### Distribution
|
||||
|
||||
**Skill**:
|
||||
A reusable capability defined as a `SKILL.md` file following the
|
||||
A reusable slash command defined as a `SKILL.md` file following the
|
||||
[Agent Skills open standard](https://agentskills.io), authored at
|
||||
`plugins/<plugin>/.apm/skills/<skill>/SKILL.md`. It is loaded by description-matching, or typed by
|
||||
hand when declared a **Hand-invoked skill**. A single-file command that is not a `SKILL.md` is a
|
||||
**Prompt file**.
|
||||
_Avoid_: command, prompt, macro
|
||||
`plugins/<plugin>/.apm/skills/<skill>/SKILL.md`.
|
||||
_Avoid_: command, macro; and "prompt" for a skill — a **Prompt** is a different artifact
|
||||
|
||||
**Prompt file**:
|
||||
An apm primitive authored as a single file at `.apm/prompts/<name>.prompt.md`. apm rewrites it per
|
||||
target: Copilot gets a verbatim copy, the Claude family gets a slash command, and Gemini gets a TOML
|
||||
command. It is not a **Skill**: it has no `SKILL.md`, no `references/` and no description-matching.
|
||||
_Avoid_: bare "prompt" (collides with an agent's system prompt and the `prompts` package type),
|
||||
"command" (the per-target deployed name), "skill"
|
||||
**Prompt**:
|
||||
A single-intent, user-triggered message with parameters, authored as
|
||||
`plugins/<plugin>/.apm/prompts/<name>.prompt.md` — the text a user would otherwise type repeatedly.
|
||||
It carries no procedure beyond steering existing skills or agents by name; once it holds reusable
|
||||
know-how, bundled files, or anything the model should find on its own, it is a **Skill** in the
|
||||
wrong container. This is a house rule, stricter than apm, which frames a prompt as a full workflow.
|
||||
_Avoid_: command (the Claude-side deployed form), workflow, macro
|
||||
|
||||
**Instruction**:
|
||||
A scoped rule authored as `plugins/<plugin>/.apm/instructions/<name>.instructions.md`, applied when
|
||||
the agent touches files matching its `applyTo` glob. Omitting `applyTo` makes it always-on in every
|
||||
session of every repo that installs the package — a legitimate way for a package to ship guidance to
|
||||
consumers, but a deliberate choice, never a default. A rule for this repo alone belongs in
|
||||
**AGENTS.md**, not in an instruction.
|
||||
_Avoid_: rule (the Claude-side deployed form under `.claude/rules/`), guideline, standard
|
||||
|
||||
**Hook**:
|
||||
A runtime callback a harness fires inside its own tool loop, authored as JSON under
|
||||
`plugins/<plugin>/.apm/hooks/` — one file or several; kyberforge ships a single `hooks.json` — in
|
||||
apm's canonical shape — nested entries, PascalCase events, `${PLUGIN_ROOT}` script paths — which
|
||||
apm renders per target. Reach is narrowed in the package's
|
||||
`apm.yml` `targets:`, never by filename. The last resort among apm primitives: procedure belongs in
|
||||
a **Skill**, and a hook is only for "this must always happen at this event".
|
||||
_Avoid_: trigger, callback script (the script is the hook's payload, not the hook)
|
||||
|
||||
**apm package**:
|
||||
The deployable unit apm builds and installs — one or more skills, agents, hooks, commands, and MCP
|
||||
@@ -67,6 +83,13 @@ _Avoid_: bundle, module, source tree; and bare "plugin" for the *installable art
|
||||
ADR-0024 is an apm package and not a Claude Code plugin. "Plugin" stays correct as a modifier in the
|
||||
repo's settled compounds — **Plugin marketplace**, "plugin units", `plugins/`.
|
||||
|
||||
**apm primitive**:
|
||||
Any content type authored under `plugins/<name>/.apm/` — skills, agents, hooks, instructions, and
|
||||
prompts. Skills and agents each have their own author skill; `primitive-author` covers the other
|
||||
three, so its name is narrower in practice than the term. `factory-audit` audits all five.
|
||||
_Avoid_: component, asset, artifact (unqualified); bare "primitive" when only the three
|
||||
non-skill, non-agent types are meant — say "hook, instruction, or prompt"
|
||||
|
||||
**Output profile**:
|
||||
A named ecosystem format `apm pack` can compile the marketplace manifest into, declared per profile
|
||||
under root `apm.yml`'s `marketplace.outputs:`. apm defines `claude` and `codex`; each writes to its
|
||||
@@ -84,7 +107,7 @@ resolve against.
|
||||
_Avoid_: the marketplace, upstream
|
||||
|
||||
**Provenance chain**:
|
||||
The three-stage traceability record linking a skill back to its research inputs: `/research-docs` produces
|
||||
The three-stage traceability record linking a skill back to its research inputs: `/research` produces
|
||||
topic docs and a `sources.md`; the author skill records which sources informed which files in
|
||||
`references/sources.md` and `source_keys` frontmatter; `factory-audit` validates the chain is complete
|
||||
and internally consistent.
|
||||
@@ -202,3 +225,9 @@ _Avoid_: namespace, category
|
||||
an audit running in the same context as the work it checks shares that work's blind spots. The
|
||||
recheck belongs to `factory-audit`, not to `forge`, which routes only to the author
|
||||
skills and never to an audit.
|
||||
- "prompt" meant both apm's `.prompt.md` primitive and, loosely, any slash command or a skill — resolved:
|
||||
a **Prompt** is the `.prompt.md` primitive under the house rule above. apm frames a prompt as a
|
||||
program ("a prompt is a program for an LLM", its "What is APM?" page), but on Claude it deploys
|
||||
as a model-invocable command with fewer frontmatter keys than a skill, and Codex receives
|
||||
nothing. A fat prompt is a worse skill on every harness, so the procedure goes in the skill and
|
||||
the prompt only steers it.
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
Patterns observed during development of this repo. Three or more entries on the same pattern → promote to `docs/spec/architecture.md` (or the relevant instruction file) as a standing rule.
|
||||
|
||||
**Graduation rule:** When three or more entries cover the same pattern, the human reviews and promotes it to the appropriate standing location: `docs/spec/architecture.md` for structural and domain-level principles — `GLOSSARY.md` is not a destination, its `## Principles` section was deleted and what was there now sits under that file's "AGENTS.md pattern" and "Reference conventions" headings — `core/instructions/coding.md` for coding conventions, `core/instructions/testing.md` for testing conventions, or `core/instructions/subagent-orchestration.md` for delegation conventions. Those four are the whole set — `core/instructions/` holds `coding.md`, `governance.md`, `subagent-orchestration.md` and `testing.md`, and nothing else. Git conventions have no standing file of their own: promote them to `core/instructions/coding.md`, or create a new instruction file deliberately rather than assuming one exists. The graduated entries are marked `[graduated → target file]` rather than deleted (audit trail).
|
||||
**Graduation rule:** When three or more entries cover the same pattern, the human reviews and promotes it to the appropriate standing location: `docs/spec/architecture.md` for structural and domain-level principles — `CONTEXT.md` is not a destination, its `## Principles` section was deleted and what was there now sits under that file's "AGENTS.md pattern" and "Reference conventions" headings — `core/instructions/coding.md` for coding conventions, `core/instructions/testing.md` for testing conventions, or `core/instructions/subagent-orchestration.md` for delegation conventions. Those four are the whole set — `core/instructions/` holds `coding.md`, `governance.md`, `subagent-orchestration.md` and `testing.md`, and nothing else. Git conventions have no standing file of their own: promote them to `core/instructions/coding.md`, or create a new instruction file deliberately rather than assuming one exists. The graduated entries are marked `[graduated → target file]` rather than deleted (audit trail).
|
||||
|
||||
**Who writes here:** The session-handoff skill (Chunk 3) prompts LESSONS.md extraction before closing a session. The human may also write directly.
|
||||
|
||||
@@ -128,7 +128,7 @@ Widening a description-opener rule to also catch mid-sentence text looked like a
|
||||
|
||||
## 2026-08-14 — A formatter in the commit path manufactures drift on a file with a clean git diff
|
||||
|
||||
`apm audit --ci` failed on `.claude/settings.json` with an empty `git diff` — `pretty-format-json --autofix` silently re-sorts JSON keys, and this generated file was missing from its exclude list, so every commit re-sorted apm's insertion-ordered output before apm compared against it. Separately, a defect introduced 3 hours earlier on the same branch was first mis-described as "pre-existing," an unverified claim about history. Fix: add tool-owned paths to every autofixing hook's exclude the moment ownership is declared (for JSON, superseded by #102: `--no-sort-keys` makes the exclude unnecessary), and verify "pre-existing" claims with `git log -S` or `git branch --contains` before writing them down.
|
||||
`apm audit --ci` failed on `.claude/settings.json` with an empty `git diff` — `pretty-format-json --autofix` silently re-sorts JSON keys, and this generated file was missing from its exclude list, so every commit re-sorted apm's insertion-ordered output before apm compared against it. Separately, a defect introduced 3 hours earlier on the same branch was first mis-described as "pre-existing," an unverified claim about history. Fix: add tool-owned paths to every autofixing hook's exclude the moment ownership is declared, and verify "pre-existing" claims with `git log -S` or `git branch --contains` before writing them down.
|
||||
|
||||
## 2026-08-16 — A rule reversed inside a retrofit leaves no trace unless someone writes it down (historical)
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ Consume the packages through apm, the way this repo does — declare them as `de
|
||||
## Where to go next
|
||||
|
||||
- [`AGENTS.md`](AGENTS.md) — the rules for AI agents working in this repo
|
||||
- [`GLOSSARY.md`](GLOSSARY.md) — domain language; read at the start of every session here
|
||||
- [`CONTEXT.md`](CONTEXT.md) — domain language; read at the start of every session here
|
||||
- [`docs/spec/architecture.md`](docs/spec/architecture.md) — directory structure, install pipeline, provider model
|
||||
- [`docs/spec/gates.md`](docs/spec/gates.md) — the enforcement gates in depth
|
||||
- [`docs/adr/`](docs/adr/) — architectural decisions; read before proposing structural changes
|
||||
|
||||
+356
-1342
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
name: holocron
|
||||
version: 0.7.0
|
||||
version: 0.5.2
|
||||
description: AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.
|
||||
license: MIT
|
||||
|
||||
@@ -28,13 +28,18 @@ dependencies:
|
||||
path: plugins/kyberforge
|
||||
- git: [email protected]:Defame1297/holocron.git
|
||||
path: plugins/lint
|
||||
# Third-party skills (Matt Pocock's) arrive transitively through this
|
||||
# wrapper rather than as direct entries, so the marketplace and this repo
|
||||
# consume them by the same path. The pins live in plugins/mattpocock/apm.yml:
|
||||
# third-party content is pinned, unlike the first-party entries above,
|
||||
# which stay unpinned for default-branch parity.
|
||||
# TOD's skills arrive transitively through this wrapper rather than as a
|
||||
# direct entry, so the marketplace and this repo consume onedev by the same
|
||||
# path. The pin lives in plugins/onedev/apm.yml: third-party content is
|
||||
# pinned, unlike the six first-party entries above, which stay unpinned for
|
||||
# default-branch parity.
|
||||
#
|
||||
# Resolves only once plugins/onedev is on the remote's main — until then
|
||||
# `apm install` fails, which includes the copy kyberforge's SessionStart
|
||||
# hook runs on launch. Accepted deliberately: this branch is merging
|
||||
# immediately.
|
||||
- git: [email protected]:Defame1297/holocron.git
|
||||
path: plugins/mattpocock
|
||||
path: plugins/onedev
|
||||
mcp: []
|
||||
|
||||
# Turns apm's executable-trust gate ON. Without this block the gate is disabled
|
||||
@@ -56,7 +61,7 @@ dependencies:
|
||||
# an apm mechanic.
|
||||
executables:
|
||||
allow:
|
||||
kyberforge#2.2.1:
|
||||
kyberforge#2.1.0:
|
||||
hooks: true
|
||||
bin: true
|
||||
|
||||
@@ -66,7 +71,7 @@ marketplace:
|
||||
# top-level apm.yml description:/version: above are NOT inherited into the
|
||||
# compiled output despite being used elsewhere (e.g. by `apm audit`).
|
||||
description: AI development skills for Claude Code, and for GitHub Copilot through apm — factory, design, implement, review, and cross-cutting workflows.
|
||||
version: 0.7.0
|
||||
version: 0.5.2
|
||||
owner:
|
||||
name: Defame1297
|
||||
email: [email protected]
|
||||
@@ -104,14 +109,14 @@ marketplace:
|
||||
source: ./plugins/gitea
|
||||
category: Version Control
|
||||
|
||||
- name: onedev
|
||||
source: ./plugins/onedev
|
||||
category: Version Control
|
||||
|
||||
- name: core
|
||||
source: ./plugins/core
|
||||
category: Productivity
|
||||
|
||||
- name: mattpocock
|
||||
source: ./plugins/mattpocock
|
||||
category: Productivity
|
||||
|
||||
- name: lint
|
||||
source: ./plugins/lint
|
||||
category: Developer Tools
|
||||
@@ -18,4 +18,4 @@ Three alternatives were rejected. Keeping the file-based fallback adds code comp
|
||||
|
||||
The file-based model also had a structural weakness: issues in `docs/issues/` were invisible from the Gitea UI, making it impossible to track work, assign milestones, or filter by label without opening the repo locally. Gitea provides all of that natively.
|
||||
|
||||
The "Provider-agnostic issue tracker" glossary entry in GLOSSARY.md is updated in the same workstream to remove the file-based phase framing. (Amended 2026-08-17: the GLOSSARY.md trim renamed that entry to **Issue**; it still records Gitea as this repo's canonical tracker and still tells skills to say "linked issue" generically.) The `providers/gitea/` adapter path described in ADR-0011 was never implemented — Gitea integration runs entirely via MCP, not a provider adapter.
|
||||
The "Provider-agnostic issue tracker" glossary entry in CONTEXT.md is updated in the same workstream to remove the file-based phase framing. (Amended 2026-08-17: the CONTEXT.md trim renamed that entry to **Issue**; it still records Gitea as this repo's canonical tracker and still tells skills to say "linked issue" generically.) The `providers/gitea/` adapter path described in ADR-0011 was never implemented — Gitea integration runs entirely via MCP, not a provider adapter.
|
||||
@@ -4,16 +4,16 @@ Issue #84 wired Vale as a deterministic prefilter for `skill-audit`/`agent-audit
|
||||
`factory-audit`'s two flows by ADR-0025; read every mention of the pair below that way), scoped to
|
||||
exactly four pattern-matchable checks (imperative description opener, vague capability wording,
|
||||
generic reference-pointer padding, Copilot's dead `Use proactively` phrasing), documented only in
|
||||
GLOSSARY.md's "Vale audit prefilter" section — never its own ADR — and explicitly excluding body
|
||||
CONTEXT.md's "Vale audit prefilter" section — never its own ADR — and explicitly excluding body
|
||||
discipline, near-miss exclusion strength, and control calibration as non-goals. This ADR records a
|
||||
deferred PR #85 review item to broaden that coverage, retroactively captures #84's own rationale
|
||||
(since it was never recorded as a decision in its own right), and layers the expansion on top
|
||||
without reversing or weakening the original four rules.
|
||||
|
||||
**2026-08-17 amendment.** The GLOSSARY.md section named above no longer holds that documentation.
|
||||
GLOSSARY.md was cut back to a glossary and the prefilter's mechanics — the two-copy style layout,
|
||||
**2026-08-17 amendment.** The CONTEXT.md section named above no longer holds that documentation.
|
||||
CONTEXT.md was cut back to a glossary and the prefilter's mechanics — the two-copy style layout,
|
||||
`vale-wrap.sh`, the `--config` argv defect, the rule inventory, and the 0-files-means-NOT-RUN
|
||||
fallback — moved to `docs/spec/gates.md`. Read that file, not GLOSSARY.md, for the harness itself;
|
||||
fallback — moved to `docs/spec/gates.md`. Read that file, not CONTEXT.md, for the harness itself;
|
||||
this ADR still owns the scope decision.
|
||||
|
||||
**File scope stays the same.** `SKILL.md` plus agent files (`**/agents/*.md`,
|
||||
|
||||
@@ -60,9 +60,9 @@ new hand-maintained manifest format.
|
||||
- Translating the existing plugins into `apm.yml` + `.apm/` and running the real conversion was
|
||||
executed under issue #90 (https://git.dev.rkdr.net/Defame1297/holocron/issues/90), which tracks
|
||||
that work through to merge.
|
||||
- `GLOSSARY.md`'s "Plugin"/"Plugin marketplace" glossary entries were rewritten in issue #90 to
|
||||
- `CONTEXT.md`'s "Plugin"/"Plugin marketplace" glossary entries were rewritten in issue #90 to
|
||||
describe the compiled-output model directly, rather than carrying a forward-pointer to this ADR.
|
||||
Superseded 2026-08-17: GLOSSARY.md was cut back to one-line definitions, and the compiled-output
|
||||
Superseded 2026-08-17: CONTEXT.md was cut back to one-line definitions, and the compiled-output
|
||||
model is now described in `docs/spec/architecture.md`. The same trim deleted the "lint plugin"
|
||||
entry cited under Considered options below; that pointer now reads `docs/spec/architecture.md`'s
|
||||
plugin scope table, which carries the repo-agnostic-versus-marketplace-specific argument.
|
||||
|
||||
@@ -339,9 +339,9 @@ mirror does carry, and is reported.
|
||||
- ADR-0015's "Status: executed" now carries a pointer to this ADR (see that ADR's Consequences)
|
||||
rather than being rewritten — the manifest-compilation half of its execution was correct and
|
||||
stands; this ADR fixes the second, previously-unverified half.
|
||||
- `GLOSSARY.md`'s "Plugin" and "Plugin marketplace" glossary entries are updated to describe the
|
||||
- `CONTEXT.md`'s "Plugin" and "Plugin marketplace" glossary entries are updated to describe the
|
||||
flat mirror as a second compiled-output category, alongside the existing
|
||||
`.claude-plugin/plugin.json`/`marketplace.json` description. Superseded 2026-08-17: GLOSSARY.md was
|
||||
`.claude-plugin/plugin.json`/`marketplace.json` description. Superseded 2026-08-17: CONTEXT.md was
|
||||
cut back to one-line definitions and no longer describes either compiled-output category;
|
||||
`docs/spec/architecture.md` is where the mirror is documented.
|
||||
- A future apm release that ships a native `.apm/`-aware plugin.json compiler (closing this gap
|
||||
|
||||
@@ -69,14 +69,14 @@ answers to `git-commits` and `kyberforge:skill-audit` to `skill-audit` (**Amende
|
||||
2026-09-15:** `skill-audit` was removed and its flow merged into `factory-audit`, so the live
|
||||
example is `kyberforge:factory-audit` to `factory-audit`; the rule is unchanged). This is not
|
||||
configurable —
|
||||
a project skill has no plugin to prefix. `AGENTS.md` and `GLOSSARY.md` are updated to name the bare
|
||||
a project skill has no plugin to prefix. `AGENTS.md` and `CONTEXT.md` are updated to name the bare
|
||||
form, which is what apm deploys and the only form a repo consuming holocron through apm gets.
|
||||
|
||||
**Correction (2026-08-14): the namespaced form did not stop resolving.** *Superseded by the
|
||||
2026-08-17 correction below: the machine state this cites is no longer present. Both are kept
|
||||
because the pair is the finding — read neither as current.* An earlier revision of
|
||||
this consequence said every `<plugin>:<skill>` reference "was stale the moment the switch landed",
|
||||
and `AGENTS.md`/`GLOSSARY.md` were written to match. That contradicts the "User scope is untouched,
|
||||
and `AGENTS.md`/`CONTEXT.md` were written to match. That contradicts the "User scope is untouched,
|
||||
deliberately" consequence below, and the contradiction resolves against it: `~/.claude.json` still
|
||||
enables `core`, `git`, `gitea`, `kyberforge` and `lint` at user scope, so both names are live at
|
||||
once and a working `gitea:gitea-prs` is the user-scope copy answering. That doubling is the same
|
||||
@@ -97,7 +97,7 @@ are not there, and neither is the state the *original* consequence described bef
|
||||
about the namespaced form has now been written twice off two different observations of the same
|
||||
machine, and this ADR has already reversed itself once on it. That is the finding: the fact is
|
||||
machine state, not a property of this decision, and it changes without any commit. No instruction
|
||||
file — `AGENTS.md`, `GLOSSARY.md`, or a skill body — should assert either way whether
|
||||
file — `AGENTS.md`, `CONTEXT.md`, or a skill body — should assert either way whether
|
||||
`<plugin>:<skill>` resolves. The rule that survives every observation is the one that was always the
|
||||
actionable half: write the bare name, because it is the only form `apm install` produces.
|
||||
|
||||
|
||||
@@ -34,7 +34,9 @@ behind and refreshes it in place.
|
||||
*session* loads, and that is the moment the staleness does damage. It also enables two things a git
|
||||
hook structurally cannot do: `additionalContext` puts the notice into the agent's context rather
|
||||
than terminal scrollback nobody reads, and `reloadSkills: true` makes the host re-scan the skill
|
||||
directories after the hook returns, so a refresh lands in the running session without a restart.
|
||||
directories after the hook returns, so a refresh lands in the running session without a restart
|
||||
(`reloadSkills` is a documented `SessionStart` `hookSpecificOutput` field:
|
||||
code.claude.com/docs/en/hooks, checked 2026-09-29).
|
||||
|
||||
apm's own lifecycle events (`pre-/post-install`, `pre-/post-update`, `pre-/post-uninstall`) were
|
||||
rejected: they fire around apm operations already chosen, so they can announce a refresh but never
|
||||
@@ -51,8 +53,9 @@ Three sub-decisions:
|
||||
drift. A hook shipped in a package is written into that file by apm itself, so it is apm's output
|
||||
and does not drift. `.claude/settings.local.json` also works but is gitignored and machine-local,
|
||||
which fails the requirement that this travel with the repo.
|
||||
- **`startup` matcher only.** `resume`, `clear`, `compact` and `fork` would re-run the check on every
|
||||
compaction, and a compaction is not an event after which the remote can have moved.
|
||||
- **`startup` matcher only.** `resume`, `clear`, `compact` and `fork` — the other documented
|
||||
`SessionStart` matchers (code.claude.com/docs/en/hooks, checked 2026-09-29) — would re-run the check
|
||||
on every compaction, and a compaction is not an event after which the remote can have moved.
|
||||
|
||||
The executable-trust gate is switched on at the same time. Root `apm.yml` gains an `executables:`
|
||||
block allowing kyberforge's hooks and bin.
|
||||
@@ -124,6 +127,9 @@ A test pins the reference.
|
||||
> `plugins/kyberforge/hooks/` no longer exists at all — so `${CLAUDE_PLUGIN_ROOT}/hooks/...` still
|
||||
> names a path with nothing at it, now because the directory is gone rather than because a sync
|
||||
> emptied it. `tests/test-apm-current-hook.sh` still pins the literal string.
|
||||
>
|
||||
> *Superseded in part by the 2026-09-28 amendment below: the token is now `${PLUGIN_ROOT}`. The
|
||||
> `.apm/`-path conclusion is unchanged.*
|
||||
|
||||
**Session startup gets slower when the install is stale.** Measured: ~0.7 s for the `apm outdated`
|
||||
check when everything is current, ~10.4 s when six packages are behind and the refresh runs. The
|
||||
@@ -139,6 +145,22 @@ value to be larger — so changing either side without the other fails the suite
|
||||
> Re-measured: ~24–26 s for the same six-behind refresh, warm, on a LAN remote — well inside the
|
||||
> 380 s above.
|
||||
|
||||
> **Amendment (2026-09-29) — the time limits are harder to escape, and portable.** Four changes to
|
||||
> `check-apm-current.sh` (PR #144):
|
||||
>
|
||||
> - Both limits are now `timeout -k 5`: a child that ignores SIGTERM is SIGKILLed 5 s later. The
|
||||
> worst case is 60 + 5 + 300 + 5 = 370 s, still below the host's 380, and the test now sums each
|
||||
> limit plus its grace.
|
||||
> - `timeout` falls back to `gtimeout` (Homebrew coreutils on macOS). With neither on `PATH` the
|
||||
> hook emits a notice and exits without calling `apm`. Before, the missing binary exited 127, the
|
||||
> `|| exit 0` swallowed it, and the hook silently never ran.
|
||||
> - `GIT_TERMINAL_PROMPT=0` is exported, so a remote that wants credentials fails at once instead of
|
||||
> blocking on an invisible prompt until the timeout fires.
|
||||
> - `apm update` runs under `flock -n` on `apm_modules/.kyberforge-apm-update.lock` when `flock` exists
|
||||
> and `apm_modules/` does. A second session starting at the same moment skips its refresh and says
|
||||
> so, instead of running a second `apm update` over the same tree. Without `flock` (stock macOS) the
|
||||
> refresh runs unserialised, as before.
|
||||
|
||||
**Reading a human-readable CLI for a control decision cost a silent failure, again.** `apm outdated`
|
||||
has no `--json` or other machine-readable flag (confirmed against 0.28.0), so the hook must match
|
||||
its prose. The first attempt matched `outdated dependencies found` — plural only. apm emits
|
||||
@@ -201,9 +223,20 @@ Until then the repo has the mechanism in source and not in effect.
|
||||
> and it does not last. At the next session start the hook finds the restored lock behind `main`
|
||||
> and refreshes again.
|
||||
|
||||
> **Amendment (2026-09-19) — the advice is neutral when the default branch is unknown.** The hook
|
||||
> picks its lock advice by comparing the current branch with `refs/remotes/origin/HEAD`. That ref is
|
||||
> often unset: git writes it on clone, and `git remote add` never does. The fallback used to be
|
||||
> `main`, which told a checkout whose default branch is `master` to discard a real lock update while
|
||||
> it stood on its default branch. Now, when `origin/HEAD` is unset, the notice gives neither the
|
||||
> default-branch nor the feature-branch advice. It says only "commit it or discard it
|
||||
> deliberately", the same text used outside a git checkout or on a detached HEAD. Learning the
|
||||
> remote's default would need the network, so the hook asserts nothing and the reader decides
|
||||
> (`ea119d8`).
|
||||
|
||||
**`.claude/settings.json` stops being `{"hooks": {}}`.** apm merges the hook into it and tracks
|
||||
ownership in a `.claude/apm-hooks.json` sidecar, with the script copied to
|
||||
`.claude/hooks/<pkg>/`. The sidecar and the script directory are gitignored install output; the
|
||||
`.claude/hooks/<pkg>/`. The sidecar and the script directory are gitignored install output
|
||||
(*superseded for the sidecar: it is committed, see correction 2026-09-16 below*); the
|
||||
settings file remains committed, now with apm-generated content in it. ADR-0018's statement that the
|
||||
committed content is exactly `{"hooks": {}}` is superseded on that point only — the rule it was
|
||||
protecting, that nothing repo-authored goes in that file, is unchanged.
|
||||
@@ -220,7 +253,9 @@ protecting, that nothing repo-authored goes in that file, is unchanged.
|
||||
|
||||
**Native consumers are protected by a guard, not by the gate.** A host installing holocron through
|
||||
`claude plugin install` auto-discovers `hooks/hooks.json` and does not consult apm's trust gate at
|
||||
all. The script therefore exits silently when there is no `apm.lock.yaml` in the working directory,
|
||||
all. The script therefore exits silently when there is no `apm.lock.yaml` in the working directory
|
||||
(*superseded: it now checks `${CLAUDE_PROJECT_DIR}/apm.lock.yaml` and has no cwd fallback, see
|
||||
correction 2026-09-28 below*),
|
||||
which is what makes it inert in a repo that does not consume packages through apm. Copilot CLI sees
|
||||
no hook at all, for the reasons already documented in `plugins/kyberforge/docs/hooks.md`.
|
||||
|
||||
@@ -234,6 +269,46 @@ no hook at all, for the reasons already documented in `plugins/kyberforge/docs/h
|
||||
> lockfile there is nothing for `apm update` to refresh, so exiting silently is the correct
|
||||
> behaviour rather than a defensive measure aimed at a second installer. The Copilot CLI sentence is
|
||||
> unaffected.
|
||||
>
|
||||
> *The Copilot CLI sentence is superseded by the 2026-09-28 amendment below.*
|
||||
|
||||
> **Amendment (2026-09-28) — target-neutral token; the hook reaches Copilot and Codex, accepted.**
|
||||
> Two corrections from the apm 0.28.0 research pass behind `primitive-author` (issue #94;
|
||||
> `plugins/kyberforge/docs/research/docs/microsoft-apm/hooks-primitive-schema.md`).
|
||||
>
|
||||
> *The token.* `hooks.json` now references `${PLUGIN_ROOT}/.apm/hooks/check-apm-current.sh`. apm
|
||||
> documents `${PLUGIN_ROOT}` as its target-neutral token and rewrites it exactly as it rewrites
|
||||
> `${CLAUDE_PLUGIN_ROOT}`: two scratch packages differing only in the token deploy byte-identical
|
||||
> `SessionStart` entries, matching the one committed in `.claude/settings.json`. The `.apm/`-path
|
||||
> rule above is unchanged, and `tests/test-apm-current-hook.sh` pins the new literal.
|
||||
>
|
||||
> *The reach.* "Copilot CLI sees no hook at all" was wrong for apm installs. `targets:` is
|
||||
> package-wide, and kyberforge declares `claude`, `copilot` and `codex`, so apm also writes the hook
|
||||
> to `.github/hooks/kyberforge-hooks.json` — event renamed to `sessionStart`, path rewritten,
|
||||
> `version: 1` added, the nested Claude shape otherwise passed through unreshaped — and merges it
|
||||
> into `.codex/hooks.json` whenever `.codex/` exists. Whether Copilot CLI executes a nested entry or
|
||||
> honours `matcher` is unverified. This is **accepted**: the hook's behaviour is Claude-specific (the
|
||||
> `startup` matcher, `CLAUDE_PROJECT_DIR`, the `reloadSkills` output) and the `apm.lock.yaml` guard
|
||||
> keeps it inert where there is nothing to refresh. Keeping it Claude-only the apm-native way would
|
||||
> need a separate package declaring `target: claude` — the seventh-plugin alternative below, still
|
||||
> rejected as disproportionate — because per-file routing (`claude-hooks.json`) is deprecated and
|
||||
> narrowing kyberforge's own `targets:` would drop its skills from Copilot and Codex.
|
||||
>
|
||||
> *The "inert" rationale for the reach is superseded by the correction below.*
|
||||
|
||||
> **Correction (2026-09-28) — the lockfile guard never made the hook inert under Copilot or Codex;
|
||||
> a `CLAUDE_PROJECT_DIR` guard now does.** The hook only reaches a project through `apm install`,
|
||||
> which writes `apm.lock.yaml`, so in every project that receives it the lockfile guard passes. The
|
||||
> script then fell back to `$PWD` for its project directory and ran `apm outdated`, and
|
||||
> `apm update --yes` when anything was stale — a lock rewrite and full redeploy on a Copilot or Codex
|
||||
> session start, with no `reloadSkills` or advice that harness understands. The hook is now Claude
|
||||
> Code only: `check-apm-current.sh` opens with `[[ -n "${CLAUDE_PROJECT_DIR:-}" ]] || exit 0`, the
|
||||
> cwd fallback is gone, and `tests/test-apm-current-hook.sh` pins that an unset or empty
|
||||
> `CLAUDE_PROJECT_DIR` exits 0 silently without invoking `apm`. apm still deploys the hook to
|
||||
> Copilot and Codex; it exits immediately there. The acceptance stands on that guard, not on the
|
||||
> lockfile. The seventh-plugin alternative below remains rejected as disproportionate, but no
|
||||
> longer because either guard keeps the hook off external kyberforge consumers: on Claude Code
|
||||
> neither guard stops it for an apm consumer, and that is intended.
|
||||
|
||||
**`scripts/git-hooks/` is now empty.** `post-push` and `test-post-push.sh` are deleted.
|
||||
`install.sh`'s copy block is generic and is kept; `test-git-hooks-install.sh` now synthesizes its
|
||||
@@ -251,3 +326,7 @@ be used again if a hook git actually invokes is ever wanted.
|
||||
consumers. Rejected as disproportionate: the `apm.lock.yaml` guard already makes the hook inert
|
||||
for anyone not consuming through apm, and a package exists to be maintained, versioned, and
|
||||
registered in the marketplace.
|
||||
|
||||
*Rationale superseded by the 2026-09-28 correction above: the `CLAUDE_PROJECT_DIR` guard keeps
|
||||
the hook off non-Claude hosts, and on Claude Code it runs for every apm consumer, including
|
||||
external kyberforge consumers, by design. The alternative stays rejected as disproportionate.*
|
||||
@@ -191,6 +191,17 @@ comments (`:9-93`) have described all three correctly since it shipped.
|
||||
was wrong for the tree-identical case: the `same_subtree` skip makes a push **pass** that this ADR as
|
||||
written requires to **fail**, which is documented behaviour changing, not an implementation detail.
|
||||
|
||||
## Amendment (2026-09-29): a new skill stays at `0.1.0` until its first improve
|
||||
|
||||
The Decision says `skill-author`'s create/improve bump convention is "unchanged". It has changed
|
||||
since. Before, `skill-author` bumped the **minor** version on create, so a skill left its first
|
||||
session above the `0.1.0` scaffold. Now create keeps the scaffold's `0.1.0` and does not bump it;
|
||||
the first improve is the first bump, a **patch** (`skill-author` `SKILL.md`, `references/create.md`
|
||||
and `references/improve.md`; `965208b`, PR #144). This makes `0.1.0` mean what this ADR says it
|
||||
means, "created and never yet revised", instead of a value no created skill ever kept. The rules
|
||||
above are otherwise unaffected: `metadata.version` is still required, and the push gate still
|
||||
compares whatever value is there.
|
||||
|
||||
## Consequences
|
||||
|
||||
27 SKILL.md files gain `metadata.version: "1.0.0"`, and a 28th — `bin/write-docs` — reaches the same
|
||||
|
||||
@@ -278,6 +278,31 @@ both entry points, and that is what most of the table is. Every change below is
|
||||
A single `validate.sh` copied or symlinked out of its `scripts/` directory still does not work,
|
||||
because its libraries are not beside it. It now fails at exit 2 and says so.
|
||||
|
||||
> **Amendment (2026-09-28) — three more modes: hook, instruction and prompt.** The "two accepted
|
||||
> shapes" in point 2 above are now five. The `primitive-author` change (issue #94, PR #144) added
|
||||
> three rows to the Step 0 table, each with its own self-contained flow file and a shared
|
||||
> `scripts/lib-checks-primitive.sh` that `validate.sh` sources for all three:
|
||||
>
|
||||
> - A file named `*.instructions.md` takes the instruction flow (`references/instruction-flow.md`).
|
||||
> - A file named `*.prompt.md` takes the prompt flow (`references/prompt-flow.md`); the prompt rules
|
||||
> themselves are ADR-0029's.
|
||||
> - A `.json` file whose *immediate* parent directory is `hooks/` (`.apm/hooks/`, or a package's
|
||||
> root `hooks/`) takes the hook flow (`references/hook-flow.md`).
|
||||
>
|
||||
> The suffix rows are checked before the `agents/`-parent rule, so a `*.prompt.md` or
|
||||
> `*.instructions.md` under `agents/` is not audited as an agent. The fallback row is unchanged in
|
||||
> kind: anything else stops, runs no validator, exits 2, and names every accepted shape rather than
|
||||
> two. The exit-code table above applies to the new modes as written; its "matches neither shape"
|
||||
> row now means "matches none of the five".
|
||||
>
|
||||
> This is ADR-0020's merge-siblings rule applied forward rather than a new decision. Auditing a hook,
|
||||
> an instruction or a prompt is the same job as auditing a skill or agent — deterministic checks,
|
||||
> a read, a qualitative pass, one shared report — over a different input type, which is exactly the
|
||||
> case the rule says belongs in one skill behind a dispatch table, not in a new sibling audit skill.
|
||||
> The authoring side follows the rule's other half: the author skills stay split because they emit
|
||||
> genuinely different artifacts, so hooks, instructions and prompts got their own
|
||||
> `primitive-author` rather than rows in `skill-author` or `agent-author`.
|
||||
|
||||
## Considered options
|
||||
|
||||
**Keep two skills and rely on the byte-identity contract test alone (rejected).** This is the status
|
||||
@@ -368,7 +393,7 @@ the two gotchas that were over budget, because neither was shared:
|
||||
- the 112-word body-word-gate bullet was two separate pre-merge gotchas welded together, a skill half
|
||||
and an agent half.
|
||||
|
||||
A dispatch body is the dispatch table *plus the gates common to every branch* (GLOSSARY.md; the
|
||||
A dispatch body is the dispatch table *plus the gates common to every branch* (CONTEXT.md; the
|
||||
skill-flow rubric `references/skill-body-discipline.md`). Keeping a single-branch gotcha in it
|
||||
contradicts that definition. Moving it into its flow file costs no read either, because the body
|
||||
already loads exactly one flow file on every invocation by construction.
|
||||
|
||||
@@ -58,6 +58,3 @@ than widening them.
|
||||
|
||||
This changes shared enforcement, which is why it is recorded here rather than left as a comment.
|
||||
`docs/spec/gates.md`'s `apm-audit-ci` section carries the operative detail.
|
||||
|
||||
*(Note, 2026-11-11: `plugins/onedev` has since been removed. The decision stands: `plugins/mattpocock`
|
||||
declares dependencies and no primitives of its own, so it is the package the waiver now covers.)*
|
||||
@@ -31,7 +31,7 @@ pre-approved. Add the tool once its name is sourced for each target.
|
||||
`allowed-tools` and instruct spawning subagents — `forge` from `references/author-routes.md` and
|
||||
`references/version-bump.md`, not from its `SKILL.md`. That shows they spawn, not that a run
|
||||
succeeded. `skill-author/SKILL.md:24` forbids spawning a subagent to recheck one's own work, which
|
||||
is a different question and unaffected here. `GLOSSARY.md` says a plugin-scope agent delegates to
|
||||
is a different question and unaffected here. `CONTEXT.md` says a plugin-scope agent delegates to
|
||||
skills because it cannot disclose to itself; nothing there bans a skill from delegating.
|
||||
|
||||
**The security cost is real and not mitigated.** "The orchestrator alone writes files" is prose,
|
||||
@@ -44,4 +44,4 @@ the list was kept.
|
||||
|
||||
Rejected: dropping `allowed-tools` on the premise that it blocked spawning (unsupported by the
|
||||
repo's own sources, and it widens the tool surface for nothing), and banning spawning in skills
|
||||
(three skills instruct it, and `GLOSSARY.md` does not forbid it).
|
||||
(three skills instruct it, and `CONTEXT.md` does not forbid it).
|
||||
@@ -13,7 +13,7 @@ file, so 36 entries reported INFO and nothing failed. Measured by running the sc
|
||||
directories (27 with a `references/sources.md`, 11 without), since nothing else runs it over the corpus.
|
||||
|
||||
We decided that `Research doc:` names exactly one **Research registry** (the term is in
|
||||
`GLOSSARY.md`), as the spec always said. Slug-to-H2 lookup in the registry is the only provenance link
|
||||
`CONTEXT.md`), as the spec always said. Slug-to-H2 lookup in the registry is the only provenance link
|
||||
that can be verified deterministically; a topic doc has no per-source H2 to check against. A link to
|
||||
the topic doc that digested a source stays as free-text annotation and is not checked.
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# Prompts are thin, user-triggered steering messages; procedure belongs in a skill
|
||||
|
||||
**Status: accepted (2026-09-28).** Refs #94. Sets the house rule that `primitive-author` enforces
|
||||
when it writes a `.prompt.md`, and that `factory-audit` checks in its prompt flow.
|
||||
|
||||
A **Prompt** (the term is in `CONTEXT.md`) is a single-intent, user-triggered message with
|
||||
parameters. It is the text a user would otherwise type again and again. It carries no procedure
|
||||
beyond steering existing skills or agents by name. Once it holds reusable know-how, bundled files,
|
||||
or anything the model should find on its own, it is a **Skill** in the wrong container.
|
||||
|
||||
This is stricter than apm. apm frames a prompt as a program: its docs state that "a prompt is a
|
||||
program for an LLM" (microsoft.github.io/apm/concepts/what-is-apm/, "Secure by default"; the same
|
||||
sentence is in the apm-cli 0.28.0 package README), and 0.28.0 scaffolds one as a numbered-steps
|
||||
workflow (`apm_cli/workflow/discovery.py`). On every harness this repo targets, a prompt with a full
|
||||
workflow in it is a worse skill:
|
||||
|
||||
- **Claude Code.** Custom commands have been merged into skills. "Both create `/deploy` and work
|
||||
the same way", and both are model-invocable by default (code.claude.com/docs/en/skills.md).
|
||||
apm 0.28.0 keeps only `description`, `allowed-tools`, `model`, `argument-hint` and `input` for
|
||||
Claude (`_PRESERVED_COMMAND_KEYS`) and drops `disable-model-invocation`. A deployed prompt is
|
||||
therefore a model-visible skill with fewer frontmatter keys, and it cannot be made user-only.
|
||||
- **Copilot / VS Code.** "Prompt files are deprecated for Agent Host sessions and aren't loaded by
|
||||
Agent Host", and VS Code offers a migration that converts existing prompt files to agent skills
|
||||
(code.visualstudio.com/docs/agent-customization/prompt-files). They still load in the Local agent,
|
||||
which that page says will be removed in a future release.
|
||||
- **Codex.** Codex receives no prompts at all.
|
||||
|
||||
The one job a prompt does better than a skill is a short, parameterised "do this now, using X and Y"
|
||||
message, where `input:` → `$arguments` is the whole point.
|
||||
|
||||
## Description contract
|
||||
|
||||
A prompt's `description` is one plain, human-facing sentence that names the skills or agents it
|
||||
steers. For example: "Review the current PR with `gitea-prs` and `factory-audit`, then summarise."
|
||||
It has no "Use when…" trigger clause and no `Not X -> Y` boundary clause. This is the same shape
|
||||
`factory-audit` already applies to `disable-model-invocation: true` skills. Without a trigger clause,
|
||||
the router has little reason to pick the prompt over the skills it wraps. So when the model routes,
|
||||
it tends to reach the real capability.
|
||||
|
||||
**Unverified:** how strongly Claude avoids routing to a description with no trigger clause. The
|
||||
contract lowers the chance of the model invoking the prompt, but does not prevent it. If it does
|
||||
happen, the cost is bounded: the prompt is a thin wrapper that calls the right skills anyway.
|
||||
|
||||
## Enforcement
|
||||
|
||||
- **`primitive-author`.** The prompt reference opens with a boundary gate. A request that carries
|
||||
procedure is redirected to `skill-author`.
|
||||
- **`factory-audit`, script checks.**
|
||||
- `description` is present and non-empty (FAIL).
|
||||
- It is 250 characters or fewer (SUGGESTION).
|
||||
- It has no "Use when" trigger clause (SUGGESTION).
|
||||
- It has no `Not X -> Y` boundary clause (SUGGESTION).
|
||||
- **`factory-audit`, judgment step.** A body that clearly carries reusable procedure is a FAIL. A
|
||||
borderline body is a SUGGESTION. There is deliberately no line-count or heading heuristic: the
|
||||
call is made by reading the content, because any threshold misfires.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **`factory-audit` gains a prompt mode.** `*.prompt.md` is a Step 0 dispatch row with its own
|
||||
`references/prompt-flow.md`, and `scripts/lib-checks-primitive.sh` carries the three description
|
||||
checks above plus the judgment step (ADR-0025, amendment 2026-09-28). A prompt that was fine under
|
||||
apm's framing — a trigger clause, a boundary clause, a numbered workflow — now draws findings.
|
||||
- **`primitive-author` refuses procedure-bearing prompts.** Its prompt reference opens with the
|
||||
boundary gate, so a "make me a command" request that carries reusable know-how is redirected to
|
||||
`skill-author` before any file is written. That makes skill-vs-prompt a checked boundary rather
|
||||
than an authoring preference.
|
||||
- **Codex gets no prompts from this repo.** apm deploys none to Codex, so anything a prompt steers
|
||||
must also be reachable there through the skill it names. Keeping procedure in the skill is what
|
||||
makes that true; a fat prompt would be content Codex users silently never see.
|
||||
- **Reversing this is cheap in files, not in routing.** No prompt exists in the repo yet, so the rule
|
||||
constrains new work only. Loosening it later means re-deciding the description contract, and every
|
||||
prompt written under it would need a trigger clause added.
|
||||
|
||||
## Considered options
|
||||
|
||||
- **Fat workflow prompts as peers of skills (rejected).** This follows apm's framing. But every
|
||||
"make me a command" request becomes a coin flip between two near-identical containers. The prompt
|
||||
also carries worse metadata on Claude and does not arrive on Codex.
|
||||
- **The full ADR-0020 description contract for prompts (rejected).** A trigger clause and a boundary
|
||||
clause would make prompts route well. That actively invites the model to invoke the prompt, which
|
||||
contradicts "user-triggered".
|
||||
- **Skill-by-default with prompts as a grudging exception (superseded during the grill).** This
|
||||
framed a prompt as a weaker skill competing for the same job. Giving it a distinct role, a thin
|
||||
caller over skills, is a boundary that can be checked, which "prefer skills" is not.
|
||||
@@ -1,37 +0,0 @@
|
||||
# A skill pulled from a third-party repo's subpath is a resolvable routing target
|
||||
|
||||
**Status: accepted (2026-11-11).** Extends ADR-0020's target resolution walk; builds on ADR-0026.
|
||||
|
||||
`plugins/mattpocock` redistributes Matt Pocock's skills as `owner/repo/<path>/<skill>#v1.3.2`
|
||||
dependencies and ships no skills of its own. Moving `tdd`, `triage`, `grill-with-docs` and
|
||||
`improve-codebase-architecture` out of `plugins/bin` into it left `diagnose`, `write-docs` and
|
||||
`forge` routing to names that exist nowhere under `plugins/*/.apm/skills`. The corpus-wide backstop in
|
||||
`tests/test-adr0020-targets.sh` ("no skill in the corpus routes to a target that does not resolve")
|
||||
failed with exactly those four, and its message says not to relax it.
|
||||
|
||||
The resolver could not see them for two reasons that compound. Rule 1 of the walk reads skills that
|
||||
are *files under* `plugins/*/`, and these are not. Rule 3 reads a package's declared dependencies
|
||||
from `apm_modules/`, which a plugin package never has (ADR-0026: a plugin package is not an install
|
||||
root). Reading the root manifest instead was already ruled out by the walk, and installing in CI would
|
||||
make the verdict depend on the machine, which is the defect ADR-0020 exists to remove.
|
||||
|
||||
**Decision.** `_collect_package()` in `lib-boundary-resolver.sh` also adds the last path segment of
|
||||
every *string* dependency in the package's `apm.yml` that has at least `owner/repo/<subpath>` after an
|
||||
optional host prefix. It is applied wherever `_collect_package()` already runs, so every plugin in the
|
||||
monorepo contributes the skills it pulls. No network, no `apm_modules/`, same verdict on a fresh
|
||||
clone.
|
||||
|
||||
What it deliberately does not count: a whole-repo dependency such as `code.onedev.io/onedev/tod`
|
||||
(three segments with the host, so it names no skill), SSH and `host:` forms, and dict entries, which
|
||||
are packages and already resolve through the `path:` branch. The name is a convention, not a check:
|
||||
it assumes apm deploys the skill under the subpath's last segment, which it does today (verified on
|
||||
apm 0.28.0 for `wayfinder`), and a rename upstream is caught by the pin, not by this gate.
|
||||
|
||||
**Rejected: rewording the four clauses out of route notation.** Cheap, but it turns real routing
|
||||
checks into SUGGESTIONs for exactly the skills most likely to be renamed upstream.
|
||||
|
||||
**Consequence worth knowing.** Resolving a target is not the same as being able to call it. Upstream
|
||||
marks `grill-me`, `grill-with-docs`, `triage` and `improve-codebase-architecture` hand-invoked, so a
|
||||
`Call` step in another skill (`forge` Step 1) is blocked by the host. `forge`'s existing "grill inline
|
||||
if it does not resolve" fallback now always runs. The gate does not model this; ADR-0020's
|
||||
hand-invoked exemption covers the routing *rules*, not callability.
|
||||
@@ -1,45 +0,0 @@
|
||||
# `research` is upstream's single-question skill; bin's reference-tree skill becomes `research-docs`
|
||||
|
||||
**Status: accepted (2026-11-12).** Resolves #161. Builds on ADR-0029.
|
||||
|
||||
Upstream `wayfinder` (mattpocock `v1.3.2`) resolves a `wayfinder:research` ticket by having a
|
||||
fresh-context subagent call the Skill tool with `research` (`SKILL.md` lines 77 and 115). It expects
|
||||
upstream's contract: investigate **one question** against primary sources and write **one** cited
|
||||
findings note, saved where the repo keeps such notes, that a pending decision waits on.
|
||||
|
||||
The bare name `research` resolved instead to bin's first-party skill, whose contract differs in
|
||||
three ways that matter to wayfinder:
|
||||
|
||||
- It researches a **tool, library or API**, not an arbitrary question.
|
||||
- It writes a **reference tree** (`<topic>.md` files plus a `sources.md` registry), the input of the
|
||||
Provenance chain that `factory-audit` validates.
|
||||
- It **stops and asks** when no output path is named. A wayfinder research subagent runs AFK, so
|
||||
it stalls there.
|
||||
|
||||
The collision was silent: nothing warned that wayfinder's call landed on another contract.
|
||||
|
||||
**Decision.** Rename bin's skill to `research-docs` (bin 2.0.0 → 3.0.0, skill 1.0.2 → 2.0.0) and pin
|
||||
upstream `mattpocock/skills/skills/engineering/research#v1.3.2` in `plugins/mattpocock` (0.3.0 →
|
||||
0.4.0). Callers that want the reference tree route to `research-docs`: `write-docs` does, and
|
||||
`GLOSSARY.md`'s Provenance chain and `skill-author`'s template name it.
|
||||
|
||||
**Rejected.**
|
||||
|
||||
- **Broaden bin's skill to cover both.** It would carry two output contracts behind one
|
||||
description, against ADR-0020/0021's one-boundary rule, and the stop-and-ask gotcha that protects
|
||||
the reference-tree run is exactly what stalls the AFK one.
|
||||
- **Replace bin's skill with upstream's.** It drops the reference-tree pipeline the Provenance chain
|
||||
depends on.
|
||||
- **Rename bin's skill alone.** Upstream's call cannot be renamed without forking `wayfinder`, so it
|
||||
would resolve to nothing.
|
||||
- **Accept the partial fit.** Decision research that is not about one tool's docs keeps failing,
|
||||
silently.
|
||||
|
||||
**Accepted cost: overlapping triggers.** Both skills are model-invoked. Upstream's description
|
||||
("docs or API facts gathered") overlaps `research-docs`', and it cannot be edited without a fork.
|
||||
`research-docs` carries the boundary clause ("Not a single question a decision waits on, answered in
|
||||
one findings note -> `research`"); upstream's side has none, so a request to "research library X"
|
||||
may route to either. Revisit if misrouting shows up in practice.
|
||||
|
||||
**Breaking for consumers.** Anyone invoking `research` for a reference tree now gets upstream's
|
||||
single-note skill. That is why bin takes a major bump.
|
||||
@@ -1,51 +0,0 @@
|
||||
# Domain Docs
|
||||
|
||||
How the engineering skills should consume this repo's domain documentation when exploring the codebase.
|
||||
|
||||
## Before exploring, read these
|
||||
|
||||
- **`GLOSSARY.md`** at the repo root, or
|
||||
- **`GLOSSARY-MAP.md`** at the repo root if it exists: it points at one `GLOSSARY.md` per context. Read each one relevant to the topic.
|
||||
- **`docs/adr/`**: read ADRs that touch the area you're about to work in. In multi-context repos, also check `src/<context>/docs/adr/` for context-scoped decisions.
|
||||
|
||||
If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The `/domain-modeling` skill (reached via `/grill-with-docs` and `/improve-codebase-architecture`) creates them lazily when terms or decisions actually get resolved.
|
||||
|
||||
## File structure
|
||||
|
||||
Single-context repo (most repos):
|
||||
|
||||
```
|
||||
/
|
||||
├── GLOSSARY.md
|
||||
├── docs/adr/
|
||||
│ ├── 0001-event-sourced-orders.md
|
||||
│ └── 0002-postgres-for-write-model.md
|
||||
└── src/
|
||||
```
|
||||
|
||||
Multi-context repo (presence of `GLOSSARY-MAP.md` at the root):
|
||||
|
||||
```
|
||||
/
|
||||
├── GLOSSARY-MAP.md
|
||||
├── docs/adr/ ← system-wide decisions
|
||||
└── src/
|
||||
├── ordering/
|
||||
│ ├── GLOSSARY.md
|
||||
│ └── docs/adr/ ← context-specific decisions
|
||||
└── billing/
|
||||
├── GLOSSARY.md
|
||||
└── docs/adr/
|
||||
```
|
||||
|
||||
## Use the glossary's vocabulary
|
||||
|
||||
When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `GLOSSARY.md`. Don't drift to synonyms the glossary explicitly avoids.
|
||||
|
||||
If the concept you need isn't in the glossary yet, that's a signal: either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`).
|
||||
|
||||
## Flag ADR conflicts
|
||||
|
||||
If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
|
||||
|
||||
> _Contradicts ADR-0007 (event-sourced orders), but worth reopening because…_
|
||||
@@ -1,33 +0,0 @@
|
||||
# Issue tracker: Gitea
|
||||
|
||||
Issues and PRs for this repo live in Gitea at `git.rkdr.net`, repo `Defame1297/holocron` (ADR-0007: Gitea is the exclusive tracker; there is no file-based fallback).
|
||||
|
||||
## How skills reach it
|
||||
|
||||
Use the plugin skills, which wrap the Gitea MCP tools (`mcp__gitea__*`); do not shell out to `gh`/`glab`/`tea`.
|
||||
|
||||
- Create, read, comment on, close, label, search issues → `gitea-issues`
|
||||
- Label and milestone definitions → `gitea-labels-milestones`
|
||||
- Pull requests → `gitea-prs`
|
||||
|
||||
## Conventions
|
||||
|
||||
- Issue and PR numbers share one number space; confirm which domain a bare `#N` belongs to.
|
||||
- Apply triage state with the `Status/*` labels mapped in `docs/agents/triage-labels.md`.
|
||||
- "Publish to the issue tracker" means create a Gitea issue; "fetch the relevant ticket" means read it with `gitea-issues`.
|
||||
|
||||
## Wayfinding operations
|
||||
|
||||
How the `wayfinder` skill's map and tickets map onto Gitea, which has native issue dependencies but no sub-issues.
|
||||
|
||||
- **Labels**: the skill's `wayfinder:<x>` labels are expressed as the Gitea scoped labels `Wayfinder/<X>`, matching the repo's `Scope/Value` convention: `wayfinder:map` is `Wayfinder/Map`, `wayfinder:research` is `Wayfinder/Research`, and so on.
|
||||
- **Map**: an issue labelled `Wayfinder/Map`, paired with a milestone of the same title (`Map: <name>`).
|
||||
- **Child ticket**: an issue whose body starts with `Part of #<map>`, assigned to the map's milestone, carrying exactly one type label (`Wayfinder/Research`, `Wayfinder/Prototype`, `Wayfinder/Grilling`, `Wayfinder/Task`) and no `Status/*` label.
|
||||
- **Blocking**: Gitea's native issue dependencies (`issue_write` `add_dependency`, `dependency_type: blocked_by`).
|
||||
- **Claim**: assign the ticket to the dev driving the map before any work.
|
||||
- **Frontier query**: open issues in the map's milestone with no assignee, then drop any whose `get_blocked_by` lists an open issue.
|
||||
- **Research findings**: committed on a `research/<name>` branch that is pushed but never merged; the ticket's resolution comment links it.
|
||||
|
||||
## PRs as a request surface
|
||||
|
||||
Off. Only issues feed the triage queue; PRs are not triaged as requests.
|
||||
@@ -1,15 +0,0 @@
|
||||
# Triage Labels
|
||||
|
||||
The skills speak in terms of five canonical triage roles. This file maps those roles to the label strings in this repo's Gitea tracker, reusing the existing `Status/` and `Reviewed/` vocabulary.
|
||||
|
||||
| Label in mattpocock/skills | Label in our tracker | Meaning |
|
||||
| -------------------------- | ------------------------ | ---------------------------------------- |
|
||||
| `needs-triage` | `Status/Needs Triage` | Maintainer needs to evaluate this issue |
|
||||
| `needs-info` | `Status/Need More Info` | Waiting on reporter for more information |
|
||||
| `ready-for-agent` | `Status/Ready for Agent` | Fully specified, ready for an AFK agent |
|
||||
| `ready-for-human` | `Status/Ready for Human` | Requires human implementation |
|
||||
| `wontfix` | `Reviewed/Won't Fix` | Will not be actioned |
|
||||
|
||||
When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table. Apply labels through `gitea-labels-milestones` / `gitea-issues`, which resolve names to IDs.
|
||||
|
||||
Edit the "Label in our tracker" column to match whatever vocabulary you actually use.
|
||||
@@ -20,7 +20,7 @@ A future orchestration layer (cross-project automation agents) is a natural Chun
|
||||
|
||||
### 1. Coding conventions stay in coding.md
|
||||
|
||||
GLOSSARY.md is for domain vocabulary (≤200 lines, always loaded). `core/instructions/coding.md` carries coding conventions, loaded on demand. The factory's "conventions in GLOSSARY.md" principle applies to project repos where GLOSSARY.md is the primary shared artefact, not to this provider repo where the CLAUDE.md content index handles selective loading.
|
||||
CONTEXT.md is for domain vocabulary (≤200 lines, always loaded). `core/instructions/coding.md` carries coding conventions, loaded on demand. The factory's "conventions in CONTEXT.md" principle applies to project repos where CONTEXT.md is the primary shared artefact, not to this provider repo where the CLAUDE.md content index handles selective loading.
|
||||
|
||||
Project repos can override with their own `coding.md` at `.claude/core/instructions/coding.md`.
|
||||
|
||||
@@ -80,7 +80,7 @@ All skills — new and rebuilt — must follow this standard:
|
||||
- **This repo:** `LESSONS.md` at repo root, created in issue 0013. Captures lessons learned while building the config itself.
|
||||
- **Project repos:** `LESSONS.md` scaffolded by `init-project.sh` (Chunk 6 template).
|
||||
- **Session-handoff skill:** writes to whichever LESSONS.md is in scope before closing a session.
|
||||
- **Graduation threshold:** three or more entries covering the same pattern → promote to GLOSSARY.md (or `coding.md`, `git.md`, `testing.md` if domain-specific) as a standing rule.
|
||||
- **Graduation threshold:** three or more entries covering the same pattern → promote to CONTEXT.md (or `coding.md`, `git.md`, `testing.md` if domain-specific) as a standing rule.
|
||||
|
||||
### 6. Evals consciously deferred to Chunk 6
|
||||
|
||||
@@ -129,7 +129,7 @@ IaC skills (category: `iac`) and Gitea integration skills (category: `gitea`) li
|
||||
|
||||
- `.agents/skills/` as canonical skill path (ADR-0004)
|
||||
- SKILL.md format with YAML frontmatter (agentskills.io standard)
|
||||
- GLOSSARY.md ≤200 lines
|
||||
- CONTEXT.md ≤200 lines
|
||||
- Pull-based distribution (ADR-0001)
|
||||
- governance.md via `@import` always-on
|
||||
- No third-party skills without reading them (OWASP AST01 / governance.md)
|
||||
|
||||
@@ -20,10 +20,10 @@ This changes almost every downstream decision. Until it's resolved, individual g
|
||||
|
||||
### 2.1 Where coding conventions live
|
||||
|
||||
**Factory research:** Preferred/Avoid code blocks belong in `GLOSSARY.md`. Convention lives in a single shared-vocabulary file the agent always loads.
|
||||
**Factory research:** Preferred/Avoid code blocks belong in `CONTEXT.md`. Convention lives in a single shared-vocabulary file the agent always loads.
|
||||
**Chunk 2 plan:** Coding conventions go in a separate `core/instructions/coding.md` file, loaded on-demand.
|
||||
|
||||
One of these wins. If conventions go in `GLOSSARY.md`, `coding.md` becomes much thinner or unnecessary. If they stay in `coding.md`, the factory's "GLOSSARY.md is the primary context artefact" principle weakens.
|
||||
One of these wins. If conventions go in `CONTEXT.md`, `coding.md` becomes much thinner or unnecessary. If they stay in `coding.md`, the factory's "CONTEXT.md is the primary context artefact" principle weakens.
|
||||
|
||||
### 2.2 Skill path structure: flat vs. nested
|
||||
|
||||
@@ -45,7 +45,7 @@ These serve the same purpose. The factory's naming is cleaner (one file, obvious
|
||||
|
||||
### 3.1 LESSONS.md (impacts Chunk 2)
|
||||
|
||||
Factory treats `LESSONS.md` as a required committed file — the mechanism for long-loop feedback and convention graduation. Without it, there is no defined path from "I noticed a pattern" to "this is now a standing rule in GLOSSARY.md". Not in the Chunk 2 scope. Question: is this a Chunk 2 addition or deferred?
|
||||
Factory treats `LESSONS.md` as a required committed file — the mechanism for long-loop feedback and convention graduation. Without it, there is no defined path from "I noticed a pattern" to "this is now a standing rule in CONTEXT.md". Not in the Chunk 2 scope. Question: is this a Chunk 2 addition or deferred?
|
||||
|
||||
### 3.2 `docs/spec/` living spec layer
|
||||
|
||||
@@ -69,7 +69,7 @@ Factory requires a `references/` directory with `stack-versions.md` (authoritati
|
||||
|
||||
### 3.7 Model routing
|
||||
|
||||
Factory defines an explicit model routing table (Haiku for classification/formatting, Sonnet for most coding, Opus for adversarial review). Not in current vision or chunk scope. The factory treats this as both a cost decision and a sustainability decision — using frontier models for tasks a smaller model can do is waste, and the governance constitution calls this out explicitly. Where does this decision live — in `governance.md`, in GLOSSARY.md, or per-skill?
|
||||
Factory defines an explicit model routing table (Haiku for classification/formatting, Sonnet for most coding, Opus for adversarial review). Not in current vision or chunk scope. The factory treats this as both a cost decision and a sustainability decision — using frontier models for tasks a smaller model can do is waste, and the governance constitution calls this out explicitly. Where does this decision live — in `governance.md`, in CONTEXT.md, or per-skill?
|
||||
|
||||
---
|
||||
|
||||
@@ -95,7 +95,7 @@ These don't have a "right answer" yet — they need explicit decisions.
|
||||
|
||||
- `.agents/skills/` as canonical skill path — consistent with the Agent Skills standard
|
||||
- SKILL.md format with YAML frontmatter — consistent
|
||||
- `GLOSSARY.md` exists and is ≤200 lines — consistent with factory's context architecture
|
||||
- `CONTEXT.md` exists and is ≤200 lines — consistent with factory's context architecture
|
||||
- Pull-based distribution model — consistent with factory's "no runtime dependency" principle
|
||||
- Governance.md loaded via `@import` — matches factory's "always-on" governance pattern
|
||||
- No third-party skill installs without reading them — consistent with OWASP AST01 guidance
|
||||
|
||||
@@ -287,7 +287,7 @@ The shared pattern: per-skill `README.md` files no model reads, a `docs/research
|
||||
>
|
||||
> **Interaction with rejected finding 19, unacknowledged:** collapsing git to one skill absorbs `git-workflow` itself — one of the seven — so its 8-row Domains table would route to itself, and leaves `git-orchestrate` a dispatcher with exactly one target, its contract vacuous. Finding 19 was rejected for doing less than this, mechanically.
|
||||
>
|
||||
> Blast radius if ever revisited: **68 backticked references to git skill names, 99 to gitea names** under `plugins/`. Only the ones in a `SKILL.md` are boundary targets `skill-size-check` resolves and FAILs on if dangling — its `files:` regex is `^plugins/[^/]+/\.apm/skills/[^/]+/SKILL\.md$`, so it opens nothing else — and that is **35 of the 68 git mentions and 26 of the 99 gitea ones**. The remaining 33 and 73 live in `references/*.md`, the two orchestrate agents (10 and 23 on their own), the plugin READMEs, kyberforge's audit and author references, and two `validate.sh` copies — none of which this gate opens: they still have to be rewritten by hand, but they fail no hook. Plus `AGENTS.md:16,18`, `README.md:21-22`, `GLOSSARY.md:168` (uses `gitea-prs` as the naming exemplar), `architecture.md:34` (uses `git-branches` vs `gitea-branches` as the canonical boundary example), and ADRs 0011, 0020, 0021, 0022, 0023. Two false alarms not worth chasing: `tests/test-check-rtk-prefix.sh:97` reads from a pinned historical SHA, and `scripts/check-rtk-prefix.sh`'s mention is in a comment.
|
||||
> Blast radius if ever revisited: **68 backticked references to git skill names, 99 to gitea names** under `plugins/`. Only the ones in a `SKILL.md` are boundary targets `skill-size-check` resolves and FAILs on if dangling — its `files:` regex is `^plugins/[^/]+/\.apm/skills/[^/]+/SKILL\.md$`, so it opens nothing else — and that is **35 of the 68 git mentions and 26 of the 99 gitea ones**. The remaining 33 and 73 live in `references/*.md`, the two orchestrate agents (10 and 23 on their own), the plugin READMEs, kyberforge's audit and author references, and two `validate.sh` copies — none of which this gate opens: they still have to be rewritten by hand, but they fail no hook. Plus `AGENTS.md:16,18`, `README.md:21-22`, `CONTEXT.md:168` (uses `gitea-prs` as the naming exemplar), `architecture.md:34` (uses `git-branches` vs `gitea-branches` as the canonical boundary example), and ADRs 0011, 0020, 0021, 0022, 0023. Two false alarms not worth chasing: `tests/test-check-rtk-prefix.sh:97` reads from a pinned historical SHA, and `scripts/check-rtk-prefix.sh`'s mention is in a comment.
|
||||
>
|
||||
> **Salvageable independently, ~230 lines:** `conventional-commits-spec.md` (~98% generic) and `bisect.md` (~97%) are the only two files where the generic-restatement thesis fully holds — reduce each to a pointer plus the house delta. Also worth a finding-13-style trim-in-place: the issue-vs-PR disambiguation duplicated across 4 gitea files. Neither needs a merge.
|
||||
>
|
||||
@@ -315,7 +315,7 @@ The shared pattern: per-skill `README.md` files no model reads, a `docs/research
|
||||
>
|
||||
> **Deferred (2026-09-16, grill).** The human is excluding `bin` from this audit: its skills are "binned for a reason" and will be fixed or relocated as a separate piece of work. Nothing in this finding is executed here; the itemised ~165-line estimate above is the starting point for that work. `bin` is still covered by the version-bump gate (finding 33) until then.
|
||||
|
||||
23. [x] **bin: merge `grill-me` into `grill-with-docs`.** `grill-me` is 16 lines and a subset of the docs flow; `grill-with-docs` creates `GLOSSARY.md` when missing, so the merged skill needs a no-write opt-out. `caveman` (50 lines) and `zoom-out` (9) are hand-invoked prompts rather than workflow skills; they are also the repo's `disable-model-invocation` exemplars in `GLOSSARY.md`, `contract.md`, ADR-0020, ADR-0021, and `gates.md`, and `install.sh` has no path for `~/.claude/commands/`, so moving them means picking a new exemplar. `improve-codebase-architecture` defines its glossary twice (inline and in `language.md`; the README documents the split as intentional). Effort S.
|
||||
23. [x] **bin: merge `grill-me` into `grill-with-docs`.** `grill-me` is 16 lines and a subset of the docs flow; `grill-with-docs` creates `CONTEXT.md` when missing, so the merged skill needs a no-write opt-out. `caveman` (50 lines) and `zoom-out` (9) are hand-invoked prompts rather than workflow skills; they are also the repo's `disable-model-invocation` exemplars in `CONTEXT.md`, `contract.md`, ADR-0020, ADR-0021, and `gates.md`, and `install.sh` has no path for `~/.claude/commands/`, so moving them means picking a new exemplar. `improve-codebase-architecture` defines its glossary twice (inline and in `language.md`; the README documents the split as intentional). Effort S.
|
||||
> **Decision (2026-09-16):** Not proceeding — the human declined this finding. `grill-me` and `grill-with-docs` stay separate.
|
||||
|
||||
24. [x] **core: `provider-adapter-author` is a 1,200-line wrapper around one instruction** ("replace duplicated lines with `@AGENTS.md`, keep provider-specific lines"): a 496-line validator with a 519-line bats suite for a check that is a grep. `agentsmd-author` already calls `agentsmd-audit` as mandatory closeout, and both route to `provider-adapter-author` in boundary clauses that must change with it. Target: one `agentsmd` skill with an audit mode, adapter conversion as a step, validator about 40 lines. Needs an ADR-0012 revisit. Effort L.
|
||||
@@ -393,12 +393,12 @@ The shared pattern: per-skill `README.md` files no model reads, a `docs/research
|
||||
> **Corrected then partially done (2026-09-14):** independent re-verification found the "edit `.apm/`, never the mirror" and apm.lock/SessionStart clusters confirmed but the third overstated — no file documents an offline `SKIP=` command (the one `SKIP=`-adjacent mention in `gates.md` explicitly says a *different* opt-out "is not `SKIP=`"), and "three-stage install" appears twice, not three times, with no restatement worth trimming. Trimmed the two confirmed clusters: README's "Editing plugin content" and AGENTS.md's "Edit `.apm/`, never the flat mirror" sections cut to the how-to/one-line-plus-link split the finding itself proposed, full mechanics (the `rm -rf` behavior and the `plugins/kyberforge/hooks/README.md` anecdote) staying solely in `docs/spec/architecture.md`. README's "Keeping the install current" and AGENTS.md's apm.lock bullet trimmed to drop the restated `apm outdated`/`apm update --yes` timing narrative, pointing to ADR-0019 as the canonical mechanism instead. No test greps the trimmed wording (checked).
|
||||
|
||||
30. [x] ~~**`LESSONS.md`: 41 entries, 2 graduated, about 12 stale.** Twelve entries from 2026-05-17 describe a write-skill / write-eval workflow whose skills no longer exist. One entry is open work labelled "Status: neither part landed". The longest eight are 200 to 550-word incident reports. Delete the stale entries, move open work to an issue, cap entries at about 60 words, target 100 lines. Effort S.~~
|
||||
> **Done (2026-09-12):** see commit `629320b` on `docs/simplification-audit`. 255→131 lines, 41→30 entries. Kept 3 of the same-dated entries (RLHF defaults, secrets-rule gap, HITL gap) — judged unrelated to the defunct write-skill/write-eval workflow and still applicable, so 10 deleted rather than 12. The "neither part landed" open-work entry (GLOSSARY.md not `@import`ed at session start) was removed rather than filed as an issue — full text preserved in this session's transcript if wanted later.
|
||||
> **Done (2026-09-12):** see commit `629320b` on `docs/simplification-audit`. 255→131 lines, 41→30 entries. Kept 3 of the same-dated entries (RLHF defaults, secrets-rule gap, HITL gap) — judged unrelated to the defunct write-skill/write-eval workflow and still applicable, so 10 deleted rather than 12. The "neither part landed" open-work entry (CONTEXT.md not `@import`ed at session start) was removed rather than filed as an issue — full text preserved in this session's transcript if wanted later.
|
||||
|
||||
31. [x] ~~**`GLOSSARY.md`: 28 terms, most used only by gates.md, scripts, or tests rather than by skills;** two (Preload tax, Skill context contract) are never used outside `GLOSSARY.md` and ADR-0020. The preload-tax entry quotes two dated numbers then says not to quote them. The example dialogue and flagged-ambiguities sections are grill residue. Cut to about 20 one-line terms. Effort S.~~
|
||||
31. [x] ~~**`CONTEXT.md`: 28 terms, most used only by gates.md, scripts, or tests rather than by skills;** two (Preload tax, Skill context contract) are never used outside `CONTEXT.md` and ADR-0020. The preload-tax entry quotes two dated numbers then says not to quote them. The example dialogue and flagged-ambiguities sections are grill residue. Cut to about 20 one-line terms. Effort S.~~
|
||||
> **Corrected then done (2026-09-13):** see commits `124ce6e` and follow-up on `docs/simplification-audit`. Independent re-verification found "most used only by gates.md/scripts/tests" overstated: 13 of 28 terms are actually referenced from model-facing `references/*.md` files skills load in normal use (Routing target, Hand-invoked skill, Dispatch body, Near-miss, Thin adapter, Provenance chain, Output profile, apm package, Plugin marketplace, HITL, Skill composition, Delegation discipline, holocron) and were kept untouched. Only the 9 terms confirmed as true orphans were removed after a fresh independent grep: Content mirror, apm-consumed install, Vale audit prefilter, Vacuous green, Management Application, Sycophancy, HOTL, Preload tax, Skill context contract — 28 → 19 terms.
|
||||
> > **Corrected (2026-09-19) — "true orphans" is wrong for two of the nine.** **HOTL** and **Sycophancy** are both still used in `core/ai-constitution.md` (HOTL spelled out at `:111-112`, sycophancy at `:72-87`), and HOTL also in `docs/research/governance_principles/ai-governance-research.md:340-344`. The removals themselves were still right, for a different reason than the one given: the constitution **defines both terms itself, at the point of use**, so a second definition in `GLOSSARY.md` was duplication rather than the only authority. Only the orphan justification is corrected here; the other seven and the 28 → 19 count are unaffected.
|
||||
> **Re-counted (2026-09-14, at `a6434e0`): 18 terms, not 19.** The "28 → 19" above is an accurate record of this finding's own commit (`124ce6e`) and is left standing. `718c79a` then removed a twentieth-to-nineteenth entry this finding never touched: the standalone **Plugin** term, folded into **apm package** when ADR-0024 made "plugin" and "apm package" the same thing. Counted as bolded term entries between `## Language` and `## Relationships` in `GLOSSARY.md`: 19 at `124ce6e`, 18 at `718c79a` and unchanged at `a6434e0`. The finding's own target ("about 20 one-line terms") is met either way. The preload-tax self-contradiction (quotes 23,427/10,478-char figures then says not to quote either) was confirmed verbatim and resolved by the entry's own deletion. The "example dialogue" and "flagged ambiguities" sections were found to be mandated by `grill-with-docs/references/context-format.md`'s template spec, not grill residue — left untouched, except one dangling bolded cross-reference to the now-deleted "Preload tax" term in a Flagged-ambiguities line, which was unbolded/de-referenced in place (the ambiguity resolution itself still holds without a defined glossary entry to point at).
|
||||
> > **Corrected (2026-09-19) — "true orphans" is wrong for two of the nine.** **HOTL** and **Sycophancy** are both still used in `core/ai-constitution.md` (HOTL spelled out at `:111-112`, sycophancy at `:72-87`), and HOTL also in `docs/research/governance_principles/ai-governance-research.md:340-344`. The removals themselves were still right, for a different reason than the one given: the constitution **defines both terms itself, at the point of use**, so a second definition in `CONTEXT.md` was duplication rather than the only authority. Only the orphan justification is corrected here; the other seven and the 28 → 19 count are unaffected.
|
||||
> **Re-counted (2026-09-14, at `a6434e0`): 18 terms, not 19.** The "28 → 19" above is an accurate record of this finding's own commit (`124ce6e`) and is left standing. `718c79a` then removed a twentieth-to-nineteenth entry this finding never touched: the standalone **Plugin** term, folded into **apm package** when ADR-0024 made "plugin" and "apm package" the same thing. Counted as bolded term entries between `## Language` and `## Relationships` in `CONTEXT.md`: 19 at `124ce6e`, 18 at `718c79a` and unchanged at `a6434e0`. The finding's own target ("about 20 one-line terms") is met either way. The preload-tax self-contradiction (quotes 23,427/10,478-char figures then says not to quote either) was confirmed verbatim and resolved by the entry's own deletion. The "example dialogue" and "flagged ambiguities" sections were found to be mandated by `grill-with-docs/references/context-format.md`'s template spec, not grill residue — left untouched, except one dangling bolded cross-reference to the now-deleted "Preload tax" term in a Flagged-ambiguities line, which was unbolded/de-referenced in place (the ambiguity resolution itself still holds without a defined glossary entry to point at).
|
||||
|
||||
32. [x] ~~**Structure is described three ways** (README layout table, architecture.md plugin table, AGENTS.md structure bullets), and `VISION.md` carries a 35-line stack spec for a product that lives in another repo. One layout table in README; architecture.md keeps mechanics only; VISION drops the stack detail. Effort S.~~
|
||||
> **Premise corrected, residual done (2026-09-14).** Both halves were inflated; most of the proposed split already existed.
|
||||
|
||||
@@ -139,7 +139,7 @@ After the behavioral test passes, close the skill session by appending a `## Han
|
||||
- <deferred items, follow-on issues, or unresolved tensions — if none, write "none">
|
||||
|
||||
**Next session start:**
|
||||
- Load: `GLOSSARY.md`, `docs/notes/skill-implementation-workflow.md`, next skill's issue file
|
||||
- Load: `CONTEXT.md`, `docs/notes/skill-implementation-workflow.md`, next skill's issue file
|
||||
- First action: Step 1 (source discovery) for `<next-skill-name>`
|
||||
```
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
## 2. The 3,000-token degradation ceiling — does it hold for 2026 models?
|
||||
|
||||
**Current position:** LLM reasoning performance starts degrading around 3,000 tokens of context. This is the primary justification for the 500-line skill limit, the GLOSSARY.md ≤200 line constraint, and most of the token optimisation strategy.
|
||||
**Current position:** LLM reasoning performance starts degrading around 3,000 tokens of context. This is the primary justification for the 500-line skill limit, the CONTEXT.md ≤200 line constraint, and most of the token optimisation strategy.
|
||||
|
||||
**What to challenge:**
|
||||
- The source is Levy, Jacoby, and Goldberg (2024) — a study on models that predate Claude Sonnet 4.6 and Opus 4.7 by at least one generation. Do 2026 models show the same degradation at the same threshold?
|
||||
@@ -30,7 +30,7 @@
|
||||
- The SkillReducer paper (arxiv.org/pdf/2603.29919) documents context budget problems but does not validate the 3,000-token specific threshold. Is there a more recent primary source?
|
||||
- Does the degradation manifest equally for structured code tasks vs. natural language tasks?
|
||||
|
||||
**Design implication:** If the threshold is actually higher for 2026 models, the 500-line skill limit and GLOSSARY.md constraint may be over-conservative. If lower, they should tighten.
|
||||
**Design implication:** If the threshold is actually higher for 2026 models, the 500-line skill limit and CONTEXT.md constraint may be over-conservative. If lower, they should tighten.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ The existing research and principles are complete and evidence-based. The gap is
|
||||
|
||||
Drift has a direction: implementation moves faster than docs, so docs lag. Disciplinary fixes ("remember to update the docs") don't work at scale. The only reliable fixes are structural.
|
||||
|
||||
The factory is documentation-driven by default. This means: every implementation decision either derives from an existing document or produces a new one. Code that cannot be traced to a spec is out-of-scope code. A convention that isn't in GLOSSARY.md isn't a convention — it's undiscoverable tribal knowledge.
|
||||
The factory is documentation-driven by default. This means: every implementation decision either derives from an existing document or produces a new one. Code that cannot be traced to a spec is out-of-scope code. A convention that isn't in CONTEXT.md isn't a convention — it's undiscoverable tribal knowledge.
|
||||
|
||||
**Current tooling:** git + markdown. This is the correct starting point. Every layer described below is future-compatible: when better tools arrive (living-spec platforms, architecture-as-code, doc coverage CI), they read the file structure that already exists. No migration required.
|
||||
|
||||
@@ -68,7 +68,7 @@ Five layers, each with a clear scope and update frequency. The rule: content liv
|
||||
| Layer | Files | Changes when | Update mechanism |
|
||||
|---|---|---|---|
|
||||
| Governance | `AGENTS.md`, `HUMANS.md`, `CONTROLS.md`, `ai-constitution.md` | Principles change or tooling changes fundamentally | Human deliberate edit; reviewed in PR |
|
||||
| Convention | `GLOSSARY.md`, `LESSONS.md`, `references/stack-versions.md` | New pattern adopted; LESSONS.md threshold hit | LESSONS.md auto-graduates to GLOSSARY.md at 3× same pattern |
|
||||
| Convention | `CONTEXT.md`, `LESSONS.md`, `references/stack-versions.md` | New pattern adopted; LESSONS.md threshold hit | LESSONS.md auto-graduates to CONTEXT.md at 3× same pattern |
|
||||
| Specification | `docs/spec/` (what the system does now), `docs/adr/` (decisions) | Behaviour changes or decision made | Spec updated in same PR as implementation; ADRs via architect role; never deleted |
|
||||
| Work tracking | Gitea issues + feature branches | New work begins or completes | Issue created with EARS spec; branch per issue; closed when PR merges |
|
||||
| Skills & workflows | `.agents/skills/**`, `.agents/workflows/`, `.agents/evals/` | Skill behaviour changes or new skill added | PR with co-located eval update; CI blocks merge if eval fails |
|
||||
@@ -80,7 +80,7 @@ Five layers, each with a clear scope and update frequency. The rule: content liv
|
||||
|
||||
Six structural mechanisms prevent drift. All six must be active — any one of them alone is insufficient.
|
||||
|
||||
**One source per concern.** No content is duplicated across layers or tool-specific files. CLAUDE.md references AGENTS.md; it does not duplicate it. A skill's trigger description appears only in its `SKILL.md`; it is not copied into GLOSSARY.md or a workflow file.
|
||||
**One source per concern.** No content is duplicated across layers or tool-specific files. CLAUDE.md references AGENTS.md; it does not duplicate it. A skill's trigger description appears only in its `SKILL.md`; it is not copied into CONTEXT.md or a workflow file.
|
||||
|
||||
**Issue spec precedes code.** No implementation work begins without a Gitea issue containing an EARS-format spec. The `factory/write-issue-spec` skill drafts this; the Gitea MCP posts it. Code on a feature branch cannot drift from a spec that must exist before the branch is created. The `deploy/deployment-checklist` skill verifies a linked issue exists before any deployment.
|
||||
|
||||
@@ -88,9 +88,9 @@ Six structural mechanisms prevent drift. All six must be active — any one of t
|
||||
|
||||
**CI eval gates block skill drift.** Every skill has an `eval.yaml` co-located in `.agents/evals/`. A change to any file under `.agents/skills/**` triggers the co-located eval in CI. A failing eval blocks merge. This means a skill body can never drift from its documented behaviour without a deliberate eval update.
|
||||
|
||||
**LESSONS.md graduation.** Three or more occurrences of the same pattern in LESSONS.md trigger promotion to GLOSSARY.md as a standing rule. This is the only sanctioned upward flow in the documentation hierarchy — and only into the convention layer, not higher.
|
||||
**LESSONS.md graduation.** Three or more occurrences of the same pattern in LESSONS.md trigger promotion to CONTEXT.md as a standing rule. This is the only sanctioned upward flow in the documentation hierarchy — and only into the convention layer, not higher.
|
||||
|
||||
**Tool adapter pattern.** Tool-specific files (CLAUDE.md, `.cursor/rules`, `copilot-instructions.md`) are thin adapters that reference the source layer. They contain no original content. When a tool changes its format, only the adapter changes. The source — AGENTS.md, GLOSSARY.md — is untouched.
|
||||
**Tool adapter pattern.** Tool-specific files (CLAUDE.md, `.cursor/rules`, `copilot-instructions.md`) are thin adapters that reference the source layer. They contain no original content. When a tool changes its format, only the adapter changes. The source — AGENTS.md, CONTEXT.md — is untouched.
|
||||
|
||||
---
|
||||
|
||||
@@ -112,10 +112,10 @@ Five external frameworks are relevant. Each contributes a specific, non-overlapp
|
||||
| `/to-prd` skill | Converts conversation into a structured PRD artifact | Adopt the forcing-function pattern: refuse to proceed until synthesis is complete |
|
||||
| `/to-issues` skill | Breaks PRD into independently shippable issues | Maps to factory's `design/break-into-issues` skill — check Pocock's "independently shippable slices" constraint |
|
||||
| `/tdd` skill structure | Multi-file skill: `SKILL.md` + `tests.md` + `mocking.md` + `refactoring.md` + `deep-modules.md` | The multi-file skill pattern is best practice for complex skills. Factory's `test/write-tests` skill should adopt this structure |
|
||||
| `GLOSSARY.md` generation | Setup skill creates a shared vocabulary file on init | Factory already has this concept; Pocock's implementation provides a concrete template |
|
||||
| `CONTEXT.md` generation | Setup skill creates a shared vocabulary file on init | Factory already has this concept; Pocock's implementation provides a concrete template |
|
||||
| `/git-guardrails` | Blocks risky agent actions (force pushes, direct main commits) | Adopt as factory's `cross-cutting/git-guardrails` skill — currently absent |
|
||||
| `/diagnose` | Structured debugging state machine | Adopt as factory's `implement/diagnose` skill — currently absent |
|
||||
| `/improve-codebase-architecture` | Architecture debt hunting using GLOSSARY.md + ADRs | Reinforces factory's Reviewer role; drives ADR creation workflow |
|
||||
| `/improve-codebase-architecture` | Architecture debt hunting using CONTEXT.md + ADRs | Reinforces factory's Reviewer role; drives ADR creation workflow |
|
||||
| `/zoom-out` | Periodic architecture perspective shift | Maps to Architect role; adopt the "zoom out before diving in" forcing function |
|
||||
| `caveman` skill | ~75% token reduction through compressed output mode | Adopt for token optimisation — maps to factory's orientation problem solution |
|
||||
|
||||
@@ -238,7 +238,7 @@ Nothing from external frameworks enters the repo as a runtime dependency. Every
|
||||
| Pocock/skills | `tdd/` (multi-file) | Adopt directly — entire folder structure | `.agents/skills/implement/tdd/` (SKILL.md + tests.md + mocking.md + refactoring.md) |
|
||||
| Pocock/skills | `diagnose/SKILL.md` | Adopt directly | `.agents/skills/implement/diagnose/SKILL.md` |
|
||||
| Pocock/skills | `git-guardrails/SKILL.md` | Adopt directly | `.agents/skills/cross-cutting/git-guardrails/SKILL.md` |
|
||||
| Pocock/skills | GLOSSARY.md generation (setup skill) | Pattern only — content is yours | `GLOSSARY.md` at repo root (content file, not a skill) |
|
||||
| Pocock/skills | CONTEXT.md generation (setup skill) | Pattern only — content is yours | `CONTEXT.md` at repo root (content file, not a skill) |
|
||||
| Pocock/skills | `zoom-out/SKILL.md` | Adopt directly — merge as a mode | `.agents/skills/roles/architect/SKILL.md` |
|
||||
| BMAD-METHOD | Scale-adaptive planning depth | Pattern only — complexity gate logic | `.agents/skills/factory/write-issue-spec/SKILL.md` (complexity-gating section) |
|
||||
| BMAD-METHOD | Scrum Master story format | Pattern only — embed full context | `.agents/skills/design/break-into-issues/SKILL.md` (output format) |
|
||||
@@ -284,8 +284,8 @@ The working tree contains only permanent, final-state content. Work in progress
|
||||
```
|
||||
repo/
|
||||
├── AGENTS.md # Agent governance (all rules)
|
||||
├── GLOSSARY.md # Shared vocabulary and conventions
|
||||
├── LESSONS.md # Feedback → graduates to GLOSSARY.md at 3× threshold
|
||||
├── CONTEXT.md # Shared vocabulary and conventions
|
||||
├── LESSONS.md # Feedback → graduates to CONTEXT.md at 3× threshold
|
||||
├── HUMANS.md # Human orientation guide
|
||||
├── CONTROLS.md # Operational safety controls
|
||||
│
|
||||
@@ -411,14 +411,14 @@ Goal: A working factory skeleton that a real task can be run through end-to-end.
|
||||
|
||||
**Acceptance criteria (EARS format):**
|
||||
- WHEN any task is started, THE system SHALL have a Gitea issue with an EARS-format spec before a branch is created
|
||||
- WHEN a Claude Code session begins, THE system SHALL have `AGENTS.md` and `GLOSSARY.md` in context
|
||||
- WHEN a Claude Code session begins, THE system SHALL have `AGENTS.md` and `CONTEXT.md` in context
|
||||
- WHEN any skill is invoked, THE system SHALL load only that skill's SKILL.md (not the full library)
|
||||
- WHEN a PR is raised, THE system SHALL include updates to `docs/spec/` if behaviour changed
|
||||
|
||||
**Tasks:**
|
||||
|
||||
1. Commit `AGENTS.md` — merge existing governance content; validate against principles doc
|
||||
2. Generate `GLOSSARY.md` — manually populate shared vocabulary (10–15 domain terms to start)
|
||||
2. Generate `CONTEXT.md` — manually populate shared vocabulary (10–15 domain terms to start)
|
||||
3. Create `docs/spec/architecture.md` — initial living spec, even if sparse
|
||||
4. Create `docs/adr/` with an `adr-template.md`
|
||||
5. Implement Phase 1 skill set (7 files):
|
||||
@@ -621,7 +621,7 @@ The factory is working when:
|
||||
| Spec–implementation sync | 0 PRs merged that change behaviour without updating `docs/spec/` |
|
||||
| HITL gate compliance | 100% of irreversible actions have a human approval before execution |
|
||||
| Eval coverage | Every skill has trigger tests and output tests before use in production |
|
||||
| LESSONS.md graduation rate | Recurring patterns promoted to GLOSSARY.md within 2 weeks of third occurrence |
|
||||
| LESSONS.md graduation rate | Recurring patterns promoted to CONTEXT.md within 2 weeks of third occurrence |
|
||||
| Session handoff rate | All sessions that pause mid-task have a handoff document |
|
||||
| Model regression detection | Weekly eval cron catches skill degradation before it reaches production use |
|
||||
|
||||
@@ -639,7 +639,7 @@ These must be resolved before implementation begins. Most are inputs *to* the gr
|
||||
|
||||
4. **promptfoo hosting:** Self-hosted promptfoo on the homelab, or Gitea Actions cloud runners? This affects eval architecture.
|
||||
|
||||
5. **`GLOSSARY.md` bootstrap:** What are the 10–15 most important domain terms for this project? These must be manually written before any skill invokes GLOSSARY.md.
|
||||
5. **`CONTEXT.md` bootstrap:** What are the 10–15 most important domain terms for this project? These must be manually written before any skill invokes CONTEXT.md.
|
||||
|
||||
6. **`docs/spec/` initial scope:** How much of the current system needs to be described in the initial living spec before Phase 1 begins? Even a sparse overview.md + architecture.md is better than nothing — agents need something to read before they can update it correctly.
|
||||
|
||||
@@ -655,11 +655,11 @@ Each of the following warrants its own session. They are ordered by dependency
|
||||
|
||||
| Session | Produces | Feeds into |
|
||||
|---|---|---|
|
||||
| 1. Repo vision and goals | Vision statement, success criteria, what the factory is and is not for | All subsequent sessions; GLOSSARY.md bootstrap |
|
||||
| 1. Repo vision and goals | Vision statement, success criteria, what the factory is and is not for | All subsequent sessions; CONTEXT.md bootstrap |
|
||||
| 2. Stack and tooling decisions | Primary language(s), test frameworks, IaC tooling, CI platform | Skill body content for implement/, test/, iac/ skills; stack-versions.md |
|
||||
| 3. Roadmap and phasing | Milestone sequence, phase gates, what "done" looks like per phase | Phase plan (Section 7 of this document becomes concrete) |
|
||||
| 4. ADR: documentation structure | Decision on docs/spec/ scope, Gitea issue template, ADR conventions, Diátaxis applicability | write-issue-spec skill, docs/spec/ initial structure, issue template |
|
||||
| 5. ADR: governance file structure | Decision on which governance files exist, what each owns, what adapters look like | AGENTS.md, CLAUDE.md, GLOSSARY.md |
|
||||
| 5. ADR: governance file structure | Decision on which governance files exist, what each owns, what adapters look like | AGENTS.md, CLAUDE.md, CONTEXT.md |
|
||||
| 6. ADR: skill library scope | Which skills to build first; factory/ vs other categories; which to defer | Phase 1 and 2 skill build order |
|
||||
|
||||
### What to give Claude Code before each session
|
||||
@@ -676,7 +676,7 @@ ai-coding-factory-skills-index.md
|
||||
ai-coding-factory-implementation-guidance.md
|
||||
|
||||
# Add for sessions 2-6 (outputs from session 1)
|
||||
GLOSSARY.md (once bootstrapped)
|
||||
CONTEXT.md (once bootstrapped)
|
||||
docs/adr/ (any ADRs already produced)
|
||||
```
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
**Scope:** Design, structure, and operation of the AI-assisted software development and infrastructure management factory
|
||||
**Audience:** Humans maintaining and extending the factory; AI agents making design decisions within it
|
||||
**Derivation:** Derived from sourced research across ten design topics. Principles are evidence-based, not aspirational.
|
||||
**Operative files:** `AGENTS.md` (agent governance) | `GLOSSARY.md` (project conventions) | `.agents/skills/` (skill library)
|
||||
**Operative files:** `AGENTS.md` (agent governance) | `CONTEXT.md` (project conventions) | `.agents/skills/` (skill library)
|
||||
**Research basis:** `ai-coding-factory-research.md`
|
||||
|
||||
The factory is a governed AI-assisted development environment. This document defines the principles behind its structure — why it is built the way it is and what governs changes to it. It is not an implementation guide; the implementation lives in the repository files this document governs.
|
||||
@@ -17,7 +17,7 @@ The factory is a governed AI-assisted development environment. This document def
|
||||
Write conventions, principles, and skills once in plain language with no tool-specific references. Translate into tool-specific format (CLAUDE.md, copilot-instructions.md, cursor rules) with thin adapter files that reference the source, not duplicate it. When tools change, only the adapter changes. This is the same separation-of-concerns pattern as the governance constitution: conventions are stable; tool formats are not.
|
||||
|
||||
**One source of truth per concern.**
|
||||
AGENTS.md is the single source of governance rules. GLOSSARY.md is the single source of project conventions. Each skill is the single source for its task type. Duplicating content into tool-specific files creates maintenance debt and drift — it is prohibited.
|
||||
AGENTS.md is the single source of governance rules. CONTEXT.md is the single source of project conventions. Each skill is the single source for its task type. Duplicating content into tool-specific files creates maintenance debt and drift — it is prohibited.
|
||||
|
||||
**Spec before implementation.**
|
||||
Every non-trivial implementation task begins with a spec. The spec is the prompt for all downstream work — it defines what the Developer role builds, what QA tests, and what the Reviewer evaluates. Without a spec the factory has no contract between its stages. Spec-Driven Development is rapidly emerging but not yet mainstream in production: GitHub Spec Kit (~92K stars, May 2026), AWS Kiro (~250K signups over its first preview period), dedicated DeepLearning.AI course. No controlled study comparing SDD with ad-hoc prompting outcomes exists as of May 2026. Even so: SDD overhead is documented and real — skip the spec skill for single-file fixes, obvious one-line changes, or tasks the human can describe completely in one sentence. GitHub's own documentation notes Spec Kit is "best suited for greenfield builds and large feature work rather than small bug fixes." (Thoughtworks Radar: "Assess, not Adopt", November 2025, with the pointed observation: *"We may be relearning a bitter lesson — that handcrafting detailed rules for AI ultimately doesn't scale."*)
|
||||
@@ -130,7 +130,7 @@ Veracode's 2025 GenAI Code Security Report found that **45% of tested AI-generat
|
||||
Tests derived from implementation validate behaviour, which may itself be wrong — circular reasoning. Tests derived from the spec validate intent. This is a structural constraint on the write-tests skill: it requires spec input, not just code input.
|
||||
|
||||
**Design both feedback loops explicitly.**
|
||||
The short loop (finding → immediate fix) happens by default. The long loop (recurring pattern → standing convention) must be deliberately designed. The session-handoff skill explicitly prompts LESSONS.md extraction before closing a session. Convention graduation threshold: three or more LESSONS.md entries covering the same pattern promote to GLOSSARY.md as a standing rule.
|
||||
The short loop (finding → immediate fix) happens by default. The long loop (recurring pattern → standing convention) must be deliberately designed. The session-handoff skill explicitly prompts LESSONS.md extraction before closing a session. Convention graduation threshold: three or more LESSONS.md entries covering the same pattern promote to CONTEXT.md as a standing rule.
|
||||
|
||||
**LESSONS.md is the repo-level feedback mechanism.**
|
||||
Claude Code auto-memory is per-machine and not repo-shared. For lessons to survive machine boundaries and become team-inheritable, they must be committed to `LESSONS.md` in the repo root. This is a correction from common practice — auto-memory is not a substitute.
|
||||
@@ -184,7 +184,7 @@ Promptfoo is the current standard tool (MIT, YAML-based, self-hosted, CI-native)
|
||||
## 9. Context and Token Architecture
|
||||
|
||||
**Orientation is the primary token sink — solve it with structure.**
|
||||
Agents spend up to 80% of token budget on orientation rather than work. The solution is well-structured, always-available context files, not prompt compression. GLOSSARY.md and the reference file architecture solve this at the source.
|
||||
Agents spend up to 80% of token budget on orientation rather than work. The solution is well-structured, always-available context files, not prompt compression. CONTEXT.md and the reference file architecture solve this at the source.
|
||||
|
||||
**Progressive disclosure governs the load strategy.**
|
||||
Only skill name and description pairs load at startup (~30–50 tokens per skill). Full skill bodies load on trigger. Reference files load only when needed during execution. 30 skills cost approximately 900–1,500 tokens at startup. The full body cost is paid only when a skill activates.
|
||||
@@ -192,7 +192,7 @@ Only skill name and description pairs load at startup (~30–50 tokens per skill
|
||||
| Context | Target | Load pattern |
|
||||
|---|---|---|
|
||||
| AGENTS.md | ≤2,000 tokens | Always loaded |
|
||||
| GLOSSARY.md | ≤200 lines | Always loaded |
|
||||
| CONTEXT.md | ≤200 lines | Always loaded |
|
||||
| Per skill body | ≤500 lines | On demand — skill activation |
|
||||
| Per skill references | As needed | On demand — skill instruction |
|
||||
| Session handoff doc | ≤1,000 tokens | Compressed state per boundary |
|
||||
@@ -207,7 +207,7 @@ Using frontier models for tasks a smaller model handles adequately imposes unnec
|
||||
| Adversarial and complex | Flagship (Opus) | architecture-review, security-review (STRIDE), write-spec (ambiguous requirements), incident-diagnosis |
|
||||
|
||||
**Prompt caching is the highest single-ROI optimisation.**
|
||||
Place static content first (AGENTS.md, GLOSSARY.md); dynamic input last. The per-token discount is 90% on cache reads ($0.30/MTok vs. $3.00/MTok for Sonnet 4.6). Actual aggregate savings depend on hit rate, which varies by workflow type; peer-quality agentic data (arXiv 2601.06007) shows 41–80% cost reduction. **TTL caveat:** Around March 2026, Anthropic silently regressed the default cache TTL from 1 hour to 5 minutes for Pro/API users (Max subscribers retained 1-hour TTL). Factor this into strategy — intra-session reuse is reliable under 5 minutes; inter-session reuse requires Max tier or explicit API configuration for 1-hour TTL at 2× write cost.
|
||||
Place static content first (AGENTS.md, CONTEXT.md); dynamic input last. The per-token discount is 90% on cache reads ($0.30/MTok vs. $3.00/MTok for Sonnet 4.6). Actual aggregate savings depend on hit rate, which varies by workflow type; peer-quality agentic data (arXiv 2601.06007) shows 41–80% cost reduction. **TTL caveat:** Around March 2026, Anthropic silently regressed the default cache TTL from 1 hour to 5 minutes for Pro/API users (Max subscribers retained 1-hour TTL). Factor this into strategy — intra-session reuse is reliable under 5 minutes; inter-session reuse requires Max tier or explicit API configuration for 1-hour TTL at 2× write cost.
|
||||
|
||||
**Tokens per completed task is the sustainability metric.**
|
||||
It simultaneously tracks cost, carbon intensity, and whether AI is doing genuine work. Per-token costs fall; aggregate consumption rises because adoption scale outpaces efficiency gains (Jevons paradox). Measure it per task, not in aggregate.
|
||||
|
||||
@@ -197,7 +197,7 @@ Veracode is a security tool vendor with commercial interest in finding vulnerabi
|
||||
4. Design both feedback loops explicitly — short (finding → fix) and long (pattern → convention).
|
||||
5. Repo-level lessons learned live in committed `LESSONS.md`, not in auto memory.
|
||||
6. Tier review findings by severity — alert fatigue breaks the loop.
|
||||
7. Convention graduation: 3+ LESSONS.md entries on same pattern → promote to GLOSSARY.md.
|
||||
7. Convention graduation: 3+ LESSONS.md entries on same pattern → promote to CONTEXT.md.
|
||||
8. Session handoff skill explicitly prompts LESSONS.md extraction before closing.
|
||||
|
||||
---
|
||||
@@ -385,7 +385,7 @@ Context engineering has largely superseded prompt engineering in 2026. Four stra
|
||||
- **OOLONG benchmark (arXiv 2511.02817, November 2025):** All frontier models (including GPT-5, Claude Sonnet 4, Gemini 2.5 Pro) score **<50% at 128K context on aggregation reasoning** — directly contradicting the assumption that large context windows solve comprehension problems.
|
||||
- **"Intelligence Degradation in Long-Context LLMs" (arXiv 2601.15300):** F1 collapses ~45% at 50% of maximum context for tested models — degradation is catastrophic past a threshold, not gradual.
|
||||
|
||||
**Design implication:** The 500-line skill limit and ≤200-line GLOSSARY.md constraint remain well-founded for a different reason: not because reasoning degrades at exactly 3,000 tokens, but because (a) aggregation reasoning is poor even at 128K for all current models, and (b) the SkillReducer paper (arXiv 2603.29919) confirms that large skill bodies provide worse quality output than compressed equivalents, independent of absolute token counts. Drop the "3,000-token ceiling" framing; keep the size limits with this corrected rationale. Source: Levy et al. (2024) via thomas-wiegold.com; arxiv.org/abs/2511.02817; arxiv.org/abs/2601.15300; Anthropic MRCR v2 eval.
|
||||
**Design implication:** The 500-line skill limit and ≤200-line CONTEXT.md constraint remain well-founded for a different reason: not because reasoning degrades at exactly 3,000 tokens, but because (a) aggregation reasoning is poor even at 128K for all current models, and (b) the SkillReducer paper (arXiv 2603.29919) confirms that large skill bodies provide worse quality output than compressed equivalents, independent of absolute token counts. Drop the "3,000-token ceiling" framing; keep the size limits with this corrected rationale. Source: Levy et al. (2024) via thomas-wiegold.com; arxiv.org/abs/2511.02817; arxiv.org/abs/2601.15300; Anthropic MRCR v2 eval.
|
||||
|
||||
### XML tags: when they help
|
||||
|
||||
@@ -397,7 +397,7 @@ Claude Opus 4.5 and 4.6 tend to overengineer — extra files, unnecessary abstra
|
||||
|
||||
### Context file design
|
||||
|
||||
"Decisions not descriptions" → ~20% token reduction. AST-level file loading → ~65% fewer file reads. Source: earezki.com/ai-news/2026-02-26 (February 2026 — single practitioner case study). ⚠️ **Commercial bias: Nicola Alessi is the developer of vexp** (vexp.dev, the AST-loading tool used in the case study). The case study should not be treated as an independent third-party result. The general principle (precise context over broad loading) is sound; the specific 65% figure reflects vexp's capabilities in that specific codebase and should be treated as an indicative upper bound, not a guaranteed outcome. The "40 file reads" baseline was also unusually broad — more disciplined GLOSSARY.md instructions could close most of the gap without AST tooling. Technology choices with rationale, ADRs, codebase-specific anti-patterns, Preferred/Avoid code blocks. Source: packmind.com/context-engineering-ai-coding (April 2026).
|
||||
"Decisions not descriptions" → ~20% token reduction. AST-level file loading → ~65% fewer file reads. Source: earezki.com/ai-news/2026-02-26 (February 2026 — single practitioner case study). ⚠️ **Commercial bias: Nicola Alessi is the developer of vexp** (vexp.dev, the AST-loading tool used in the case study). The case study should not be treated as an independent third-party result. The general principle (precise context over broad loading) is sound; the specific 65% figure reflects vexp's capabilities in that specific codebase and should be treated as an indicative upper bound, not a guaranteed outcome. The "40 file reads" baseline was also unusually broad — more disciplined CONTEXT.md instructions could close most of the gap without AST tooling. Technology choices with rationale, ADRs, codebase-specific anti-patterns, Preferred/Avoid code blocks. Source: packmind.com/context-engineering-ai-coding (April 2026).
|
||||
|
||||
### Chain-of-thought for review skills
|
||||
|
||||
@@ -413,14 +413,14 @@ XML experiment small sample (N=12). "20% reduction" and "65% reduction" are sing
|
||||
|
||||
### Provisional principles
|
||||
|
||||
1. Context engineering is the primary discipline — GLOSSARY.md and reference files are the primary artefact.
|
||||
1. Context engineering is the primary discipline — CONTEXT.md and reference files are the primary artefact.
|
||||
2. Keep loaded context per skill invocation lean — the 500-line skill limit is justified by SkillReducer's "less-is-more effect" (+2.8% quality from compressed skills) and OOLONG's finding of <50% aggregation reasoning at 128K even for frontier models. The previous "3,000-token ceiling" framing (Levy et al. 2024) was a misreading — see corrected evidence above.
|
||||
3. XML for complex skills (500+ tokens, 3+ sections); plain prose for simple skills.
|
||||
4. Every implementation skill includes an explicit constraints section.
|
||||
5. Use `<thinking>` + named output tags for review and security skills.
|
||||
6. Reference files by path rather than loading full content.
|
||||
7. End every implementation skill with a self-check instruction.
|
||||
8. Document Preferred/Avoid code blocks in GLOSSARY.md for every convention that matters.
|
||||
8. Document Preferred/Avoid code blocks in CONTEXT.md for every convention that matters.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,302 +0,0 @@
|
||||
# Agent team structures for software delivery
|
||||
|
||||
Researched 2026-11-13 for holocron#170 (ADR-0031, GLOSSARY "Delivery team"). This note builds on
|
||||
`docs/research/team-patterns/multi-agent-team-patterns.md` (branch `research/team-patterns`) and
|
||||
does not repeat it: that note already showed that generic roles loading skills beat tool
|
||||
specialists, and that orchestrator–worker with state passed by pointer is the standard shape. This
|
||||
note gathers evidence and makes a recommendation. It does not decide anything.
|
||||
|
||||
## Question
|
||||
|
||||
How do multi-agent delivery teams relate an orchestrator or lead to its role agents in practice?
|
||||
Which structure fits holocron's constraints: provider-agnostic apm, human on the loop, and state
|
||||
passed by pointer through Gitea? Two scope additions are folded in. The first is function
|
||||
specialists *within* a stage (test writer, implementer, QA). The second is a "stage lead per
|
||||
session" model.
|
||||
|
||||
## Answer in brief
|
||||
|
||||
- **The orchestrator is almost always the main loop.** That is the main session, or code that
|
||||
carries a prompt. It is not a separately dispatched agent. Where a vendor calls it an agent
|
||||
(Anthropic's LeadResearcher, Magentic manager, CrewAI manager, Claude agent-team lead), it is
|
||||
still the top of the loop, and in Claude agent teams "the main session is the lead for its
|
||||
lifetime" [S7].
|
||||
- **Orchestrators decompose dynamically, and fixed SDLC roles are rarer.** Orchestrator–workers
|
||||
is defined by subtasks that "aren't pre-defined" [S1]. Fixed role chains appear in research
|
||||
systems (MetaGPT, ChatDev, AgentCoder), in Anthropic's planner/generator/evaluator harness
|
||||
[S21], and in VS Code's Plan→Implement→Review handoffs [S26]. The fixed role with the best
|
||||
evidence is a **separate verifier or evaluator**, not a separate implementer.
|
||||
- **Nested delegation is not portable.** Claude Code nests by default, up to three levels [S4].
|
||||
Cursor allows one extra level [S14]. Gemini CLI forbids nesting [S13]. Codex blocks it by
|
||||
default [S12][S27]. Copilot CLI is unverified. ADR-0031's *conclusion* (leaf role agents) stands
|
||||
as the lowest common denominator. Its stated *reason* is out of date: Claude Code subagents can
|
||||
now spawn subagents.
|
||||
- **A fixed pipeline should be sequenced by deterministic code, with the LLM working inside each
|
||||
stage.** Every framework says so: Anthropic workflows [S1], the OpenAI "orchestrating via code"
|
||||
section [S8], Microsoft Agent Framework's "If you can write a function to handle the task, do
|
||||
that" [S23], ADK graph workflows [S24], and the LangChain custom workflow [S17].
|
||||
- **Recommendation:** keep leaf role agents and state passed by pointer. Replace the
|
||||
cross-stage LLM Lead with **one session per stage**. Tracker labels and a small script sequence
|
||||
the stages, and each session's main loop is that stage's lead, dispatching flat leaf
|
||||
specialists. Inside *implement*, add a test-author step before the implementer and keep a
|
||||
fresh-context verifier. Those are function specialists working one at a time, never parallel
|
||||
writers.
|
||||
|
||||
## 1. Structural patterns in use
|
||||
|
||||
| Pattern | Who controls the flow | First-party examples |
|
||||
|---|---|---|
|
||||
| Orchestrator–worker or supervisor (agents as tools) | Main loop calls workers and keeps control | Anthropic orchestrator–workers [S1] and research system [S2]. Claude Code, Codex, Gemini CLI, Cursor and Copilot subagents [S4][S12][S13][S14][S25]. OpenAI `Agent.as_tool()`, "manager keeps control" [S8]. LangChain "Subagents: a main agent coordinates subagents as tools" [S17]. OpenHands `task` tool: "the parent blocks until the sub-agent finishes" [S28] |
|
||||
| Hierarchical (nested supervisors) | Supervisors of supervisors | `langgraph-supervisor` supports multi-level setups, but its maintainers now recommend the supervisor pattern "directly via tools" for most cases (search-result snippet of [S29], not read in full). ADK hierarchical decomposition [S9]. Manager Devins spawning child Devins [S22] |
|
||||
| Handoffs or swarm | Control passes peer to peer, and the active agent changes | OpenAI handoffs: "that specialist becomes the active agent" [S8]. `langgraph-swarm` [S29]. MAF Handoff [S23]. VS Code custom-agent `handoffs`, which are user-clicked and use `send: false` by default [S26] |
|
||||
| SOP pipeline with fixed roles | A fixed sequence of persona roles | MetaGPT's "assembly line paradigm to assign diverse roles" [S15]. ChatDev's design, coding and testing phases via a chat chain [S16]. Anthropic's planner→generator→evaluator harness [S21] |
|
||||
| Group chat or magentic | A manager selects the next speaker in a shared conversation | MAF Group Chat and Magentic, where Magentic is "a dedicated Magentic manager" with a task and progress ledger, built on AutoGen Magentic-One [S23]. MAF warns that performance outside the original Magentic-One design "is untested" |
|
||||
| Workflow or graph (deterministic) | Code or graph edges | Anthropic prompt chaining [S1]. OpenAI code orchestration [S8]. MAF Sequential/Concurrent workflows [S23]. ADK graph and dynamic workflows, which are "deterministic processes that combine code logic and AI reasoning" (ADK 2.0) [S24]. CrewAI sequential process [S30] |
|
||||
| Peer team with a shared task list | Lead plus self-claiming teammates | Claude Code agent teams. These are experimental, with "No nested teams", "Lead is fixed", and "Start with research and review" [S7] |
|
||||
| Single agent plus skills | One loop that loads context | LangChain: "A single agent stays in control while loading context from skills" [S17]. Cognition [S3][S22] |
|
||||
|
||||
What vendors report working in production for coding, as of 2026: Cognition's April 2026
|
||||
follow-up says "writes stay single-threaded and the additional agents contribute intelligence
|
||||
rather than actions". In practice that means a generator–verifier loop in which review works best
|
||||
"when the coding and review agents do not share any context beforehand", plus manager-and-children
|
||||
map-reduce. It calls "arbitrary networks of agents negotiating with each other" "mostly a
|
||||
distraction" [S22].
|
||||
|
||||
## 2. Orchestrator: an agent definition or the main loop? Role-less or fixed roles?
|
||||
|
||||
| Source | What the orchestrator is | Workers |
|
||||
|---|---|---|
|
||||
| Anthropic research system [S2] | A prompted LeadResearcher at the top of the loop. Only the lead is described creating subagents | Dynamic and per-query ("it can be any number") |
|
||||
| Anthropic "Building effective agents" [S1] | "a central LLM" | "subtasks aren't pre-defined" |
|
||||
| Claude Code [S4][S7] | The main session. `claude --agent X` makes the *main thread* adopt agent X. The agent-team lead is fixed to the main session | Generic built-ins plus user-defined agents |
|
||||
| Codex, Gemini CLI, Cursor [S12][S13][S14] | "ChatGPT or Codex handles orchestration". Gemini: subagents are "exposed to the main agent as a tool" | Generic built-ins (worker, explorer, generalist and similar) |
|
||||
| OpenAI Agents SDK [S8] | Either a manager agent (LLM) or code | Specialists |
|
||||
| CrewAI hierarchical [S30] | `manager_llm` (auto-created manager) or a custom `manager_agent` | Persona roles |
|
||||
| MAF Magentic [S23] | A manager agent with fixed Magentic-One prompts by default | User-defined specialists |
|
||||
| Cognition [S22] | A manager Devin. Failure modes: managers are "overly prescriptive", and children wrongly assume they share state | Child Devins |
|
||||
|
||||
**Synthesis.** The orchestrator is the top of the loop. Packaging it as an "agent definition" is
|
||||
just a way to hand that loop a prompt (`--agent`), and only some runtimes support it (§5). Generic
|
||||
decomposition is the default. Fixed SDLC roles have direct evidence in their favour in only one
|
||||
place: **separating the evaluator or verifier from the producer**.
|
||||
|
||||
- Anthropic's harness: agents "reliably skew positive when grading their own work", and tuning a
|
||||
standalone evaluator to be skeptical is "far more tractable" [S21].
|
||||
- Cognition: review without shared context works best [S22].
|
||||
- Claude Code best practice: `/code-review` runs "in a fresh subagent that never saw your
|
||||
conversation". Also, "Handing the same task to a subagent doesn't make the answer any better. A
|
||||
fresh reviewer does help" [S31].
|
||||
|
||||
The evidence against fixed roles:
|
||||
|
||||
- In Anthropic's own harness, roles were *removed* as models improved. With Opus 4.6 the sprint
|
||||
construct went, and the evaluator moved to a single pass at the end. The planner stayed, because
|
||||
the generator under-scoped without it [S21].
|
||||
- Anthropic's long-running harness used two "agents" that were the *same* system prompt and tools
|
||||
with different first prompts. It left open whether specialised testing or QA agents do better
|
||||
[S32].
|
||||
- MAST found 14 failure modes across 1,600+ traces, including inter-agent misalignment [S19].
|
||||
|
||||
## 3. Nested delegation support (verified 2026-11-13)
|
||||
|
||||
| Runtime | Can a subagent spawn subagents? | Evidence |
|
||||
|---|---|---|
|
||||
| Claude Code (v2.1.323) | **Yes, by default, up to 3 layers** below main. `CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH`, where `1` turns nesting off. A per-agent block is possible by omitting `Agent` from its tools. Agent teams: "No nested teams" | [S4][S7] |
|
||||
| Codex CLI | **No, by default.** Multi-agent V1 uses `agents.max_depth` with default `1` (root=0, so children cannot spawn), and it is configurable. The opt-in V2 (`multi_agent_v2`, `default_enabled: false`) ignores `max_depth`. The current public docs no longer list `max_depth` | Source `codex-rs/core/src/config/mod.rs` `DEFAULT_AGENT_MAX_DEPTH: i32 = 1`, `features/src/lib.rs`, commit `69231e1` (2026-11-13) [S27]. Docs [S12] |
|
||||
| Gemini CLI | **No.** "subagents cannot call other subagents" | [S13] |
|
||||
| Cursor (2.5+) | **One extra level.** The main agent and its direct subagents can spawn, "but a subagent launched by another subagent can't launch further ones" | [S14] |
|
||||
| Copilot CLI | **Unverified.** The docs are silent. A third-party changelog mirror mentions "nested subagents respect concurrency limits" (1.0.62), which is not confirmed | [S25] |
|
||||
| VS Code Copilot, Local harness | Off by default. `chat.subagents.allowInvocationsFromSubagents` allows a maximum depth of 5. The Local harness is deprecated and will be removed in February 2027. The Copilot harness (`task` tool) is undocumented on this point | [S26] |
|
||||
|
||||
**Implication.** The portable lowest common denominator is *one* level: main loop → leaf.
|
||||
ADR-0031's "Lead is the only dispatcher" is correct for portability. GLOSSARY and the issue should
|
||||
cite Gemini CLI and Codex's default as the binding constraints, not Claude Code.
|
||||
|
||||
## 4. Deterministic code versus LLM orchestration for a fixed pipeline
|
||||
|
||||
- Anthropic: "workflows offer predictability and consistency for well-defined tasks". Agents are
|
||||
for when "flexibility and model-driven decision-making are needed" [S1].
|
||||
- OpenAI: orchestrating via code "makes tasks more deterministic and predictable, in terms of
|
||||
speed, cost and performance". Its patterns are classify-then-route, chaining, and
|
||||
evaluator loops [S8].
|
||||
- Microsoft: use a workflow when "the process has well-defined steps" and "you need explicit
|
||||
control over execution order". "If you can write a function to handle the task, do that instead
|
||||
of using an AI agent" [S23].
|
||||
- Google ADK: template workflow agents run "without consulting an AI model … deterministic and
|
||||
predictable". ADK 2.0 adds graph and dynamic workflows that mix code and LLM nodes [S24].
|
||||
|
||||
spec → tickets → code → review → merge has fixed stages and human gates. The *transition* between
|
||||
stages is a pure function of tracker state: label X means run stage Y. That is code. The *work
|
||||
inside* a stage (decomposing a spec, writing code, judging a diff) is LLM work. An LLM Lead that
|
||||
reads labels and picks the next stage is an LLM doing a lookup. It adds cost and an
|
||||
instruction-following failure surface (MAST "system design" failures [S19]) for no flexibility the
|
||||
human gates do not already remove.
|
||||
|
||||
## 5. "Stage lead per session": runtime support
|
||||
|
||||
The model runs each stage as its own top-level session whose main loop is the stage lead. That
|
||||
lead spawns leaf specialists, so the model needs no nesting. Hand-off between stages goes through
|
||||
Gitea plus human gates, and a script chains headless sessions in run mode.
|
||||
|
||||
| Runtime | Main session as a custom agent | Headless | Both together |
|
||||
|---|---|---|---|
|
||||
| Claude Code | `--agent <name>`. The main-thread agent can spawn subagents, and `Agent(type)` allowlists them [S4][S33] | `-p` | **Verified locally**: `claude -p --agent lint-runner …` ran with the agent's prompt (v2.1.323) |
|
||||
| Copilot CLI | `--agent <id>` or `/agent` [S34] | `-p` / `--prompt`, with `--allow-tool` and `--no-ask-user` [S35] | Documented example: `copilot --agent security-auditor --prompt "…"` [S34] |
|
||||
| Codex CLI | **No `--agent` flag** for the root session (checked in source: `exec/src/cli.rs`). Closest: `--profile`, `-c developer_instructions=…` or `model_instructions_file` [S36] | `codex exec` | Via profile or config override, not an agent file |
|
||||
| Gemini CLI | **No `--agent` flag** (checked in `packages/cli/src/config/config.ts`). `GEMINI_SYSTEM_MD` *replaces* the whole system prompt [S37] | `-p` | Via `GEMINI_SYSTEM_MD`, or a prompt that invokes the stage skill |
|
||||
| Cursor CLI | **No flag.** `--mode` accepts only `plan` or `ask` [S38] | `-p` / `--print` | Prompt only |
|
||||
|
||||
So `--agent` is portable to two of five runtimes. What is portable to all five is **a headless
|
||||
session whose prompt invokes the stage skill**. That is how ADR-0031's Lead skill already works.
|
||||
The stage lead should therefore be a *skill* (one per stage), with a thin `--agent` wrapper only
|
||||
where the runtime has one.
|
||||
|
||||
**Vendor precedent for chaining sessions with a script.** Anthropic's long-running harness runs
|
||||
each step as a fresh session. State is handed over through `claude-progress.txt`, a JSON feature
|
||||
list and git commits, so that a new session can "quickly understand the state of work when
|
||||
starting with a fresh context window" [S32]. Claude Code's best practices say to write `SPEC.md`
|
||||
and "start a fresh session to build from it". They also recommend a second session as the
|
||||
independent reviewer [S31]. Copilot and Cursor document `-p` specifically "for scripts, CI
|
||||
pipelines, or automation" [S35][S38]. I found no vendor that recommends one long-lived LLM
|
||||
orchestrator spanning spec through merge, and Claude agent teams cannot be resumed ("No session
|
||||
resumption") [S7].
|
||||
|
||||
## 6. Function specialists within a stage
|
||||
|
||||
The earlier note argued against **tool** specialists (an "ansible-engineer"). **Function**
|
||||
specialists (test author, implementer, verifier) are a different question, and the evidence on
|
||||
them is mixed.
|
||||
|
||||
**(a) Separating test authoring from implementation**
|
||||
|
||||
- AgentCoder: programmer, test designer and test executor agents. Test accuracy was 61.0/51.8
|
||||
when a single agent wrote both, against 87.8/89.9 with a separate designer (HumanEval/MBPP),
|
||||
because "the tests designed by the same agent that generates the code can be biased by the code
|
||||
and lose objectivity". Ablation pass@1 (likely GPT-3.5) rose from 61.0 for the programmer alone
|
||||
to 79.9 for the full pipeline [S39]. Caveat: these are 2023–24 function-level benchmarks, not
|
||||
repository work.
|
||||
- ImpossibleBench (Oct 2025): agents with test access "may delete failing tests rather than fix
|
||||
the underlying bug". GPT-5 cheats 54% on Conflicting-SWEbench (76% one-off). Hiding tests cuts
|
||||
cheating to near zero but hurts legitimate performance. Read-only tests are "a middle ground"
|
||||
that "does not eliminate … special-casing or operator overloading" [S40]. Anthropic system cards
|
||||
track hard-coding and special-casing as reward hacking (secondary reading only, not verified in
|
||||
the PDFs) [S41].
|
||||
- Counter-evidence: "More agent-written tests do not mean more solves" (six frontier models, Apr
|
||||
2026) [S42]. This concerns the *volume* of tests a single agent writes, not author separation.
|
||||
|
||||
**(b) Flat versus per-stage sub-lead**
|
||||
|
||||
A per-stage sub-lead *as a subagent* needs two levels. That works on Claude and Cursor, and fails
|
||||
on Gemini and on Codex's default (§3). The portable options are:
|
||||
|
||||
1. **Flat**: the top-level Lead dispatches test author, implementer and verifier directly.
|
||||
2. **Stage lead per session** (§5): the stage session *is* the sub-lead, and its specialists are
|
||||
one level down.
|
||||
|
||||
LangGraph's maintainers steering users from the multi-level supervisor library to a flat
|
||||
supervisor via tools [S29] points the same way (secondary snippet).
|
||||
|
||||
**(c) Benefits versus costs**
|
||||
|
||||
- Benefits: test oracles independent of the code [S39], and less self-grading bias [S21][S22][S31].
|
||||
- Costs: multi-agent systems use about 15× the tokens of chat [S2]. Agent teams use "significantly
|
||||
more tokens" [S7]. A fresh subagent "can end up *slower*", because it re-gathers context [S31].
|
||||
Context loss at hand-off and children assuming shared state are reported failures [S22][S19].
|
||||
- AgentCoder reports *lower* tokens than its multi-agent baselines (56.9K against 138.2K) [S39].
|
||||
That comparison is against other multi-agent systems, not a single agent.
|
||||
|
||||
**Implication.** One function specialist is justified: the one that **verifies or constrains** the
|
||||
writer. That covers a test author working before the code, and a verifier or reviewer with fresh
|
||||
context. A second *writer* running in parallel is not justified [S3][S22]. A sequential
|
||||
test-author → implementer hand-off keeps a single writer at any one time.
|
||||
|
||||
## 7. Recommendation
|
||||
|
||||
Keep the parts of ADR-0031 that fit the evidence: leaf role agents, human-set gates, state passed
|
||||
by pointer, and one dispatcher per session. Change the shape of the Lead:
|
||||
|
||||
1. **Sequence stages with tracker state and code, not an LLM.** Each stage is a skill
|
||||
(`spec-lead`, `tickets-lead`, `implement-lead`, `review-lead`, `verify-lead`), started as its
|
||||
own session. Interactive mode: a human starts it. Run mode: a short script maps a Gitea label to
|
||||
the next stage and launches `claude -p --agent implement-lead …`, `copilot --agent … -p …`, or
|
||||
`codex exec` / `gemini -p` / `agent -p` with a prompt that invokes the skill. The thin `--agent`
|
||||
wrapper is optional and only exists for Claude and Copilot.
|
||||
2. **Within a session, the stage skill is the only dispatcher**, and specialists stay leaves. No
|
||||
nesting is required on any runtime.
|
||||
3. **Inside implement, use sequential function specialists**: test author (writes failing
|
||||
acceptance tests from the ticket and commits them) → implementer (tests read-only) → verifier
|
||||
(fresh context, runs the tests and checks the diff against the ticket). Enforce "implementer
|
||||
does not edit the test author's tests" with a hook or pre-push diff check, not a prompt
|
||||
(governance: deterministic enforcement). Do not run parallel writers on one ticket.
|
||||
4. Correct the stated rationale in ADR-0031, GLOSSARY and #170. The binding constraints are Gemini
|
||||
CLI (no nesting) and Codex's default `max_depth=1`. Claude Code is not one of them.
|
||||
|
||||
**Strongest counter-argument.** Do less: one implementer session per ticket doing test-first
|
||||
itself, followed by a fresh-context reviewer.
|
||||
|
||||
- Every extra hand-off loses context and costs tokens and latency [S2][S31].
|
||||
- Vendors are *removing* harness roles as models improve [S21].
|
||||
- More agent-written tests do not move outcomes [S42].
|
||||
- Read-only tests do not stop special-casing [S40], so the test-author split buys an independent
|
||||
oracle but not integrity.
|
||||
- A per-stage session also gives up any cross-stage judgement a long-lived Lead could exercise,
|
||||
and adds a script to maintain.
|
||||
|
||||
Answer: the human gates already supply that cross-stage judgement. And the verifier step is the
|
||||
part the evidence supports most strongly [S21][S22][S31]. If cost matters more than oracle
|
||||
independence, drop the test author first and keep the verifier.
|
||||
|
||||
## Unverified or not reached
|
||||
|
||||
- Copilot CLI nested subagents, and whether the Copilot harness `task` tool nests.
|
||||
- Whether Codex V2 multi-agent permits unbounded nesting in practice. Source shows that
|
||||
`max_depth` is ignored, but the V2 depth logic was not traced.
|
||||
- The headless/`--agent` combination on Copilot CLI is documented but was not run locally.
|
||||
- Anthropic system-card reward-hacking figures were read only through secondary quotes.
|
||||
- The ADK multi-agent page (`sub_agents` single-parent rule) is now a redirect, so the 2.0 graph and
|
||||
dynamic docs were used instead.
|
||||
|
||||
## Sources
|
||||
|
||||
Fetched 2026-11-13 unless noted. S1–S20 carry the numbering of the prior note.
|
||||
|
||||
- [S1] Anthropic, "Building effective agents" (2024-12-19) — <https://www.anthropic.com/engineering/building-effective-agents>
|
||||
- [S2] Anthropic, "How we built our multi-agent research system" (2025-06-13) — <https://www.anthropic.com/engineering/multi-agent-research-system>
|
||||
- [S3] Cognition, "Don't build multi-agents" (2025-06-12) — <https://cognition.com/blog/dont-build-multi-agents>
|
||||
- [S4] Claude Code docs, "Subagents" — <https://code.claude.com/docs/en/sub-agents>
|
||||
- [S7] Claude Code docs, "Agent teams" — <https://code.claude.com/docs/en/agent-teams>
|
||||
- [S8] OpenAI Agents SDK, "Agent orchestration" — <https://openai.github.io/openai-agents-python/multi_agent/>
|
||||
- [S9] Google Developers Blog, multi-agent patterns in ADK (cited from prior note)
|
||||
- [S12] Codex docs, "Subagents" — <https://learn.chatgpt.com/docs/agent-configuration/subagents>
|
||||
- [S13] Gemini CLI docs, "Subagents" — <https://geminicli.com/docs/core/subagents/>
|
||||
- [S14] Cursor docs, "Subagents" — <https://cursor.com/docs/context/subagents>
|
||||
- [S15] Hong et al., MetaGPT, arXiv:2308.00352 v7 — <https://arxiv.org/abs/2308.00352>
|
||||
- [S16] Qian et al., ChatDev, arXiv:2307.07924 v5 (ACL 2024) — <https://arxiv.org/abs/2307.07924>
|
||||
- [S17] LangChain docs, "Multi-agent" — <https://docs.langchain.com/oss/python/langchain/multi-agent>
|
||||
- [S19] Cemri et al., MAST, arXiv:2503.13657 v3 — <https://arxiv.org/abs/2503.13657>
|
||||
- [S21] Anthropic, "Harness design for long-running application development" (2026-03-24) — <https://www.anthropic.com/engineering/harness-design-long-running-apps>
|
||||
- [S22] Cognition, "Multi-Agents: What's Actually Working" (2026-04-22) — <https://cognition.com/blog/multi-agents-working>
|
||||
- [S23] Microsoft Agent Framework docs: Overview (2026-10-23), Orchestrations, Magentic — <https://learn.microsoft.com/en-us/agent-framework/overview/>, <https://learn.microsoft.com/en-us/agent-framework/workflows/orchestrations/magentic>
|
||||
- [S24] Google ADK docs: Agents, Template workflows, Graph-based and Dynamic workflows (ADK 2.0) — <https://github.com/google/adk-docs/tree/main/docs> (`agents/index.md`, `agents/workflow-agents/index.md`, `graphs/index.md`, `graphs/dynamic.md`)
|
||||
- [S25] GitHub Docs, "About custom agents" (Copilot CLI) — <https://docs.github.com/en/copilot/concepts/agents/copilot-cli/about-custom-agents>
|
||||
- [S26] VS Code docs, "Subagents" and "Custom agents" (2026-11-11) — <https://code.visualstudio.com/docs/agents/run/subagents>, <https://code.visualstudio.com/docs/copilot/customization/custom-agents>
|
||||
- [S27] openai/codex source at commit `69231e119bfc` (2026-11-13): `codex-rs/core/src/config/mod.rs`, `core/src/tools/spec_plan.rs`, `core/src/agent/registry.rs`, `features/src/lib.rs`, `core/config.schema.json` — <https://github.com/openai/codex>
|
||||
- [S28] OpenHands SDK docs, "Task tool set" — <https://docs.openhands.dev/sdk/guides/task-tool-set>
|
||||
- [S29] LangChain reference, `langgraph-supervisor` / `langgraph-swarm` — <https://reference.langchain.com/python/langgraph-supervisor> (the multi-level and "use tools instead" claims come from search snippets, not the page as fetched)
|
||||
- [S30] CrewAI docs, "Processes" — <https://docs.crewai.com/en/concepts/processes>
|
||||
- [S31] Claude Code docs, "Best practices" — <https://code.claude.com/docs/en/best-practices>
|
||||
- [S32] Anthropic, "Effective harnesses for long-running agents" (2025-11-26) — <https://www.anthropic.com/engineering/effective-harnesses-for-long-running-agents>
|
||||
- [S33] Claude Code docs, "CLI reference" — <https://code.claude.com/docs/en/cli-reference>
|
||||
- [S34] GitHub Docs, "Creating custom agents for Copilot CLI" — <https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/create-custom-agents-for-cli>
|
||||
- [S35] GitHub Docs, "Run Copilot CLI programmatically" — <https://docs.github.com/en/copilot/how-tos/copilot-cli/automate-copilot-cli/run-cli-programmatically>
|
||||
- [S36] Codex config reference — <https://learn.chatgpt.com/codex/config-file/config-reference>; `codex-rs/exec/src/cli.rs`, `utils/cli/src/shared_options.rs` [S27]
|
||||
- [S37] Gemini CLI source and docs: `packages/cli/src/config/config.ts`, `docs/cli/system-prompt.md` — <https://github.com/google-gemini/gemini-cli>
|
||||
- [S38] Cursor CLI docs, "Overview" and "Parameters" — <https://cursor.com/docs/cli/overview>, <https://cursor.com/docs/cli/reference/parameters>
|
||||
- [S39] Huang et al., AgentCoder, arXiv:2312.13010 v3 (§4.3 Table 2, §4.7 Table 6) — <https://arxiv.org/html/2312.13010v3>
|
||||
- [S40] Zhong, Raghunathan, Carlini, ImpossibleBench, arXiv:2510.20270 v1 — <https://arxiv.org/html/2510.20270v1>
|
||||
- [S41] Anthropic, Claude Opus 4 & Sonnet 4 system card (May 2025), reward-hacking section (read only through secondary quotes)
|
||||
- [S42] "Rethinking the Value of Agent-Generated Tests", arXiv:2602.07900 v2 (2026-04-09) — <https://arxiv.org/html/2602.07900v2>
|
||||
|
||||
Repo sources: `docs/adr/0031-first-party-delivery-team-replaces-mattpocock-chain.md` (untracked on
|
||||
`docs/wayfinding-operations`), `GLOSSARY.md` "Delivery team",
|
||||
`docs/research/team-patterns/multi-agent-team-patterns.md` (branch `research/team-patterns`).
|
||||
@@ -61,7 +61,7 @@ Plugin-root documentation belongs in `docs/`. That convention is older than the
|
||||
Those on-demand files are plain markdown — no frontmatter, no schema. The agent decides when to read each one from task context and the content index label alone. Frontmatter is deferred until there is evidence that agents are loading the wrong files in practice; it is a deliberate deferral, not an oversight to close.
|
||||
|
||||
The governance layer has two phases:
|
||||
- **Phase 1** (complete): instruction and documentation layer — `governance.md` loaded via `@import`; `core/ai-constitution.md` and `docs/wiki/HUMANS.md` as human-facing reference; `GLOSSARY.md` glossing the one governance term used unglossed elsewhere (HITL); the rest of the governance vocabulary is defined in `core/ai-constitution.md`.
|
||||
- **Phase 1** (complete): instruction and documentation layer — `governance.md` loaded via `@import`; `core/ai-constitution.md` and `docs/wiki/HUMANS.md` as human-facing reference; `CONTEXT.md` glossing the one governance term used unglossed elsewhere (HITL); the rest of the governance vocabulary is defined in `core/ai-constitution.md`.
|
||||
- **Phase 2** (planned): deterministic enforcement layer — pre-commit hooks, CI gates, secret scanning, licence scanning. Specified in `docs/research/governance_principles/CONTROLS.md`.
|
||||
|
||||
## AGENTS.md pattern
|
||||
@@ -73,9 +73,9 @@ This repo uses two `AGENTS.md` files as the provider-agnostic source of always-o
|
||||
|
||||
Both `CLAUDE.md` files are thin adapters: they import from their respective `AGENTS.md` and add only Claude Code-specific syntax (`@import`, content index paths). They carry no original always-on content.
|
||||
|
||||
This repo also has a `CLAUDE.md` at its root — the Claude Code entry point for working in this repo. It imports `AGENTS.md` and nothing else; there is no `@GLOSSARY.md` import. It is not import-only either: below the import sits a fenced `<!-- rtk-instructions v2 -->` … `<!-- /rtk-instructions -->` block carrying the RTK command-prefix convention, which is tool-specific content with no `AGENTS.md` source. This is distinct from `providers/claude-code/CLAUDE.md`, which is the global config deployed to `~/.claude/`.
|
||||
This repo also has a `CLAUDE.md` at its root — the Claude Code entry point for working in this repo. It imports `AGENTS.md` and nothing else; there is no `@CONTEXT.md` import. It is not import-only either: below the import sits a fenced `<!-- rtk-instructions v2 -->` … `<!-- /rtk-instructions -->` block carrying the RTK command-prefix convention, which is tool-specific content with no `AGENTS.md` source. This is distinct from `providers/claude-code/CLAUDE.md`, which is the global config deployed to `~/.claude/`.
|
||||
|
||||
`GLOSSARY.md` is therefore **not** always-loaded. `AGENTS.md` instructs agents to read it at session start, which is a behavioural instruction, not an `@import` guarantee.
|
||||
`CONTEXT.md` is therefore **not** always-loaded. `AGENTS.md` instructs agents to read it at session start, which is a behavioural instruction, not an `@import` guarantee.
|
||||
|
||||
## Reference conventions
|
||||
|
||||
|
||||
+46
-38
@@ -283,9 +283,7 @@ monorepo root further up.
|
||||
The universe is then:
|
||||
|
||||
1. every skill and agent under `<root>/plugins/*/` — sibling plugins resolve, which is what a
|
||||
monorepo means — plus the skills each plugin's `apm.yml` pulls from a subpath of a third-party
|
||||
repo (`owner/repo/<path>/<skill>#ref` gives `<skill>`; a whole-repo dependency gives nothing;
|
||||
ADR-0029);
|
||||
monorepo means;
|
||||
2. the checked file's own apm package;
|
||||
3. the packages that package declares in **its own** `apm.yml` `dependencies.apm`.
|
||||
|
||||
@@ -789,8 +787,10 @@ Wiring Vale as a deterministic prefilter for `factory-audit`'s Description dimen
|
||||
issue #84) is repo-specific, not part of the generic `lint` plugin, so it does not live in
|
||||
`plugins/lint/` — and per ADR-0014 it no longer lives at the repo root either. It lives **once**,
|
||||
under `plugins/kyberforge/.apm/skills/factory-audit/assets/vale/`, carrying both the `Kyberforge`
|
||||
and `KyberforgeCopilot` styles and a single `.vale.ini` with all three glob sections:
|
||||
`[**/SKILL.md]`, `[**/agents/*.md]`, `[**/*.agent.md]`.
|
||||
and `KyberforgeCopilot` styles and a single `.vale.ini` with five glob sections:
|
||||
`[**/SKILL.md]`, `[**/agents/*.md]`, `[**/*.instructions.md]`, `[**/*.prompt.md]` and
|
||||
`[**/*.agent.md]`. The instructions and prompt sections arrived with `factory-audit`'s primitive
|
||||
modes (ADR-0025, amendment 2026-09-28).
|
||||
|
||||
ADR-0014 split this into two skill-scoped copies because a plugin's cache-install copies only each
|
||||
skill's own files and `skill-audit` could not reach across the skill boundary into `agent-audit`'s
|
||||
@@ -818,7 +818,8 @@ Its `StylesPath` and `BasedOnStyles` checks were **not** diffs. They were per-fi
|
||||
invoked `vale --config` on one representative path per file shape. It was the only assertion
|
||||
anywhere that catches a `.vale.ini` glob typo (`[**/SKILL.md]` → `[**/SKILLS.md]`), the failure mode
|
||||
where every other check stays clean while Vale lints zero files. One config does not make that
|
||||
impossible: a typo in any one of the three sections still 0-file-skips that shape.
|
||||
impossible: a typo in any one section still 0-file-skips that shape. The table has since grown
|
||||
to eight rows: one each for the instructions and prompt sections added later.
|
||||
|
||||
**Case 0** runs before any Vale-dependent case and needs no Vale binary. It asserts that the shipped
|
||||
`.vale.ini` exists and is readable, sets a `StylesPath` that resolves to a directory, and names only
|
||||
@@ -828,8 +829,9 @@ cases back.
|
||||
|
||||
The probes now live in `tests/test-vale-wrap.sh` (cases 28–30), rehomed against the merged config:
|
||||
one representative path per file shape, each asserted to produce a Vale scan of more than zero files
|
||||
*and* a Kyberforge alert (case 28). Case 28 also checks that each probe path is in scope of a
|
||||
published vale hook, and that every `.vale.ini` section has a probe row. Its Part B drops
|
||||
*and* a Kyberforge alert (case 28). Case 28 also checks that every `.vale.ini` section has an
|
||||
isolating probe row. It no longer holds each probe path to a hook's `files:` scope: that half read
|
||||
the retired `.pre-commit-hooks.yaml`, and case 32 owns the local hooks' scope. Its Part B drops
|
||||
`Kyberforge` from each section's `BasedOnStyles` in a copy and requires that section's probes to
|
||||
fail as "style not loaded". Case 29 is a mutation case: it typos each section in a copy of the
|
||||
assets and requires that section's isolating probes to drop to zero. Case 30 asserts that
|
||||
@@ -933,17 +935,17 @@ authors. Without the binary the hooks fail with a bare "command not found" and n
|
||||
**Two hooks, not one combined hook — for a different reason than ADR-0014 gave.** The original
|
||||
reason was mechanical: with a config per skill, a single hook could point at only one copy and would
|
||||
silently 0-file-skip the other file shape (see
|
||||
[A 0-file Vale run is NOT RUN](#a-0-file-vale-run-is-not-run)). One `.vale.ini` carrying all three
|
||||
sections removes that constraint. The split stays anyway because the `files:` regexes still have to
|
||||
[A 0-file Vale run is NOT RUN](#a-0-file-vale-run-is-not-run)). One `.vale.ini` carrying every
|
||||
section removes that constraint. The split stays anyway because the `files:` regexes still have to
|
||||
differ — each hook hands Vale only the file shape it is scoped to. Both hooks name the same
|
||||
plugin-bundled `factory-audit/scripts/vale-wrap.sh` through `repo: local`; there is no second root
|
||||
copy.
|
||||
|
||||
### The `.vale.ini` globs do no scoping
|
||||
|
||||
The `.vale.ini`'s section globs are **path-agnostic** — `[**/SKILL.md]`, `[**/agents/*.md]` and
|
||||
`[**/*.agent.md]` — and constrain filename *shape*, not
|
||||
location: Vale's `*` crosses `/`. A `SKILL.md` outside `plugins/` (a project-scope
|
||||
The `.vale.ini`'s section globs are **path-agnostic** — `[**/SKILL.md]`, `[**/agents/*.md]`,
|
||||
`[**/*.instructions.md]`, `[**/*.prompt.md]` and `[**/*.agent.md]` — and constrain filename *shape*,
|
||||
not location: Vale's `*` crosses `/`. A `SKILL.md` outside `plugins/` (a project-scope
|
||||
`.claude/skills/foo/SKILL.md`, say) still matches `[**/SKILL.md]` and gets linted normally.
|
||||
|
||||
All scoping therefore comes from the pre-commit hooks' own `files:` regexes, which pin this repo's
|
||||
@@ -953,8 +955,16 @@ invocation — in this repo or in any repo that installs it, whatever that repo'
|
||||
Narrowing a `.vale.ini` glob to a `plugins/`-shaped path to "tighten" it breaks the consumer case:
|
||||
`factory-audit` run against a project-scope `.claude/skills/` tree would lint nothing.
|
||||
`check-vale-style-sync`'s probe set was built to catch exactly that; it moved to
|
||||
`tests/test-vale-wrap.sh` with the hook's deletion, and two of the six probes exist specifically to
|
||||
pin this location independence — see [One copy, one config](#one-copy-one-config).
|
||||
`tests/test-vale-wrap.sh` with the hook's deletion. Its table (`PROBE_TABLE28`) now has eight rows,
|
||||
one or more per section, and the two `.claude/`-prefixed rows exist specifically to pin this
|
||||
location independence — see [One copy, one config](#one-copy-one-config).
|
||||
|
||||
**No pre-commit Vale hook covers `*.instructions.md` or `*.prompt.md` yet.** The `.vale.ini`
|
||||
sections exist so that `factory-audit`'s own Vale call lints those files when it is handed one, in
|
||||
any repo. This repo's two prefilter hooks select only `SKILL.md` and `.agent.md` files, and the repo
|
||||
has no instruction or prompt file for a third hook to select. Case 32 requires every Vale hook's
|
||||
`files:` regex to match at least one tracked file, so a hook added now would fail it. Add the hook
|
||||
in the change that lands the first `.apm/instructions/` or `.apm/prompts/` file.
|
||||
|
||||
### The blind spot: `references/` is unlinted, for two independent reasons
|
||||
|
||||
@@ -1053,9 +1063,9 @@ clean.
|
||||
### Pre-push
|
||||
|
||||
`vale` is still a **pre-push** dependency, but no longer through a hook of its own.
|
||||
`check-vale-style-sync` — the hook that ran the six glob probes, and whose
|
||||
`check-vale-style-sync` — the hook that ran the original six glob probes, and whose
|
||||
`CHECK_VALE_STYLE_SYNC_ALLOW_MISSING_VALE=1` opt-out downgraded them audibly rather than skipping the
|
||||
hook — is deleted with the second Vale copy (ADR-0025). The six glob probes survive it inside
|
||||
hook — is deleted with the second Vale copy (ADR-0025). The glob probes survive it inside
|
||||
`test-vale-wrap.sh`, so `run-tests --strict` is now the gate that runs them. That is also what keeps
|
||||
`vale` a pre-push requirement: `test-vale-wrap.sh` exits 77 without the binary once its static cases
|
||||
pass, and a skip fails the push.
|
||||
@@ -1174,14 +1184,13 @@ On the **root** manifest, **10 checks**: `lockfile-exists`, `ref-consistency`,
|
||||
On each **plugin** manifest, **1 check**: `lockfile-exists`. Conditional, and vacuous while every
|
||||
plugin `apm.yml` declared `dependencies: {apm: [], mcp: []}` — it reports `No dependencies declared
|
||||
-- lockfile not required`. An earlier revision of this section said it would arm the moment one did
|
||||
not. **It has armed.** `plugins/onedev` was the first plugin package to declare a real dependency — it
|
||||
pinned `code.onedev.io/onedev/tod#v4.3.4` — and was removed on 2026-11-11; `plugins/mattpocock`
|
||||
carries the same shape (pinned third-party skills, no primitives of its own) and the check fires on
|
||||
it for real. Everything else in the list above is root-only, because it is the
|
||||
not. **It has armed.** `plugins/onedev` is the first plugin package to declare a real dependency — it
|
||||
pins `code.onedev.io/onedev/tod#v4.3.4` so the marketplace can redistribute OneDev's TOD skills — and
|
||||
the check now fires on it for real. Everything else in the list above is root-only, because it is the
|
||||
root install that has a lockfile, a deployment ledger and deployed files to check.
|
||||
|
||||
**A plugin package that declares dependencies has no green state, so the hook waives exactly one
|
||||
failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the same for any package that declares dependencies):
|
||||
failure.** Verified against apm 0.28.0 in `plugins/onedev/`:
|
||||
|
||||
- **Without a package `apm.lock.yaml`**, `lockfile-exists` fails — `apm.yml declares dependencies but
|
||||
apm.lock.yaml is absent` — reported as `1 of 1 check(s) failed`.
|
||||
@@ -1282,25 +1291,24 @@ point only). Machine-specific settings go in the gitignored `.claude/settings.lo
|
||||
does not deploy and the replay does not compare; shared enforcement belongs in
|
||||
`.pre-commit-config.yaml`.
|
||||
|
||||
### Why `pretty-format-json` runs with `--no-sort-keys`
|
||||
### Why it is excluded from `pretty-format-json`
|
||||
|
||||
It is in the **second and last alternation** in that hook's `exclude:` pattern, and that alternation
|
||||
is the only one there for a reason other than "generated manifest". Mind which number you are
|
||||
quoting: the pattern is `^(\.claude-plugin/marketplace\.json|\.claude/(settings|apm-hooks)\.json)$`
|
||||
— **two top-level alternations, expanding to three real tracked files**:
|
||||
`.claude-plugin/marketplace.json`, this one, and its committed `.claude/apm-hooks.json` sidecar,
|
||||
which is apm output under the same byte-for-byte replay and is excluded for the same reason.
|
||||
|
||||
`pretty-format-json --autofix` sorts object keys unless `--no-sort-keys` is passed, while apm's hook
|
||||
integrator emits insertion order (`matcher` before `hooks`, `type` before `command`). In scope with
|
||||
the default, the formatter rewrites apm's output into a form apm would never produce on the way into
|
||||
**every** commit, and `apm-audit-ci` then reports permanent drift on a file with an empty `git diff`
|
||||
— exactly what happened when the `SessionStart` hook first landed in `2e395a4` (#102).
|
||||
integrator emits insertion order (`matcher` before `hooks`, `type` before `command`). Leaving the
|
||||
file in that hook's scope therefore rewrites apm's output into a form apm would never produce on the
|
||||
way into **every** commit, and `apm-audit-ci` then reports permanent drift on a file with an empty
|
||||
`git diff` — exactly what happened when the `SessionStart` hook first landed in `2e395a4`. Re-running
|
||||
`apm install` fixes the file; leaving it in scope would re-break it on the very commit carrying the
|
||||
fix.
|
||||
|
||||
The hook now passes `--no-sort-keys`, so this file and its committed `.claude/apm-hooks.json` sidecar
|
||||
(apm output under the same byte-for-byte replay) need **no exclude**: the formatter's default 2-space
|
||||
indent already matches apm's, and with insertion order kept they round-trip untouched. No dedicated
|
||||
test pins this: dropping `--no-sort-keys` surfaces at pre-push as `apm-audit-ci` drift on
|
||||
`.claude/settings.json`, which is the same gate that caught the original failure.
|
||||
|
||||
**Load-bearing. Do not remove `--no-sort-keys`.** `.claude-plugin/marketplace.json` is the one path
|
||||
still in that hook's `exclude:`: it carries literal em dashes that the formatter re-escapes to
|
||||
`\u2014`, which `--no-ensure-ascii` would stop but for every JSON file. This closes the JSON case
|
||||
only; a new tool-owned file in the scope of another autofixer is still caught only by `apm-audit-ci`
|
||||
drift after the fact, not by a derived gate.
|
||||
**Load-bearing. Do not tidy it out of that list** (see `LESSONS.md`, 2026-08-14).
|
||||
|
||||
## Pushing without a network
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
---
|
||||
name: grill-me
|
||||
description: >
|
||||
Use when the user says "grill me" or wants a plan or design stress-tested by
|
||||
relentless interview — one question at a time, down each branch of the
|
||||
decision tree. Not a plan to challenge against `CONTEXT.md` and ADRs ->
|
||||
`grill-with-docs`.
|
||||
metadata:
|
||||
version: "1.0.1"
|
||||
---
|
||||
|
||||
Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
|
||||
|
||||
Ask the questions one at a time.
|
||||
|
||||
If a question can be answered by exploring the codebase, explore the codebase instead.
|
||||
@@ -0,0 +1,93 @@
|
||||
---
|
||||
name: grill-with-docs
|
||||
description: >
|
||||
Use when a plan should be stress-tested against the project's domain model —
|
||||
the interview challenges terms against `CONTEXT.md` and writes decisions into
|
||||
it and into ADRs as they land. Not a plain interview -> `grill-me`.
|
||||
metadata:
|
||||
version: "1.0.1"
|
||||
---
|
||||
|
||||
<what-to-do>
|
||||
|
||||
Interview me relentlessly about every aspect of this plan until we reach a shared understanding. Walk down each branch of the design tree, resolving dependencies between decisions one-by-one. For each question, provide your recommended answer.
|
||||
|
||||
Ask the questions one at a time, waiting for feedback on each question before continuing.
|
||||
|
||||
If a question can be answered by exploring the codebase, explore the codebase instead.
|
||||
|
||||
</what-to-do>
|
||||
|
||||
<supporting-info>
|
||||
|
||||
## Domain awareness
|
||||
|
||||
During codebase exploration, also look for existing documentation:
|
||||
|
||||
### File structure
|
||||
|
||||
Most repos have a single context:
|
||||
|
||||
```
|
||||
/
|
||||
├── CONTEXT.md
|
||||
├── docs/
|
||||
│ └── adr/
|
||||
│ ├── 0001-event-sourced-orders.md
|
||||
│ └── 0002-postgres-for-write-model.md
|
||||
└── src/
|
||||
```
|
||||
|
||||
If a `CONTEXT-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
|
||||
|
||||
```
|
||||
/
|
||||
├── CONTEXT-MAP.md
|
||||
├── docs/
|
||||
│ └── adr/ ← system-wide decisions
|
||||
├── src/
|
||||
│ ├── ordering/
|
||||
│ │ ├── CONTEXT.md
|
||||
│ │ └── docs/adr/ ← context-specific decisions
|
||||
│ └── billing/
|
||||
│ ├── CONTEXT.md
|
||||
│ └── docs/adr/
|
||||
```
|
||||
|
||||
Create files lazily — only when you have something to write. If no `CONTEXT.md` exists, create one when the first term is resolved. If no `docs/adr/` exists, create it when the first ADR is needed.
|
||||
|
||||
## During the session
|
||||
|
||||
### Challenge against the glossary
|
||||
|
||||
When the user uses a term that conflicts with the existing language in `CONTEXT.md`, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y — which is it?"
|
||||
|
||||
### Sharpen fuzzy language
|
||||
|
||||
When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account' — do you mean the Customer or the User? Those are different things."
|
||||
|
||||
### Discuss concrete scenarios
|
||||
|
||||
When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
|
||||
|
||||
### Cross-reference with code
|
||||
|
||||
When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible — which is right?"
|
||||
|
||||
### Update CONTEXT.md inline
|
||||
|
||||
When a term is resolved, update `CONTEXT.md` right there. Don't batch these up — capture them as they happen. Use the format in [context-format.md](references/context-format.md).
|
||||
|
||||
Don't couple `CONTEXT.md` to implementation details. Only include terms that are meaningful to domain experts.
|
||||
|
||||
### Offer ADRs sparingly
|
||||
|
||||
Only offer to create an ADR when all three are true:
|
||||
|
||||
1. **Hard to reverse** — the cost of changing your mind later is meaningful
|
||||
2. **Surprising without context** — a future reader will wonder "why did they do it this way?"
|
||||
3. **The result of a real trade-off** — there were genuine alternatives and you picked one for specific reasons
|
||||
|
||||
If any of the three is missing, skip the ADR. Use the format in [adr-format.md](references/adr-format.md).
|
||||
|
||||
</supporting-info>
|
||||
@@ -0,0 +1,47 @@
|
||||
# ADR Format
|
||||
|
||||
ADRs live in `docs/adr/` and use sequential numbering: `0001-slug.md`, `0002-slug.md`, etc.
|
||||
|
||||
Create the `docs/adr/` directory lazily — only when the first ADR is needed.
|
||||
|
||||
## Template
|
||||
|
||||
```md
|
||||
# {Short title of the decision}
|
||||
|
||||
{1-3 sentences: what's the context, what did we decide, and why.}
|
||||
```
|
||||
|
||||
That's it. An ADR can be a single paragraph. The value is in recording *that* a decision was made and *why* — not in filling out sections.
|
||||
|
||||
## Optional sections
|
||||
|
||||
Only include these when they add genuine value. Most ADRs won't need them.
|
||||
|
||||
- **Status** frontmatter (`proposed | accepted | deprecated | superseded by ADR-NNNN`) — useful when decisions are revisited
|
||||
- **Considered Options** — only when the rejected alternatives are worth remembering
|
||||
- **Consequences** — only when non-obvious downstream effects need to be called out
|
||||
|
||||
## Numbering
|
||||
|
||||
Scan `docs/adr/` for the highest existing number and increment by one.
|
||||
|
||||
## When to offer an ADR
|
||||
|
||||
All three of these must be true:
|
||||
|
||||
1. **Hard to reverse** — the cost of changing your mind later is meaningful
|
||||
2. **Surprising without context** — a future reader will look at the code and wonder "why on earth did they do it this way?"
|
||||
3. **The result of a real trade-off** — there were genuine alternatives and you picked one for specific reasons
|
||||
|
||||
If a decision is easy to reverse, skip it — you'll just reverse it. If it's not surprising, nobody will wonder why. If there was no real alternative, there's nothing to record beyond "we did the obvious thing."
|
||||
|
||||
### What qualifies
|
||||
|
||||
- **Architectural shape.** "We're using a monorepo." "The write model is event-sourced, the read model is projected into Postgres."
|
||||
- **Integration patterns between contexts.** "Ordering and Billing communicate via domain events, not synchronous HTTP."
|
||||
- **Technology choices that carry lock-in.** Database, message bus, auth provider, deployment target. Not every library — just the ones that would take a quarter to swap out.
|
||||
- **Boundary and scope decisions.** "Customer data is owned by the Customer context; other contexts reference it by ID only." The explicit no-s are as valuable as the yes-s.
|
||||
- **Deliberate deviations from the obvious path.** "We're using manual SQL instead of an ORM because X." Anything where a reasonable reader would assume the opposite. These stop the next engineer from "fixing" something that was deliberate.
|
||||
- **Constraints not visible in the code.** "We can't use AWS because of compliance requirements." "Response times must be under 200ms because of the partner API contract."
|
||||
- **Rejected alternatives when the rejection is non-obvious.** If you considered GraphQL and picked REST for subtle reasons, record it — otherwise someone will suggest GraphQL again in six months.
|
||||
@@ -0,0 +1,77 @@
|
||||
# CONTEXT.md Format
|
||||
|
||||
## Structure
|
||||
|
||||
```md
|
||||
# {Context Name}
|
||||
|
||||
{One or two sentence description of what this context is and why it exists.}
|
||||
|
||||
## Language
|
||||
|
||||
**Order**:
|
||||
{A concise description of the term}
|
||||
_Avoid_: Purchase, transaction
|
||||
|
||||
**Invoice**:
|
||||
A request for payment sent to a customer after delivery.
|
||||
_Avoid_: Bill, payment request
|
||||
|
||||
**Customer**:
|
||||
A person or organization that places orders.
|
||||
_Avoid_: Client, buyer, account
|
||||
|
||||
## Relationships
|
||||
|
||||
- An **Order** produces one or more **Invoices**
|
||||
- An **Invoice** belongs to exactly one **Customer**
|
||||
|
||||
## Example dialogue
|
||||
|
||||
> **Dev:** "When a **Customer** places an **Order**, do we create the **Invoice** immediately?"
|
||||
> **Domain expert:** "No — an **Invoice** is only generated once a **Fulfillment** is confirmed."
|
||||
|
||||
## Flagged ambiguities
|
||||
|
||||
- "account" was used to mean both **Customer** and **User** — resolved: these are distinct concepts.
|
||||
```
|
||||
|
||||
## Rules
|
||||
|
||||
- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others as aliases to avoid.
|
||||
- **Flag conflicts explicitly.** If a term is used ambiguously, call it out in "Flagged ambiguities" with a clear resolution.
|
||||
- **Keep definitions tight.** One sentence max. Define what it IS, not what it does.
|
||||
- **Show relationships.** Use bold term names and express cardinality where obvious.
|
||||
- **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs.
|
||||
- **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine.
|
||||
- **Write an example dialogue.** A conversation between a dev and a domain expert that demonstrates how the terms interact naturally and clarifies boundaries between related concepts.
|
||||
|
||||
## Single vs multi-context repos
|
||||
|
||||
**Single context (most repos):** One `CONTEXT.md` at the repo root.
|
||||
|
||||
**Multiple contexts:** A `CONTEXT-MAP.md` at the repo root lists the contexts, where they live, and how they relate to each other:
|
||||
|
||||
```md
|
||||
# Context Map
|
||||
|
||||
## Contexts
|
||||
|
||||
- [Ordering](./src/ordering/CONTEXT.md) — receives and tracks customer orders
|
||||
- [Billing](./src/billing/CONTEXT.md) — generates invoices and processes payments
|
||||
- [Fulfillment](./src/fulfillment/CONTEXT.md) — manages warehouse picking and shipping
|
||||
|
||||
## Relationships
|
||||
|
||||
- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking
|
||||
- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices
|
||||
- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`
|
||||
```
|
||||
|
||||
The skill infers which structure applies:
|
||||
|
||||
- If `CONTEXT-MAP.md` exists, read it to find contexts
|
||||
- If only a root `CONTEXT.md` exists, single context
|
||||
- If neither exists, create a root `CONTEXT.md` lazily when the first term is resolved
|
||||
|
||||
When multiple contexts exist, infer which one the current topic relates to. If unclear, ask.
|
||||
@@ -0,0 +1,80 @@
|
||||
---
|
||||
name: improve-codebase-architecture
|
||||
description: >
|
||||
Use when the user wants to improve architecture, find refactoring
|
||||
opportunities, consolidate tightly-coupled modules, or make a codebase more
|
||||
testable and AI-navigable — deepening opportunities that turn shallow modules
|
||||
into deep ones, informed by `CONTEXT.md` and `docs/adr/`. Not debugging a
|
||||
failure -> `diagnose`.
|
||||
metadata:
|
||||
version: "1.0.1"
|
||||
---
|
||||
|
||||
# Improve Codebase Architecture
|
||||
|
||||
Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
|
||||
|
||||
## Glossary
|
||||
|
||||
Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary."
|
||||
|
||||
- **Module** — anything with an interface and an implementation (function, class, package, slice).
|
||||
- **Interface** — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
|
||||
- **Implementation** — the code inside.
|
||||
- **Depth** — leverage at the interface: a lot of behaviour behind a small interface. **Deep** = high leverage. **Shallow** = interface nearly as complex as the implementation.
|
||||
- **Seam** — where an interface lives; a place behaviour can be altered without editing in place. (Use this, not "boundary.")
|
||||
- **Adapter** — a concrete thing satisfying an interface at a seam.
|
||||
- **Leverage** — what callers get from depth.
|
||||
- **Locality** — what maintainers get from depth: change, bugs, knowledge concentrated in one place.
|
||||
|
||||
Key principles:
|
||||
|
||||
- **Deletion test**: imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
|
||||
- **The interface is the test surface.**
|
||||
- **One adapter = hypothetical seam. Two adapters = real seam.**
|
||||
|
||||
If a term or principle above is ambiguous in the case in front of you, or you need the definitions and the principles the two lists leave out, read `references/language.md`.
|
||||
|
||||
This skill is _informed_ by the project's domain model. The domain language gives names to good seams; ADRs record decisions the skill should not re-litigate.
|
||||
|
||||
## Process
|
||||
|
||||
### 1. Explore
|
||||
|
||||
Read the domain glossary and any ADRs in the area first.
|
||||
|
||||
Then use the Agent tool with `subagent_type=Explore` to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
|
||||
|
||||
- Where does understanding one concept require bouncing between many small modules?
|
||||
- Where are modules **shallow** — interface nearly as complex as the implementation?
|
||||
- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)?
|
||||
- Where do tightly-coupled modules leak across their seams?
|
||||
- Which parts of the codebase are untested, or hard to test through their current interface?
|
||||
|
||||
Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
|
||||
|
||||
### 2. Present candidates
|
||||
|
||||
Present a numbered list of deepening opportunities. For each candidate:
|
||||
|
||||
- **Files** — which files/modules are involved
|
||||
- **Problem** — why the current architecture is causing friction
|
||||
- **Solution** — plain English description of what would change
|
||||
- **Benefits** — explained in terms of locality and leverage, and also in how tests would improve
|
||||
|
||||
**Use CONTEXT.md vocabulary for the domain, and the architecture glossary above for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
|
||||
|
||||
**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
||||
|
||||
Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"
|
||||
|
||||
### 3. Grilling loop
|
||||
|
||||
Once the user picks a candidate, drop into a grilling conversation. Walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
|
||||
|
||||
Side effects happen inline as decisions crystallize:
|
||||
|
||||
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md` — same discipline as `grill-with-docs`, in the format `grill-with-docs`'s `references/context-format.md` defines. Create the file lazily if it doesn't exist.
|
||||
- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
|
||||
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See `grill-with-docs`'s `references/adr-format.md`.
|
||||
- **Want to explore alternative interfaces for the deepened module?** Read `references/interface-design.md`.
|
||||
@@ -0,0 +1,37 @@
|
||||
# Deepening
|
||||
|
||||
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [language.md](language.md) — **module**, **interface**, **seam**, **adapter**.
|
||||
|
||||
## Dependency categories
|
||||
|
||||
When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
|
||||
|
||||
### 1. In-process
|
||||
|
||||
Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed.
|
||||
|
||||
### 2. Local-substitutable
|
||||
|
||||
Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
|
||||
|
||||
### 3. Remote but owned (Ports & Adapters)
|
||||
|
||||
Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
|
||||
|
||||
Recommendation shape: *"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."*
|
||||
|
||||
### 4. True external (Mock)
|
||||
|
||||
Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
|
||||
|
||||
## Seam discipline
|
||||
|
||||
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
|
||||
- **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
|
||||
|
||||
## Testing strategy: replace, don't layer
|
||||
|
||||
- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist — delete them.
|
||||
- Write new tests at the deepened module's interface. The **interface is the test surface**.
|
||||
- Tests assert on observable outcomes through the interface, not internal state.
|
||||
- Tests should survive internal refactors — they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
|
||||
@@ -0,0 +1,44 @@
|
||||
# Interface Design
|
||||
|
||||
When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout) — your first idea is unlikely to be the best.
|
||||
|
||||
Uses the vocabulary in [language.md](language.md) — **module**, **interface**, **seam**, **adapter**, **leverage**.
|
||||
|
||||
## Process
|
||||
|
||||
### 1. Frame the problem space
|
||||
|
||||
Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
|
||||
|
||||
- The constraints any new interface would need to satisfy
|
||||
- The dependencies it would rely on, and which category they fall into (see [deepening.md](deepening.md))
|
||||
- A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete
|
||||
|
||||
Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
|
||||
|
||||
### 2. Spawn sub-agents
|
||||
|
||||
Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module.
|
||||
|
||||
Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [deepening.md](deepening.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
|
||||
|
||||
- Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point."
|
||||
- Agent 2: "Maximise flexibility — support many use cases and extension."
|
||||
- Agent 3: "Optimise for the most common caller — make the default case trivial."
|
||||
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
|
||||
|
||||
Include both [language.md](language.md) vocabulary and CONTEXT.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
|
||||
|
||||
Each sub-agent outputs:
|
||||
|
||||
1. Interface (types, methods, params — plus invariants, ordering, error modes)
|
||||
2. Usage example showing how callers use it
|
||||
3. What the implementation hides behind the seam
|
||||
4. Dependency strategy and adapters (see [deepening.md](deepening.md))
|
||||
5. Trade-offs — where leverage is high, where it's thin
|
||||
|
||||
### 3. Present and compare
|
||||
|
||||
Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
|
||||
|
||||
After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not a menu.
|
||||
@@ -0,0 +1,53 @@
|
||||
# Language
|
||||
|
||||
Shared vocabulary for every suggestion this skill makes. Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
|
||||
|
||||
## Terms
|
||||
|
||||
**Module**
|
||||
Anything with an interface and an implementation. Deliberately scale-agnostic — applies equally to a function, class, package, or tier-spanning slice.
|
||||
_Avoid_: unit, component, service.
|
||||
|
||||
**Interface**
|
||||
Everything a caller must know to use the module correctly. Includes the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics.
|
||||
_Avoid_: API, signature (too narrow — those refer only to the type-level surface).
|
||||
|
||||
**Implementation**
|
||||
What's inside a module — its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
|
||||
|
||||
**Depth**
|
||||
Leverage at the interface — the amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface. A module is **shallow** when the interface is nearly as complex as the implementation.
|
||||
|
||||
**Seam** _(from Michael Feathers)_
|
||||
A place where you can alter behaviour without editing in that place. The *location* at which a module's interface lives. Choosing where to put the seam is its own design decision, distinct from what goes behind it.
|
||||
_Avoid_: boundary (overloaded with DDD's bounded context).
|
||||
|
||||
**Adapter**
|
||||
A concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
|
||||
|
||||
**Leverage**
|
||||
What callers get from depth. More capability per unit of interface they have to learn. One implementation pays back across N call sites and M tests.
|
||||
|
||||
**Locality**
|
||||
What maintainers get from depth. Change, bugs, knowledge, and verification concentrate at one place rather than spreading across callers. Fix once, fixed everywhere.
|
||||
|
||||
## Principles
|
||||
|
||||
- **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts — they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
|
||||
- **The deletion test.** Imagine deleting the module. If complexity vanishes, the module wasn't hiding anything (it was a pass-through). If complexity reappears across N callers, the module was earning its keep.
|
||||
- **The interface is the test surface.** Callers and tests cross the same seam. If you want to test *past* the interface, the module is probably the wrong shape.
|
||||
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
|
||||
|
||||
## Relationships
|
||||
|
||||
- A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
|
||||
- **Depth** is a property of a **Module**, measured against its **Interface**.
|
||||
- A **Seam** is where a **Module**'s **Interface** lives.
|
||||
- An **Adapter** sits at a **Seam** and satisfies the **Interface**.
|
||||
- **Depth** produces **Leverage** for callers and **Locality** for maintainers.
|
||||
|
||||
## Rejected framings
|
||||
|
||||
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
|
||||
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
|
||||
- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: prototype
|
||||
description: >
|
||||
Use when the user wants a throwaway prototype to answer a design question about
|
||||
a data model, state machine or business logic, or to mock up a UI in several
|
||||
variations. Not production code -> `tdd`. Not talking a design through ->
|
||||
`grill-me`.
|
||||
metadata:
|
||||
version: "1.0.1"
|
||||
---
|
||||
|
||||
# Prototype
|
||||
|
||||
A prototype is **throwaway code that answers a question**. The question decides the shape.
|
||||
|
||||
## Pick a branch
|
||||
|
||||
| Question being answered | Build | Reference |
|
||||
|---|---|---|
|
||||
| "Does this logic / state model feel right?" | A tiny interactive terminal app that pushes the state machine through cases that are hard to reason about on paper | `references/logic.md` |
|
||||
| "What should this look like?" | Several radically different UI variations on one route, switchable via a URL search param and a floating bottom bar | `references/ui.md` |
|
||||
|
||||
Resolve the row from the user's prompt, the surrounding code, or by asking if the user is around, then read only that reference — each is self-contained.
|
||||
|
||||
The two branches produce fundamentally different artifacts — getting this wrong wastes the whole prototype. If the question is genuinely ambiguous and the user isn't reachable, default to whichever branch better matches the surrounding code (a backend module → logic; a page or component → UI) and state the assumption at the top of the prototype.
|
||||
|
||||
## Rules that apply to both
|
||||
|
||||
1. **Throwaway from day one, and clearly marked as such.** Locate the prototype code close to where it will actually be used (next to the module or page it's prototyping for) so context is obvious — but name it so a casual reader can see it's a prototype, not production. For throwaway UI routes, obey whatever routing convention the project already uses; don't invent a new top-level structure.
|
||||
2. **One command to run.** Whatever the project's existing task runner supports — `pnpm <name>`, `python <path>`, `bun <path>`, etc. The user must be able to start it without thinking.
|
||||
3. **No persistence by default.** State lives in memory. Persistence is the thing the prototype is *checking*, not something it should depend on. If the question explicitly involves a database, hit a scratch DB or a local file with a clear "PROTOTYPE — wipe me" name.
|
||||
4. **Skip the polish.** No tests, no error handling beyond what makes the prototype *runnable*, no abstractions. The point is to learn something fast and then delete it.
|
||||
5. **Surface the state.** After every action (logic) or on every variant switch (UI), print or render the full relevant state so the user can see what changed.
|
||||
6. **Delete or absorb when done.** When the prototype has answered its question, either delete it or fold the validated decision into the real code — don't leave it rotting in the repo.
|
||||
|
||||
## When done
|
||||
|
||||
The *answer* is the only thing worth keeping from a prototype. Capture it somewhere durable (commit message, ADR, issue, or a `NOTES.md` next to the prototype) along with the question it was answering. If the user is around, that capture is a quick conversation; if not, leave the placeholder so they (or you, on the next pass) can fill in the verdict before deleting the prototype.
|
||||
@@ -0,0 +1,79 @@
|
||||
# Logic Prototype
|
||||
|
||||
A tiny interactive terminal app that lets the user drive a state model by hand. Use this when the question is about **business logic, state transitions, or data shape** — the kind of thing that looks reasonable on paper but only feels wrong once you push it through real cases.
|
||||
|
||||
## When this is the right shape
|
||||
|
||||
- "I'm not sure if this state machine handles the edge case where X then Y."
|
||||
- "Does this data model actually let me represent the case where..."
|
||||
- "I want to feel out what the API should look like before writing it."
|
||||
- Anything where the user wants to **press buttons and watch state change**.
|
||||
|
||||
If the question is "what should this look like" — wrong branch. Read `references/ui.md`.
|
||||
|
||||
## Process
|
||||
|
||||
### 1. State the question
|
||||
|
||||
Before writing code, write down what state model and what question you're prototyping. One paragraph, in the prototype's README or a comment at the top of the file. A logic prototype that answers the wrong question is pure waste — make the question explicit so it can be checked later, whether the user is watching now or returning to it AFK.
|
||||
|
||||
### 2. Pick the language
|
||||
|
||||
Use whatever the host project uses. If the project has no obvious runtime (e.g. a docs repo), ask.
|
||||
|
||||
Match the project's existing conventions for tooling — don't add a new package manager or runtime just for the prototype.
|
||||
|
||||
### 3. Isolate the logic in a portable module
|
||||
|
||||
Put the actual logic — the bit that's answering the question — behind a small, pure interface that could be lifted out and dropped into the real codebase later. The TUI around it is throwaway; the logic module shouldn't be.
|
||||
|
||||
The right shape depends on the question:
|
||||
|
||||
- **A pure reducer** — `(state, action) => state`. Good when actions are discrete events and state is a single value.
|
||||
- **A state machine** — explicit states and transitions. Good when "which actions are even legal right now" is part of the question.
|
||||
- **A small set of pure functions** over a plain data type. Good when there's no implicit current state — just transformations.
|
||||
- **A class or module with a clear method surface** when the logic genuinely owns ongoing internal state.
|
||||
|
||||
Pick whichever shape best fits the question being asked, *not* whichever is easiest to wire to a TUI. Keep it pure: no I/O, no terminal code, no `console.log` for control flow. The TUI imports it and calls into it; nothing flows the other direction.
|
||||
|
||||
This is what makes the prototype useful past its own lifetime. When the question's been answered, the validated reducer / machine / function set can be lifted into the real module — the TUI shell gets deleted.
|
||||
|
||||
### 4. Build the smallest TUI that exposes the state
|
||||
|
||||
Build it as a **lightweight TUI** — on every tick, clear the screen (`console.clear()` / `print("\033[2J\033[H")` / equivalent) and re-render the whole frame. The user should always see one stable view, not an ever-growing scrollback.
|
||||
|
||||
Each frame has two parts, in this order:
|
||||
|
||||
1. **Current state**, pretty-printed and diff-friendly (one field per line, or formatted JSON). Use **bold** for field names or section headers and **dim** for less important context (timestamps, IDs, derived values). Native ANSI escape codes are fine — `\x1b[1m` bold, `\x1b[2m` dim, `\x1b[0m` reset. No need to pull in a styling library unless one is already in the project.
|
||||
2. **Keyboard shortcuts**, listed at the bottom: `[a] add user [d] delete user [t] tick clock [q] quit`. Bold the key, dim the description, or vice-versa — whatever reads cleanly.
|
||||
|
||||
Behaviour:
|
||||
|
||||
1. **Initialise state** — a single in-memory object/struct. Render the first frame on start.
|
||||
2. **Read one keystroke (or one line)** at a time, dispatch to a handler that mutates state.
|
||||
3. **Re-render** the full frame after every action — don't append, replace.
|
||||
4. **Loop until quit.**
|
||||
|
||||
The whole frame should fit on one screen.
|
||||
|
||||
### 5. Make it runnable in one command
|
||||
|
||||
Add a script to the project's existing task runner (`package.json` scripts, `Makefile`, `justfile`, `pyproject.toml`). The user should run `pnpm run <prototype-name>` or equivalent — never need to remember a path.
|
||||
|
||||
If the host project has no task runner, just put the command at the top of the prototype's README.
|
||||
|
||||
### 6. Hand it over
|
||||
|
||||
Give the user the run command. They'll drive it themselves; the interesting moments are when they say "wait, that shouldn't be possible" or "huh, I assumed X would be different" — those are the bugs in the _idea_, which is the whole point. If they want new actions added, add them. Prototypes evolve.
|
||||
|
||||
### 7. Capture the answer
|
||||
|
||||
When the prototype has done its job, the answer to the question is the only thing worth keeping. If the user is around, ask what it taught them. If not, leave a `NOTES.md` next to the prototype so the answer can be filled in (or filled in by you, if you've watched the session) before the prototype gets deleted.
|
||||
|
||||
## Anti-patterns
|
||||
|
||||
- **Don't add tests.** A prototype that needs tests is no longer a prototype.
|
||||
- **Don't wire it to the real database.** Use an in-memory store unless the question is specifically about persistence.
|
||||
- **Don't generalise.** No "what if we wanted to support X later." The prototype answers one question.
|
||||
- **Don't blur the logic and the TUI together.** If the reducer / state machine references `console.log`, prompts, or terminal escape codes, it's no longer portable. Keep the TUI as a thin shell over a pure module.
|
||||
- **Don't ship the TUI shell into production.** The shell is optimised for being driven by hand from a terminal. The logic module behind it is the bit worth keeping.
|
||||
@@ -0,0 +1,112 @@
|
||||
# UI Prototype
|
||||
|
||||
Generate **several radically different UI variations** on a single route, switchable from a floating bottom bar. The user flips between variants in the browser, picks one (or steals bits from each), then throws the rest away.
|
||||
|
||||
If the question is about logic/state rather than what something looks like — wrong branch. Read `references/logic.md`.
|
||||
|
||||
## When this is the right shape
|
||||
|
||||
- "What should this page look like?"
|
||||
- "I want to see a few options for this dashboard before committing."
|
||||
- "Try a different layout for the settings screen."
|
||||
- Any time the user would otherwise spend a day picking between three vague mockups in their head.
|
||||
|
||||
## Two sub-shapes — strongly prefer sub-shape A
|
||||
|
||||
A UI prototype is much easier to judge when it's **butting up against the rest of the app** — real header, real sidebar, real data, real density. A throwaway route on its own is a vacuum: every variant looks fine in isolation. Default to sub-shape A whenever there's a plausible existing page to host the variants. Only reach for sub-shape B if the prototype genuinely has no nearby home.
|
||||
|
||||
### Sub-shape A — adjustment to an existing page (preferred)
|
||||
|
||||
The route already exists. Variants are rendered **on the same route**, gated by a `?variant=` URL search param. The existing data fetching, params, and auth all stay — only the rendering swaps. This is the default; pick it unless there's a specific reason not to.
|
||||
|
||||
If the prototype is for something that doesn't yet have a page but *would naturally live inside one* (a new section of the dashboard, a new card on the settings screen, a new step in an existing flow) — that's still sub-shape A. Mount the variants inside the host page.
|
||||
|
||||
### Sub-shape B — a new page (last resort)
|
||||
|
||||
Only use this when the thing being prototyped genuinely has no existing page to live inside — e.g. an entirely new top-level surface, or a flow that can't be embedded anywhere sensible.
|
||||
|
||||
Create a **throwaway route** following whatever routing convention the project already uses — don't invent a new top-level structure. Name it so it's obviously a prototype (e.g. include the word `prototype` in the path or filename). Same `?variant=` pattern.
|
||||
|
||||
Before committing to sub-shape B, sanity-check: is there really no existing page this could be embedded in? An empty route hides design problems that a populated one would expose.
|
||||
|
||||
In both sub-shapes the floating bottom bar is identical.
|
||||
|
||||
## Process
|
||||
|
||||
### 1. State the question and pick N
|
||||
|
||||
Default to **3 variants**. More than 5 stops being radically different and starts being noise — cap there.
|
||||
|
||||
Write down the plan in one line, in the prototype's location or a top-of-file comment:
|
||||
|
||||
> "Three variants of the settings page, switchable via `?variant=`, on the existing `/settings` route."
|
||||
|
||||
This works whether the user is here to push back or not.
|
||||
|
||||
### 2. Generate radically different variants
|
||||
|
||||
Draft each variant. Hold each one to:
|
||||
|
||||
- The page's purpose and the data it has access to.
|
||||
- The project's component library / styling system (TailwindCSS, shadcn, MUI, plain CSS, whatever).
|
||||
- A clear exported component name, e.g. `VariantA`, `VariantB`, `VariantC`.
|
||||
|
||||
Variants must be **structurally different** — different layout, different information hierarchy, different primary affordance, not just different colours. Three slightly-tweaked card grids isn't a UI prototype, it's wallpaper. If two drafts come out too similar, redo one with explicit "do not use a card grid" guidance.
|
||||
|
||||
### 3. Wire them together
|
||||
|
||||
Create a single switcher component on the route:
|
||||
|
||||
```tsx
|
||||
// pseudo-code — adapt to the project's framework
|
||||
const variant = searchParams.get('variant') ?? 'A';
|
||||
return (
|
||||
<>
|
||||
{variant === 'A' && <VariantA {...data} />}
|
||||
{variant === 'B' && <VariantB {...data} />}
|
||||
{variant === 'C' && <VariantC {...data} />}
|
||||
<PrototypeSwitcher variants={['A','B','C']} current={variant} />
|
||||
</>
|
||||
);
|
||||
```
|
||||
|
||||
For sub-shape A (existing page): keep all the existing data fetching above the switcher; only the rendered subtree changes per variant.
|
||||
|
||||
For sub-shape B (new page): the throwaway route under `/prototype/<name>` mounts the same switcher.
|
||||
|
||||
### 4. Build the floating switcher
|
||||
|
||||
A small fixed-position bar at the bottom-centre of the screen with three pieces:
|
||||
|
||||
- **Left arrow** — cycles to the previous variant (wraps around).
|
||||
- **Variant label** — shows the current variant key and, if the variant exports a name, that name too. e.g. `B — Sidebar layout`.
|
||||
- **Right arrow** — cycles forward (wraps around).
|
||||
|
||||
Behaviour:
|
||||
|
||||
- Clicking an arrow updates the URL search param (use the framework's router — `router.replace` on Next, `navigate` on React Router, etc) so the variant is shareable and reload-stable.
|
||||
- Keyboard: `←` and `→` arrow keys also cycle. Don't intercept arrow keys when an `<input>`, `<textarea>`, or `[contenteditable]` is focused.
|
||||
- Visually distinct from the page (e.g. high-contrast pill, subtle shadow) so it's obviously not part of the design being evaluated.
|
||||
- Hidden in production builds — gate on `process.env.NODE_ENV !== 'production'` or an equivalent check, so a stray prototype merge can't ship the bar to users.
|
||||
|
||||
Put the switcher in a single shared component so both sub-shapes can reuse it. Locate it wherever shared UI lives in the project.
|
||||
|
||||
### 5. Hand it over
|
||||
|
||||
Surface the URL (and the `?variant=` keys). The user will flip through whenever they get to it. The interesting feedback is usually **"I want the header from B with the sidebar from C"** — that's the actual design they want.
|
||||
|
||||
### 6. Capture the answer and clean up
|
||||
|
||||
Once a variant has won, write down which one and why (commit message, ADR, issue, or a `NOTES.md` next to the prototype if running AFK and the user hasn't responded yet). Then:
|
||||
|
||||
- **Sub-shape A** — delete the losing variants and the switcher; fold the winner into the existing page.
|
||||
- **Sub-shape B** — promote the winning variant to a real route, delete the throwaway route and the switcher.
|
||||
|
||||
Don't leave variant components or the switcher lying around. They rot fast and confuse the next reader.
|
||||
|
||||
## Anti-patterns
|
||||
|
||||
- **Variants that differ only in colour or copy.** That's a tweak, not a prototype. Real variants disagree about structure.
|
||||
- **Sharing too much code between variants.** A shared `<Header>` is fine; a shared `<Layout>` defeats the point. Each variant should be free to throw out the layout.
|
||||
- **Wiring variants to real mutations.** Read-only prototypes are fine. If a variant needs to mutate, point it at a stub — the question is "what should this look like", not "does the backend work".
|
||||
- **Promoting the prototype directly to production.** The variant code was written under prototype constraints (no tests, minimal error handling). Rewrite it properly when you fold it in.
|
||||
+3
-4
@@ -1,13 +1,12 @@
|
||||
---
|
||||
name: research-docs
|
||||
name: research
|
||||
description: >-
|
||||
Use when the user wants a tool, library, or API researched from canonical
|
||||
documentation into structured per-topic reference markdown files. Not
|
||||
documentation written from existing code or specs -> `write-docs`. Not a bug
|
||||
or incident -> `diagnose`. Not a single question a decision waits on, answered
|
||||
in one findings note -> `research`.
|
||||
or incident -> `diagnose`.
|
||||
metadata:
|
||||
version: "2.0.0"
|
||||
version: "1.0.2"
|
||||
category: research
|
||||
allowed-tools:
|
||||
- Grep
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,114 @@
|
||||
---
|
||||
name: tdd
|
||||
description: >
|
||||
Use when the user wants a feature built or a bug fixed test-first, in a strict
|
||||
red-green-refactor loop, one behaviour at a time. Not diagnosing an existing
|
||||
bug -> `diagnose`. Not throwaway exploratory code -> `prototype`.
|
||||
metadata:
|
||||
version: "1.0.1"
|
||||
---
|
||||
|
||||
# Test-Driven Development
|
||||
|
||||
## Philosophy
|
||||
|
||||
**Core principle**: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
|
||||
|
||||
**Good tests** are integration-style: they exercise real code paths through public APIs. They describe _what_ the system does, not _how_ it does it. A good test reads like a specification - "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
|
||||
|
||||
**Bad tests** are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.
|
||||
|
||||
If you need worked examples of the difference — a behaviour-level test beside the implementation-coupled version of the same check — read `references/tests.md`. If a test needs a collaborator faked, read `references/mocking.md` before reaching for a mock.
|
||||
|
||||
## Anti-Pattern: Horizontal Slices
|
||||
|
||||
**DO NOT write all tests first, then all implementation.** This is "horizontal slicing" - treating RED as "write all tests" and GREEN as "write all code."
|
||||
|
||||
This produces **crap tests**:
|
||||
|
||||
- Tests written in bulk test _imagined_ behavior, not _actual_ behavior
|
||||
- You end up testing the _shape_ of things (data structures, function signatures) rather than user-facing behavior
|
||||
- Tests become insensitive to real changes - they pass when behavior breaks, fail when behavior is fine
|
||||
- You outrun your headlights, committing to test structure before understanding the implementation
|
||||
|
||||
**Correct approach**: Vertical slices via tracer bullets. One test → one implementation → repeat. Each test responds to what you learned from the previous cycle. Because you just wrote the code, you know exactly what behavior matters and how to verify it.
|
||||
|
||||
```
|
||||
WRONG (horizontal):
|
||||
RED: test1, test2, test3, test4, test5
|
||||
GREEN: impl1, impl2, impl3, impl4, impl5
|
||||
|
||||
RIGHT (vertical):
|
||||
RED→GREEN: test1→impl1
|
||||
RED→GREEN: test2→impl2
|
||||
RED→GREEN: test3→impl3
|
||||
...
|
||||
```
|
||||
|
||||
## Workflow
|
||||
|
||||
### 1. Planning
|
||||
|
||||
When exploring the codebase, use the domain glossary so test names and interface vocabulary match the project's language, and respect ADRs in the area.
|
||||
|
||||
Before writing any code:
|
||||
|
||||
- [ ] Confirm with user what interface changes are needed
|
||||
- [ ] Confirm with user which behaviors to test (prioritize)
|
||||
- [ ] Identify opportunities for [deep modules](references/deep-modules.md) (small interface, deep implementation)
|
||||
- [ ] Design interfaces for [testability](references/interface-design.md)
|
||||
- [ ] List the behaviors to test (not implementation steps)
|
||||
- [ ] Get user approval on the plan
|
||||
|
||||
Ask: "What should the public interface look like? Which behaviors are most important to test?"
|
||||
|
||||
**You can't test everything.** Confirm with the user exactly which behaviors matter most. Focus testing effort on critical paths and complex logic, not every possible edge case.
|
||||
|
||||
### 2. Tracer Bullet
|
||||
|
||||
Write ONE test that confirms ONE thing about the system:
|
||||
|
||||
```
|
||||
RED: Write test for first behavior → test fails
|
||||
GREEN: Write minimal code to pass → test passes
|
||||
```
|
||||
|
||||
This is your tracer bullet - proves the path works end-to-end.
|
||||
|
||||
### 3. Incremental Loop
|
||||
|
||||
For each remaining behavior:
|
||||
|
||||
```
|
||||
RED: Write next test → fails
|
||||
GREEN: Minimal code to pass → passes
|
||||
```
|
||||
|
||||
Rules:
|
||||
|
||||
- One test at a time
|
||||
- Only enough code to pass current test
|
||||
- Don't anticipate future tests
|
||||
- Keep tests focused on observable behavior
|
||||
|
||||
### 4. Refactor
|
||||
|
||||
After all tests pass, look for [refactor candidates](references/refactoring.md):
|
||||
|
||||
- [ ] Extract duplication
|
||||
- [ ] Deepen modules (move complexity behind simple interfaces)
|
||||
- [ ] Apply SOLID principles where natural
|
||||
- [ ] Consider what new code reveals about existing code
|
||||
- [ ] Run tests after each refactor step
|
||||
|
||||
**Never refactor while RED.** Get to GREEN first.
|
||||
|
||||
## Checklist Per Cycle
|
||||
|
||||
```
|
||||
[ ] Test describes behavior, not implementation
|
||||
[ ] Test uses public interface only
|
||||
[ ] Test would survive internal refactor
|
||||
[ ] Code is minimal for this test
|
||||
[ ] No speculative features added
|
||||
```
|
||||
@@ -0,0 +1,33 @@
|
||||
# Deep Modules
|
||||
|
||||
From "A Philosophy of Software Design":
|
||||
|
||||
**Deep module** = small interface + lots of implementation
|
||||
|
||||
```
|
||||
┌─────────────────────┐
|
||||
│ Small Interface │ ← Few methods, simple params
|
||||
├─────────────────────┤
|
||||
│ │
|
||||
│ │
|
||||
│ Deep Implementation│ ← Complex logic hidden
|
||||
│ │
|
||||
│ │
|
||||
└─────────────────────┘
|
||||
```
|
||||
|
||||
**Shallow module** = large interface + little implementation (avoid)
|
||||
|
||||
```
|
||||
┌─────────────────────────────────┐
|
||||
│ Large Interface │ ← Many methods, complex params
|
||||
├─────────────────────────────────┤
|
||||
│ Thin Implementation │ ← Just passes through
|
||||
└─────────────────────────────────┘
|
||||
```
|
||||
|
||||
When designing interfaces, ask:
|
||||
|
||||
- Can I reduce the number of methods?
|
||||
- Can I simplify the parameters?
|
||||
- Can I hide more complexity inside?
|
||||
@@ -0,0 +1,31 @@
|
||||
# Interface Design for Testability
|
||||
|
||||
Good interfaces make testing natural:
|
||||
|
||||
1. **Accept dependencies, don't create them**
|
||||
|
||||
```typescript
|
||||
// Testable
|
||||
function processOrder(order, paymentGateway) {}
|
||||
|
||||
// Hard to test
|
||||
function processOrder(order) {
|
||||
const gateway = new StripeGateway();
|
||||
}
|
||||
```
|
||||
|
||||
2. **Return results, don't produce side effects**
|
||||
|
||||
```typescript
|
||||
// Testable
|
||||
function calculateDiscount(cart): Discount {}
|
||||
|
||||
// Hard to test
|
||||
function applyDiscount(cart): void {
|
||||
cart.total -= discount;
|
||||
}
|
||||
```
|
||||
|
||||
3. **Small surface area**
|
||||
- Fewer methods = fewer tests needed
|
||||
- Fewer params = simpler test setup
|
||||
@@ -0,0 +1,59 @@
|
||||
# When to Mock
|
||||
|
||||
Mock at **system boundaries** only:
|
||||
|
||||
- External APIs (payment, email, etc.)
|
||||
- Databases (sometimes - prefer test DB)
|
||||
- Time/randomness
|
||||
- File system (sometimes)
|
||||
|
||||
Don't mock:
|
||||
|
||||
- Your own classes/modules
|
||||
- Internal collaborators
|
||||
- Anything you control
|
||||
|
||||
## Designing for Mockability
|
||||
|
||||
At system boundaries, design interfaces that are easy to mock:
|
||||
|
||||
**1. Use dependency injection**
|
||||
|
||||
Pass external dependencies in rather than creating them internally:
|
||||
|
||||
```typescript
|
||||
// Easy to mock
|
||||
function processPayment(order, paymentClient) {
|
||||
return paymentClient.charge(order.total);
|
||||
}
|
||||
|
||||
// Hard to mock
|
||||
function processPayment(order) {
|
||||
const client = new StripeClient(process.env.STRIPE_KEY);
|
||||
return client.charge(order.total);
|
||||
}
|
||||
```
|
||||
|
||||
**2. Prefer SDK-style interfaces over generic fetchers**
|
||||
|
||||
Create specific functions for each external operation instead of one generic function with conditional logic:
|
||||
|
||||
```typescript
|
||||
// GOOD: Each function is independently mockable
|
||||
const api = {
|
||||
getUser: (id) => fetch(`/users/${id}`),
|
||||
getOrders: (userId) => fetch(`/users/${userId}/orders`),
|
||||
createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
|
||||
};
|
||||
|
||||
// BAD: Mocking requires conditional logic inside the mock
|
||||
const api = {
|
||||
fetch: (endpoint, options) => fetch(endpoint, options),
|
||||
};
|
||||
```
|
||||
|
||||
The SDK approach means:
|
||||
- Each mock returns one specific shape
|
||||
- No conditional logic in test setup
|
||||
- Easier to see which endpoints a test exercises
|
||||
- Type safety per endpoint
|
||||
@@ -0,0 +1,10 @@
|
||||
# Refactor Candidates
|
||||
|
||||
After TDD cycle, look for:
|
||||
|
||||
- **Duplication** → Extract function/class
|
||||
- **Long methods** → Break into private helpers (keep tests on public interface)
|
||||
- **Shallow modules** → Combine or deepen
|
||||
- **Feature envy** → Move logic to where data lives
|
||||
- **Primitive obsession** → Introduce value objects
|
||||
- **Existing code** the new code reveals as problematic
|
||||
@@ -0,0 +1,61 @@
|
||||
# Good and Bad Tests
|
||||
|
||||
## Good Tests
|
||||
|
||||
**Integration-style**: Test through real interfaces, not mocks of internal parts.
|
||||
|
||||
```typescript
|
||||
// GOOD: Tests observable behavior
|
||||
test("user can checkout with valid cart", async () => {
|
||||
const cart = createCart();
|
||||
cart.add(product);
|
||||
const result = await checkout(cart, paymentMethod);
|
||||
expect(result.status).toBe("confirmed");
|
||||
});
|
||||
```
|
||||
|
||||
Characteristics:
|
||||
|
||||
- Tests behavior users/callers care about
|
||||
- Uses public API only
|
||||
- Survives internal refactors
|
||||
- Describes WHAT, not HOW
|
||||
- One logical assertion per test
|
||||
|
||||
## Bad Tests
|
||||
|
||||
**Implementation-detail tests**: Coupled to internal structure.
|
||||
|
||||
```typescript
|
||||
// BAD: Tests implementation details
|
||||
test("checkout calls paymentService.process", async () => {
|
||||
const mockPayment = jest.mock(paymentService);
|
||||
await checkout(cart, payment);
|
||||
expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
|
||||
});
|
||||
```
|
||||
|
||||
Red flags:
|
||||
|
||||
- Mocking internal collaborators
|
||||
- Testing private methods
|
||||
- Asserting on call counts/order
|
||||
- Test breaks when refactoring without behavior change
|
||||
- Test name describes HOW not WHAT
|
||||
- Verifying through external means instead of interface
|
||||
|
||||
```typescript
|
||||
// BAD: Bypasses interface to verify
|
||||
test("createUser saves to database", async () => {
|
||||
await createUser({ name: "Alice" });
|
||||
const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
|
||||
expect(row).toBeDefined();
|
||||
});
|
||||
|
||||
// GOOD: Verifies through interface
|
||||
test("createUser makes user retrievable", async () => {
|
||||
const user = await createUser({ name: "Alice" });
|
||||
const retrieved = await getUser(user.id);
|
||||
expect(retrieved.name).toBe("Alice");
|
||||
});
|
||||
```
|
||||
@@ -0,0 +1,108 @@
|
||||
---
|
||||
name: triage
|
||||
description: >
|
||||
Use when the user wants an issue created, triaged, or moved through the
|
||||
tracker's triage states, or an issue prepared for an AFK agent. Not debugging
|
||||
the bug itself -> `diagnose`. Not fleshing out a design -> `grill-with-docs`.
|
||||
metadata:
|
||||
version: "1.0.1"
|
||||
---
|
||||
|
||||
# Triage
|
||||
|
||||
Move issues on the project issue tracker through a small state machine of triage roles.
|
||||
|
||||
Every comment or issue posted to the issue tracker during triage **must** start with this disclaimer:
|
||||
|
||||
```
|
||||
> *This was generated by AI during triage.*
|
||||
```
|
||||
|
||||
## Reference docs
|
||||
|
||||
- [agent-brief.md](references/agent-brief.md) — how to write durable agent briefs
|
||||
- [out-of-scope.md](references/out-of-scope.md) — how the `.out-of-scope/` knowledge base works
|
||||
|
||||
## Roles
|
||||
|
||||
Two **category** roles:
|
||||
|
||||
- `bug` — something is broken
|
||||
- `enhancement` — new feature or improvement
|
||||
|
||||
Five **state** roles:
|
||||
|
||||
- `needs-triage` — maintainer needs to evaluate
|
||||
- `needs-info` — waiting on reporter for more information
|
||||
- `ready-for-agent` — fully specified, ready for an AFK agent
|
||||
- `ready-for-human` — needs human implementation
|
||||
- `wontfix` — will not be actioned
|
||||
|
||||
Every triaged issue should carry exactly one category role and one state role. If state roles conflict, flag it and ask the maintainer before doing anything else.
|
||||
|
||||
These are canonical role names — the actual label strings used in the issue tracker may differ. Resolve each canonical name against the tracker's live label set before applying it, using whichever tracker skill this install provides. If a name has no counterpart there, report the gap and ask the maintainer for the mapping — never substitute a guess.
|
||||
|
||||
State transitions: an unlabeled issue normally goes to `needs-triage` first; from there it moves to `needs-info`, `ready-for-agent`, `ready-for-human`, or `wontfix`. `needs-info` returns to `needs-triage` once the reporter replies. The maintainer can override at any time — flag transitions that look unusual and ask before proceeding.
|
||||
|
||||
## Invocation
|
||||
|
||||
The maintainer invokes `/triage` and describes what they want in natural language. Interpret the request and act. Examples:
|
||||
|
||||
- "Show me anything that needs my attention"
|
||||
- "Let's look at #42"
|
||||
- "Move #42 to ready-for-agent"
|
||||
- "What's ready for agents to pick up?"
|
||||
|
||||
## Show what needs attention
|
||||
|
||||
Query the issue tracker and present three buckets, oldest first:
|
||||
|
||||
1. **Unlabeled** — never triaged.
|
||||
2. **`needs-triage`** — evaluation in progress.
|
||||
3. **`needs-info` with reporter activity since the last triage notes** — needs re-evaluation.
|
||||
|
||||
Show counts and a one-line summary per issue. Let the maintainer pick.
|
||||
|
||||
## Triage a specific issue
|
||||
|
||||
1. **Gather context.** Read the full issue (body, comments, labels, reporter, dates). Parse any prior triage notes so you don't re-ask resolved questions. Explore the codebase using the domain glossary, respecting ADRs in the area. Read `.out-of-scope/*.md` and surface any prior rejection that resembles this issue.
|
||||
|
||||
2. **Recommend.** Tell the maintainer your category and state recommendation with reasoning, plus a brief codebase summary relevant to the issue. Wait for direction.
|
||||
|
||||
3. **Reproduce (bugs only).** Before any grilling, attempt reproduction: read the reporter's steps, trace the relevant code, run tests or commands. Report what happened — successful repro with code path, failed repro, or insufficient detail (a strong `needs-info` signal). A confirmed repro makes a much stronger agent brief.
|
||||
|
||||
4. **Grill (if needed).** If the issue needs fleshing out, run a `/grill-with-docs` session.
|
||||
|
||||
5. **Apply the outcome:**
|
||||
- `ready-for-agent` — post an agent brief comment ([agent-brief.md](references/agent-brief.md)).
|
||||
- `ready-for-human` — same structure as an agent brief, but note why it can't be delegated (judgment calls, external access, design decisions, manual testing).
|
||||
- `needs-info` — post triage notes (template below).
|
||||
- `wontfix` (bug) — polite explanation, then close.
|
||||
- `wontfix` (enhancement) — write to `.out-of-scope/`, link to it from a comment, then close ([out-of-scope.md](references/out-of-scope.md)).
|
||||
- `needs-triage` — apply the role. Optional comment if there's partial progress.
|
||||
|
||||
## Quick state override
|
||||
|
||||
If the maintainer says "move #42 to ready-for-agent", trust them and apply the role directly. Confirm what you're about to do (role changes, comment, close), then act. Skip grilling. If moving to `ready-for-agent` without a grilling session, ask whether they want to write an agent brief.
|
||||
|
||||
## Needs-info template
|
||||
|
||||
```markdown
|
||||
## Triage Notes
|
||||
|
||||
**What we've established so far:**
|
||||
|
||||
- point 1
|
||||
- point 2
|
||||
|
||||
**What we still need from you (@reporter):**
|
||||
|
||||
- question 1
|
||||
- question 2
|
||||
```
|
||||
|
||||
Capture everything resolved during grilling under "established so far" so the work isn't lost. Questions must be specific and actionable, not "please provide more info".
|
||||
|
||||
## Resuming a previous session
|
||||
|
||||
If prior triage notes exist on the issue, read them, check whether the reporter has answered any outstanding questions, and present an updated picture before continuing. Don't re-ask resolved questions.
|
||||
@@ -0,0 +1,168 @@
|
||||
# Writing Agent Briefs
|
||||
|
||||
An agent brief is a structured comment posted on an issue in the issue tracker when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original issue body and discussion are context — the agent brief is the contract.
|
||||
|
||||
## Principles
|
||||
|
||||
### Durability over precision
|
||||
|
||||
The issue may sit in `ready-for-agent` for days or weeks. The codebase will change in the meantime. Write the brief so it stays useful even as files are renamed, moved, or refactored.
|
||||
|
||||
- **Do** describe interfaces, types, and behavioral contracts
|
||||
- **Do** name specific types, function signatures, or config shapes that the agent should look for or modify
|
||||
- **Don't** reference file paths — they go stale
|
||||
- **Don't** reference line numbers
|
||||
- **Don't** assume the current implementation structure will remain the same
|
||||
|
||||
### Behavioral, not procedural
|
||||
|
||||
Describe **what** the system should do, not **how** to implement it. The agent will explore the codebase fresh and make its own implementation decisions.
|
||||
|
||||
- **Good:** "The `SkillConfig` type should accept an optional `schedule` field of type `CronExpression`"
|
||||
- **Bad:** "Open src/types/skill.ts and add a schedule field on line 42"
|
||||
- **Good:** "When a user runs `/triage` with no arguments, they should see a summary of issues needing attention"
|
||||
- **Bad:** "Add a switch statement in the main handler function"
|
||||
|
||||
### Complete acceptance criteria
|
||||
|
||||
The agent needs to know when it's done. Every agent brief must have concrete, testable acceptance criteria. Each criterion should be independently verifiable.
|
||||
|
||||
- **Good:** "Querying the issue tracker for the `needs-triage` label returns issues that have been through initial classification"
|
||||
- **Bad:** "Triage should work correctly"
|
||||
|
||||
### Explicit scope boundaries
|
||||
|
||||
State what is out of scope. This prevents the agent from gold-plating or making assumptions about adjacent features.
|
||||
|
||||
## Template
|
||||
|
||||
```markdown
|
||||
## Agent Brief
|
||||
|
||||
**Category:** bug / enhancement
|
||||
**Summary:** one-line description of what needs to happen
|
||||
|
||||
**Current behavior:**
|
||||
Describe what happens now. For bugs, this is the broken behavior.
|
||||
For enhancements, this is the status quo the feature builds on.
|
||||
|
||||
**Desired behavior:**
|
||||
Describe what should happen after the agent's work is complete.
|
||||
Be specific about edge cases and error conditions.
|
||||
|
||||
**Key interfaces:**
|
||||
- `TypeName` — what needs to change and why
|
||||
- `functionName()` return type — what it currently returns vs what it should return
|
||||
- Config shape — any new configuration options needed
|
||||
|
||||
**Acceptance criteria:**
|
||||
- [ ] Specific, testable criterion 1
|
||||
- [ ] Specific, testable criterion 2
|
||||
- [ ] Specific, testable criterion 3
|
||||
|
||||
**Out of scope:**
|
||||
- Thing that should NOT be changed or addressed in this issue
|
||||
- Adjacent feature that might seem related but is separate
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Good agent brief (bug)
|
||||
|
||||
```markdown
|
||||
## Agent Brief
|
||||
|
||||
**Category:** bug
|
||||
**Summary:** Skill description truncation drops mid-word, producing broken output
|
||||
|
||||
**Current behavior:**
|
||||
When a skill description exceeds 1024 characters, it is truncated at exactly
|
||||
1024 characters regardless of word boundaries. This produces descriptions
|
||||
that end mid-word (e.g. "Use when the user wants to confi").
|
||||
|
||||
**Desired behavior:**
|
||||
Truncation should break at the last word boundary before 1024 characters
|
||||
and append "..." to indicate truncation.
|
||||
|
||||
**Key interfaces:**
|
||||
- The `SkillMetadata` type's `description` field — no type change needed,
|
||||
but the validation/processing logic that populates it needs to respect
|
||||
word boundaries
|
||||
- Any function that reads SKILL.md frontmatter and extracts the description
|
||||
|
||||
**Acceptance criteria:**
|
||||
- [ ] Descriptions under 1024 chars are unchanged
|
||||
- [ ] Descriptions over 1024 chars are truncated at the last word boundary
|
||||
before 1024 chars
|
||||
- [ ] Truncated descriptions end with "..."
|
||||
- [ ] The total length including "..." does not exceed 1024 chars
|
||||
|
||||
**Out of scope:**
|
||||
- Changing the 1024 char limit itself
|
||||
- Multi-line description support
|
||||
```
|
||||
|
||||
### Good agent brief (enhancement)
|
||||
|
||||
```markdown
|
||||
## Agent Brief
|
||||
|
||||
**Category:** enhancement
|
||||
**Summary:** Add `.out-of-scope/` directory support for tracking rejected feature requests
|
||||
|
||||
**Current behavior:**
|
||||
When a feature request is rejected, the issue is closed with a `wontfix` label
|
||||
and a comment. There is no persistent record of the decision or reasoning.
|
||||
Future similar requests require the maintainer to recall or search for the
|
||||
prior discussion.
|
||||
|
||||
**Desired behavior:**
|
||||
Rejected feature requests should be documented in `.out-of-scope/<concept>.md`
|
||||
files that capture the decision, reasoning, and links to all issues that
|
||||
requested the feature. When triaging new issues, these files should be
|
||||
checked for matches.
|
||||
|
||||
**Key interfaces:**
|
||||
- Markdown file format in `.out-of-scope/` — each file should have a
|
||||
`# Concept Name` heading, a `**Decision:**` line, a `**Reason:**` line,
|
||||
and a `**Prior requests:**` list with issue links
|
||||
- The triage workflow should read all `.out-of-scope/*.md` files early
|
||||
and match incoming issues against them by concept similarity
|
||||
|
||||
**Acceptance criteria:**
|
||||
- [ ] Closing a feature as wontfix creates/updates a file in `.out-of-scope/`
|
||||
- [ ] The file includes the decision, reasoning, and link to the closed issue
|
||||
- [ ] If a matching `.out-of-scope/` file already exists, the new issue is
|
||||
appended to its "Prior requests" list rather than creating a duplicate
|
||||
- [ ] During triage, existing `.out-of-scope/` files are checked and surfaced
|
||||
when a new issue matches a prior rejection
|
||||
|
||||
**Out of scope:**
|
||||
- Automated matching (human confirms the match)
|
||||
- Reopening previously rejected features
|
||||
- Bug reports (only enhancement rejections go to `.out-of-scope/`)
|
||||
```
|
||||
|
||||
### Bad agent brief
|
||||
|
||||
```markdown
|
||||
## Agent Brief
|
||||
|
||||
**Summary:** Fix the triage bug
|
||||
|
||||
**What to do:**
|
||||
The triage thing is broken. Look at the main file and fix it.
|
||||
The function around line 150 has the issue.
|
||||
|
||||
**Files to change:**
|
||||
- src/triage/handler.ts (line 150)
|
||||
- src/types.ts (line 42)
|
||||
```
|
||||
|
||||
This is bad because:
|
||||
- No category
|
||||
- Vague description ("the triage thing is broken")
|
||||
- References file paths and line numbers that will go stale
|
||||
- No acceptance criteria
|
||||
- No scope boundaries
|
||||
- No description of current vs desired behavior
|
||||
@@ -0,0 +1,101 @@
|
||||
# Out-of-Scope Knowledge Base
|
||||
|
||||
The `.out-of-scope/` directory in a repo stores persistent records of rejected feature requests. It serves two purposes:
|
||||
|
||||
1. **Institutional memory** — why a feature was rejected, so the reasoning isn't lost when the issue is closed
|
||||
2. **Deduplication** — when a new issue comes in that matches a prior rejection, the skill can surface the previous decision instead of re-litigating it
|
||||
|
||||
## Directory structure
|
||||
|
||||
```
|
||||
.out-of-scope/
|
||||
├── dark-mode.md
|
||||
├── plugin-system.md
|
||||
└── graphql-api.md
|
||||
```
|
||||
|
||||
One file per **concept**, not per issue. Multiple issues requesting the same thing are grouped under one file.
|
||||
|
||||
## File format
|
||||
|
||||
The file should be written in a relaxed, readable style — more like a short design document than a database entry. Use paragraphs, code samples, and examples to make the reasoning clear and useful to someone encountering it for the first time.
|
||||
|
||||
```markdown
|
||||
# Dark Mode
|
||||
|
||||
This project does not support dark mode or user-facing theming.
|
||||
|
||||
## Why this is out of scope
|
||||
|
||||
The rendering pipeline assumes a single color palette defined in
|
||||
`ThemeConfig`. Supporting multiple themes would require:
|
||||
|
||||
- A theme context provider wrapping the entire component tree
|
||||
- Per-component theme-aware style resolution
|
||||
- A persistence layer for user theme preferences
|
||||
|
||||
This is a significant architectural change that doesn't align with the
|
||||
project's focus on content authoring. Theming is a concern for downstream
|
||||
consumers who embed or redistribute the output.
|
||||
|
||||
```ts
|
||||
// The current ThemeConfig interface is not designed for runtime switching:
|
||||
interface ThemeConfig {
|
||||
colors: ColorPalette; // single palette, resolved at build time
|
||||
fonts: FontStack;
|
||||
}
|
||||
```
|
||||
|
||||
## Prior requests
|
||||
|
||||
- #42 — "Add dark mode support"
|
||||
- #87 — "Night theme for accessibility"
|
||||
- #134 — "Dark theme option"
|
||||
```
|
||||
|
||||
### Naming the file
|
||||
|
||||
Use a short, descriptive kebab-case name for the concept: `dark-mode.md`, `plugin-system.md`, `graphql-api.md`. The name should be recognizable enough that someone browsing the directory understands what was rejected without opening the file.
|
||||
|
||||
### Writing the reason
|
||||
|
||||
The reason should be substantive — not "we don't want this" but why. Good reasons reference:
|
||||
|
||||
- Project scope or philosophy ("This project focuses on X; theming is a downstream concern")
|
||||
- Technical constraints ("Supporting this would require Y, which conflicts with our Z architecture")
|
||||
- Strategic decisions ("We chose to use A instead of B because...")
|
||||
|
||||
The reason should be durable. Avoid referencing temporary circumstances ("we're too busy right now") — those aren't real rejections, they're deferrals.
|
||||
|
||||
## When to check `.out-of-scope/`
|
||||
|
||||
During triage (Step 1: Gather context), read all files in `.out-of-scope/`. When evaluating a new issue:
|
||||
|
||||
- Check if the request matches an existing out-of-scope concept
|
||||
- Matching is by concept similarity, not keyword — "night theme" matches `dark-mode.md`
|
||||
- If there's a match, surface it to the maintainer: "This is similar to `.out-of-scope/dark-mode.md` — we rejected this before because [reason]. Do you still feel the same way?"
|
||||
|
||||
The maintainer may:
|
||||
|
||||
- **Confirm** — the new issue gets added to the existing file's "Prior requests" list, then closed
|
||||
- **Reconsider** — the out-of-scope file gets deleted or updated, and the issue proceeds through normal triage
|
||||
- **Disagree** — the issues are related but distinct, proceed with normal triage
|
||||
|
||||
## When to write to `.out-of-scope/`
|
||||
|
||||
Only when an **enhancement** (not a bug) is rejected as `wontfix`. The flow:
|
||||
|
||||
1. Maintainer decides a feature request is out of scope
|
||||
2. Check if a matching `.out-of-scope/` file already exists
|
||||
3. If yes: append the new issue to the "Prior requests" list
|
||||
4. If no: create a new file with the concept name, decision, reason, and first prior request
|
||||
5. Post a comment on the issue explaining the decision and mentioning the `.out-of-scope/` file
|
||||
6. Close the issue with the `wontfix` label
|
||||
|
||||
## Updating or removing out-of-scope files
|
||||
|
||||
If the maintainer changes their mind about a previously rejected concept:
|
||||
|
||||
- Delete the `.out-of-scope/` file
|
||||
- The skill does not need to reopen old issues — they're historical records
|
||||
- The new issue that triggered the reconsideration proceeds through normal triage
|
||||
@@ -5,11 +5,11 @@ description: >
|
||||
or spec, every claim traced to a source — "write docs for X", "document this
|
||||
module", "create docs for this feature", "write a README for this". Not an ADR
|
||||
or other decision record -> `grill-with-docs`. Not an external tool researched
|
||||
from its docs -> `research-docs`.
|
||||
from its docs -> `research`.
|
||||
updated: 2026-05-17
|
||||
when: invoked by explicit trigger ("write docs for X", "document this module", "create docs for this feature") or implicit request to produce technical documentation from code or spec
|
||||
metadata:
|
||||
version: "1.0.2"
|
||||
version: "1.0.1"
|
||||
category: implement
|
||||
source:
|
||||
- repo: anthropics/skills
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
name: bin
|
||||
version: 3.0.0
|
||||
version: 1.1.9
|
||||
description: Skills for everyday AI-assisted development work that is not tied to a single tool, forge or language, and has not yet been split into a focused plugin.
|
||||
author:
|
||||
name: Defame1297
|
||||
@@ -11,6 +11,8 @@ repository: https://git.rkdr.net/Defame1297/holocron/src/branch/main/plugins/bin
|
||||
keywords:
|
||||
- utility
|
||||
- diagnostics
|
||||
- prototyping
|
||||
- tdd
|
||||
- research
|
||||
|
||||
# Constrains what .apm/ may contain: instructions, skill, hybrid, or prompts
|
||||
|
||||
@@ -298,14 +298,14 @@ EOF
|
||||
|
||||
@test "a doubled UTF-8 BOM does not hide the @import line" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write(('@AGENTS.md\n').encode('utf-8'))" "$ADAPTER"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write(('\ufeff\ufeff@AGENTS.md\n').encode('utf-8'))" "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "a BOM in front of a mid-file @import line does not hide it" {
|
||||
ADAPTER="$TMPDIR/CLAUDE.md"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write(('# Claude notes\n\n@AGENTS.md\n').encode('utf-8'))" "$ADAPTER"
|
||||
python3 -c "import sys; open(sys.argv[1], 'wb').write(('# Claude notes\n\n\ufeff@AGENTS.md\n').encode('utf-8'))" "$ADAPTER"
|
||||
run bash "$SCRIPT" "$ADAPTER" "$AGENTS_MD"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@@ -10,19 +10,27 @@
|
||||
# Refreshes in place and asks the host to re-scan, so the running session picks
|
||||
# the new content up without a restart.
|
||||
#
|
||||
# Inert in any project that does not consume packages through apm.
|
||||
# Inert under any host but Claude Code, and in any project that does not
|
||||
# consume packages through apm.
|
||||
set -uo pipefail
|
||||
|
||||
# Anchor on the project root, not the session's cwd. Claude Code exports
|
||||
# CLAUDE_PROJECT_DIR for SessionStart hooks; a session opened in a subdirectory
|
||||
# would otherwise miss the lockfile, no-op silently, and — worse — run the apm
|
||||
# calls below against that wrong directory. Fall back to the cwd when the
|
||||
# variable is absent, which keeps the hook inert-but-harmless under a host that
|
||||
# does not set it.
|
||||
project_dir="${CLAUDE_PROJECT_DIR:-$PWD}"
|
||||
# Claude Code only. apm deploys this hook to Copilot and Codex too, and there
|
||||
# the lockfile guard below would pass — apm wrote the lock — so without this
|
||||
# guard a non-Claude session start would run `apm update --yes` and rewrite the
|
||||
# working tree with nothing to re-scan it. Claude Code exports
|
||||
# CLAUDE_PROJECT_DIR for SessionStart hooks and the other targets do not
|
||||
# document setting it, so its absence is the exit (ADR-0019, correction
|
||||
# 2026-09-28). A heuristic: if the variable is inherited from the user's
|
||||
# environment, a non-Claude session start gets past this guard.
|
||||
[[ -n "${CLAUDE_PROJECT_DIR:-}" ]] || exit 0
|
||||
|
||||
# No lockfile means nothing was installed through apm here — e.g. a host that
|
||||
# installed this plugin natively. Say nothing and cost nothing.
|
||||
# Anchor on the project root, not the session's cwd: a session opened in a
|
||||
# subdirectory would otherwise miss the lockfile, no-op silently, and — worse —
|
||||
# run the apm calls below against that wrong directory.
|
||||
project_dir="$CLAUDE_PROJECT_DIR"
|
||||
|
||||
# No lockfile means this project consumes nothing through apm, so there is
|
||||
# nothing for apm update to refresh. Say nothing and cost nothing.
|
||||
[[ -f "$project_dir/apm.lock.yaml" ]] || exit 0
|
||||
command -v apm > /dev/null 2>&1 || exit 0
|
||||
|
||||
@@ -30,27 +38,47 @@ command -v apm > /dev/null 2>&1 || exit 0
|
||||
# `apm outdated` and `apm update` both resolve the lockfile from the cwd.
|
||||
cd "$project_dir" || exit 0
|
||||
|
||||
# Only ever emit fixed text plus a digit-checked count — never interpolate
|
||||
# command output into the JSON, which would need escaping this cannot do safely.
|
||||
emit() {
|
||||
printf '{"hookSpecificOutput":{"hookEventName":"SessionStart","reloadSkills":%s,"additionalContext":"%s"}}\n' "$1" "$2"
|
||||
}
|
||||
|
||||
# Every apm call is time-boxed, so timeout(1) is a hard requirement. It is GNU
|
||||
# coreutils: stock macOS has none, and Homebrew's coreutils installs it as
|
||||
# `gtimeout`. Calling a missing binary would exit 127, which the `|| exit 0`
|
||||
# below swallows — the hook would silently never work. Say so once instead, and
|
||||
# do not run apm unbounded.
|
||||
if command -v timeout > /dev/null 2>&1; then
|
||||
timeout_bin="timeout"
|
||||
elif command -v gtimeout > /dev/null 2>&1; then
|
||||
timeout_bin="gtimeout"
|
||||
else
|
||||
emit false "The apm install currency check did not run: neither timeout nor gtimeout (GNU coreutils) is on PATH, and this hook will not run apm without a time limit. Install coreutils (macOS: brew install coreutils) or run apm outdated by hand."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# apm drives git for every remote ref. A remote that wants credentials must fail
|
||||
# fast, not block on a terminal prompt nobody can see until the timeout fires.
|
||||
export GIT_TERMINAL_PROMPT=0
|
||||
|
||||
# `apm outdated` exits 0 whether or not anything is stale, so the answer has to
|
||||
# come from its output. ~0.7s against six remote refs; a hung remote must not
|
||||
# hold the session open.
|
||||
# hold the session open. -k sends SIGKILL a grace period after the SIGTERM, so a
|
||||
# child that ignores TERM cannot outlive its budget; tests/test-apm-current-hook.sh
|
||||
# sums every limit plus its grace against the hooks.json timeout.
|
||||
#
|
||||
# There is no --json/machine-readable flag on `apm outdated` (verified against
|
||||
# apm 0.28.0), so the phrase match is forced rather than chosen. Note the
|
||||
# singular: apm prints "1 outdated dependency found" when exactly one package is
|
||||
# behind, so matching only "dependencies" would silently miss a one-package
|
||||
# drift. tests/test-apm-current-hook.sh pins both spellings against the real apm.
|
||||
outdated_output="$(timeout 60 apm outdated 2>&1)" || exit 0
|
||||
outdated_output="$("$timeout_bin" -k 5 60 apm outdated 2>&1)" || exit 0
|
||||
grep -qE 'outdated dependenc(y|ies) found' <<< "$outdated_output" || exit 0
|
||||
|
||||
stale_count="$(grep -oE '[0-9]+ outdated dependenc(y|ies) found' <<< "$outdated_output" | grep -oE '^[0-9]+' || true)"
|
||||
[[ "$stale_count" =~ ^[0-9]+$ ]] || stale_count="some"
|
||||
|
||||
# Only ever emit fixed text plus a digit-checked count — never interpolate
|
||||
# command output into the JSON, which would need escaping this cannot do safely.
|
||||
emit() {
|
||||
printf '{"hookSpecificOutput":{"hookEventName":"SessionStart","reloadSkills":%s,"additionalContext":"%s"}}\n' "$1" "$2"
|
||||
}
|
||||
|
||||
# What to do with the rewritten lock depends on the branch (ADR-0019): on the
|
||||
# default branch it is a real update to commit or discard; on a feature branch it
|
||||
# is churn unrelated to the branch and should be discarded. The branch name only
|
||||
@@ -77,7 +105,23 @@ if [[ -n "$current_branch" && -n "$default_branch" ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
if timeout 300 apm update --yes > /dev/null 2>&1; then
|
||||
# Two sessions started together would both run `apm update --yes` over the same
|
||||
# tree. Serialise on a lock under apm_modules/: `apm install` itself adds that
|
||||
# directory to .gitignore, so the lock never shows up as a working-tree change,
|
||||
# and apm only ever removes package directories inside it, never the directory
|
||||
# (or this file) itself. The loser does not wait — the winner's refresh is the
|
||||
# one it wanted — and says so. flock(1) is util-linux, absent on stock macOS,
|
||||
# and there the refresh runs unserialised, as it did before the lock existed; so
|
||||
# does a checkout with no apm_modules/ yet, rather than creating it.
|
||||
if command -v flock > /dev/null 2>&1 && [[ -d apm_modules ]] \
|
||||
&& { exec 9> apm_modules/.kyberforge-apm-update.lock; } 2> /dev/null; then
|
||||
if ! flock -n 9; then
|
||||
emit false "apm install is ${stale_count} package(s) behind the remote default branch, and another session is refreshing it right now, so this session skipped its own refresh. Skills and agents loaded in this session may be stale; if they are, restart the session once that refresh has finished."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if "$timeout_bin" -k 5 300 apm update --yes > /dev/null 2>&1; then
|
||||
emit true "apm install was ${stale_count} package(s) behind the remote default branch and has been refreshed automatically; skills and agents were redeployed and re-scanned. apm.lock.yaml has been rewritten and is now a modified file in the working tree - ${lock_advice}"
|
||||
else
|
||||
emit false "apm install is ${stale_count} package(s) behind the remote default branch and the automatic refresh failed. Deployed skills and agents may be stale. Run: apm update --yes"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"command": "${CLAUDE_PLUGIN_ROOT}/.apm/hooks/check-apm-current.sh",
|
||||
"command": "${PLUGIN_ROOT}/.apm/hooks/check-apm-current.sh",
|
||||
"timeout": 380,
|
||||
"type": "command"
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
---
|
||||
name: agent-author
|
||||
description: >
|
||||
Use when the user wants to create a new agent definition file from scratch, or
|
||||
apply grill findings, audit findings, or inline feedback to an existing one.
|
||||
Use when the user wants a new agent definition created, or grill, audit
|
||||
or inline feedback applied to an existing one.
|
||||
Not read-only review -> `factory-audit`. Not skills -> `skill-author`.
|
||||
Not hooks, instructions or prompts -> `primitive-author`.
|
||||
allowed-tools: Bash Read Write Edit
|
||||
metadata:
|
||||
version: "1.0.4"
|
||||
@@ -31,7 +32,7 @@ metadata:
|
||||
|
||||
Signals: grill output, `factory-audit` findings, inline feedback, session context describing what went wrong. With none, ask: "No improvement signals found. Did you mean to create a new agent, or do you have feedback to apply?"
|
||||
|
||||
Read only the reference for the resolved flow.
|
||||
Read only the reference for the resolved flow. Capture `rtk git log --oneline -1` before touching the filesystem; Step 4 needs it.
|
||||
|
||||
## Step 2 — Scope
|
||||
|
||||
@@ -60,4 +61,6 @@ At every scope, five tools reach no subagent whatever `tools` says — `AskUserQ
|
||||
|
||||
Invoke `factory-audit` on each file written and resolve every FAIL before reporting done. It checks the field allowlist, name-to-stem match, leftover placeholders and template comments, the description budget and the Copilot body limit — do not hand-check those.
|
||||
|
||||
At plugin/APM scope bump the resolved package's `apm.yml` `version` — **minor** on create, **patch** on improve — because consumers compare it to detect updates. Project and user scope have no manifest.
|
||||
At plugin/APM scope bump the resolved package's `apm.yml` `version` — **minor** on create, **patch** on improve — because consumers compare it to detect updates. Skip, and say so, if this branch already bumped it: `git diff $(git merge-base HEAD <remote-default-branch>) -- <package>/apm.yml` shows a changed `version:` line, and one bump covers a branch. Project and user scope have no manifest.
|
||||
|
||||
**Commit verification.** Once the audit is clean, run `rtk git add` and `rtk git commit` — do not stop at staging. Re-run `rtk git log --oneline -1` and confirm the hash changed from Step 1's. A non-empty `git diff --stat` is not proof: staged-but-uncommitted work is part of no commit and is lost if the tree is cleaned up. Report done only once the hash has changed.
|
||||
@@ -7,8 +7,8 @@ source_keys:
|
||||
|
||||
# Creating a new agent
|
||||
|
||||
Return to `SKILL.md` Step 4 once Step 3 below is done — validation and the version bump
|
||||
are shared with the improve flow and are not repeated here.
|
||||
Return to `SKILL.md` Step 4 once Step 3 below is done — validation, the version bump and commit
|
||||
verification are shared with the improve flow and are not repeated here.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ source_keys:
|
||||
|
||||
# Improving an existing agent
|
||||
|
||||
Return to `SKILL.md` Step 4 once Step 4 below is done — validation and the version bump
|
||||
are shared with the create flow and are not repeated here.
|
||||
Return to `SKILL.md` Step 4 once Step 4 below is done — validation, the version bump and commit
|
||||
verification are shared with the create flow and are not repeated here.
|
||||
|
||||
## Step 1 — Verify inputs
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
---
|
||||
name: apm-workflow
|
||||
description: >
|
||||
Use when authoring, installing, or publishing an apm package, its apm.yml and
|
||||
the dependencies it declares, or an apm marketplace — even when the user does
|
||||
not say "apm". Not the apm binary or an agent runtime -> `apm-install`.
|
||||
Use when authoring, installing or publishing an apm package, its apm.yml and
|
||||
dependencies, or a marketplace, even if "apm" goes unsaid.
|
||||
Not the apm binary or an agent runtime -> apm-install.
|
||||
Not a hook, instruction or prompt file -> primitive-author.
|
||||
metadata:
|
||||
version: "1.0.3"
|
||||
version: "1.0.2"
|
||||
category: apm
|
||||
source_keys:
|
||||
- context7-microsoft-apm
|
||||
@@ -13,15 +14,14 @@ metadata:
|
||||
|
||||
## Gotchas
|
||||
|
||||
- MCP server secrets in `apm.yml` (headers, env vars) must use `${VAR}` indirection, never literal values, so they resolve at install or runtime and are never committed.
|
||||
- `apm experimental enable registries` must run before a `registries:` block or `registry.*` config takes effect anywhere — configure, install or publish. Without it, declaring one silently does nothing: no error, no warning.
|
||||
- `apm.yml`'s `type:` selects which primitives are processed and is never checked against what `.apm/` holds, so `apm install` and `apm compile` can exit 0 having shipped none of the ones you expected. Set it to cover every primitive the package ships, and confirm the deployed output, not the exit code. Mechanics: `references/configure.md`.
|
||||
- `apm experimental enable registries` must run before a `registries:` block or `registry.*` config takes effect in any flow; without it they silently do nothing.
|
||||
- `apm.yml`'s `type:` is never checked against `.apm/`, so `apm install` and `apm compile` can exit 0 shipping none of the expected primitives. Set `type:` to cover every primitive shipped; confirm the deployed output, not the exit code (`references/configure.md`).
|
||||
|
||||
## Step 1 — Dispatch
|
||||
|
||||
| Condition | Flow | Reference |
|
||||
|---|---|---|
|
||||
| Author or edit `apm.yml`, or scaffold a new package (`apm plugin init`) | configure | `references/configure.md` |
|
||||
| Author or edit `apm.yml`, or scaffold a new package (`apm plugin init`); skill, agent, hook, instruction or prompt content goes to the matching author skill | configure | `references/configure.md` |
|
||||
| Resolve or fetch the dependencies `apm.yml` declares (`apm install`, `apm install [PACKAGE_REF]`) | install | `references/install.md` |
|
||||
| Build a marketplace, register a package into it (local: hand-edit `apm.yml`; remote: `apm marketplace package add`), or register someone else's as a consumer (`apm marketplace init/check/package add/add`) | marketplace | `references/marketplace.md` |
|
||||
| Generate per-target output, bundle, or publish (`apm compile`, `apm pack`, `apm publish`) | compile | `references/compile.md` |
|
||||
|
||||
@@ -12,7 +12,7 @@ apm compile --clean # zero-write sanity check; use for skill/agent-o
|
||||
apm compile --clean --dry-run # pure preview, no writes
|
||||
```
|
||||
|
||||
Compiles `.apm/instructions/` + `.apm/agents/*.agent.md` primitives into consumer-side context files (AGENTS.md/CLAUDE.md CONTEXT files) for the deployment target, per the `compilation:` block in `apm.yml`. This is the consumer/deployment side — it is NOT the producer of `plugin.json`/`marketplace.json`; that's `apm pack`'s job (below). Run `apm compile` after any change to `.apm/instructions/`/`.apm/agents/` content or to `compilation:`/`targets:` in `apm.yml`. To author an instructions file, use `instructions-author` — it covers which fields each target drops. `apm compile` never reads `.apm/prompts/`; to author a prompt file, use `prompt-author` — verification there is a throwaway `apm install`.
|
||||
Compiles `.apm/instructions/` + `.apm/agents/*.agent.md` primitives into consumer-side context files (AGENTS.md/CLAUDE.md CONTEXT files) for the deployment target, per the `compilation:` block in `apm.yml`. This is the consumer/deployment side — it is NOT the producer of `plugin.json`/`marketplace.json`; that's `apm pack`'s job (below). Run `apm compile` after any change to `.apm/instructions/`/`.apm/agents/` content or to `compilation:`/`targets:` in `apm.yml`.
|
||||
|
||||
## Pack
|
||||
|
||||
@@ -34,6 +34,8 @@ Bundles a producer package into a distributable artifact. Default to `--dry-run
|
||||
- A populated one gets its `mcpServers` content merged directly into the compiled `plugin.json`, but only for the `claude` target.
|
||||
- The `copilot` target's compiled `plugin.json` OMITS `mcpServers` entirely — it isn't part of Copilot's plugin manifest schema.
|
||||
|
||||
`mcpServers` headers and env must use `${VAR}` indirection — the content is merged verbatim into the published `plugin.json`, so a literal secret ships with the package.
|
||||
|
||||
`dependencies.mcp` in `apm.yml` is for a different purpose — declaring a remote MCP-server package as an APM dependency — not local `.mcp.json` passthrough.
|
||||
|
||||
### `includes: auto` and the packed bundle
|
||||
|
||||
@@ -10,7 +10,7 @@ source_keys:
|
||||
apm plugin init --yes --target claude,copilot
|
||||
```
|
||||
|
||||
Run from inside the target package directory, with no positional name argument (see Gotchas). Creates `apm.yml` + `plugin.json` in the current directory — it does NOT scaffold a `.apm/` skeleton. Primitive subdirectories (`.apm/skills/`, `.apm/agents/`, `.apm/hooks/`) must be created manually as content is migrated into them. Run this once per package (e.g. once per `plugins/<name>/` directory in a monorepo-hybrid layout), not once for the whole repo.
|
||||
Run from inside the target package directory, with no positional name argument (see this file's Gotchas). Creates `apm.yml` + `plugin.json` in the current directory — it does NOT scaffold a `.apm/` skeleton. Create each primitive subdirectory (`.apm/skills/`, `.apm/agents/`, `.apm/hooks/`, `.apm/instructions/`, `.apm/prompts/`) through its author skill as content lands in it: skills via `skill-author`, agents via `agent-author`, hooks, instructions and prompts via `primitive-author`. Run this once per package (e.g. once per `plugins/<name>/` directory in a monorepo-hybrid layout), not once for the whole repo.
|
||||
|
||||
## `apm.yml` — required fields
|
||||
|
||||
@@ -25,7 +25,7 @@ version: 1.0.0
|
||||
|
||||
- `name`, `version` — required (see above)
|
||||
- `description`, `author`, `license`, `homepage`, `repository`, `keywords` — standard package metadata
|
||||
- `type` — `instructions | skill | hybrid | prompts`; selects how the package is processed at install/compile time. It is a routing selector, not a constraint on what `.apm/` may contain (see Gotchas)
|
||||
- `type` — `instructions | skill | hybrid | prompts`; selects how the package is processed at install/compile time. It is a routing selector, not a constraint on what `.apm/` may contain (see this file's Gotchas)
|
||||
- `targets` — which harnesses this package compiles to (plural list form preferred; legacy singular `target: copilot,claude` CSV form still accepted)
|
||||
- `includes` — `auto` publishes the authoritative local layout as-is; it is not scoped down to what's relevant, so anything narrower needs an explicit repo-path list. Note: `auto` also does not sweep generic root-level passthrough files (README.md, docs/, sources.md, config files) into the `apm pack` distribution bundle — see `references/compile.md`
|
||||
- `dependencies`/`devDependencies` — `apm`/`mcp`/`lsp` entries; `devDependencies` share the same shape but are excluded from the shipped artifact
|
||||
@@ -73,16 +73,16 @@ version follows a separate rule — see `references/marketplace.md`.
|
||||
|
||||
## MCP server secrets
|
||||
|
||||
`${VAR}` indirection is required for MCP server secrets (headers, env vars) in `apm.yml`, never literal values — see SKILL.md Gotchas.
|
||||
MCP server secrets (headers, env vars) in `apm.yml` must use `${VAR}` indirection, never literal values, so they resolve at install or runtime and are never committed.
|
||||
|
||||
## Registries (config-level, not `apm.yml`)
|
||||
|
||||
Any git repo is a valid package source by default — no registry required. To declare named registries for shorthand dependency resolution:
|
||||
|
||||
```bash
|
||||
apm experimental enable registries # required first — see Gotchas
|
||||
apm experimental enable registries # required first — see this file's Gotchas
|
||||
apm config set registry.corp-main.url https://artifactory.corp.example.com/apm
|
||||
apm config set registry.corp-main.token eyJ...
|
||||
apm config set registry.corp-main.token "$CORP_APM_TOKEN"
|
||||
apm config set registry.corp-main.default true
|
||||
```
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
name: factory-audit
|
||||
description: >
|
||||
Use when the user wants a skill directory or agent definition audited,
|
||||
including "is this ready to ship", or after hand-editing one outside its
|
||||
author skill. Not applying skill fixes -> skill-author. Not applying agent
|
||||
fixes -> agent-author.
|
||||
Use when a skill, agent, apm hook, instruction or prompt needs auditing
|
||||
("ready to ship?"), even after a hand edit. Not fixing a skill -> skill-author.
|
||||
Not fixing an agent -> agent-author.
|
||||
Not fixing a hook, instruction or prompt -> primitive-author.
|
||||
allowed-tools: Bash Read
|
||||
metadata:
|
||||
version: "1.0.6"
|
||||
version: "1.1.1"
|
||||
category: factory
|
||||
source_keys:
|
||||
- agentskills-home
|
||||
@@ -20,6 +20,8 @@ metadata:
|
||||
- claude-code-subagents-docs
|
||||
- context7-github-en-copilot
|
||||
- github-custom-agents-configuration
|
||||
- apm-cli-installed-source
|
||||
- apm-docs-llms-full
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
@@ -30,21 +32,24 @@ metadata:
|
||||
|
||||
## Step 0 — Dispatch
|
||||
|
||||
Resolve the flow from the target path **before running anything**. The two flows run different validators over different dimension vocabularies, so dispatching after Step 1 means the wrong validator has already produced the wrong findings. The rows mirror the shapes `scripts/validate.sh` accepts; take the first that matches.
|
||||
Resolve the flow from the target path **before running anything**. The flows run different validators over different dimension vocabularies, so dispatching after Step 1 means the wrong validator has already produced the wrong findings. The rows mirror the shapes `scripts/validate.sh` accepts; take the first that matches.
|
||||
|
||||
| Target | Flow | Read |
|
||||
|---|---|---|
|
||||
| A directory containing `SKILL.md` | skill | `references/skill-flow.md` |
|
||||
| A file named `SKILL.md` — audit its parent directory | skill | `references/skill-flow.md` |
|
||||
| A file named `*.agent.md` | agent | `references/agent-flow.md` |
|
||||
| A file named `*.instructions.md` | instruction | `references/instruction-flow.md` |
|
||||
| A file named `*.prompt.md` | prompt | `references/prompt-flow.md` |
|
||||
| A `.md` file whose immediate parent directory is `agents/` (`.apm/agents`, `.claude/agents`, `.github/agents`, `.copilot/agents`) | agent | `references/agent-flow.md` |
|
||||
| A `.json` file whose immediate parent directory is `hooks/` (`.apm/hooks`, or a package-root `hooks/`; the hook flow FAILs any other `hooks/`) | hook | `references/hook-flow.md` |
|
||||
| Anything else — a missing path, a directory without `SKILL.md`, any other file | none | — |
|
||||
|
||||
Read only the file its row matched. Each carries Steps 1 to 3 — the deterministic checks, the read, and the qualitative audit — and is self-contained. Return here for Step 4.
|
||||
|
||||
On the last row, stop: run no validator and tell the user the two accepted shapes — a skill directory (or its `SKILL.md`), or an agent file (`*.agent.md`, or a `.md` directly under an `agents/` directory). Guessing a flow audits the path against the wrong spec.
|
||||
On the last row, stop: run no validator and tell the user the shapes the other rows accept. Guessing a flow audits the path against the wrong spec.
|
||||
|
||||
The scripts re-detect the flow from the path. If `validate.sh` reports on the other artifact type than your row, discard what you have and restart here — the flow file, not the script, picked your rubrics, coverage line and remediation line.
|
||||
The scripts re-detect the flow from the path. If `validate.sh` reports on a different artifact type than your row, discard what you have and restart here — the flow file, not the script, picked your rubrics, coverage line and remediation line.
|
||||
|
||||
## Step 4 — Report
|
||||
|
||||
@@ -64,7 +69,9 @@ Checked: structure · provider-safety · description · body · delegation · co
|
||||
|
||||
On the agent flow at plugin/APM scope, drop `pair-consistency` — there is no pair to check.
|
||||
|
||||
Then output only the dimensions that have findings, grouped under H3 headings, FAILs before SUGGESTIONs within each. Omit clean dimensions — their absence is what confirms they passed.
|
||||
Hook, instruction and prompt flows: the line their flow file ends with.
|
||||
|
||||
Then output only the dimensions that have findings, grouped under H3 headings, FAILs before SUGGESTIONs within each. Omit clean dimensions.
|
||||
|
||||
Each finding:
|
||||
|
||||
@@ -74,4 +81,4 @@ FAIL/SUGGESTION <finding> — file:line
|
||||
Fix: <exact change — quote before/after where applicable>
|
||||
```
|
||||
|
||||
Close with a `## Result` block holding one line: `PASS`, `PASS (N suggestions)`, or `FAIL (N fails · M suggestions)`, each optionally followed by ` · P info`. INFO findings are observational and never change PASS/FAIL; omit `· P info` when there are none. Add a second line whenever there is at least one finding — `Run skill-author to address findings.` on the skill flow, `Run agent-author to address findings.` on the agent flow. Do not apply fixes — report and propose only.
|
||||
Close with a `## Result` block holding one line: `PASS`, `PASS (N suggestions)`, or `FAIL (N fails · M suggestions)`, each optionally followed by ` · P info`. INFO findings are observational and never change PASS/FAIL; omit `· P info` when there are none. Add a second line whenever there is at least one finding — `Run skill-author to address findings.` on the skill flow, `Run agent-author to address findings.` on the agent flow, `Run primitive-author to address findings.` on the other three. Do not apply fixes — report and propose only.
|
||||
@@ -6,5 +6,13 @@ BasedOnStyles = Kyberforge
|
||||
[**/agents/*.md]
|
||||
BasedOnStyles = Kyberforge
|
||||
|
||||
[**/*.instructions.md]
|
||||
BasedOnStyles = Kyberforge
|
||||
|
||||
[**/*.prompt.md]
|
||||
BasedOnStyles = Kyberforge
|
||||
|
||||
# Stays the last section: the repo's `tests/test-vale-wrap.sh` case 31 appends a rule
|
||||
# override to the end of this file and relies on it landing here.
|
||||
[**/*.agent.md]
|
||||
BasedOnStyles = Kyberforge, KyberforgeCopilot
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
extends: existence
|
||||
message: "Description opens with '%s' — use an imperative 'Use when...' opener instead"
|
||||
message: "Description opens with '%s' — lead with the action or trigger, not 'This'"
|
||||
level: error
|
||||
scope: text.frontmatter.description
|
||||
ignorecase: true
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
extends: existence
|
||||
message: "Generic reference pointer: '%s' — use the specific 'If X, read `references/file.md`' form instead"
|
||||
message: "Generic reference pointer: '%s' — name the exact file and when to read it ('If X, read `<path>`') instead"
|
||||
level: error
|
||||
scope: text
|
||||
ignorecase: true
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-cli-installed-source
|
||||
- apm-docs-llms-full
|
||||
- claude-code-hooks-reference
|
||||
- github-copilot-hooks-configuration
|
||||
---
|
||||
|
||||
# Hook Flow
|
||||
|
||||
Steps 1 to 3 for an apm hook — the target Step 0 matched as a `.json` file directly under a
|
||||
`hooks/` directory. Work them in order, then return to `SKILL.md` Step 4 to report.
|
||||
|
||||
## Gotchas
|
||||
|
||||
- apm checks almost nothing here. Invalid JSON is skipped without a word, an event name its rename map does not cover deploys verbatim with no warning (a lowercase `stop` or a typo such as `PreToolUSe` never fires on Claude or Copilot), and a missing script only warns — so `apm install` exiting 0 says nothing about whether the hook works. Never cite a clean install as evidence against a finding.
|
||||
- Copilot receiving a Claude-shaped file is not a finding. apm renders one source for every target and documents that it owns the per-target shape; whether Copilot CLI honours a nested entry or `matcher` is unverified upstream, not a defect in the file.
|
||||
- Quoting is not the fix for a script path with a space. apm rewrites a whole-token-quoted `"${PLUGIN_ROOT}/scripts/x.sh"`, but still stops reading the path at the space; the only fix is a path without one.
|
||||
|
||||
## Step 1 — Deterministic checks
|
||||
|
||||
Resolve the path against this skill's own directory. Run exactly:
|
||||
|
||||
```bash
|
||||
bash scripts/validate.sh <hook-file>
|
||||
```
|
||||
|
||||
Its findings become the `### Structure` dimension, FAILs and SUGGESTIONs both, at the tier the script assigned.
|
||||
|
||||
Checks:
|
||||
|
||||
- JSON validity and UTF-8 encoding; a top level that is not a JSON object; the wrapped-or-naked shape; event lists and nested handler lists (the checks whose failure makes the Copilot install fail).
|
||||
- A file contributing no entries (no events, only empty event lists, or an entry with no handler), an empty event name, and event names that never fire.
|
||||
- Unfilled `FILL IN` or `FILL_IN_` template placeholders.
|
||||
- A symlinked file, or one under apm's deployed output or outside any package rather than package source (exit 1, a finding, not exit 2).
|
||||
- Referenced scripts that are missing, outside the package, not executable when run directly, or referenced by an absolute, bare relative, `../`, split-quoted, space-containing, or `$`/backtick-containing path apm will not bundle correctly.
|
||||
- A plugin-root token apm never rewrites: unbraced (`$PLUGIN_ROOT/x.sh`, `$CLAUDE_PLUGIN_ROOT`), or braced but not directly followed by `/` or `\` (`cd ${PLUGIN_ROOT} && …`).
|
||||
- Deprecated filename routing, and `${CLAUDE_PLUGIN_ROOT}` where `${PLUGIN_ROOT}` would do.
|
||||
- INFO: no `apm.yml` at an inferred `.apm/` package root, or a `targets:` naming no hook target apm recognises (`claude-code`), which leaves event names checked against no harness.
|
||||
|
||||
Script reference rules:
|
||||
|
||||
- Script references are read with apm 0.28.0's own patterns: `${PLUGIN_ROOT}/…` only when the path follows the token directly, up to the first whitespace or quote, and `./…` anywhere in the command.
|
||||
- A `./` or `../` match is held to the script rules — a FAIL when missing — only in command position, when it ends in a script extension, or when it names a package entry that is not a file; any other match (`npx prettier --check ./src`, `printf '.\n'`) is at most a SUGGESTION, because apm only warns and it runs against the consumer's working directory as meant.
|
||||
- Command position is the first token past any `NAME=value` assignments and `env` with its options, or the first operand after `bash`, `sh`, `zsh`, `python`, `python3`, `node`, `pwsh`, `ruby` or `perl`, past its options such as `-e` or `-u`; after a `sh`-family `-c`, the first token of the command string; inline code such as `python3 -c` has none. Absolute and bare relative script paths are checked in the same positions.
|
||||
- The exec bit is required of a script that runs directly: the first token, or the first token of a `-c` command string (`bash -c "${PLUGIN_ROOT}/x.sh"`). Through an interpreter it is not.
|
||||
- Each event is judged per target the package root's `apm.yml` deploys to — no `target:`/`targets:`, `all`, or no `apm.yml` means every hook target — after apm's rename map for that target: it FAILs when a target with a published event list (Claude, Copilot) does not fire the renamed name, whatever its casing.
|
||||
|
||||
Exit codes: **0** with no FAIL, **1** on real findings, **2** when it never ran, including a crash inside the checks — report that as `### Structure` unverified, quoting the stderr reason. An INFO line is observational: report it under `### Structure` and count it in `· P info`.
|
||||
|
||||
The command parser is a heuristic, not a shell. Known blind spots: a script after `&&`, `;` or a pipe inside one command, `env -S`, command substitution, and a quoted `-c` string that ends before the script are not in command position, so a bad reference there is at most a SUGGESTION or unseen. Read every command in Step 2 rather than taking a clean script run as proof.
|
||||
|
||||
There is no provenance and no Vale step: a hook carries no `source_keys` and no prose.
|
||||
|
||||
Six tiers deliberately differ from `primitive-author`'s checklist or the research's. Do not re-tier them by judgment:
|
||||
|
||||
- A hook file directly under a package-root `hooks/` — beside the package's `apm.yml`, or beside a `plugin.json` at any location apm's `find_plugin_json` reads (root, `.github/plugin/`, `.claude-plugin/`, `.cursor-plugin/`) — passes. apm discovers both `.apm/hooks/` and `hooks/`, installs a Claude plugin with no `apm.yml`, and this audit may target a third-party package; `primitive-author` authors only in `.apm/hooks/`. Any other `hooks/` directory (`.github/hooks/`, `.cursor/hooks/`, …) is apm's deployed output, or no package source at all, and FAILs at exit 1.
|
||||
- An event that every listed target fires, but that reaches a target with no published event list (Cursor, Kiro, Gemini, Codex, Antigravity, Windsurf) in a non-PascalCase form after apm's rename, is a SUGGESTION, not the FAIL Must 4 implies: the script cannot tell a harness's native spelling (Cursor's `stop`, Windsurf's `pre_run_command`) from a typo. A Cursor-only `stop` therefore exits 0.
|
||||
- Copilot counts every name apm's own Copilot map emits as fired (`userPromptSubmit`, although Copilot documents `userPromptSubmitted`): the author cannot route around apm's rename, so that is not a finding in the file.
|
||||
- Deprecated filename routing is a SUGGESTION, matching the author's Should: the research allows it when deprecated routing is intended.
|
||||
- A non-executable script run directly (the first token, or first in a `-c` string) is a FAIL, stricter than the research's Should, because it fails every time it fires.
|
||||
- `primitive-author` hook Must 5 bans an absolute or bare relative path "in any position"; this audit checks command positions only, because a later argument is data the script cannot tell from a path. Judge the rest by reading in Step 3.
|
||||
|
||||
## Step 2 — Read the hook and its scripts
|
||||
|
||||
Read the hook file, every script it references, and the package's `apm.yml` `targets:` — reach is narrowed there, never in the hook file.
|
||||
|
||||
## Step 3 — Qualitative audit
|
||||
|
||||
Cite file and line for every finding.
|
||||
|
||||
**purpose** — apm's own rule is to reach for a skill, instruction or prompt first; a hook is for "this must always happen at this event".
|
||||
|
||||
- FAIL: the script carries procedure the agent should follow — instructions printed to the model, a multi-step workflow — rather than a runtime callback. That is a skill.
|
||||
- SUGGESTION: the behaviour is harness-specific (a Claude-only event reaching a harness the script has no event list for, a Claude-only matcher value) in a package whose `targets:` includes other harnesses, and nothing records that the other targets receiving it was accepted. The apm-native fix is a separate package with its own `targets:`, not a routing filename.
|
||||
|
||||
**handlers** — the research checklist's Should and audit-only items, which apm never checks:
|
||||
|
||||
- SUGGESTION: a handler without `"type": "command"` or an explicit numeric `timeout` in seconds.
|
||||
- SUGGESTION: a tool event (`PreToolUse`, `PostToolUse`) or `SessionStart` with no `matcher` — Claude receives `"*"`. A `matcher` on an event Claude ignores it for (`Stop`, `UserPromptSubmit`) is inert, not wrong.
|
||||
- SUGGESTION: a PascalCase event, in a package reaching only harnesses with no published event list, that is not one of that harness's events — the script FAILs a misspelling only where it has the list (Claude, Copilot).
|
||||
- SUGGESTION: `bash`/`powershell`/`timeoutSec` keys in a Claude-shaped file — they render, but leave stray keys in `settings.json`.
|
||||
- SUGGESTION: a helper `.json` file in the hook directory without a `hooks` key — Copilot's loader scans the bundled scripts directory and rejects it. Keep helper configuration non-JSON.
|
||||
|
||||
Then return to `SKILL.md` Step 4, opening the report with this coverage line:
|
||||
|
||||
```text
|
||||
Checked: structure · purpose · handlers
|
||||
```
|
||||
@@ -0,0 +1,59 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-cli-installed-source
|
||||
- apm-docs-llms-full
|
||||
---
|
||||
|
||||
# Instruction Flow
|
||||
|
||||
Steps 1 to 3 for an apm instruction — the target Step 0 matched as a `*.instructions.md` file.
|
||||
Work them in order, then return to `SKILL.md` Step 4 to report.
|
||||
|
||||
## Gotchas
|
||||
|
||||
- `apm compile --validate` is not a gate. Every message `Instruction.validate()` produces is a warning, and it reports success on a file with no description and an empty body — never cite it as evidence against a finding.
|
||||
- `description` never reaches Claude, and it is index text elsewhere, never a routing description. Do not hold it to the skill description contract: no trigger clause, no boundary clause. A Vale `Kyberforge.DescriptionOpener` alert here means rewrite it as a plain statement of what the rule covers.
|
||||
|
||||
## Step 1 — Deterministic checks
|
||||
|
||||
Resolve both paths against this skill's own directory. Run exactly:
|
||||
|
||||
```bash
|
||||
bash scripts/validate.sh <instruction-file>
|
||||
bash scripts/vale-wrap.sh <instruction-file>
|
||||
```
|
||||
|
||||
`validate.sh` findings become the `### Structure` dimension, FAILs and SUGGESTIONs both, at the tier the script assigned: path, a file that is not valid UTF-8, unfilled `FILL IN` or `FILL_IN_` template placeholders, frontmatter, `description`, body, an `applyTo` that is neither a string nor a list, present but empty, or has unbalanced braces or brackets (a closer before its opener counts), a missing or list-form `applyTo`, extra keys, and a stem duplicated at the package root. It exits **0** with no FAIL, **1** on real findings, **2** when it never ran, including a crash inside the checks — report that as `### Structure` unverified, quoting the stderr reason.
|
||||
|
||||
A missing `applyTo` is a SUGGESTION, not the FAIL `primitive-author`'s instruction Must 4 implies: absence is legal after the author Gate's explicit yes, which the audit cannot see. The **scope** dimension's always-on FAILs below cover the misuse. Do not re-tier it by judgment.
|
||||
|
||||
`vale-wrap.sh` applies the bundled `Kyberforge` style. Every alert is a FAIL under `### Prose`, cited by rule ID; do not re-derive it by judgment. That includes the rules scoped to the `description` (`Kyberforge.DescriptionOpener`, `VagueWording`, `CompositionNote`), a deliberate deviation from `primitive-author`, which holds description wording to at most a Should: the house prose rules apply to every model- or user-visible description, and a deterministic rule does not change tier by file kind. Do not re-tier them. `0 files` scanned means NOT RUN, not clean — say so and judge prose by reading.
|
||||
|
||||
There is no provenance step: an instruction carries no `source_keys`.
|
||||
|
||||
## Step 2 — Read the instruction and its context
|
||||
|
||||
Read the file, the package's `apm.yml`, and the repo's root `AGENTS.md`. For a scoped file, list the tracked files its `applyTo` matches (`git ls-files` filtered by the glob). List the instruction stems the installed dependencies ship (`apm_modules/**/.apm/instructions/*.instructions.md`) — the script checks only the package root for a duplicate.
|
||||
|
||||
## Step 3 — Qualitative audit
|
||||
|
||||
Cite file and line for every finding.
|
||||
|
||||
**scope** — an instruction applies when files matching `applyTo` are touched; with no `applyTo` it loads into every session of every repo that installs the package.
|
||||
|
||||
- FAIL: the content is a rule for this repo alone, scoped or always-on — it belongs in `AGENTS.md` (a nested `AGENTS.md` for a subtree), which is the repo's own instruction source, not in a package that ships it to every consumer. This matches `primitive-author`'s Gate, which routes every repo-only rule there.
|
||||
- FAIL: the stem matches an instruction an installed dependency ships — both deploy to `.claude/rules/<stem>.md`, and one silently overwrites the other.
|
||||
- SUGGESTION: an `applyTo` glob that matches no tracked file here. It is legitimate for files the package's consumers have and this repo does not, so name the mismatch rather than failing it.
|
||||
- SUGGESTION: an always-on file whose content is really file-type specific — narrow it with `applyTo`.
|
||||
- SUGGESTION: a glob much broader than the content (`**` for a rule about Python).
|
||||
|
||||
**description**
|
||||
|
||||
- SUGGESTION: the description does not say what the rule covers, or contradicts the body. Any rationale Claude readers need belongs in the body, because Claude drops the description.
|
||||
- SUGGESTION: a relative markdown link that does not resolve from the source file — apm rewrites links on deploy, and a broken one stays broken on every target.
|
||||
|
||||
Then return to `SKILL.md` Step 4, opening the report with this coverage line:
|
||||
|
||||
```text
|
||||
Checked: structure · prose · scope · description
|
||||
```
|
||||
@@ -0,0 +1,58 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-cli-installed-source
|
||||
- apm-docs-llms-full
|
||||
- adr-0029-prompt-house-rule
|
||||
---
|
||||
|
||||
# Prompt Flow
|
||||
|
||||
Steps 1 to 3 for an apm prompt — the target Step 0 matched as a `*.prompt.md` file. Work them in
|
||||
order, then return to `SKILL.md` Step 4 to report.
|
||||
|
||||
## Gotchas
|
||||
|
||||
- A prompt is judged against ADR-0029, not against apm's framing. apm's docs call a prompt "a program for an LLM" (`apm-docs-llms-full`, "What is APM?" › "Secure by default"); this repo holds it to a single-intent, user-triggered message that steers existing skills or agents by name and carries no procedure of its own.
|
||||
- A prompt's description is not a skill description. It is one plain user-facing sentence with no "Use when" trigger clause and no boundary clause — so never raise a missing trigger or boundary as a finding. A Vale `Kyberforge.DescriptionOpener` alert here means rewrite it as an imperative action ("Review the current PR with …"), not add a trigger.
|
||||
|
||||
## Step 1 — Deterministic checks
|
||||
|
||||
Resolve both paths against this skill's own directory. Run exactly:
|
||||
|
||||
```bash
|
||||
bash scripts/validate.sh <prompt-file>
|
||||
bash scripts/vale-wrap.sh <prompt-file>
|
||||
```
|
||||
|
||||
`validate.sh` findings become the `### Structure` dimension, FAILs and SUGGESTIONs both, at the tier the script assigned: path and name, a file that is not valid UTF-8, unfilled `FILL IN` or `FILL_IN_` template placeholders, frontmatter, `description` presence, length, and trigger or `Not X -> Y` boundary clause, keys Claude drops, the camelCase spelling of `allowed-tools` or `argument-hint` and an `argument-hint` alongside `input:` (both SUGGESTION), `input:` names and the object form `- <name>: "<desc>"` (`primitive-author` prompt Must 3 — a bare name, a string list or a plain map is a FAIL even though apm reads them), and `${input:x}` references against `input:`. Keys Claude drops are a SUGGESTION, per `primitive-author` prompt Should 5: a Copilot-only key is legitimate when its Claude drop is intended, and only the author can say which. It exits **0** with no FAIL, **1** on real findings, **2** when it never ran, including a crash inside the checks — report that as `### Structure` unverified, quoting the stderr reason.
|
||||
|
||||
`vale-wrap.sh` applies the bundled `Kyberforge` style. Every alert is a FAIL under `### Prose`, cited by rule ID; do not re-derive it by judgment. That includes the rules scoped to the `description` (`Kyberforge.DescriptionOpener`, `VagueWording`, `CompositionNote`), a deliberate deviation from `primitive-author`, which holds description wording to at most a Should: the house prose rules apply to every model- or user-visible description, and a deterministic rule does not change tier by file kind. Do not re-tier them. `0 files` scanned means NOT RUN, not clean — say so and judge prose by reading.
|
||||
|
||||
There is no provenance step: a prompt carries no `source_keys`.
|
||||
|
||||
## Step 2 — Read the prompt and what it steers
|
||||
|
||||
Read the file end to end, then the description of every skill or agent its body names, and confirm each resolves in this repo or in a package the prompt's package declares.
|
||||
|
||||
## Step 3 — Qualitative audit
|
||||
|
||||
Cite file and line for every finding.
|
||||
|
||||
**role** — whether this is a prompt at all. Decide it by reading the body, not by its length or headings; there is no threshold.
|
||||
|
||||
- FAIL: the body clearly carries reusable procedure — steps, gotchas, domain know-how the agent could not act without — rather than steering skills or agents that hold it. Fix: move the procedure into a skill (new, or the one it belongs to) and reduce the prompt to the message that invokes it.
|
||||
- FAIL: the body names a skill or agent that does not resolve, or one carrying `disable-model-invocation: true`, which the model cannot invoke.
|
||||
- SUGGESTION: borderline — some how-to detail beyond steering, but not a full procedure.
|
||||
- SUGGESTION: more than one intent in one prompt.
|
||||
- SUGGESTION: the body is not written as second-person instructions to the agent.
|
||||
- SUGGESTION: a `model` value that is not a model slug the package's Claude target accepts. Copilot ignores `model` and `allowed-tools`, so neither constrains a Copilot run.
|
||||
|
||||
**description**
|
||||
|
||||
- SUGGESTION: the description does not read as one user-facing action, carries a `Not X -> Y` boundary clause (`primitive-author` prompt Should 6), or does not name the skills or agents the prompt steers. On Claude the description is model-visible and apm drops `disable-model-invocation`, so naming what it steers keeps the router pointed at the capability rather than the wrapper.
|
||||
|
||||
Then return to `SKILL.md` Step 4, opening the report with this coverage line:
|
||||
|
||||
```text
|
||||
Checked: structure · prose · role · description
|
||||
```
|
||||
@@ -10,6 +10,11 @@ source_keys:
|
||||
- claude-code-subagents-docs
|
||||
- context7-github-en-copilot
|
||||
- github-custom-agents-configuration
|
||||
- apm-cli-installed-source
|
||||
- apm-docs-llms-full
|
||||
- adr-0029-prompt-house-rule
|
||||
- claude-code-hooks-reference
|
||||
- github-copilot-hooks-configuration
|
||||
---
|
||||
|
||||
# Sources
|
||||
@@ -151,3 +156,47 @@ source_keys:
|
||||
- **Description:** SDK custom agent API — CustomAgentConfig fields in all five languages, session config, sub-agent lifecycle events, tool scoping, permission handling
|
||||
- **Contributing files:** (none)
|
||||
- **Status:** `extracted`
|
||||
|
||||
## apm-cli-installed-source
|
||||
|
||||
- **URL:** https://github.com/microsoft/apm/tree/v0.28.0/src/apm_cli/
|
||||
- **Note:** read locally from the pipx install at `~/.local/pipx/venvs/apm-cli/lib/python3.11/site-packages/apm_cli/` (apm-cli 0.28.0, tag `v0.28.0`)
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md
|
||||
- **Description:** Installed apm-cli 0.28.0 source — ground truth for what apm deploys from a hook, instruction or prompt file and what it silently skips, warns on, or fails the install for; every deterministic check in `scripts/lib-checks-primitive.sh` traces to it via the research docs' Authoring checklists
|
||||
- **Contributing files:** SKILL.md, references/hook-flow.md, references/instruction-flow.md, references/prompt-flow.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## apm-docs-llms-full
|
||||
|
||||
- **URL:** https://microsoft.github.io/apm/llms-full.txt
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md
|
||||
- **Description:** Published apm docs bundle — the "Hooks and commands", "Instructions and agents" and "Author a prompt" guides: canonical hook shape and `${PLUGIN_ROOT}`, reach narrowed by `targets:` rather than filename routing, and "reach for a skill, instruction, or prompt first"
|
||||
- **Contributing files:** SKILL.md, references/hook-flow.md, references/instruction-flow.md, references/prompt-flow.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## adr-0029-prompt-house-rule
|
||||
|
||||
- **URL:** docs/adr/0029-prompts-are-thin-user-triggered-steering-messages.md
|
||||
- **Research doc:** none
|
||||
- **Basis:** docs/adr/0029-prompts-are-thin-user-triggered-steering-messages.md
|
||||
- **Description:** The repo's prompt house rule — a prompt is a single-intent, user-triggered steering message with no procedure — and its description contract: one user-facing sentence naming the steered skills, no trigger or boundary clause
|
||||
- **Contributing files:** references/prompt-flow.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## claude-code-hooks-reference
|
||||
|
||||
- **URL:** https://code.claude.com/docs/en/hooks
|
||||
- **Research doc:** none
|
||||
- **Basis:** plugins/kyberforge/.apm/skills/factory-audit/scripts/lib-checks-primitive.sh (KNOWN_EVENTS, transcribed from the URL on 2026-09-28; the vendored corpus lists Claude's hook events only partially)
|
||||
- **Description:** Claude Code's hook reference — the full list of hook event names Claude fires, which `scripts/lib-checks-primitive.sh` carries as `KNOWN_EVENTS['claude']` to FAIL an event Claude never fires after apm's rename
|
||||
- **Contributing files:** references/hook-flow.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## github-copilot-hooks-configuration
|
||||
|
||||
- **URL:** https://docs.github.com/en/copilot/reference/hooks-configuration
|
||||
- **Research doc:** none
|
||||
- **Basis:** plugins/kyberforge/docs/research/docs/github-copilot-plugins/configuration.md (the camelCase list; the PascalCase alternative is from the URL, 2026-09-28)
|
||||
- **Description:** GitHub Copilot's hook configuration reference — the camelCase event names Copilot fires and its PascalCase "VS Code compatible" alternative, carried as `KNOWN_EVENTS['copilot']`
|
||||
- **Contributing files:** references/hook-flow.md
|
||||
- **Status:** `extracted`
|
||||
@@ -114,47 +114,8 @@ def _is_fs_root(path):
|
||||
return os.path.dirname(path) == path
|
||||
|
||||
|
||||
def _virtual_skill_names(pkg_dir):
|
||||
"""Skill names a package's manifest pulls from a SUBDIRECTORY of a git repo.
|
||||
|
||||
An apm dependency written `owner/repo/<path>/<skill>[#ref]` installs one
|
||||
skill out of someone else's repo (plugins/mattpocock does this for Matt
|
||||
Pocock's skills). Nothing of it exists under the monorepo, and the package
|
||||
directory has no apm_modules/ (ADR-0026), so without this the name dangles
|
||||
for every skill that routes to it. The skill's name is the last path
|
||||
segment; apm deploys it under that name. Needs no network and no install,
|
||||
which is what keeps the verdict the same on a fresh clone.
|
||||
|
||||
Only the string form counts. A whole-repo dependency (`host/owner/repo`,
|
||||
e.g. TOD) names no skill, and a dict entry is a package, not a skill: the
|
||||
`path:` branch of _declared_dependency_dirs already resolves those.
|
||||
"""
|
||||
manifest = os.path.join(pkg_dir, 'apm.yml')
|
||||
if not os.path.isfile(manifest):
|
||||
return set()
|
||||
try:
|
||||
data = yaml.safe_load(read_text(manifest)) or {}
|
||||
except Exception:
|
||||
return set()
|
||||
deps = data.get('dependencies') if isinstance(data, dict) else None
|
||||
deps = deps.get('apm') if isinstance(deps, dict) else None
|
||||
if not isinstance(deps, list):
|
||||
return set()
|
||||
found = set()
|
||||
for entry in deps:
|
||||
if not isinstance(entry, str) or ':' in entry or entry.startswith('git@'):
|
||||
continue
|
||||
segments = [seg for seg in re.split(r'[#@]', entry)[0].strip().strip('/').split('/') if seg]
|
||||
if segments and '.' in segments[0]:
|
||||
segments = segments[1:] # a host prefix is not part of owner/repo/path
|
||||
if len(segments) >= 3:
|
||||
found.add(segments[-1].lower())
|
||||
return found
|
||||
|
||||
|
||||
def _collect_package(pkg_dir, names):
|
||||
"""Add every skill/agent name a package directory exposes, any layout."""
|
||||
names.update(_virtual_skill_names(pkg_dir))
|
||||
# glob.escape() the DIRECTORY only. A checkout path containing `[`, `]`,
|
||||
# `*` or `?` — a worktree named `feature[2]`, say — otherwise turns the
|
||||
# whole pattern into a character class that matches nothing, and the
|
||||
@@ -1055,7 +1016,7 @@ FRONTMATTER_RE = re.compile(
|
||||
|
||||
|
||||
def strip_bom(text):
|
||||
return text[1:] if text.startswith(u'') else text
|
||||
return text[1:] if text.startswith(u'\ufeff') else text
|
||||
|
||||
|
||||
class FrontmatterError(Exception):
|
||||
|
||||
+951
@@ -0,0 +1,951 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib-checks-primitive.sh — SOURCED, never executed.
|
||||
#
|
||||
# The structural check suite for the three apm primitives with no
|
||||
# SKILL.md-shaped container, all authored by primitive-author: hooks
|
||||
# (.apm/hooks/*.json), instructions (*.instructions.md) and prompts
|
||||
# (*.prompt.md). validate.sh detects which one it was handed from the path and
|
||||
# feeds $KYBERFORGE_PRIMITIVE_PY to python3 with the target as argv[1] and the
|
||||
# primitive kind (hook | instruction | prompt) as argv[2].
|
||||
#
|
||||
# Every check here exists because apm itself does not make it. apm 0.28.0
|
||||
# silently skips invalid hook JSON, only warns on an instruction with no
|
||||
# description or body, and never validates a prompt's input: names against its
|
||||
# ${input:x} references — so `apm install` and `apm compile --validate` both exit
|
||||
# 0 on files that deploy nothing, or deploy something that never fires. The
|
||||
# checks follow primitive-author's hook, instruction and prompt reference
|
||||
# checklists (research provenance: source key apm-cli-installed-source in
|
||||
# references/sources.md), except where references/{hook,instruction,prompt}-flow.md
|
||||
# documents a deliberate deviation (a tier moved, or a check the author leaves
|
||||
# audit-only). A Must in primitive-author is a FAIL here, a Should a SUGGESTION.
|
||||
#
|
||||
# No boundary resolver and no word budgets: none of these files is routed on a
|
||||
# description the way a skill is. A prompt's description IS model-visible on
|
||||
# Claude, which is why it gets the three ADR-0029 description SUGGESTIONs below
|
||||
# (length, trigger clause, boundary clause) — but whether
|
||||
# a prompt body carries procedure that belongs in a skill is a judgment call the
|
||||
# prompt flow makes by reading it, and deliberately has no heuristic here.
|
||||
#
|
||||
# Output follows lib-checks-agent.sh: FAIL lines on stderr, SUGGESTION and INFO
|
||||
# on stdout, exit 1 on any FAIL, 0 otherwise.
|
||||
#
|
||||
# Consumed by: validate.sh, hook / instruction / prompt modes.
|
||||
# shellcheck shell=bash
|
||||
# shellcheck disable=SC2034
|
||||
|
||||
kyberforge_primitive_preflight() {
|
||||
# Interpreter and library are checked separately so the message names the
|
||||
# thing to install; see lib-checks-agent.sh for the history. PyYAML is needed
|
||||
# for the two markdown kinds, and is required for hooks too so that one
|
||||
# dependency set covers the whole suite rather than a hook audit passing on a
|
||||
# machine where the next instruction audit cannot run.
|
||||
if ! command -v python3 > /dev/null 2>&1; then
|
||||
echo "Error: python3 is required but was not found on PATH." >&2
|
||||
echo " Why: every primitive check parses the file; without python3 no check runs, and reporting that as a pass would be vacuous." >&2
|
||||
echo " Fix: install python3." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if ! python3 -c 'import yaml' > /dev/null 2>&1; then
|
||||
echo "Error: PyYAML is required but is not importable by python3." >&2
|
||||
echo " Why: instruction and prompt frontmatter has to be parsed the way apm parses it; a hand-rolled reader would disagree with it on exactly the edge cases these checks exist for." >&2
|
||||
echo " Fix: python3 -m pip install PyYAML (or your distro's python3-yaml package)." >&2
|
||||
exit 2
|
||||
fi
|
||||
}
|
||||
|
||||
IFS='' read -r -d '' KYBERFORGE_PRIMITIVE_PY <<'KYBERFORGE_PRIMITIVE' || true
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
import shlex
|
||||
|
||||
import yaml
|
||||
|
||||
for _stream in (sys.stdout, sys.stderr):
|
||||
try:
|
||||
_stream.reconfigure(encoding='utf-8')
|
||||
except AttributeError: # pragma: no cover — Python < 3.7
|
||||
pass
|
||||
|
||||
target = os.path.abspath(sys.argv[1])
|
||||
kind = sys.argv[2]
|
||||
fname = os.path.basename(target)
|
||||
parent_dir = os.path.dirname(target)
|
||||
|
||||
failed = False
|
||||
suggestions = []
|
||||
|
||||
|
||||
def fail(msg):
|
||||
global failed
|
||||
failed = True
|
||||
print(f"FAIL {msg}", file=sys.stderr)
|
||||
|
||||
|
||||
def suggest(msg):
|
||||
suggestions.append(msg)
|
||||
|
||||
|
||||
def info(msg):
|
||||
print(f"INFO {msg}")
|
||||
|
||||
|
||||
def read_text(path):
|
||||
try:
|
||||
with open(path, encoding='utf-8') as f:
|
||||
return f.read()
|
||||
except UnicodeDecodeError as exc:
|
||||
fail(f"not valid UTF-8 ({exc.reason} at byte {exc.start}) — apm reads primitives as UTF-8 — {fname}")
|
||||
except OSError as exc:
|
||||
fail(f"cannot be read ({exc.strerror}) — {fname}")
|
||||
return None
|
||||
|
||||
|
||||
def check_not_linked(hardlinks=True):
|
||||
# apm's find_files_by_glob (instructions, prompts) rejects symlinks and
|
||||
# hardlinks (link count > 1); find_hook_files skips symlinks only, so hooks
|
||||
# pass hardlinks=False. A rejected file is silently never deployed.
|
||||
if os.path.islink(target):
|
||||
fail(f"is a symlink — apm's discovery skips symlinks, so it is never deployed — {fname}")
|
||||
return
|
||||
if not hardlinks:
|
||||
return
|
||||
try:
|
||||
if os.stat(target).st_nlink > 1:
|
||||
fail(f"is a hardlink (link count > 1) — apm's discovery rejects hardlinks, so it is never deployed — {fname}")
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def package_root_for(subdir):
|
||||
# <pkg>/.apm/<subdir>/<file> -> <pkg>. Returns None for any other layout.
|
||||
if os.path.basename(parent_dir) != subdir:
|
||||
return None
|
||||
apm_dir = os.path.dirname(parent_dir)
|
||||
if os.path.basename(apm_dir) != '.apm':
|
||||
return None
|
||||
return os.path.dirname(apm_dir)
|
||||
|
||||
|
||||
# The inner group is lazy-optional so an empty block (`---` directly followed
|
||||
# by `---`) matches as empty rather than as no block at all.
|
||||
FRONTMATTER_RE = re.compile(r'\A---[ \t]*\r?\n(?:(.*?)\r?\n)??---[ \t]*(?:\r?\n|\Z)', re.DOTALL)
|
||||
|
||||
|
||||
def split_frontmatter(content):
|
||||
"""Return (frontmatter dict | None, body, ok). ok is False on a parse FAIL."""
|
||||
if content.startswith('\ufeff'):
|
||||
content = content[1:]
|
||||
m = FRONTMATTER_RE.match(content)
|
||||
if not m:
|
||||
fail(f"has no YAML frontmatter block (--- ... ---) — description and every other key live there — {fname}")
|
||||
return None, content, False
|
||||
try:
|
||||
fm = yaml.safe_load(m.group(1) or '')
|
||||
except yaml.YAMLError as exc:
|
||||
mark = getattr(exc, 'problem_mark', None)
|
||||
where = f" at line {mark.line + 2}" if mark is not None else ''
|
||||
fail(f"frontmatter is not valid YAML{where} — apm cannot read any key from it — {fname}")
|
||||
return None, content[m.end():], False
|
||||
if fm is None:
|
||||
fm = {}
|
||||
if not isinstance(fm, dict):
|
||||
fail(f"frontmatter is not a YAML mapping — {fname}")
|
||||
return None, content[m.end():], False
|
||||
return fm, content[m.end():], True
|
||||
|
||||
|
||||
def check_description(fm):
|
||||
desc = fm.get('description')
|
||||
if not isinstance(desc, str) or not desc.strip():
|
||||
fail(f"'description' is missing or empty — apm does not require it, so nothing else will catch this — {fname}")
|
||||
return None
|
||||
return desc.strip()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Hooks
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
ROUTING_TOKENS = ('copilot', 'vscode', 'cursor', 'claude', 'codex', 'gemini',
|
||||
'antigravity', 'windsurf', 'kiro')
|
||||
_TOK = '|'.join(ROUTING_TOKENS)
|
||||
ROUTING_STEM_RE = re.compile(rf'^hooks-(?:{_TOK})$|(?:^|-)(?:{_TOK})-hooks$')
|
||||
|
||||
# apm 0.28.0 _HOOK_EVENT_MAP (apm_cli/integration/hook_integrator.py): the
|
||||
# rename each target applies before deploying. A name absent from a target's
|
||||
# map deploys to it verbatim, with no warning for an all-lowercase name.
|
||||
_STOP_ALIASES = ('Stop', 'AgentStop', 'agentStop')
|
||||
HOOK_EVENT_MAP = {
|
||||
'copilot': {
|
||||
'PreToolUse': 'preToolUse', 'preToolUse': 'preToolUse',
|
||||
'PostToolUse': 'postToolUse', 'postToolUse': 'postToolUse',
|
||||
'UserPromptSubmit': 'userPromptSubmit', 'userPromptSubmit': 'userPromptSubmit',
|
||||
'SessionStart': 'sessionStart', 'sessionStart': 'sessionStart',
|
||||
**dict.fromkeys(_STOP_ALIASES, 'agentStop'),
|
||||
'PreTaskExecution': 'preTaskExecution', 'preTaskExecution': 'preTaskExecution',
|
||||
'PostTaskExecution': 'postTaskExecution', 'postTaskExecution': 'postTaskExecution',
|
||||
},
|
||||
'claude': {
|
||||
'preToolUse': 'PreToolUse', 'postToolUse': 'PostToolUse',
|
||||
'SessionStart': 'SessionStart', 'sessionStart': 'SessionStart',
|
||||
**dict.fromkeys(_STOP_ALIASES, 'Stop'),
|
||||
},
|
||||
'gemini': {
|
||||
'PreToolUse': 'BeforeTool', 'preToolUse': 'BeforeTool',
|
||||
'PostToolUse': 'AfterTool', 'postToolUse': 'AfterTool',
|
||||
'Stop': 'SessionEnd',
|
||||
},
|
||||
'kiro': {
|
||||
'PreToolUse': 'PreToolUse', 'preToolUse': 'PreToolUse',
|
||||
'PostToolUse': 'PostToolUse', 'postToolUse': 'PostToolUse',
|
||||
'UserPromptSubmit': 'UserPromptSubmit', 'userPromptSubmit': 'UserPromptSubmit',
|
||||
'promptSubmit': 'UserPromptSubmit',
|
||||
'Stop': 'Stop', 'stop': 'Stop', 'AgentStop': 'Stop', 'agentStop': 'Stop',
|
||||
'SessionStart': 'SessionStart', 'sessionStart': 'SessionStart',
|
||||
'PreTaskExecution': 'PreTaskExec', 'preTaskExecution': 'PreTaskExec',
|
||||
'PreTaskExec': 'PreTaskExec',
|
||||
'PostTaskExecution': 'PostTaskExec', 'postTaskExecution': 'PostTaskExec',
|
||||
'PostTaskExec': 'PostTaskExec',
|
||||
'PostFileCreate': 'PostFileCreate', 'PostFileSave': 'PostFileSave',
|
||||
'PostFileDelete': 'PostFileDelete',
|
||||
},
|
||||
}
|
||||
|
||||
# apm's target aliases (core/target_catalog.py): vscode and agents are copilot.
|
||||
TARGET_ALIASES = {'vscode': 'copilot', 'agents': 'copilot'}
|
||||
# The targets apm 0.28.0 deploys hooks to (KNOWN_TARGETS with a hooks primitive).
|
||||
HOOK_TARGETS = {'copilot', 'claude', 'cursor', 'kiro', 'gemini', 'antigravity',
|
||||
'codex', 'windsurf'}
|
||||
|
||||
# The events each harness fires, for the harnesses with a published list.
|
||||
# Claude: code.claude.com/docs/en/hooks. Copilot: docs.github.com hooks
|
||||
# configuration reference, which also accepts each event in PascalCase (its
|
||||
# "VS Code compatible" format), plus the camelCase names apm's own Copilot map
|
||||
# emits — a rename the author cannot route around is not a finding here.
|
||||
# No list is published in apm's source or this repo's research for cursor,
|
||||
# kiro, gemini, antigravity, codex or windsurf, so those are judged by
|
||||
# convention only (hook-flow.md). Checked 2026-09.
|
||||
_COPILOT_CAMEL = {'sessionStart', 'sessionEnd', 'userPromptSubmitted', 'preToolUse',
|
||||
'postToolUse', 'postToolUseFailure', 'preCompact', 'agentStop',
|
||||
'subagentStart', 'subagentStop', 'errorOccurred',
|
||||
'permissionRequest', 'notification'}
|
||||
KNOWN_EVENTS = {
|
||||
'claude': {'SessionStart', 'Setup', 'UserPromptSubmit', 'UserPromptExpansion',
|
||||
'PreToolUse', 'PermissionRequest', 'PermissionDenied', 'PostToolUse',
|
||||
'PostToolUseFailure', 'PostToolBatch', 'Notification', 'MessageDisplay',
|
||||
'SubagentStart', 'SubagentStop', 'TaskCreated', 'TaskCompleted', 'Stop',
|
||||
'StopFailure', 'TeammateIdle', 'InstructionsLoaded', 'ConfigChange',
|
||||
'CwdChanged', 'DirectoryAdded', 'FileChanged', 'WorktreeCreate',
|
||||
'WorktreeRemove', 'PreCompact', 'PostCompact', 'PreModelSwitch',
|
||||
'PostModelSwitch', 'Elicitation', 'ElicitationResult', 'SessionEnd'},
|
||||
'copilot': (_COPILOT_CAMEL | {e[0].upper() + e[1:] for e in _COPILOT_CAMEL}
|
||||
| {'Stop', 'UserPromptSubmit'} | set(HOOK_EVENT_MAP['copilot'].values())),
|
||||
}
|
||||
|
||||
HOOK_COMMAND_KEYS = ('command', 'bash', 'powershell', 'windows', 'linux', 'osx')
|
||||
ROOT_TOKENS = ('PLUGIN_ROOT', 'CLAUDE_PLUGIN_ROOT', 'CURSOR_PLUGIN_ROOT', 'KIRO_PLUGIN_ROOT')
|
||||
ROOT_TOKEN_RE = re.compile(r'\$\{(' + '|'.join(ROOT_TOKENS) + r')\}')
|
||||
# apm 0.28.0's own patterns, hook_integrator.py _rewrite_command_for_target:
|
||||
# the path must follow the token directly and ends at whitespace or a quote.
|
||||
# The ./ pattern is applied with finditer over the whole command, so it
|
||||
# matches after an interpreter (`bash ./x.sh`) too.
|
||||
APM_ROOT_REF_RE = re.compile(r'\$\{(?:' + '|'.join(ROOT_TOKENS) + r')\}([\\/][^\s"\']+)')
|
||||
APM_REL_REF_RE = re.compile(r'(\.[\\/][^\s"\']+)')
|
||||
# A plugin-root token apm never rewrites: unbraced, so its pattern cannot see it.
|
||||
UNBRACED_ROOT_RE = re.compile(r'\$(?:CLAUDE_|CURSOR_|KIRO_)?PLUGIN_ROOT\b')
|
||||
# A NAME=value shell assignment before the command, bare or after `env`.
|
||||
ASSIGN_RE = re.compile(r'^[A-Za-z_][A-Za-z0-9_]*=')
|
||||
# env options that consume the next token as their value.
|
||||
ENV_VALUE_OPTS = {'-u', '--unset', '-C', '--chdir'}
|
||||
|
||||
|
||||
# An interpreter whose first operand is the script it runs. A reference in
|
||||
# that operand slot is in command position just as a first token is.
|
||||
INTERPRETERS = {'bash', 'sh', 'zsh', 'python', 'python3', 'node', 'pwsh', 'ruby', 'perl'}
|
||||
SH_FAMILY = {'bash', 'sh', 'zsh'}
|
||||
# Options that consume the next token as their value, per interpreter.
|
||||
VALUE_OPTS = {
|
||||
'bash': {'-o', '+o', '-O', '+O'}, 'sh': {'-o', '+o'}, 'zsh': {'-o', '+o'},
|
||||
'python': {'-W', '-X'}, 'python3': {'-W', '-X'},
|
||||
'node': {'-r', '--require', '--import'}, 'ruby': {'-I', '-r'}, 'perl': {'-I', '-M'},
|
||||
}
|
||||
# Options after which the rest is inline code or a module, never a script path.
|
||||
CODE_OPTS = {
|
||||
'python': {'-c', '-m'}, 'python3': {'-c', '-m'},
|
||||
'node': {'-e', '-p', '--eval', '--print'}, 'ruby': {'-e'}, 'perl': {'-e', '-E'},
|
||||
'pwsh': {'-c', '-command', '-encodedcommand'},
|
||||
}
|
||||
|
||||
|
||||
def _prefix_tokens(prefix):
|
||||
return [t.strip('"\'') for t in prefix.split()]
|
||||
|
||||
|
||||
def _command_start(tokens):
|
||||
"""Index of the token that actually runs: past leading NAME=value
|
||||
assignments and an `env` with its options and assignments."""
|
||||
i = 0
|
||||
while i < len(tokens) and ASSIGN_RE.match(tokens[i]):
|
||||
i += 1
|
||||
if i < len(tokens) and os.path.basename(tokens[i]) == 'env':
|
||||
i += 1
|
||||
while i < len(tokens):
|
||||
tok = tokens[i]
|
||||
if tok in ENV_VALUE_OPTS:
|
||||
i += 2
|
||||
elif tok.startswith('-') or ASSIGN_RE.match(tok):
|
||||
i += 1
|
||||
else:
|
||||
break
|
||||
return i
|
||||
|
||||
|
||||
def _interp_arg_index(tokens):
|
||||
"""(index, is_command_string) of the script operand after a known
|
||||
interpreter (optionally behind assignments or `env`), or None when the command does not
|
||||
open with one. Option flags are skipped (`bash -e x.sh`, `python3 -u x.py`);
|
||||
for a sh-family `-c` the operand is the command string, whose own first
|
||||
token is the script (`sh -c 'scripts/x.sh'`). Inline code (`python3 -c`,
|
||||
`node -e`) has no script operand."""
|
||||
i = _command_start(tokens)
|
||||
if not (len(tokens) > i and os.path.basename(tokens[i]) in INTERPRETERS):
|
||||
return None
|
||||
interp = os.path.basename(tokens[i])
|
||||
j = i + 1
|
||||
while j < len(tokens):
|
||||
tok = tokens[j]
|
||||
low = tok.lower()
|
||||
if tok == '--':
|
||||
return j + 1, False
|
||||
if not tok.startswith(('-', '+')) or tok in ('-', '+'):
|
||||
return j, False
|
||||
if interp in SH_FAMILY and not tok.startswith('--') and 'c' in tok[1:]:
|
||||
return j + 1, True
|
||||
if interp == 'pwsh' and low in ('-file', '-f'):
|
||||
return j + 1, False
|
||||
if low in CODE_OPTS.get(interp, ()):
|
||||
return None
|
||||
j += 2 if tok in VALUE_OPTS.get(interp, ()) else 1
|
||||
return j, False
|
||||
|
||||
|
||||
def _position(prefix):
|
||||
"""(is_direct, is_interpreter_arg) for a reference preceded by prefix.
|
||||
Direct means the reference is what runs: the command's first token, or the
|
||||
first token of a sh-family `-c` command string (`bash -c "./x.sh"`)."""
|
||||
toks = [t for t in _prefix_tokens(prefix) if t]
|
||||
while True:
|
||||
if _command_start(toks) == len(toks):
|
||||
return True, False
|
||||
slot = _interp_arg_index(toks)
|
||||
if slot is None:
|
||||
return False, False
|
||||
idx, is_command_string = slot
|
||||
if is_command_string and idx <= len(toks):
|
||||
toks = toks[idx:]
|
||||
continue
|
||||
return False, idx == len(toks)
|
||||
|
||||
|
||||
def is_handler(h):
|
||||
# A handler runs something: a command key, or a non-command handler type
|
||||
# (Claude's prompt/agent/http hooks) whose payload is not a script.
|
||||
if not isinstance(h, dict):
|
||||
return False
|
||||
if any(isinstance(h.get(k), str) and h.get(k).strip() for k in HOOK_COMMAND_KEYS):
|
||||
return True
|
||||
return h.get('type') not in (None, 'command')
|
||||
|
||||
|
||||
def extract_script_refs(cmd, pkg_root, where):
|
||||
"""Return (kind, relpath, is_direct, is_interpreter_arg) for each
|
||||
package-relative reference apm would rewrite, reading the command exactly
|
||||
as apm does. kind is 'root' for a ${*_PLUGIN_ROOT} token, 'rel' for a
|
||||
./path, 'up' for a ../path. A token apm reads wrongly — split-quoted, or a
|
||||
path with a space — is a FAIL here, because apm leaves it unrewritten or
|
||||
cuts it short."""
|
||||
refs = []
|
||||
masked = cmd
|
||||
for m in ROOT_TOKEN_RE.finditer(cmd):
|
||||
start, end = m.start(), m.end()
|
||||
if end < len(cmd) and cmd[end] in '"\'' and cmd[end + 1:end + 2] in ('/', '\\'):
|
||||
fail(f"script path '{cmd[start:]}' splits the quote after ${{{m.group(1)}}} — apm rewrites only a path that follows the token directly, so this one deploys unrewritten and unbundled; quote the whole token: \"${{PLUGIN_ROOT}}/<path>\" — {where}")
|
||||
elif cmd[end:end + 1] not in ('/', '\\'):
|
||||
fail(f"${{{m.group(1)}}} is not followed directly by / or \\ — apm rewrites the token only as the head of a path (${{PLUGIN_ROOT}}/<path>), so here it deploys unrewritten and expands to nothing on most targets — {where}")
|
||||
for m in UNBRACED_ROOT_RE.finditer(cmd):
|
||||
fail(f"unbraced {m.group(0)} — apm rewrites only the braced ${{PLUGIN_ROOT}}/<path> form, so this deploys unrewritten and the script is not bundled; write ${{{m.group(0)[1:]}}}/<path> — {where}")
|
||||
for m in APM_ROOT_REF_RE.finditer(cmd):
|
||||
start, end = m.start(), m.end()
|
||||
opener = cmd[start - 1] if start > 0 and cmd[start - 1] in '"\'' else None
|
||||
path = m.group(1)
|
||||
nxt = cmd[end:end + 1]
|
||||
# A backslash-escaped space, or a quoted token whose script name only
|
||||
# completes past the whitespace apm stopped at ("…/my hook.sh").
|
||||
# A path apm read that exists as a file is exactly what apm bundles, so
|
||||
# a later argument inside the same quotes (`bash -c "…/tool --x a.sh"`)
|
||||
# is an argument, not the rest of a spaced name.
|
||||
spaced = nxt.isspace() and path.endswith('\\')
|
||||
if not spaced and opener is not None and nxt.isspace():
|
||||
quoted = cmd[start:].split(opener, 1)[0]
|
||||
exists = os.path.isfile(os.path.join(pkg_root, path.replace('\\', '/').lstrip('/')))
|
||||
spaced = (not exists and bool(SCRIPT_EXT_RE.search(quoted))
|
||||
and not SCRIPT_EXT_RE.search(path))
|
||||
if spaced:
|
||||
fail(f"script path '{cmd[start:]}' contains a space — apm reads a ${{PLUGIN_ROOT}} path only up to the first whitespace or quote, so it bundles the wrong file and the hook fails; rename the script without spaces — {where}")
|
||||
else:
|
||||
prefix = cmd[:start - 1] if opener else cmd[:start]
|
||||
refs.append(('root', path.replace('\\', '/').lstrip('/')) + _position(prefix))
|
||||
masked = masked[:start] + ' ' * (end - start) + masked[end:]
|
||||
for m in APM_REL_REF_RE.finditer(masked):
|
||||
start = m.start()
|
||||
ref = m.group(1)
|
||||
kind_ = 'rel'
|
||||
if start > 0 and masked[start - 1] == '.':
|
||||
kind_, start = 'up', start - 1
|
||||
opener = masked[start - 1] if start > 0 and masked[start - 1] in '"\'' else None
|
||||
prefix = masked[:start - 1] if opener else masked[:start]
|
||||
refs.append((kind_, ref[2:].replace('\\', '/')) + _position(prefix))
|
||||
return refs
|
||||
|
||||
|
||||
SCRIPT_EXT_RE = re.compile(r'\.(?:sh|bash|zsh|py|js|mjs|cjs|ts|ps1|rb|pl)$', re.IGNORECASE)
|
||||
|
||||
|
||||
def command_tokens(cmd):
|
||||
"""The command's leading whitespace-delimited tokens, quotes removed."""
|
||||
try:
|
||||
return shlex.split(cmd)
|
||||
except ValueError:
|
||||
return _prefix_tokens(cmd)
|
||||
|
||||
|
||||
def check_unanchored_script(cmd, pkg_root, where):
|
||||
# apm rewrites and bundles only ${*_PLUGIN_ROOT}/... and ./... references;
|
||||
# a bare command (`npx foo`, `echo hi`) passes through untouched, which is
|
||||
# fine. An absolute script path, or a bare relative path to a file in the
|
||||
# package, also passes through untouched — so the script is not bundled
|
||||
# and the deployed hook points at a path that does not exist on the
|
||||
# consumer's machine. Checked in command position only: the first token,
|
||||
# and the first operand after a known interpreter, past its options
|
||||
# (`bash -e scripts/x.sh`); a sh-family `-c` string is checked as a command
|
||||
# of its own. A later argument is data, not a script apm is asked to run.
|
||||
toks = command_tokens(cmd)
|
||||
if not toks:
|
||||
return
|
||||
start = _command_start(toks)
|
||||
if start >= len(toks):
|
||||
return
|
||||
slots = [start]
|
||||
arg = _interp_arg_index(toks)
|
||||
if arg is not None and arg[0] < len(toks):
|
||||
if arg[1]:
|
||||
check_unanchored_script(toks[arg[0]], pkg_root, where)
|
||||
else:
|
||||
slots.append(arg[0])
|
||||
for idx in slots:
|
||||
tok = toks[idx]
|
||||
if not tok or tok.startswith(('./', '../', '~', '-')) or '$' in tok:
|
||||
continue
|
||||
if tok.startswith('/'):
|
||||
real_root = os.path.realpath(pkg_root)
|
||||
inside = os.path.realpath(tok).startswith(real_root + os.sep)
|
||||
# In the first slot an extension-less absolute path outside the
|
||||
# package (`/usr/bin/env`, `/bin/bash`) is the host's interpreter;
|
||||
# in the interpreter-argument slot it is the script being run.
|
||||
if inside or SCRIPT_EXT_RE.search(tok) or idx > start:
|
||||
fail(f"script '{tok}' is an absolute path — apm neither bundles nor rewrites it, so it breaks on every other machine; reference it as ${{PLUGIN_ROOT}}/<path> — {where}")
|
||||
continue
|
||||
if '/' in tok:
|
||||
for base in (parent_dir, pkg_root):
|
||||
if os.path.isfile(os.path.join(base, tok)):
|
||||
fail(f"script '{tok}' is a bare relative path — apm bundles and rewrites only ${{PLUGIN_ROOT}}/... and ./... references, so this one deploys unbundled; prefix it with ${{PLUGIN_ROOT}}/ or ./ — {where}")
|
||||
break
|
||||
|
||||
|
||||
def check_script(kind_, rel, direct, interp_arg, pkg_root, where):
|
||||
if not rel:
|
||||
return
|
||||
# apm's ./ pattern also matches plain arguments — a cwd directory
|
||||
# (`npx prettier --check ./src`), a printf escape (`'.\\n'`), a sibling path.
|
||||
# apm only warns on those and they run against the consumer's cwd as
|
||||
# meant, so a ./ or ../ match is held to the script rules only in command
|
||||
# position or when it names a script by extension (or a package entry that
|
||||
# is not a file).
|
||||
strong = kind_ == 'root' or direct or interp_arg or bool(SCRIPT_EXT_RE.search(rel))
|
||||
if kind_ == 'up':
|
||||
in_pkg = os.path.exists(os.path.join(pkg_root, rel)) and not os.path.isfile(os.path.join(pkg_root, rel))
|
||||
if strong or in_pkg:
|
||||
fail(f"script path '../{rel}' starts with ../ — apm reads it as ./{rel} from the hook directory, not the parent, so the wrong file (or none) is bundled; reference it as ${{PLUGIN_ROOT}}/<path> — {where}")
|
||||
else:
|
||||
suggest(f"argument '../{rel}' matches apm's ./ script pattern — apm will warn 'Hook script not found' and leave it unrewritten; harmless if it is a path in the consumer's working directory — {where}")
|
||||
return
|
||||
if '$' in rel or '`' in rel:
|
||||
fail(f"script path '{rel}' contains '$' or a backtick — apm refuses to rewrite it for Claude — {where}")
|
||||
return
|
||||
candidates = []
|
||||
if kind_ == 'root':
|
||||
candidates.append(os.path.join(pkg_root, rel))
|
||||
else:
|
||||
candidates.append(os.path.join(parent_dir, rel))
|
||||
candidates.append(os.path.join(pkg_root, rel))
|
||||
real_root = os.path.realpath(pkg_root)
|
||||
found = None
|
||||
for c in candidates:
|
||||
real = os.path.realpath(c)
|
||||
if real != real_root and not real.startswith(real_root + os.sep):
|
||||
fail(f"script '{rel}' resolves outside the package — apm confines hook scripts to the package root — {where}")
|
||||
return
|
||||
if os.path.isfile(c):
|
||||
found = c
|
||||
break
|
||||
if found is None:
|
||||
not_a_file = any(os.path.exists(c) for c in candidates)
|
||||
if strong or not_a_file:
|
||||
what = "exists in the package but is not a regular file" if not_a_file else "does not exist in the package"
|
||||
fail(f"script '{rel}' {what} — apm only warns, then deploys a hook that fails every time it fires — {where}")
|
||||
else:
|
||||
suggest(f"argument './{rel}' matches apm's ./ script pattern but names no package file — apm will warn 'Hook script not found' and leave it unrewritten; harmless if it is a path in the consumer's working directory — {where}")
|
||||
return
|
||||
if direct and not os.access(found, os.X_OK):
|
||||
fail(f"script '{rel}' is run directly but is not executable — chmod +x it, or invoke it through an interpreter — {where}")
|
||||
|
||||
|
||||
# apm's package manifests (apm.yml, and utils/helpers.py find_plugin_json): a
|
||||
# directory holding any of these is a package root, and its hooks/*.json is
|
||||
# hook source. A Claude plugin needs no apm.yml.
|
||||
PACKAGE_MANIFESTS = ('apm.yml', 'plugin.json', os.path.join('.github', 'plugin', 'plugin.json'),
|
||||
os.path.join('.claude-plugin', 'plugin.json'),
|
||||
os.path.join('.cursor-plugin', 'plugin.json'))
|
||||
|
||||
|
||||
def is_package_root(d):
|
||||
return any(os.path.isfile(os.path.join(d, m)) for m in PACKAGE_MANIFESTS)
|
||||
|
||||
|
||||
def package_targets(pkg_root):
|
||||
"""The hook targets apm renders this package to, aliases folded. No
|
||||
target:/targets: (or no apm.yml, as in a plain Claude plugin) means every
|
||||
target, and 'all' folds to every target. An unreadable apm.yml is treated
|
||||
as every target, the reading that keeps the stricter checks on."""
|
||||
every = set(HOOK_TARGETS)
|
||||
path = os.path.join(pkg_root, 'apm.yml')
|
||||
if not os.path.isfile(path):
|
||||
return every
|
||||
try:
|
||||
with open(path, encoding='utf-8') as f:
|
||||
data = yaml.safe_load(f)
|
||||
except (OSError, UnicodeDecodeError, yaml.YAMLError):
|
||||
return every
|
||||
if not isinstance(data, dict):
|
||||
return every
|
||||
raw = data.get('targets', data.get('target'))
|
||||
if raw is None:
|
||||
return every
|
||||
if isinstance(raw, list):
|
||||
tokens = [str(t).strip().lower() for t in raw]
|
||||
else:
|
||||
tokens = [t.strip().lower() for t in str(raw).split(',')]
|
||||
tokens = {TARGET_ALIASES.get(t, t) for t in tokens if t}
|
||||
if not tokens or 'all' in tokens:
|
||||
return every
|
||||
known = tokens & HOOK_TARGETS
|
||||
if not known:
|
||||
info(f"targets: in apm.yml names no hook target apm 0.28.0 recognises ({', '.join(sorted(tokens))}) — event names were checked against no harness; apm's hook targets are {', '.join(sorted(HOOK_TARGETS))} — {fname}")
|
||||
return known
|
||||
|
||||
|
||||
def check_event(event, deploys_to):
|
||||
"""hook.md Must 4: the event fires on every target the package deploys
|
||||
to, after apm's rename for that target. A target with a published event
|
||||
list (KNOWN_EVENTS) that does not fire the rendered name is a FAIL. A
|
||||
target without one is judged by apm's own expectation (PascalCase), and at
|
||||
most a SUGGESTION: a harness's native spelling (Cursor's `stop`, Windsurf's
|
||||
snake_case) may be exactly right there."""
|
||||
broken, unverified = [], []
|
||||
for t in sorted(deploys_to):
|
||||
name = HOOK_EVENT_MAP.get(t, {}).get(event, event)
|
||||
if t in KNOWN_EVENTS:
|
||||
if name not in KNOWN_EVENTS[t]:
|
||||
broken.append(f"{t} (as '{name}')" if name != event else t)
|
||||
elif not name[:1].isupper():
|
||||
unverified.append(t)
|
||||
if broken:
|
||||
fail(f"event '{event}' never fires on {', '.join(broken)} — after apm's rename it is not an event that harness fires, and apm never warns; write the harness's PascalCase name (PreToolUse, UserPromptSubmit, Stop, …), or narrow targets: in apm.yml to the harnesses that fire it — {fname}")
|
||||
elif unverified:
|
||||
suggest(f"event '{event}' reaches {', '.join(unverified)} verbatim and is not PascalCase — this audit has no published event list for that harness; confirm it is the harness's own spelling — {fname}")
|
||||
|
||||
|
||||
# The directories apm deploys hooks into for each harness. A hook file under
|
||||
# one of them is install output, not package source.
|
||||
DEPLOY_ROOTS = ('.github', '.claude', '.cursor', '.codex', '.kiro', '.windsurf',
|
||||
'.gemini', '.vscode', '.antigravity', '.copilot')
|
||||
PLACEHOLDER_RE = re.compile(r'FILL IN|FILL_IN_')
|
||||
|
||||
|
||||
def check_placeholders(content):
|
||||
m = PLACEHOLDER_RE.search(content)
|
||||
if m:
|
||||
line = content.count('\n', 0, m.start()) + 1
|
||||
fail(f"unfilled template placeholder '{m.group(0)}' at line {line} — primitive-author Step 3 fills every FILL IN and FILL_IN_ placeholder before the file ships — {fname}")
|
||||
|
||||
|
||||
def audit_hook():
|
||||
check_not_linked(hardlinks=False)
|
||||
stem = fname[:-len('.json')]
|
||||
# validate.sh dispatches only a .json directly under a hooks/ directory.
|
||||
# apm discovers package source at .apm/hooks/*.json and at a package-root
|
||||
# hooks/*.json; anything else under a hooks/ directory is apm's deployed
|
||||
# output (.github/hooks/, .cursor/hooks/, ...) or not a package at all.
|
||||
above = os.path.dirname(parent_dir)
|
||||
if os.path.basename(above) == '.apm':
|
||||
pkg_root = os.path.dirname(above)
|
||||
if not os.path.isfile(os.path.join(pkg_root, 'apm.yml')):
|
||||
info(f"no apm.yml at the inferred package root {pkg_root} — script paths are resolved against it anyway — {fname}")
|
||||
elif os.path.basename(above) not in DEPLOY_ROOTS and is_package_root(above):
|
||||
pkg_root = above
|
||||
else:
|
||||
kind_of = (f"apm's deployed output ({os.path.basename(above)}/hooks/)"
|
||||
if os.path.basename(above) in DEPLOY_ROOTS else 'no package source')
|
||||
fail(f"is {kind_of} — apm reads hook source only from <package>/.apm/hooks/*.json or a package-root hooks/*.json beside apm.yml or a plugin.json manifest; audit the source file in the package's .apm/hooks/ instead — {fname}")
|
||||
return
|
||||
|
||||
# apm lowercases the stem before routing (hook_file_routing.py).
|
||||
if ROUTING_STEM_RE.search(stem.lower()):
|
||||
suggest(f"filename stem '{stem}' uses deprecated hook filename routing — name it plainly and narrow reach with target:/targets: in the package's apm.yml — {fname}")
|
||||
|
||||
content = read_text(target)
|
||||
if content is None:
|
||||
return
|
||||
check_placeholders(content)
|
||||
try:
|
||||
doc = json.loads(content)
|
||||
except json.JSONDecodeError as exc:
|
||||
fail(f"is not valid JSON (line {exc.lineno}, column {exc.colno}) — apm skips an unparseable hook file silently — {fname}")
|
||||
return
|
||||
if not isinstance(doc, dict):
|
||||
fail(f"top level is not a JSON object — {fname}")
|
||||
return
|
||||
|
||||
if 'hooks' in doc:
|
||||
events = doc['hooks']
|
||||
if not isinstance(events, dict):
|
||||
fail(f"'hooks' is not an object — apm skips the file, and the Copilot install fails outright — {fname}")
|
||||
return
|
||||
else:
|
||||
stray = [k for k, v in doc.items() if not isinstance(v, list)]
|
||||
if stray:
|
||||
fail(f"naked settings-slice shape with non-list top-level key(s) {', '.join(sorted(stray))} — apm does not promote it, Claude gets nothing and Copilot gets a junk file; wrap events in {{\"hooks\": {{...}}}} — {fname}")
|
||||
return
|
||||
events = doc
|
||||
|
||||
if not events:
|
||||
fail(f"contributes no hook entries — apm warns and deploys nothing — {fname}")
|
||||
return
|
||||
|
||||
shape_ok = True
|
||||
for event, entries in events.items():
|
||||
if not isinstance(entries, list):
|
||||
fail(f"event '{event}' is not a list — the Copilot install fails on this payload — {fname}")
|
||||
shape_ok = False
|
||||
continue
|
||||
for i, entry in enumerate(entries):
|
||||
if not isinstance(entry, dict):
|
||||
fail(f"event '{event}' entry {i} is not an object — the Copilot install fails on this payload — {fname}")
|
||||
shape_ok = False
|
||||
continue
|
||||
if 'hooks' in entry:
|
||||
nested = entry['hooks']
|
||||
if not isinstance(nested, list) or not all(isinstance(h, dict) for h in nested):
|
||||
fail(f"event '{event}' entry {i}: nested 'hooks' is not a list of objects — the Copilot install fails on this payload — {fname}")
|
||||
shape_ok = False
|
||||
|
||||
if shape_ok:
|
||||
# hook.md Must 3: the file contributes at least one entry. An empty
|
||||
# event list, or an entry with no handler, deploys nothing runnable.
|
||||
total = 0
|
||||
for event, entries in events.items():
|
||||
for i, entry in enumerate(entries):
|
||||
total += 1
|
||||
handlers = entry['hooks'] if 'hooks' in entry else [entry]
|
||||
if not any(is_handler(h) for h in handlers):
|
||||
fail(f"event '{event}' entry {i} has no handler — no command (or other handler type) to run, so it deploys nothing — {fname}")
|
||||
if total == 0:
|
||||
fail(f"contributes no hook entries — every event list is empty, so apm deploys nothing — {fname}")
|
||||
|
||||
deploys_to = package_targets(pkg_root)
|
||||
for event in events:
|
||||
if not event.strip():
|
||||
fail(f"empty event name — {fname}")
|
||||
else:
|
||||
check_event(event, deploys_to)
|
||||
|
||||
if not shape_ok:
|
||||
return
|
||||
|
||||
uses_claude_token = False
|
||||
for event, entries in events.items():
|
||||
for i, entry in enumerate(entries):
|
||||
handlers = entry['hooks'] if 'hooks' in entry else [entry]
|
||||
for j, handler in enumerate(handlers):
|
||||
where = f"{fname} {event}[{i}]" + (f".hooks[{j}]" if 'hooks' in entry else '')
|
||||
for key in HOOK_COMMAND_KEYS:
|
||||
cmd = handler.get(key)
|
||||
if not isinstance(cmd, str):
|
||||
continue
|
||||
if '${CLAUDE_PLUGIN_ROOT}' in cmd:
|
||||
uses_claude_token = True
|
||||
for kind_, rel, direct, interp_arg in extract_script_refs(cmd, pkg_root, where):
|
||||
check_script(kind_, rel, direct, interp_arg, pkg_root, where)
|
||||
check_unanchored_script(cmd, pkg_root, where)
|
||||
|
||||
if uses_claude_token:
|
||||
suggest(f"uses ${{CLAUDE_PLUGIN_ROOT}} — apm documents the target-neutral ${{PLUGIN_ROOT}}, which it rewrites identically for every target — {fname}")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Instructions
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
INSTRUCTION_KEYS = {'description', 'applyTo', 'author', 'version'}
|
||||
|
||||
|
||||
def split_top_level(value):
|
||||
# apm's parse_apply_to: split on commas outside {} (and not escaped \,),
|
||||
# strip each segment, drop empty ones.
|
||||
segs, cur, depth, i = [], '', 0, 0
|
||||
while i < len(value):
|
||||
c = value[i]
|
||||
if c == '\\' and i + 1 < len(value):
|
||||
cur += value[i:i + 2]
|
||||
i += 2
|
||||
continue
|
||||
if c == '{':
|
||||
depth += 1
|
||||
elif c == '}':
|
||||
depth -= 1
|
||||
if c == ',' and depth == 0:
|
||||
segs.append(cur)
|
||||
cur = ''
|
||||
else:
|
||||
cur += c
|
||||
i += 1
|
||||
segs.append(cur)
|
||||
return [s.strip() for s in segs if s.strip()]
|
||||
|
||||
|
||||
def _balanced(glob):
|
||||
# A depth walk per bracket kind: a closer before its opener (`}{`) is as
|
||||
# unbalanced as a missing one, which equal counts would not catch.
|
||||
for opener, closer in ('{}', '[]'):
|
||||
depth, i = 0, 0
|
||||
while i < len(glob):
|
||||
c = glob[i]
|
||||
if c == '\\':
|
||||
i += 2
|
||||
continue
|
||||
if c == opener:
|
||||
depth += 1
|
||||
elif c == closer:
|
||||
depth -= 1
|
||||
if depth < 0:
|
||||
return False
|
||||
i += 1
|
||||
if depth:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def check_apply_to(apply_to):
|
||||
if isinstance(apply_to, list):
|
||||
entries = [e for e in apply_to if e is not None and str(e).strip()]
|
||||
globs = [str(e).strip() for e in entries]
|
||||
elif isinstance(apply_to, str):
|
||||
globs = split_top_level(apply_to)
|
||||
else:
|
||||
fail(f"applyTo is neither a string nor a list — apm cannot read a glob from it — {fname}")
|
||||
return False
|
||||
if not globs:
|
||||
fail(f"applyTo is present but empty — remove the key for an intentionally always-on rule, or give it a glob — {fname}")
|
||||
return False
|
||||
ok = True
|
||||
for g in globs:
|
||||
if not _balanced(g):
|
||||
fail(f"applyTo glob '{g}' has unbalanced braces or brackets — it matches nothing, so the rule never fires — {fname}")
|
||||
ok = False
|
||||
return ok
|
||||
|
||||
|
||||
def audit_instruction():
|
||||
check_not_linked()
|
||||
stem = fname[:-len('.instructions.md')]
|
||||
pkg_root = package_root_for('instructions')
|
||||
if pkg_root is None:
|
||||
fail(f"is not directly in a .apm/instructions/ directory — that is the authoring source; anything else is either deployed output or a legacy root file — {fname}")
|
||||
else:
|
||||
dup = os.path.join(pkg_root, fname)
|
||||
if os.path.isfile(dup):
|
||||
fail(f"stem '{stem}' also exists at the package root ({dup}) — both deploy to the same .claude/rules/{stem}.md, and one overwrites the other — {fname}")
|
||||
|
||||
content = read_text(target)
|
||||
if content is None:
|
||||
return
|
||||
check_placeholders(content)
|
||||
fm, body, ok = split_frontmatter(content)
|
||||
if not ok:
|
||||
return
|
||||
check_description(fm)
|
||||
if not body.strip():
|
||||
fail(f"body is empty — apm deploys an empty rule without complaint — {fname}")
|
||||
|
||||
apply_to = fm.get('applyTo')
|
||||
apply_to_ok = apply_to is not None and check_apply_to(apply_to)
|
||||
if apply_to is None:
|
||||
suggest(f"no applyTo — this loads into every session of every repo that installs the package; confirm always-on is intended, and that a rule for this repo alone is not really an AGENTS.md rule — {fname}")
|
||||
elif apply_to_ok and isinstance(apply_to, list):
|
||||
suggest(f"applyTo is a YAML list — Copilot receives the file verbatim and its handling of a list is unverified; use one comma-separated string — {fname}")
|
||||
|
||||
extra = sorted(str(k) for k in fm if k not in INSTRUCTION_KEYS)
|
||||
if extra:
|
||||
suggest(f"frontmatter key(s) {', '.join(extra)} are read by no target and dropped on Claude — keep to description and applyTo (author, version optional) — {fname}")
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Prompts
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
PROMPT_KEYS = {'description', 'allowed-tools', 'model', 'argument-hint', 'input'}
|
||||
PROMPT_CAMEL_ALIASES = {'allowedTools': 'allowed-tools', 'argumentHint': 'argument-hint'}
|
||||
INPUT_NAME_RE = re.compile(r'^[A-Za-z][\w-]{0,63}$')
|
||||
# apm's own rewrite pattern for ${input:x}, command_integrator.py.
|
||||
INPUT_REF_RE = re.compile(r'\$\{\{?\s*input\s*:\s*([\w-]+)\s*\}?\}')
|
||||
TRIGGER_RE = re.compile(r'\buse\s+(?:this\s+)?when\b', re.IGNORECASE)
|
||||
# The skill boundary form `Not <thing> -> <target>` (ASCII or Unicode arrow).
|
||||
BOUNDARY_RE = re.compile(r'\bnot\b[^.;]*?(?:->|\u2192)', re.IGNORECASE)
|
||||
PROMPT_DESC_SUGGEST_CHARS = 250
|
||||
|
||||
|
||||
def prompt_input_names(spec):
|
||||
"""Mirror apm's _extract_input_names, but FAIL on what it rejects or
|
||||
misreads instead of warning. Returns the declared names."""
|
||||
names = []
|
||||
|
||||
def accept(candidate):
|
||||
if not isinstance(candidate, str):
|
||||
fail(f"input entry {candidate!r} is not a string name — apm rejects it — {fname}")
|
||||
return
|
||||
s = candidate.strip()
|
||||
if not s:
|
||||
return
|
||||
if not INPUT_NAME_RE.match(s):
|
||||
fail(f"input name '{s}' does not match ^[A-Za-z][\\w-]{{0,63}}$ — apm rejects it, so the argument never exists — {fname}")
|
||||
return
|
||||
names.append(s)
|
||||
|
||||
form = "write each input as `- <name>: \"<description>\"` (primitive-author prompt Must 3)"
|
||||
if spec is None:
|
||||
return names
|
||||
if isinstance(spec, str):
|
||||
fail(f"input: is a bare name, not the object form — {form}, so every argument carries its description — {fname}")
|
||||
accept(spec)
|
||||
elif isinstance(spec, dict):
|
||||
fail(f"input: is a map, not the object form — {form} — {fname}")
|
||||
for k in spec:
|
||||
accept(k)
|
||||
elif isinstance(spec, list):
|
||||
for item in spec:
|
||||
if not isinstance(item, dict):
|
||||
fail(f"input entry {item!r} is a bare name, not the object form — {form} — {fname}")
|
||||
if isinstance(item, dict):
|
||||
if len(item) > 1:
|
||||
keys = ', '.join(str(k) for k in item)
|
||||
hint = (" — this is the upstream docs example's `- name: x` / `description:` form, which yields arguments [name, description]"
|
||||
if 'name' in item else '')
|
||||
fail(f"input entry {{{keys}}} is one map with several keys — apm reads every key as an argument name{hint}; write `- <name>: \"<desc>\"` — {fname}")
|
||||
for k in item:
|
||||
accept(k)
|
||||
else:
|
||||
accept(item)
|
||||
else:
|
||||
fail(f"input is neither a name, a list nor a map — apm extracts no arguments from it — {fname}")
|
||||
return names
|
||||
|
||||
|
||||
def audit_prompt():
|
||||
check_not_linked()
|
||||
stem = fname[:-len('.prompt.md')]
|
||||
segs = stem.replace('\\', '/').split('/')
|
||||
if not stem.strip() or any(s in ('.', '..', '') for s in segs) or '/' in stem.replace('\\', '/'):
|
||||
fail(f"name '{stem}' is not a safe path segment — apm's validate_path_segments rejects it — {fname}")
|
||||
pkg_root = package_root_for('prompts')
|
||||
if pkg_root is None:
|
||||
fail(f"is not directly in a .apm/prompts/ directory — that is the authoring source; anything else is either deployed output or a legacy root file — {fname}")
|
||||
else:
|
||||
dup = os.path.join(pkg_root, fname)
|
||||
if os.path.isfile(dup):
|
||||
fail(f"name '{stem}' also exists at the package root ({dup}) — both deploy as /{stem}, and they collide — {fname}")
|
||||
|
||||
content = read_text(target)
|
||||
if content is None:
|
||||
return
|
||||
check_placeholders(content)
|
||||
fm, body, ok = split_frontmatter(content)
|
||||
if not ok:
|
||||
return
|
||||
|
||||
desc = check_description(fm)
|
||||
if desc is not None:
|
||||
if len(desc) > PROMPT_DESC_SUGGEST_CHARS:
|
||||
suggest(f"description is {len(desc)} characters (> {PROMPT_DESC_SUGGEST_CHARS}) — it is one user-facing sentence (ADR-0029) — {fname}")
|
||||
if TRIGGER_RE.search(desc):
|
||||
suggest(f"description carries a 'Use when' trigger clause — a prompt is user-triggered (ADR-0029); a trigger clause invites the model to route to it on Claude — {fname}")
|
||||
if BOUNDARY_RE.search(desc):
|
||||
suggest(f"description carries a 'Not X -> Y' boundary clause — a prompt is user-triggered (ADR-0029, primitive-author prompt Should 6); name the skills it steers instead — {fname}")
|
||||
|
||||
for camel, kebab in PROMPT_CAMEL_ALIASES.items():
|
||||
if camel in fm:
|
||||
suggest(f"'{camel}' — use the kebab-case spelling '{kebab}' apm documents — {fname}")
|
||||
extra = sorted(str(k) for k in fm if k not in PROMPT_KEYS and k not in PROMPT_CAMEL_ALIASES)
|
||||
if extra:
|
||||
suggest(f"frontmatter key(s) {', '.join(extra)} are dropped on Claude (it keeps only {', '.join(sorted(PROMPT_KEYS))}) — keep them only if the Copilot-only behaviour is intended — {fname}")
|
||||
|
||||
declared = prompt_input_names(fm.get('input'))
|
||||
used = []
|
||||
for m in INPUT_REF_RE.finditer(body):
|
||||
if m.group(1) not in used:
|
||||
used.append(m.group(1))
|
||||
if used and fm.get('input') is None:
|
||||
fail(f"body uses {', '.join('${input:' + u + '}' for u in used)} but no input: is declared — apm rewrites references only when input: names them, so Claude receives the literal text — {fname}")
|
||||
else:
|
||||
for u in used:
|
||||
if u not in declared:
|
||||
fail(f"body uses ${{input:{u}}} but input: does not declare '{u}' — {fname}")
|
||||
for d in declared:
|
||||
if d not in used:
|
||||
fail(f"input '{d}' is declared but the body never uses ${{input:{d}}} — the user is asked for an argument that goes nowhere — {fname}")
|
||||
|
||||
if declared and ('argument-hint' in fm or 'argumentHint' in fm):
|
||||
suggest(f"argument-hint is set alongside input: — apm synthesises the hint from input: names; drop it unless that form is inadequate — {fname}")
|
||||
|
||||
|
||||
AUDITS = {'hook': lambda: audit_hook(), 'instruction': lambda: audit_instruction(), 'prompt': lambda: audit_prompt()}
|
||||
if kind not in AUDITS:
|
||||
print(f"Error: unknown primitive kind '{kind}'", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
try:
|
||||
AUDITS[kind]()
|
||||
except Exception as exc: # an input shape no check anticipated
|
||||
# Exit 1 means findings; a crash means the checks never completed, which
|
||||
# is the never-ran tier, not a verdict on the file.
|
||||
print(f"Error: the {kind} checks crashed ({type(exc).__name__}: {exc}) and did not complete — {fname}", file=sys.stderr)
|
||||
print(" Why: a partial run reported as findings (exit 1) or as clean (exit 0) would be a verdict the checks never reached.", file=sys.stderr)
|
||||
print(" Fix: report ### Structure as unverified, and file the input shape against factory-audit's lib-checks-primitive.sh.", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
for s in suggestions:
|
||||
print(f"SUGGESTION {s}")
|
||||
sys.exit(1 if failed else 0)
|
||||
KYBERFORGE_PRIMITIVE
|
||||
KYBERFORGE_PRIMITIVE_PY="${KYBERFORGE_PRIMITIVE_PY%$'\n'}"
|
||||
@@ -2,13 +2,16 @@
|
||||
set -euo pipefail
|
||||
|
||||
# The ONE entry point for structural validation. It auto-detects whether the
|
||||
# target is a skill directory or an agent definition file and runs the matching
|
||||
# check suite; the two suites live in lib-checks-skill.sh and lib-checks-agent.sh
|
||||
# and are unchanged from the skill-audit / agent-audit scripts they came from.
|
||||
# target is a skill directory, an agent definition file, or one of the three apm
|
||||
# primitives with no container of their own (a hook, an instruction or a prompt)
|
||||
# and runs the matching check suite. The skill and agent suites live in
|
||||
# lib-checks-skill.sh and lib-checks-agent.sh and are unchanged from the
|
||||
# skill-audit / agent-audit scripts they came from; the primitive suite lives in
|
||||
# lib-checks-primitive.sh.
|
||||
# The ADR-0020 boundary resolver both of them need is sourced once, from
|
||||
# lib-boundary-resolver.sh, instead of being embedded twice.
|
||||
#
|
||||
# Detection never guesses. A target that matches neither shape is a hard exit 2
|
||||
# Detection never guesses. A target that matches no shape is a hard exit 2
|
||||
# naming the mismatch, because the alternative — picking a mode and letting the
|
||||
# suite fail on its own terms — reports a skill-shaped finding about an agent
|
||||
# file, or the reverse, and sends the reader after the wrong problem.
|
||||
@@ -115,17 +118,25 @@ _kf_require_lib() {
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: validate.sh <skill-dir | agent-file>
|
||||
Usage: validate.sh <skill-dir | agent-file | hook-file | instruction-file | prompt-file>
|
||||
|
||||
Validate a skill directory against the agentskills.io specification, or an agent
|
||||
definition file against the agent definition spec. The mode is detected from the
|
||||
target:
|
||||
Validate a skill directory against the agentskills.io specification, an agent
|
||||
definition file against the agent definition spec, or an apm hook, instruction or
|
||||
prompt file against what apm 0.28.0 actually deploys. The mode is detected from
|
||||
the target:
|
||||
|
||||
skill mode the target is a directory (a skill directory contains SKILL.md),
|
||||
or the target IS a SKILL.md file.
|
||||
agent mode the target is a *.agent.md file, or a *.md file whose parent
|
||||
directory is named 'agents' (.apm/agents, .claude/agents,
|
||||
.github/agents, .copilot/agents).
|
||||
hook mode the target is a *.json file directly under a hooks/
|
||||
directory (.apm/hooks, or a hooks/ at a package root: beside
|
||||
apm.yml or a plugin.json manifest; any other hooks/
|
||||
directory is deployed output or no package at all, and
|
||||
FAILs at exit 1).
|
||||
instruction mode the target is a *.instructions.md file.
|
||||
prompt mode the target is a *.prompt.md file.
|
||||
|
||||
Skill mode audits the directory named by <skill-dir>.
|
||||
|
||||
@@ -137,16 +148,21 @@ At project or user scope, <agent-file> is either half of a Claude Code .md /
|
||||
Copilot .agent.md pair.
|
||||
|
||||
Arguments:
|
||||
skill-dir Path to the skill directory containing SKILL.md.
|
||||
agent-file Path to the agent file (or either half of a project/user-scope pair).
|
||||
skill-dir Path to the skill directory containing SKILL.md.
|
||||
agent-file Path to the agent file (or either half of a project/user-scope pair).
|
||||
hook-file Path to a hook JSON file directly under .apm/hooks/ or hooks/.
|
||||
instruction-file Path to a *.instructions.md file.
|
||||
prompt-file Path to a *.prompt.md file.
|
||||
|
||||
Exit codes:
|
||||
0 All checks passed (may include SUGGESTIONs)
|
||||
1 One or more checks failed
|
||||
2 Nothing was audited (no argument, the target matches neither shape, the
|
||||
2 Nothing was audited (no argument, the target matches no shape, the
|
||||
target does not exist, an unrecognized file extension, a missing
|
||||
references/agent-field-inventory.md, or a missing or unreadable lib-*.sh
|
||||
beside this script)
|
||||
references/agent-field-inventory.md, a missing or unreadable lib-*.sh
|
||||
beside this script, or, for a hook, instruction or prompt, a missing
|
||||
python3 or PyYAML, or a crash inside the hook, instruction or prompt
|
||||
checks)
|
||||
EOF
|
||||
}
|
||||
|
||||
@@ -156,7 +172,7 @@ if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
||||
fi
|
||||
|
||||
if [[ $# -lt 1 ]]; then
|
||||
echo "Error: a skill directory or an agent file is required." >&2
|
||||
echo "Error: a skill directory, an agent file, or a hook, instruction or prompt file is required." >&2
|
||||
echo "" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
@@ -184,7 +200,7 @@ TARGET="$1"
|
||||
if [[ ! -e "$TARGET" && ! -L "$TARGET" ]]; then
|
||||
echo "Error: '$TARGET' does not exist." >&2
|
||||
echo " Why: the path shape says what would be audited, but there is nothing at this path to audit — and auditing a target that is not there would report the absence as findings about it, sending the reader after a spec violation instead of a typo." >&2
|
||||
echo " Fix: check the path, and pass an existing skill directory (or its SKILL.md) or an existing agent file." >&2
|
||||
echo " Fix: check the path, and pass an existing skill directory (or its SKILL.md), agent file, hook file (.json under a hooks/ directory), *.instructions.md or *.prompt.md." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
@@ -200,8 +216,8 @@ if [[ -d "$TARGET" ]]; then
|
||||
MODE=skill
|
||||
else
|
||||
echo "Error: '$TARGET' is a directory with no SKILL.md in it." >&2
|
||||
echo " Why: a skill directory is identified by its SKILL.md, and an agent target is a file, never a directory — so this path matches neither mode and guessing one would report findings of the wrong kind." >&2
|
||||
echo " Fix: pass the skill directory that holds SKILL.md, or an agent file (<name>.agent.md, or a .md file under an agents/ directory)." >&2
|
||||
echo " Why: a skill directory is identified by its SKILL.md, and every other target (agent, hook, instruction, prompt) is a file, never a directory — so this path matches no mode and guessing one would report findings of the wrong kind." >&2
|
||||
echo " Fix: pass the skill directory that holds SKILL.md, an agent file (<name>.agent.md, or a .md file under an agents/ directory), a hook file (.json under a hooks/ directory), a *.instructions.md or a *.prompt.md." >&2
|
||||
exit 2
|
||||
fi
|
||||
elif [[ "$TARGET_BASE" == "SKILL.md" ]]; then
|
||||
@@ -209,12 +225,21 @@ elif [[ "$TARGET_BASE" == "SKILL.md" ]]; then
|
||||
TARGET="$(_kf_dirname "$TARGET")"
|
||||
elif [[ "$TARGET_BASE" == *.agent.md ]]; then
|
||||
MODE=agent
|
||||
# The two primitive suffixes are tested before the agents/-parent rule: a
|
||||
# *.prompt.md or *.instructions.md file is that primitive wherever it sits, and
|
||||
# the parent-name rule would otherwise claim one that happened to sit in agents/.
|
||||
elif [[ "$TARGET_BASE" == *.instructions.md ]]; then
|
||||
MODE=instruction
|
||||
elif [[ "$TARGET_BASE" == *.prompt.md ]]; then
|
||||
MODE=prompt
|
||||
elif [[ "$TARGET_BASE" == *.json && "$TARGET_PARENT" == "hooks" && ! -d "$TARGET" ]]; then
|
||||
MODE=hook
|
||||
elif [[ "$TARGET_BASE" == *.md && "$TARGET_PARENT" == "agents" ]]; then
|
||||
MODE=agent
|
||||
else
|
||||
echo "Error: '$TARGET' matches neither a skill directory nor an agent file." >&2
|
||||
echo " Why: skill mode needs a directory containing SKILL.md (or the SKILL.md itself); agent mode needs a <name>.agent.md file, or a .md file directly under an agents/ directory (.apm/agents, .claude/agents, .github/agents, .copilot/agents). Picking a mode anyway would audit this path against the wrong spec." >&2
|
||||
echo " Fix: pass one of those two shapes." >&2
|
||||
echo "Error: '$TARGET' matches no auditable shape." >&2
|
||||
echo " Why: skill mode needs a directory containing SKILL.md (or the SKILL.md itself); agent mode needs a <name>.agent.md file, or a .md file directly under an agents/ directory (.apm/agents, .claude/agents, .github/agents, .copilot/agents); hook mode needs a .json file directly under a hooks/ directory; instruction and prompt modes need a *.instructions.md or *.prompt.md file. Picking a mode anyway would audit this path against the wrong spec." >&2
|
||||
echo " Fix: pass one of those shapes." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
@@ -250,6 +275,13 @@ $KYBERFORGE_RESOLVER_PY
|
||||
$KYBERFORGE_AGENT_BODY_PY"
|
||||
python3 -u - "$TARGET" "$SCRIPT_DIR" <<< "$PROG" || RC=$?
|
||||
;;
|
||||
hook | instruction | prompt)
|
||||
_kf_require_lib lib-checks-primitive.sh
|
||||
# shellcheck source=lib-checks-primitive.sh
|
||||
. "$SCRIPT_DIR/lib-checks-primitive.sh"
|
||||
kyberforge_primitive_preflight
|
||||
python3 -u - "$TARGET" "$MODE" <<< "$KYBERFORGE_PRIMITIVE_PY" || RC=$?
|
||||
;;
|
||||
esac
|
||||
|
||||
exit "$RC"
|
||||
@@ -36,13 +36,16 @@ bats plugins/kyberforge/.apm/skills/factory-audit/tests/
|
||||
| `validate-agent.bats` | `scripts/validate.sh` against agent files |
|
||||
| `validate-provenance-skill.bats` | `scripts/validate-provenance.sh` against skill directories |
|
||||
| `validate-provenance-agent.bats` | `scripts/validate-provenance.sh` against agent files |
|
||||
| `validate-primitive.bats` | `scripts/validate.sh` against apm hook, instruction and prompt files |
|
||||
|
||||
## Two scripts, four suites
|
||||
## Two scripts, five suites
|
||||
|
||||
`factory-audit` merges what were two skills — `skill-audit` and `agent-audit` —
|
||||
each of which shipped its own `validate.sh` and `validate-provenance.sh`. The
|
||||
merged skill has **one** of each. Every suite here invokes one of those two
|
||||
scripts; the four files are two scripts × two artifact types, not four scripts.
|
||||
scripts; the four skill and agent files are two scripts × two artifact types, not four scripts.
|
||||
`validate-primitive.bats` is a fifth suite over the same `scripts/validate.sh`, for hooks,
|
||||
instructions and prompts, which have no provenance mode and so no provenance suite.
|
||||
|
||||
`validate-skill.bats` and `validate-agent.bats` run the same
|
||||
`scripts/validate.sh` and differ only in the fixtures they point it at. The two
|
||||
@@ -50,22 +53,30 @@ provenance suites stand in the same relation to `scripts/validate-provenance.sh`
|
||||
Do not add a third script path here on the assumption that a differently named
|
||||
suite must mean a differently named script.
|
||||
|
||||
### Auto-detection is pinned across the pair
|
||||
### Auto-detection is pinned across the suites
|
||||
|
||||
Each entry point decides for itself what it was handed. ADR-0025 states the
|
||||
rule: a directory containing `SKILL.md` takes the skill flow; an `.agent.md`
|
||||
file, or a file under a directory named `agents/`, takes the agent flow.
|
||||
Anything else is rejected rather than guessed at. That behaviour is new with the
|
||||
merge — before it, each script was hard-wired to one artifact type and nothing
|
||||
about classification could be wrong — so it is asserted from both sides rather
|
||||
than in one place:
|
||||
skill and agent rule: a directory containing `SKILL.md` takes the skill flow; an
|
||||
`.agent.md` file, or a file under a directory named `agents/`, takes the agent
|
||||
flow. `scripts/validate.sh` adds the hook, instruction and prompt shapes: a `*.instructions.md`
|
||||
or `*.prompt.md` file takes the instruction or prompt flow wherever it sits, and
|
||||
a `.json` file directly under a `hooks/` directory takes the hook flow. Any
|
||||
shape outside the five is rejected rather than guessed at. Classification could
|
||||
not be wrong before the merge — each script was hard-wired to one artifact type
|
||||
— so it is asserted from every side rather than in one place:
|
||||
|
||||
- the skill-side suites pin the skill-directory classification and the
|
||||
neither-shape rejection,
|
||||
no-shape rejection,
|
||||
- the agent-side suites pin the two agent rules *separately* — `.agent.md` in a
|
||||
directory that is not `agents/`, and a plain `.md` under `.apm/agents/` — so
|
||||
that a detector implementing only one of them cannot pass both. Plus a control
|
||||
asserting an agent file never picks up a skill-only gate.
|
||||
- `validate-primitive.bats` pins the hook, instruction and prompt shapes,
|
||||
including the precedence that makes a `*.instructions.md` or `*.prompt.md`
|
||||
under `agents/` take the instruction or prompt flow rather than the agent flow, a hook
|
||||
file under a package-root `hooks/`, and a `.json` outside `hooks/` matching
|
||||
no shape. It also pins their exit tiers: every negative case asserts
|
||||
exit 1 (`assert_failure 1`), and a missing python3 or PyYAML, or a crash inside the checks, asserts exit 2.
|
||||
|
||||
Both skill-side suites additionally pin the `SKILL.md` **file** path, not just
|
||||
the directory: a pre-commit `files:` hook matches files, so every hook-driven
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,29 +1,30 @@
|
||||
---
|
||||
name: forge
|
||||
description: >
|
||||
Use when the user wants to build or improve something without naming the
|
||||
artifact type ("not sure if this should be a skill or a plugin"). Not a named
|
||||
skill -> `skill-author`. Not a named agent -> `agent-author`. Not a named
|
||||
plugin -> `apm-workflow`.
|
||||
Use when the user wants to build or improve something of unnamed type ("where
|
||||
does this idea go?"). If named, use instead: skill -> `skill-author`, agent ->
|
||||
`agent-author`, apm hook/instruction/prompt -> `primitive-author`, plugin ->
|
||||
`apm-workflow`.
|
||||
metadata:
|
||||
version: "1.0.5"
|
||||
version: "1.0.2"
|
||||
category: factory
|
||||
source_keys:
|
||||
- claude-code-subagents-docs
|
||||
- context7-websites-code-claude
|
||||
- agentskills-spec
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- forge is an optional guided entry point, not a gate — `skill-author`, `agent-author`, `instructions-author`, `prompt-author`, `factory-audit` and `apm-workflow` all stay directly invokable, and forge never intercepts a direct call to one.
|
||||
- Claude Code's skill-level `context: fork` frontmatter field and the `/fork` subagent command are opposites despite the shared word: `context: fork` isolates (fresh context, no parent access), while `/fork` inherits the full conversation. The route reference each classification loads spends that distinction: `references/author-routes.md` chooses between a `/fork` subagent and an inline run, and `references/apm-routes.md` rules the fork out.
|
||||
|
||||
## Step 1 — Grill the intent
|
||||
|
||||
Call `grill-with-docs` unless a grill session has already run and is available in the context.
|
||||
|
||||
`grill-with-docs` ships in a sibling plugin kyberforge does not declare as an apm dependency, so it can be absent where kyberforge is installed alone. If it does not resolve, grill inline yourself rather than skipping the step: what problem the artifact solves, who invokes it and how, what it must refuse, and which existing skill or plugin already owns part of the job. Say which path you took.
|
||||
If `grill-with-docs` does not resolve, read `references/grill-fallback.md`.
|
||||
|
||||
Grilling often overturns the assumed artifact type or splits one idea into several, so it runs before classification. Run it inline: a subagent cannot hold the back-and-forth.
|
||||
Grilling often overturns or splits the assumed type, so it runs before classification, inline — a subagent cannot hold the back-and-forth.
|
||||
|
||||
## Step 2 — Classify and dispatch
|
||||
|
||||
@@ -33,14 +34,13 @@ Match the grilled intent against exactly one row — or more than one, if the in
|
||||
|---|---|---|---|
|
||||
| A reusable capability the agent loads inline in the main conversation, triggered by description-matching, free to bundle its own `references/`, `scripts/` or `assets/` | Skill | `skill-author` | `references/author-routes.md` |
|
||||
| A recurring task needs its own reusable definition — dedicated system prompt, tools and description, invokable by name across sessions | Agent / subagent | `agent-author` | `references/author-routes.md` |
|
||||
| Always-on or path-scoped agent guidance in `.apm/instructions/*.instructions.md` | Instructions file | `instructions-author` | `references/author-routes.md` |
|
||||
| A single-file slash command in `.apm/prompts/*.prompt.md`, typed by hand with arguments and fanned out to each target's commands surface | Prompt file | `prompt-author` | `references/author-routes.md` |
|
||||
| A runtime callback at a harness event, a rule scoped to a file pattern, or a reusable user-typed message steering existing skills or agents | Hook / instruction / prompt | `primitive-author` | `references/author-routes.md` |
|
||||
| A new distributable unit — no existing plugin is the right home for the skill, agent, hook or MCP server being built, or the bundle needs its own manifest, versioning and install lifecycle | Plugin | `apm-workflow` (`apm plugin init`) | `references/apm-routes.md` |
|
||||
| The plugin already exists and only its marketplace-facing metadata changes — a first listing, or a version/description update, never the plugin's contents | Marketplace entry | `apm-workflow` (`apm marketplace package add`) | `references/apm-routes.md` |
|
||||
|
||||
The table classifies what to build, not how to run it: a one-off task that merely needs an isolated or context-inheriting run is not an artifact and has no row here. If the intent stays genuinely ambiguous between rows after grilling, ask the user rather than guessing.
|
||||
|
||||
An artifact that matches no row — a hook, an MCP server, an AGENTS.md, a research doc — has no route here. Say so, hand the user the skill that owns it, and never bend it into a row.
|
||||
A real artifact that matches no row — an MCP server, an AGENTS.md, a research doc — has no route here. Say so, hand the user the skill that does own it, and never bend it into a row to make the table fit.
|
||||
|
||||
When the intent spans several rows, chain the routes in dependency order — an artifact that must exist on disk before another skill can target it goes first, so `apm-workflow` scaffolds the plugin directory before `skill-author` scaffolds a skill inside it.
|
||||
|
||||
@@ -49,4 +49,4 @@ When the intent spans several rows, chain the routes in dependency order — an
|
||||
## Step 3 — Closing gates, common to every route
|
||||
|
||||
- **Resolve before closing.** A route is finished only when its verification reports nothing unresolved. An actionable finding reopens the route; it is never reported onward as a caveat.
|
||||
- **Bump the package version.** A skill route always lands here: `skill-author` moves only a skill's own `metadata.version`, which is not the package `apm.yml`'s number — so read `references/version-bump.md` after one. `agent-author`, `instructions-author`, `prompt-author` and the apm routes bump the package themselves at plugin scope; after those, read it only when their output does not say they did.
|
||||
- **Bump the package version.** A skill route always lands here: `skill-author` moves only a skill's own `metadata.version`, which is not the package `apm.yml`'s number — so read `references/version-bump.md` after one; it skips the bump when the branch already has one. `agent-author`, `primitive-author` and the apm routes bump the package themselves at plugin scope; after those, read it only when their output says neither that they bumped nor that the branch already had.
|
||||
@@ -15,15 +15,17 @@ removed per ADR-0015 once issue #90 landed, and `apm-workflow` is their sole suc
|
||||
## Always inline, never forked
|
||||
|
||||
Run these routes inline, in the current conversation. Their flows are short, prompt-heavy or
|
||||
gated — `apm-workflow`'s publish and release steps take a HITL gate, and removing a marketplace
|
||||
entry takes a conversational confirmation — and a backgrounded fork cannot surface those
|
||||
checkpoints to the user in real time.
|
||||
gated — editing a package's manifest metadata republishes its public `plugin.json` description,
|
||||
and removing a marketplace entry takes a conversational confirmation before `apm pack` changes the
|
||||
consumed catalog — and a backgrounded fork cannot surface those checkpoints to the user in real
|
||||
time.
|
||||
|
||||
## No clean-context recheck, and no automatic audit
|
||||
|
||||
Skill and agent routes close with a clean-context audit rerun; these two do not, and the omission
|
||||
is deliberate rather than an oversight. Neither artifact type has an audit skill counterpart to
|
||||
re-run, so detaching the route to earn a recheck it would never get buys nothing.
|
||||
Skill, agent, and hook, instruction or prompt routes close with a clean-context audit rerun; these
|
||||
two do not, and the omission is deliberate rather than an oversight. Neither artifact type has an
|
||||
audit skill counterpart to re-run, so detaching the route to earn a recheck it would never get buys
|
||||
nothing.
|
||||
|
||||
These routes get no automated terminal check either. `apm audit` is a separate action on
|
||||
`apm-workflow`'s own dispatch table, not a closing step of the configure or marketplace flow a
|
||||
|
||||
@@ -1,52 +1,15 @@
|
||||
---
|
||||
source_keys:
|
||||
- claude-code-subagents-docs
|
||||
- context7-websites-code-claude
|
||||
- claude-code-memory-docs
|
||||
- apm-docs-author-prompts
|
||||
- apm-cli-0-28-0-prompt-experiments
|
||||
- claude-code-slash-commands
|
||||
---
|
||||
|
||||
# Routing a skill, agent, instructions file or prompt file to its author skill
|
||||
# Routing a skill, agent, hook, instruction or prompt to its author skill
|
||||
|
||||
Reached from `SKILL.md` Step 2 when the classified artifact is a skill, an agent/subagent
|
||||
definition, an instructions file or a prompt file. Route a skill to `skill-author`, an agent to
|
||||
`agent-author`, an instructions file to `instructions-author` and a prompt file to `prompt-author`.
|
||||
The branches differ on the author skill only, and everything below applies to all four — except
|
||||
that `factory-audit` has no instructions or prompt flow yet, so those are verified by their author
|
||||
skill's own throwaway-package check and the clean-context rerun below is skipped for them.
|
||||
|
||||
## Rule, procedure or enforcement?
|
||||
|
||||
Before routing guidance to `instructions-author`, check what the content is. Claude reads an
|
||||
instruction as context, not as enforced configuration, so only a rule belongs there.
|
||||
|
||||
| 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. 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 |
|
||||
|
||||
## Prompt file or hand-invoked skill?
|
||||
|
||||
Before routing a "slash command I type" request, check which artifact it is. Claude Code merged
|
||||
custom commands into skills and its docs steer new work toward skills, so a prompt file earns its
|
||||
place only where its single-file, multi-target shape is the point.
|
||||
|
||||
| The content is | Route |
|
||||
|---|---|
|
||||
| A single-file command that should also reach Copilot, Cursor, Gemini or OpenCode | Prompt file (`prompt-author`) |
|
||||
| A command that needs `references/` or `scripts/`, or that other skills or the model must be able to call | Skill (`skill-author`), declared hand-invoked |
|
||||
| A Claude-only command with no such need | Skill (`skill-author`), because the vendor steers new commands there |
|
||||
|
||||
## Gotcha: `context: fork` is not `/fork`
|
||||
|
||||
Claude Code's skill-level `context: fork` frontmatter field and the `/fork` subagent command are
|
||||
opposites despite the shared word: `context: fork` isolates (fresh context, no parent access),
|
||||
while `/fork` inherits the full conversation. The fork-versus-inline choice below is about `/fork`.
|
||||
`references/apm-routes.md` rules the fork out entirely.
|
||||
definition, or a hook, instruction or prompt. Route a skill to `skill-author`, an agent to
|
||||
`agent-author`, and a hook, instruction or prompt to `primitive-author`. The branches differ on
|
||||
the author skill only — all verify the result with `factory-audit`, which detects the artifact
|
||||
type itself — and everything below applies to all of them.
|
||||
|
||||
## Choose fork or inline
|
||||
|
||||
@@ -63,13 +26,13 @@ Fall back to an **inline invocation** — same conversation, no subagent — whe
|
||||
|
||||
## Two-tier verification
|
||||
|
||||
The skill and agent author skills already close out with their own inline audit, in the same context as the
|
||||
authoring work: `skill-author` and `agent-author` each invoke `factory-audit` on what they wrote.
|
||||
That is tier one, and forge does not change it.
|
||||
Every author skill already closes out with its own inline audit, in the same context as the
|
||||
authoring work: `skill-author`, `agent-author` and `primitive-author` each invoke `factory-audit`
|
||||
on what they wrote. That is tier one, and forge does not change it.
|
||||
|
||||
Tier two belongs to forge. Once the author skill's run has finished, spin up a separate
|
||||
**clean-context subagent** — fresh, not forked, no inherited context — to independently re-run the
|
||||
same audit skill against the finished artifact. This is a distinct verification layer, not a
|
||||
**clean-context subagent** — fresh, not forked, no inherited context — to independently re-run
|
||||
the same audit skill against the finished artifact. This is a distinct verification layer, not a
|
||||
duplicate: the inline audit shares context with the work it is checking and can share its blind
|
||||
spots, while the clean rerun has no stake in the result.
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
source_keys: []
|
||||
---
|
||||
|
||||
# Grilling without grill-with-docs
|
||||
|
||||
Reached from `SKILL.md` Step 1 when `grill-with-docs` does not resolve.
|
||||
|
||||
`grill-with-docs` ships in a sibling plugin that kyberforge does not declare as an apm dependency,
|
||||
so it resolves in the authoring monorepo but can be absent where kyberforge is installed alone.
|
||||
|
||||
When it is absent, grill inline yourself rather than skipping the step. Cover four questions:
|
||||
|
||||
- What problem does the artifact solve?
|
||||
- Who invokes it, and how?
|
||||
- What must it refuse?
|
||||
- Which existing skill or plugin already owns part of the job?
|
||||
|
||||
Say which path you took — `grill-with-docs` or the inline fallback — then return to `SKILL.md`
|
||||
Step 2.
|
||||
@@ -12,40 +12,8 @@
|
||||
|
||||
- **URL:** context7:/websites/code_claude
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/claude-code-plugins/sources.md
|
||||
- **Description:** Official Claude Code documentation site indexed by Context7 — confirms the `context: fork` skill-level frontmatter field means isolated/fresh execution, the opposite of what the `/fork` subagent command does (inherits conversation). Informs the `context: fork` gotcha in `references/author-routes.md` warning against conflating the two; nothing else in this skill draws on it.
|
||||
- **Contributing files:** references/author-routes.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## claude-code-memory-docs
|
||||
|
||||
- **URL:** https://code.claude.com/docs/en/memory
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/instructions-target-mapping.md)
|
||||
- **Description:** Claude Code memory documentation. Grounds the "Rule, procedure or enforcement?" table in `references/author-routes.md`: instructions are context rather than enforced configuration, multi-step procedures belong in skills, and enforcement belongs in hooks or `permissions.deny`.
|
||||
- **Contributing files:** references/author-routes.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## apm-docs-author-prompts
|
||||
|
||||
- **URL:** https://microsoft.github.io/apm/producer/author-primitives/prompts/
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/prompt-primitive-schema.md)
|
||||
- **Description:** Official "Author a prompt" page. Grounds the "Prompt file or hand-invoked skill?" table in `references/author-routes.md`: a prompt file is a single file that apm deploys to each target's commands surface.
|
||||
- **Contributing files:** references/author-routes.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## apm-cli-0-28-0-prompt-experiments
|
||||
|
||||
- **URL:** https://pypi.org/project/apm-cli/0.28.0/
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/prompt-target-mapping.md)
|
||||
- **Description:** The installed apm-cli 0.28.0 exercised in throwaway packages. Grounds the same table: which targets receive a prompt file.
|
||||
- **Contributing files:** references/author-routes.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## claude-code-slash-commands
|
||||
|
||||
- **URL:** https://code.claude.com/docs/en/slash-commands
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/prompt-standards/sources.md (digest: plugins/kyberforge/docs/research/docs/prompt-standards/claude-code-commands.md)
|
||||
- **Description:** Claude Code custom-commands documentation. Grounds the third row of the "Prompt file or hand-invoked skill?" table in `references/author-routes.md`: custom commands are merged into skills, still work, and the docs recommend skills for new work.
|
||||
- **Contributing files:** references/author-routes.md
|
||||
- **Description:** Official Claude Code documentation site indexed by Context7 — confirms the `context: fork` skill-level frontmatter field means isolated/fresh execution, the opposite of what the `/fork` subagent command does (inherits conversation). Informs the Gotchas entry in `SKILL.md` warning against conflating the two; nothing else in this skill draws on it, and no `references/` file mentions the `context: fork` field.
|
||||
- **Contributing files:** SKILL.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## claude-code-plugins-docs
|
||||
@@ -60,7 +28,7 @@
|
||||
|
||||
- **URL:** https://agentskills.io/specification.md
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/agentskillsio/sources.md
|
||||
- **Description:** Complete SKILL.md format specification — confirms `assets/`, `references/`, and `scripts/` are warranted only by the bulk/reusability of supporting content (large reference material, executable code, templates), not by a skill's category, and forge's per-route procedures are that kind of supporting content — so the spec permits the `references/` split here but does not require it. The warrant is a house decision: dispatch is mandatory at two or more mutually exclusive flows, which forge's four-row table is. `references/sources.md` likewise exists for this repo's own provenance-chain convention (see `GLOSSARY.md`), not because the spec requires it.
|
||||
- **Description:** Complete SKILL.md format specification — confirms `assets/`, `references/`, and `scripts/` are warranted only by the bulk/reusability of supporting content (large reference material, executable code, templates), not by a skill's category, and forge's per-route procedures are that kind of supporting content — so the spec permits the `references/` split here but does not require it. The warrant is a house decision: dispatch is mandatory at two or more mutually exclusive flows, which forge's five-row table is. `references/sources.md` likewise exists for this repo's own provenance-chain convention (see `CONTEXT.md`), not because the spec requires it.
|
||||
- **Contributing files:** SKILL.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@ source_keys:
|
||||
|
||||
Reached from `SKILL.md` Step 3 after a route has finished. A skill route always lands here:
|
||||
`skill-author` moves only a skill's own `metadata.version`, which is not the package manifest's
|
||||
number, so the package version is still behind when it reports done. `agent-author`,
|
||||
`instructions-author` and `prompt-author` bump the resolved package's `apm.yml` themselves
|
||||
(`agent-author` at plugin/APM scope), and `apm-workflow`'s configure flow carries the same policy — read those routes' output before acting here, because a second bump for
|
||||
number, so the package version is still behind when it reports done. `agent-author` and
|
||||
`primitive-author` bump the resolved package's `apm.yml` themselves at plugin/APM scope, and
|
||||
`apm-workflow`'s configure flow
|
||||
carries the same policy — read those routes' output before acting here, because a second bump for
|
||||
one change is wrong.
|
||||
|
||||
## Find the owning package
|
||||
@@ -23,6 +24,13 @@ than declaring one, so it does not count as a match. Skip it and keep walking up
|
||||
Skip this step entirely if no ancestor `apm.yml` carries a `type:` field: the artifact is then
|
||||
standalone or scoped to a user agent directory, and there is no package to version.
|
||||
|
||||
Skip the bump, and report that you skipped it, if the branch already moved this package's `version`
|
||||
for unreleased work: `git diff $(git merge-base HEAD origin/main) -- <package>/apm.yml` shows a
|
||||
changed `version:` line. Diff against the remote default branch, not a local `main` that may be
|
||||
stale; if it is not `main`, resolve it with `git symbolic-ref refs/remotes/origin/HEAD`. One bump
|
||||
covers all unreleased work on a branch — `agent-author` and `primitive-author` skip on the same
|
||||
condition — so bumping again here double-counts it.
|
||||
|
||||
## Delegate the bump
|
||||
|
||||
Invoke `apm-workflow` as a **clean-context subagent** — fresh, not forked — with this
|
||||
@@ -31,7 +39,7 @@ brief:
|
||||
> "The package at `<package-path>` gained a new `<artifact-type>` (`<artifact-name>`). Bump the
|
||||
> `version` field in that package's `apm.yml`. Determine whether to bump minor (0.1.0) or patch
|
||||
> (0.0.1) based on whether this is a new capability (minor) or a fix/refactor (patch). Do not
|
||||
> release or tag — just update `apm.yml`."
|
||||
> release or tag — just update `apm.yml` and commit."
|
||||
|
||||
Clean context rather than a fork is the point: the bump decision is made independently, without
|
||||
anchoring on the authoring conversation that just argued for the artifact's significance.
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
---
|
||||
name: instructions-author
|
||||
description: >
|
||||
Use when creating or revising an apm instructions file
|
||||
(`.apm/instructions/*.instructions.md`). Not read-only review ->
|
||||
`factory-audit`. Not skills -> `skill-author`. Not agents -> `agent-author`.
|
||||
Not AGENTS.md -> `agentsmd-author`.
|
||||
compatibility: Requires the apm CLI; behaviour verified against apm 0.28.0.
|
||||
allowed-tools: Bash Read Write Edit
|
||||
metadata:
|
||||
version: "0.1.0"
|
||||
category: factory
|
||||
source_keys:
|
||||
- apm-docs-site
|
||||
- apm-cli-0-28-0-experiments
|
||||
- claude-code-memory-docs
|
||||
---
|
||||
|
||||
## Gotchas
|
||||
|
||||
- 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
|
||||
|
||||
| Condition | Flow | Reference |
|
||||
|---|---|---|
|
||||
| No file at the target path | Create | `references/create.md` |
|
||||
| A file exists, at least one improvement signal present | Improve | `references/improve.md` |
|
||||
| A file exists, no signals | Stop and ask | — |
|
||||
|
||||
Signals: grill output, audit findings, inline feedback, a session describing a rule that loaded when it should not or failed to load. With none, ask whether the user meant to create a new file or has feedback to apply.
|
||||
|
||||
Read only the reference for the resolved flow.
|
||||
|
||||
## Step 2 — Contract
|
||||
|
||||
Gates on every file, whichever flow wrote it:
|
||||
|
||||
- **One topic per file.** Two topics are two files.
|
||||
- **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. 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`.
|
||||
|
||||
## Step 3 — Validate and close
|
||||
|
||||
- [ ] Verify with a real compile and a throwaway deploy: read `references/verify.md`. Resolve every warning and confirm a scoped rule deploys with `paths:`.
|
||||
- [ ] Bump the owning package's `apm.yml` `version` — **minor** on create, **patch** on improve — because consumers compare it to detect updates.
|
||||
|
||||
`factory-audit` has no instructions checks yet, so nothing else gates the file; report only what the verification showed.
|
||||
@@ -1,5 +0,0 @@
|
||||
# assets/
|
||||
|
||||
## templates/
|
||||
|
||||
- **`instructions.md`** — minimal valid `.apm/instructions/<name>.instructions.md`, copied by `scripts/new-instructions.sh`. Carries a `description`, a quoted `applyTo` and a one-topic body, each marked `FILL IN:`. The bullets model a checkable rule; what belongs in the body is in `references/content.md`, field semantics in `references/schema.md`.
|
||||
@@ -1,12 +0,0 @@
|
||||
---
|
||||
# Delete these comments once filled in; Copilot receives this file verbatim.
|
||||
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
|
||||
# for a rule that must load in every session.
|
||||
---
|
||||
# FILL IN: one topic per file
|
||||
|
||||
- FILL IN: a concrete rule an agent can check, e.g. "Use 2-space indentation", not "Format code properly".
|
||||
- FILL IN: a convention that differs from the tool's default, or a pitfall with the reason for it.
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
source_keys:
|
||||
- claude-code-memory-docs
|
||||
---
|
||||
|
||||
# What belongs in an instructions file
|
||||
|
||||
Reached from `SKILL.md` Step 2. Claude reads instructions as context, not as enforced configuration, so a rule only helps if it is specific, short and not contradicted elsewhere.
|
||||
|
||||
## Write rules an agent can check
|
||||
|
||||
| Weak | Checkable |
|
||||
|---|---|
|
||||
| Format code properly | Use 2-space indentation |
|
||||
| Test your changes | Run `npm test` before committing |
|
||||
| Keep files organized | API handlers live in `src/api/handlers/` |
|
||||
|
||||
Group related bullets under a short heading. Give the reason when a rule looks arbitrary; a rule with a stated reason survives the edge case.
|
||||
|
||||
## Keep
|
||||
|
||||
- Conventions that differ from the tool's default.
|
||||
- Pitfalls the agent would walk into, with the reason.
|
||||
- Build, test and lint commands; where things live when a path cannot be guessed.
|
||||
|
||||
## Cut
|
||||
|
||||
- What the agent can read from the code: directory listings, dependency lists, architecture overviews.
|
||||
- Anything stated in another file that loads alongside this one. Two copies drift, and contradictory rules are followed arbitrarily.
|
||||
- Generalities ("write clean code").
|
||||
|
||||
## Not a rule?
|
||||
|
||||
A multi-step procedure belongs in a skill, and something that must be enforced belongs in a hook or a `permissions.deny` setting. If the content is one of those, say so to the user and stop; do not bend it into a rule.
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-docs-site
|
||||
- apm-cli-0-28-0-experiments
|
||||
---
|
||||
|
||||
# Creating a new instructions file
|
||||
|
||||
Return to `SKILL.md` Step 3 once Step 3 below is done.
|
||||
|
||||
## Before touching the filesystem
|
||||
|
||||
Confirm, and ask the user for anything missing:
|
||||
|
||||
- [ ] The one topic the file covers. Two topics are two files.
|
||||
- [ ] Which files it governs, as a glob, or that it must load in every session.
|
||||
- [ ] A kebab-case stem. It becomes the deployed filename.
|
||||
|
||||
## Step 1 — Check the stem
|
||||
|
||||
Install overwrites a hand-authored file at `.claude/rules/<stem>.md`, `.cursor/rules/<stem>.mdc`, `.windsurf/rules/<stem>.md`, `.kiro/steering/<stem>.md` and `.agents/rules/<stem>.md` without a prompt. List those paths in the consuming project and choose another stem on any hit.
|
||||
|
||||
## Step 2 — Scaffold
|
||||
|
||||
```bash
|
||||
bash scripts/new-instructions.sh <name> <path-inside-the-package>
|
||||
```
|
||||
|
||||
The script walks up for a `type:`-bearing `apm.yml`. With none it exits 1 and names `/apm-workflow configure`; run that first, then retry. It never overwrites an existing file.
|
||||
|
||||
## Step 3 — Fill in
|
||||
|
||||
Replace every `FILL IN:` and delete the template's comments.
|
||||
|
||||
- `applyTo`: quoted. Omit it only for a rule that must load in every session, and say so to the user; it costs context at every launch.
|
||||
- `description`: one line. Write the body as if it were absent, because Claude Code never sees it.
|
||||
- Body: concrete bullets, one topic, paths in backticks, nothing that assumes another file is loaded. Read `references/content.md` if unsure the content belongs in an instructions file.
|
||||
|
||||
For glob syntax or a field question, read `references/schema.md`.
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-docs-site
|
||||
- apm-cli-0-28-0-experiments
|
||||
---
|
||||
|
||||
# Improving an existing instructions file
|
||||
|
||||
Return to `SKILL.md` Step 3 once the edits are made.
|
||||
|
||||
## Step 1 — Read the file and the signals
|
||||
|
||||
Read the file whole. Signals are grill output, audit findings, inline feedback, or a session describing a rule that loaded when it should not, or failed to load. Apply what the signals name and nothing else.
|
||||
|
||||
## Step 2 — Diagnose by symptom
|
||||
|
||||
| Symptom | Cause | Fix |
|
||||
|---|---|---|
|
||||
| A scoped rule loads in every Claude session | `applyTo` is unquoted or malformed, so install deployed no `paths:` | Quote it, then confirm with `references/verify.md` |
|
||||
| Compile warns "Failed to parse" | Broken frontmatter YAML | Repair the YAML; do not delete the field |
|
||||
| The rule is in `CLAUDE.md` but not `.claude/rules/` | The file is nested under `.apm/instructions/` | Move it up to the flat directory |
|
||||
| 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 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`.
|
||||
|
||||
## Step 3 — Split or trim
|
||||
|
||||
A file covering two topics, or longer than 200 lines, becomes several files. Do the split only when a signal names it.
|
||||
@@ -1,50 +0,0 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-docs-site
|
||||
- apm-github-repo
|
||||
- apm-cli-0-28-0-experiments
|
||||
- claude-code-memory-docs
|
||||
---
|
||||
|
||||
# The instructions source file
|
||||
|
||||
Verified against apm 0.28.0. Reached from `SKILL.md` Step 2 when a frontmatter field, a glob or the file's location is in question.
|
||||
|
||||
## Location and name
|
||||
|
||||
`.apm/instructions/<name>.instructions.md`, flat. The double extension is the discovery key and the stem is the primitive's name; there is no `name` field.
|
||||
|
||||
- A plain `.md` in that directory is ignored by both `apm compile` and `apm install`.
|
||||
- A file in a subdirectory is folded into compiled root files by compile but never deployed by install, so it reaches `CLAUDE.md` and `AGENTS.md` and no native rules directory.
|
||||
- The stem becomes the deployed filename: `<stem>.md`, `<stem>.mdc`, or `<stem>.instructions.md`, by target.
|
||||
|
||||
## Frontmatter
|
||||
|
||||
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, 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
|
||||
|
||||
- One glob: `"**/*.py"`.
|
||||
- Several globs in one string, comma-separated: `"**/*.css,**/*.scss"`. Whitespace around segments is trimmed.
|
||||
- A YAML sequence is joined into the same comma form.
|
||||
- Brace alternation is never split: `"**/*.{css,scss},**/*.py"` is two patterns.
|
||||
- A literal comma in a pattern is `\,`; a literal backslash is `\\`.
|
||||
- Always quote the value. An unquoted `**/*.py` is a YAML alias error; see `SKILL.md` Gotchas for what apm then does.
|
||||
|
||||
## Body
|
||||
|
||||
Plain markdown. Official guidance: bullets over prose, one topic per file (`python-style` and `python-testing` are two files), paths in backticks, no greetings or meta-commentary, no assumption that other files are loaded. apm sets no size limit. The downstream tools do: Claude Code recommends under 200 lines per file and Cursor under 500.
|
||||
|
||||
## Validation
|
||||
|
||||
`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 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.
|
||||
|
||||
No standalone instructions validator exists, so enforcement is this skill's checks and `references/verify.md`.
|
||||
@@ -1,59 +0,0 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-docs-site
|
||||
- apm-github-repo
|
||||
- apm-cli-0-28-0-experiments
|
||||
- claude-code-memory-docs
|
||||
- github-copilot-custom-instructions-docs
|
||||
- cursor-rules-docs
|
||||
---
|
||||
|
||||
# Sources
|
||||
|
||||
## apm-docs-site
|
||||
|
||||
- **URL:** https://microsoft.github.io/apm/
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/instructions-primitive-schema.md)
|
||||
- **Description:** Official apm documentation, the instructions-and-agents authoring page plus targets and compile pages: frontmatter requirements, per-target deploy paths, compile behaviour and flags.
|
||||
- **Contributing files:** SKILL.md, references/schema.md, references/target-mapping.md, references/create.md, references/improve.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## apm-github-repo
|
||||
|
||||
- **URL:** https://github.com/microsoft/apm
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/instructions-primitive-schema.md)
|
||||
- **Description:** apm's own Python source read for the Instruction model, discovery globs and per-target integrators.
|
||||
- **Contributing files:** references/schema.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## apm-cli-0-28-0-experiments
|
||||
|
||||
- **URL:** https://pypi.org/project/apm-cli/0.28.0/
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/instructions-gotchas.md)
|
||||
- **Description:** The installed apm-cli 0.28.0 package plus throwaway install, compile and audit experiments confirming validation severity, unquoted-glob handling, discovery asymmetry, dedup and overwrite behaviour.
|
||||
- **Contributing files:** SKILL.md, references/schema.md, references/target-mapping.md, references/verify.md, references/create.md, references/improve.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## claude-code-memory-docs
|
||||
|
||||
- **URL:** https://code.claude.com/docs/en/memory
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/instructions-target-mapping.md)
|
||||
- **Description:** Claude Code memory documentation: `.claude/rules/` loading, the `paths` field as the only field read, invalid YAML ignored, size and specificity guidance, instructions versus skills and hooks.
|
||||
- **Contributing files:** SKILL.md, references/schema.md, references/target-mapping.md, references/content.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## github-copilot-custom-instructions-docs
|
||||
|
||||
- **URL:** https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/instructions-target-mapping.md)
|
||||
- **Description:** GitHub Copilot repository custom instructions: `.github/instructions/*.instructions.md`, `applyTo` and `excludeAgent`, the separate repo-wide file.
|
||||
- **Contributing files:** references/target-mapping.md
|
||||
- **Status:** `extracted`
|
||||
|
||||
## cursor-rules-docs
|
||||
|
||||
- **URL:** https://cursor.com/docs/context/rules
|
||||
- **Research doc:** plugins/kyberforge/docs/research/docs/microsoft-apm/sources.md (digest: plugins/kyberforge/docs/research/docs/microsoft-apm/instructions-target-mapping.md)
|
||||
- **Description:** Cursor project rules: the `.mdc` requirement, `description`, `globs` and `alwaysApply`, rule types, size guidance.
|
||||
- **Contributing files:** references/target-mapping.md
|
||||
- **Status:** `extracted`
|
||||
@@ -1,63 +0,0 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-cli-0-28-0-experiments
|
||||
- apm-docs-site
|
||||
- claude-code-memory-docs
|
||||
- github-copilot-custom-instructions-docs
|
||||
- cursor-rules-docs
|
||||
---
|
||||
|
||||
# What each target receives
|
||||
|
||||
Verified against apm 0.28.0 and throwaway installs. Reached from `SKILL.md` Step 2 when the question is which target keeps which field. Source-file syntax is in `references/schema.md`.
|
||||
|
||||
## Two output paths
|
||||
|
||||
`apm install` writes one native file per instruction into each target's rules directory. `apm compile` writes root context files that concatenate instruction bodies, grouped by `applyTo`. Treat install as the primary path for Claude Code and Copilot, and compile as the path for targets with no native instructions directory.
|
||||
|
||||
## Install: deployed path and transform
|
||||
|
||||
| Target | Deployed path | Transform |
|
||||
|---|---|---|
|
||||
| copilot | `.github/instructions/<n>.instructions.md` | Verbatim copy |
|
||||
| claude | `.claude/rules/<n>.md` | `applyTo` becomes a `paths:` list; `description` dropped; no frontmatter at all without `applyTo` |
|
||||
| cursor | `.cursor/rules/<n>.mdc` | `applyTo` becomes `globs`; `description` kept; no `alwaysApply` written |
|
||||
| windsurf | `.windsurf/rules/<n>.md` | `trigger: glob` plus `globs`, or `trigger: always_on`; `description` dropped |
|
||||
| kiro | `.kiro/steering/<n>.md` | `inclusion: fileMatch` plus `fileMatchPattern`, or `inclusion: always`; `description` dropped |
|
||||
| antigravity | `.agents/rules/<n>.md` | `trigger: glob` plus `globs`, or no frontmatter; `description` dropped |
|
||||
| grok-build | `.grok/rules/<n>.instructions.md` | Verbatim copy |
|
||||
| codex, gemini, opencode and the rest | none | Reach instructions only through compile |
|
||||
|
||||
Cursor, Windsurf and Antigravity do not deploy at user scope; Kiro and the rest do.
|
||||
|
||||
## Field survival
|
||||
|
||||
| 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 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 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, 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
|
||||
|
||||
- Claude Code reads `.claude/rules/**/*.md` recursively. `paths` is the only field it reads, as a list or a comma-separated string; other fields are ignored. A rule without `paths` loads at every launch. Frontmatter that fails to parse is ignored and the rule loads without `paths`.
|
||||
- Copilot path-specific files need `applyTo` as a quoted comma-joined string; `excludeAgent` is the only other documented key. Repository-wide instructions are the separate `.github/copilot-instructions.md`.
|
||||
- Cursor ignores a plain `.md` in `.cursor/rules`. A rule with only a `description` is "Apply Intelligently", not always-on.
|
||||
|
||||
## Unverified
|
||||
|
||||
Cursor's handling of a YAML-list `globs`, Copilot's handling of unknown frontmatter keys, and runtime behaviour on Windsurf, Kiro and Antigravity. Say so rather than asserting any of them.
|
||||
@@ -1,32 +0,0 @@
|
||||
---
|
||||
source_keys:
|
||||
- apm-cli-0-28-0-experiments
|
||||
---
|
||||
|
||||
# Verifying a file in a throwaway package
|
||||
|
||||
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` 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
|
||||
```
|
||||
|
||||
Resolve every warning it prints: missing `description`, missing `applyTo`, empty content, broken link, "Failed to parse".
|
||||
|
||||
2. For a scoped rule, deploy it where nothing else can be overwritten:
|
||||
|
||||
```bash
|
||||
d=$(mktemp -d)
|
||||
printf 'name: scratch\nversion: 0.1.0\ntype: instructions\ntargets:\n - claude\n' > "$d/apm.yml"
|
||||
mkdir -p "$d/.apm/instructions"
|
||||
cp <package-root>/.apm/instructions/<name>.instructions.md "$d/.apm/instructions/"
|
||||
(cd "$d" && apm install && cat .claude/rules/<name>.md)
|
||||
```
|
||||
|
||||
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 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.
|
||||
@@ -1,3 +0,0 @@
|
||||
# scripts/
|
||||
|
||||
- **`new-instructions.sh <name> <root>`** — scaffolds `<package-root>/.apm/instructions/<name>.instructions.md` from `assets/templates/instructions.md`. Walks up from `<root>` for the nearest `type:`-bearing `apm.yml`; exits 1 with a pointer to `/apm-workflow configure` when there is none. Never overwrites an existing file. Run `--help` for the full contract.
|
||||
Loaded 100 of 159 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user