hstack 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +73 -163
  3. package/VERSION +1 -1
  4. package/dist/commands/doctor.js +18 -8
  5. package/dist/commands/doctor.js.map +1 -1
  6. package/dist/commands/init.js +7 -3
  7. package/dist/commands/init.js.map +1 -1
  8. package/dist/commands/update.js +9 -2
  9. package/dist/commands/update.js.map +1 -1
  10. package/dist/lib/descriptions.js +10 -17
  11. package/dist/lib/descriptions.js.map +1 -1
  12. package/dist/lib/wire.js +166 -138
  13. package/dist/lib/wire.js.map +1 -1
  14. package/dist/manifest.js +41 -29
  15. package/dist/manifest.js.map +1 -1
  16. package/package.json +3 -4
  17. package/template/.claude/agents/adversarial-reviewer.md +42 -50
  18. package/template/.claude/agents/app-architect.md +44 -96
  19. package/template/.claude/agents/data-architect.md +46 -89
  20. package/template/.claude/agents/test-strategist.md +39 -68
  21. package/template/.claude/skills/hstack-adr-new/SKILL.md +23 -73
  22. package/template/.claude/skills/hstack-adversarial-review/SKILL.md +46 -152
  23. package/template/.claude/skills/hstack-adversarial-review/references/finding-categories.md +80 -103
  24. package/template/.claude/skills/hstack-app-architecture/SKILL.md +43 -68
  25. package/template/.claude/skills/hstack-commit/SKILL.md +27 -68
  26. package/template/.claude/skills/hstack-data-architecture/SKILL.md +34 -56
  27. package/template/.claude/skills/hstack-promote/SKILL.md +55 -0
  28. package/template/.claude/skills/hstack-story/SKILL.md +58 -0
  29. package/template/.claude/skills/hstack-test-audit/SKILL.md +64 -0
  30. package/template/.claude/skills/hstack-wrap/SKILL.md +48 -0
  31. package/template/.claude/skills/hstack-wrap/references/pr-description.md +45 -0
  32. package/template/KERNEL.md +75 -318
  33. package/template/templates/adr.md +2 -18
  34. package/template/templates/app-architecture.md +38 -50
  35. package/template/templates/data-architecture.md +38 -89
  36. package/template/templates/infrastructure.md +54 -148
  37. package/template/templates/roadmap.md +6 -12
  38. package/template/templates/story.md +7 -13
  39. package/template/templates/tech-debt.md +2 -37
  40. package/template/templates/tech-stack.md +2 -12
  41. package/template/.claude/agents/data-specialist.md +0 -81
  42. package/template/.claude/agents/implementer.md +0 -97
  43. package/template/.claude/agents/kernel-fit-analyst.md +0 -129
  44. package/template/.claude/agents/planner.md +0 -75
  45. package/template/.claude/agents/product-discovery.md +0 -129
  46. package/template/.claude/agents/product-manager.md +0 -76
  47. package/template/.claude/agents/researcher.md +0 -87
  48. package/template/.claude/agents/security-reviewer.md +0 -88
  49. package/template/.claude/agents/spec-author.md +0 -89
  50. package/template/.claude/agents/stack-architect.md +0 -108
  51. package/template/.claude/agents/ui-ux-briefer.md +0 -75
  52. package/template/.claude/agents/verifier.md +0 -81
  53. package/template/.claude/skills/hstack-branch/SKILL.md +0 -76
  54. package/template/.claude/skills/hstack-brownfield-init/SKILL.md +0 -131
  55. package/template/.claude/skills/hstack-change-new/SKILL.md +0 -84
  56. package/template/.claude/skills/hstack-change-plan/SKILL.md +0 -108
  57. package/template/.claude/skills/hstack-configure/SKILL.md +0 -99
  58. package/template/.claude/skills/hstack-coord/SKILL.md +0 -95
  59. package/template/.claude/skills/hstack-data-review/SKILL.md +0 -93
  60. package/template/.claude/skills/hstack-finalize/SKILL.md +0 -140
  61. package/template/.claude/skills/hstack-flag/SKILL.md +0 -99
  62. package/template/.claude/skills/hstack-greenfield-init/SKILL.md +0 -148
  63. package/template/.claude/skills/hstack-help/SKILL.md +0 -153
  64. package/template/.claude/skills/hstack-implement/SKILL.md +0 -155
  65. package/template/.claude/skills/hstack-kernel-fit-promote/SKILL.md +0 -125
  66. package/template/.claude/skills/hstack-kernel-fit-scan/SKILL.md +0 -142
  67. package/template/.claude/skills/hstack-kernel-fit-scan/references/slack-setup.md +0 -42
  68. package/template/.claude/skills/hstack-kernel-fit-triage/SKILL.md +0 -121
  69. package/template/.claude/skills/hstack-module-spec/SKILL.md +0 -78
  70. package/template/.claude/skills/hstack-product-discovery/SKILL.md +0 -75
  71. package/template/.claude/skills/hstack-research/SKILL.md +0 -115
  72. package/template/.claude/skills/hstack-scaffold/SKILL.md +0 -113
  73. package/template/.claude/skills/hstack-security-review/SKILL.md +0 -95
  74. package/template/.claude/skills/hstack-ship/SKILL.md +0 -119
  75. package/template/.claude/skills/hstack-stack-decide/SKILL.md +0 -81
  76. package/template/.claude/skills/hstack-story-draft/SKILL.md +0 -92
  77. package/template/.claude/skills/hstack-tech-debt-new/SKILL.md +0 -95
  78. package/template/.claude/skills/hstack-tech-debt-resolve/SKILL.md +0 -123
  79. package/template/.claude/skills/hstack-tech-debt-stale/SKILL.md +0 -86
  80. package/template/.claude/skills/hstack-tech-debt-wontfix/SKILL.md +0 -77
  81. package/template/.claude/skills/hstack-telemetry/SKILL.md +0 -73
  82. package/template/.claude/skills/hstack-test-plan/SKILL.md +0 -159
  83. package/template/.claude/skills/hstack-ui-brief/SKILL.md +0 -81
  84. package/template/.claude/skills/hstack-verify/SKILL.md +0 -128
  85. package/template/scripts/compute-merge-readiness.mjs +0 -780
  86. package/template/scripts/coord/coord_scan.py +0 -681
  87. package/template/scripts/run-gates.sh +0 -388
  88. package/template/scripts/telemetry/__init__.py +0 -6
  89. package/template/scripts/telemetry/insights/__init__.py +0 -0
  90. package/template/scripts/telemetry/insights/contract_drift.py +0 -137
  91. package/template/scripts/telemetry/insights/kernel_fit.py +0 -438
  92. package/template/scripts/telemetry/insights/overengineering.py +0 -115
  93. package/template/scripts/telemetry/insights/quality_outcomes.py +0 -131
  94. package/template/scripts/telemetry/insights/token_economics.py +0 -302
  95. package/template/scripts/telemetry/insights/workflow_shape.py +0 -198
  96. package/template/scripts/telemetry/parsers/__init__.py +0 -0
  97. package/template/scripts/telemetry/parsers/bodies.py +0 -87
  98. package/template/scripts/telemetry/parsers/commits.py +0 -219
  99. package/template/scripts/telemetry/parsers/frontmatter.py +0 -322
  100. package/template/scripts/telemetry/parsers/sidecars.py +0 -61
  101. package/template/scripts/telemetry/parsers/transcripts.py +0 -294
  102. package/template/scripts/telemetry/render.py +0 -460
  103. package/template/scripts/telemetry/report.py +0 -150
  104. package/template/scripts/telemetry/run_kernel_fit.py +0 -95
  105. package/template/scripts/telemetry/session_id.py +0 -139
  106. package/template/scripts/validate-spec.mjs +0 -3303
  107. package/template/templates/adversarial-review.md +0 -54
  108. package/template/templates/bootstrap.md +0 -105
  109. package/template/templates/change-spec.md +0 -82
  110. package/template/templates/ci-cd.md +0 -41
  111. package/template/templates/coord-message.md +0 -56
  112. package/template/templates/data-review.md +0 -54
  113. package/template/templates/discovery/brainstorm.md +0 -69
  114. package/template/templates/discovery/forcing-questions.md +0 -76
  115. package/template/templates/discovery/project-brief.md +0 -53
  116. package/template/templates/figma-handoff.md +0 -38
  117. package/template/templates/glossary.md +0 -20
  118. package/template/templates/hardening-checklist.md +0 -73
  119. package/template/templates/incident-runbook.md +0 -57
  120. package/template/templates/kernel-fit-finding.md +0 -63
  121. package/template/templates/kernel-fit-flag.md +0 -52
  122. package/template/templates/module-spec.md +0 -49
  123. package/template/templates/persona.md +0 -38
  124. package/template/templates/plan.md +0 -53
  125. package/template/templates/product-brief.md +0 -56
  126. package/template/templates/security-review.md +0 -63
  127. package/template/templates/telemetry-sidecar.md +0 -227
  128. package/template/templates/test-plan.md +0 -119
  129. package/template/templates/threat-model.md +0 -54
  130. package/template/templates/ui-brief.md +0 -49
  131. package/template/templates/verification.md +0 -63
  132. package/template/templates/vision.md +0 -34
@@ -1,148 +0,0 @@
1
- ---
2
- name: hstack-greenfield-init
3
- description: Use to adopt hstack on an empty repository, eliciting the whole context layer across six gated phases and ending with a scaffold that makes the repo bootable. Repositories that already have source use `/hstack:brownfield-init` instead.
4
- tools:
5
- - Read
6
- - Write
7
- - Edit
8
- - Grep
9
- - Glob
10
- - Bash
11
- - Task
12
- - "node hstack/scripts/validate-spec.mjs — frontmatter validator"
13
- ---
14
-
15
- ## Purpose
16
-
17
- `hstack-greenfield-init` is the **empty-repo entry point** for adopting hstack. It composes six phases of work — five discovery atoms plus one scaffold execution — into a single orchestrator. It writes `hstack/config.yaml` and populates the full context layer, then bootstraps the repository from empty to bootable via a generated bootstrap change-spec.
18
-
19
- Greenfield-init is the only Skill that ends with code being written to the consuming repo (via the scaffold phase invoking `implementer`). Brownfield-init never writes source code — it only writes `hstack/` content against existing source.
20
-
21
- ## When to invoke
22
-
23
- Invoke when:
24
-
25
- - The consuming repo has no source code (or only an `hstack/` install and standard hidden files like `.git/`, `.gitignore`).
26
- - The engineer wants discipline (ADRs, RLS posture, declared LLM/code split) baked in from line zero rather than retrofitted later.
27
-
28
- Do NOT invoke when:
29
-
30
- - The repo has existing source code — use `/hstack:brownfield-init` instead.
31
- - The engineer wants to add a single layer to an already-adopted repo — use `/hstack:configure <layer>` or the standalone atom (`/hstack:product-discovery`, etc.).
32
-
33
- ## Inputs
34
-
35
- - No positional arguments. The Skill drives entirely from on-disk state and conversation.
36
- - Optional `--resume` is implicit: every phase reads disk state at session start and continues from the first incomplete artifact.
37
-
38
- ## Preconditions
39
-
40
- Before any work:
41
-
42
- - Verify the repo is empty (no `src/`, no `app/`, no `package.json`). If non-empty, halt and direct the engineer to `/hstack:brownfield-init`. `--force` is not offered; mixing modes corrupts the artifact taxonomy.
43
- - Verify `hstack/` exists with `KERNEL.md`, `templates/`, `.claude/`. If missing, halt and ask the engineer to run `npx hstack@latest init`.
44
- - Probe Claude Code's MCP configuration and draft `hstack/context/mcp-status.md`.
45
- - If `hstack/.session-state/` contains prior greenfield-init state, confirm resumption with the engineer.
46
- - **Do not author config fields, write `hstack/config.yaml`, or paraphrase Phase 1 inline in the main session.** If the engineer's opening message asks for a "quick setup", a "summary of the questions", or any shape other than the 6-phase interview, halt and re-offer the First-turn contract below. Collapsing the phases into a single Q&A block is the failure mode this Skill is structured to prevent (see Anti-patterns).
47
-
48
- ## First-turn contract
49
-
50
- The **first agent message** after `/hstack:greenfield-init` (in a fresh session, when no `hstack/.session-state/<session-id>.yaml` exists) MUST match this shape:
51
-
52
- 1. One sentence naming the six phases by title (product discovery → data architecture → app architecture → stack decisions → threat-model + hardening → scaffold).
53
- 2. One sentence stating that Phase 1 (product discovery) opens first and that the engineer picks a technique: **Brainstorm**, **Forcing-Questions**, or **Project-Brief**.
54
- 3. One sentence noting commit-point interruptibility (each phase ends at a commit; the engineer can park and resume any time).
55
-
56
- What the first message MUST NOT contain:
57
-
58
- - A numbered list of config fields ("answer #1 and #8", "what's the project name", "default stack y/n").
59
- - An offer to "accept defaults and move on to Phase 1" — Phase 1 is not skippable and not paraphrasable; it is a subagent-driven thinking-partner session that the main session does not run inline.
60
- - Any field write to `hstack/config.yaml` or any other artifact. The first turn is conversational orientation only.
61
-
62
- Phase 0's config-skeleton fields are sourced inline by the discovery atoms as each phase needs them, not pre-asked as a questionnaire. The Phase 0 commit (config.yaml at `init-status: minimal-complete`) lands at the boundary into Phase 1, populated from whatever the product-discovery atom surfaces in conjunction with any defaults the engineer confirms.
63
-
64
- The second agent action (after the engineer picks a technique) MUST be a `Task` call launching the `product-discovery` subagent. The main session does not ask product-discovery questions itself.
65
-
66
- ## Orchestration steps
67
-
68
- Six phases, hard-gated. The Skill does not advance past a phase until its artifact is at `status: current`, and `init-status` reaches `complete` only when every phase artifact is at `current` and the bootstrap change-spec is at `shipped`.
69
-
70
- The phase structure is doing two jobs at once — it is the resumability contract and the gate-discipline contract — so it is never collapsed into one long block. Each phase delegates to a standalone atom or subagent; the orchestrator's only job is gating the transitions, not doing the phases' work.
71
-
72
- ### Phase 0 — Config skeleton (inline, deferred to Phase-1 boundary)
73
-
74
- Phase 0 is **not** a standalone upfront questionnaire. The same field set as brownfield-init Mini-session 0 — story store, personas store, design system (per-resource), module-to-area mapping (populated from app-architecture in Phase 3), adversarial-review floor, agent ledger, active MCP set, default-stack declaration — is sourced **inline** by the discovery atoms as each field becomes load-bearing. Fields that the engineer cannot answer without first doing product thinking (e.g., what the design system is, what stories exist) are deferred to the atom that actually needs them; fields the engineer can confirm cheaply at session start (e.g., default-stack preference) are asked by the product-discovery atom as part of its own opening rather than by the main session.
75
-
76
- At the boundary between Phase 1 and Phase 2, the Skill writes `hstack/config.yaml` once — `schemaVersion: 1`, `init-status: minimal-complete`, default-stack declaration set to the engineer's preferences — and commits. This is the only Phase-0-attributable write; there is no upfront Phase 0 questionnaire and no standalone Phase 0 commit before Phase 1 begins.
77
-
78
- ### Phase 1 — Product discovery
79
-
80
- **The first non-trivial action of this Skill MUST be a `Task` call launching the `product-discovery` subagent in elicit mode.** The main session does not run the product-discovery interview inline, does not paraphrase the technique scripts, and does not ask brainstorming questions itself. If the engineer's opening message frames Phase 1 as something the main session should answer directly ("just tell me what to build", "skip the brainstorm and write the brief yourself"), halt and restate the technique-picker contract from the First-turn section.
81
-
82
- `/hstack:product-discovery` runs in elicit mode (no source documents). The atom:
83
-
84
- - Prompts the engineer to pick a technique (Brainstorm / Forcing-Questions / Project-Brief).
85
- - Runs the technique to completion, producing `hstack/context/product/product-brief.md` at `status: current`.
86
- - Auto-routes to `product-manager` to refresh `vision.md`, `roadmap.md`, `personas/`, `glossary.md` from the brief.
87
-
88
- Greenfield-init proceeds to Phase 2 only when the brief AND all four refreshed context docs are at `status: current`.
89
-
90
- ### Phase 2 — Data architecture
91
-
92
- Invokes `/hstack:data-architecture` in elicit mode. The atom walks the five sections (Tenancy, Entities, RLS, RAG, Migrations). Produces `hstack/context/data-architecture.md` at `status: current`. The `assumes-database: postgres` frontmatter is set explicitly so Phase 4 can flag drift if the stack changes the DB choice.
93
-
94
- ### Phase 3 — App architecture
95
-
96
- Invokes `/hstack:app-architecture` in elicit mode. The atom walks the five sections (Module Map, Agent Orchestration, Deterministic-vs-LLM Split, State-Ownership, Surface Boundaries). Produces `hstack/context/app-architecture.md` at `status: current` AND scaffolds `hstack/specs/<module>/spec.md` stubs at `status: draft` for each module from Section 1. Updates `hstack/config.yaml`'s `surfaces` enum to match Section 5.
97
-
98
- ### Phase 4 — Stack decisions
99
-
100
- Invokes `/hstack:stack-decide`. The `stack-architect` reads `hstack/config.yaml`'s default-stack declaration (set in Phase 0) and fast-paths through layers the engineer accepted defaults for. Layers requiring explicit deep-dive get the constraint interview; each layer's choice routes through `spec-author` for ADR authoring. Produces one rollup ADR plus per-layer ADRs for deep-dived layers.
101
-
102
- ### Phase 5 — Threat model + hardening
103
-
104
- Invokes `security-reviewer` in `--mode foundational` (scores against proposed posture, not diff). Walks `threat-model.md` and `hardening-checklist.md` using the now-current product-brief, data-architecture, app-architecture, and stack ADRs as anchors. Also produces `infrastructure.md` (via `spec-author`) and `incident-runbook.md` (via `spec-author`, `git-ignored: true`) per the brownfield-init pattern.
105
-
106
- ### Phase 6 — Scaffold
107
-
108
- Invokes `/hstack:scaffold`. The scaffold Skill generates a bootstrap change-spec from `hstack/templates/bootstrap.md` with `area: bootstrap`, `surfaces: [infra]`, and `in-scope` enumerated from the app-architecture Module Map plus the data-architecture Migration Sketches. Runs `data-review` and `security-review` in `--mode foundational` against the proposed posture, then planner → implementer (phase-by-phase) → verifier. At terminal state the repo is bootable: the build command exits 0, the test command exits 0, the initial migrations have landed with RLS enforced from line zero.
109
-
110
- After Phase 6, `hstack/config.yaml`'s `init-status` advances to `complete` and the per-change workflow Skills become available.
111
-
112
- ## Outputs
113
-
114
- - `hstack/config.yaml` at `init-status: complete`.
115
- - `hstack/context/product/product-brief.md` at `current` (Phase 1).
116
- - `hstack/context/vision.md`, `roadmap.md`, `personas/*`, `glossary.md` at `current` (Phase 1 auto-route).
117
- - `hstack/context/data-architecture.md` at `current` (Phase 2).
118
- - `hstack/context/app-architecture.md` at `current` plus module-spec stubs (Phase 3).
119
- - `hstack/adr/ADR-*` files — rollup + per-layer (Phase 4).
120
- - `hstack/context/threat-model.md`, `hardening-checklist.md`, `infrastructure.md`, `incident-runbook.md` (Phase 5).
121
- - The bootstrap change-spec at `shipped` plus the actual source files, migrations, CI config, and module shells in the consuming repo (Phase 6).
122
-
123
- ## Auto-commit triggers
124
-
125
- - `hstack/config.yaml` reaches `init-status: minimal-complete` (end of Phase 0).
126
- - Each phase's terminal artifact reaches `status: current` (end of Phases 1–5).
127
- - Each phase of the bootstrap change-spec's plan completes (Phase 6 per-phase commits).
128
- - The bootstrap change-spec reaches `shipped` (end of Phase 6).
129
- - `hstack/config.yaml`'s `init-status` advances to `complete` (after Phase 6 ships).
130
-
131
- ## Idempotency contract
132
-
133
- Re-running `hstack-greenfield-init` reads disk state, recognizes completed phases (artifacts at `current`), and resumes at the first incomplete phase. No re-interview of committed phases. If a downstream phase had triggered an upstream drift recovery, the upstream artifact will be at `needs-refresh` rather than `current`; the Skill resumes at the upstream's refresh interview.
134
-
135
- ## Stop conditions
136
-
137
- Beyond the kernel's general stop conditions, this Skill halts when:
138
-
139
- - The repo is not empty at session start.
140
- - A phase's atom halts (e.g., `HSTACK-HALT: reason=upstream-drift`). The Skill surfaces the halt and offers the engineer the recovery paths the atom named.
141
- - A configured MCP that a downstream phase requires (Supabase MCP for Phase 2 extract-mode references, Notion MCP for persona storage) is unreachable and the phase is load-bearing on it.
142
- - The engineer signals end-of-session — persist state, exit cleanly.
143
-
144
- ## Failure modes
145
-
146
- - **Phase 6 implementer halts.** Bootstrap is partially scaffolded; the change-spec is at `ready-for-implementation` with some phases of `plan.md` complete. Re-running greenfield-init resumes from the first incomplete plan phase via the standard `/hstack:implement` idempotency.
147
- - **Bidirectional drift recovery during Phases 2–4.** A downstream phase finds an upstream gap; the Skill routes the engineer through `/hstack:configure <upstream-atom>` and resumes after the upstream artifact returns to `current`. This path is never bypassed — the upstream MUST be refreshed before the downstream resumes, because a silent override produces contradictions between artifacts that nothing downstream will catch.
148
- - **Stack-architect contradicts data-architecture's Postgres assumption.** Phase 4 halts and surfaces; the engineer either revises data-architecture or revises the stack choice.
@@ -1,153 +0,0 @@
1
- ---
2
- name: hstack-help
3
- description: Use for situation awareness across every hstack artifact — where the work stands, what is healthy, which commands are runnable now, or the phase DAG for one change. Read-only; no subagents, no writes.
4
- tools:
5
- - Read
6
- - Grep
7
- - Glob
8
- - Bash
9
- - "node hstack/scripts/validate-spec.mjs — invoked in --validate sub-mode to surface any artifact drift"
10
- ---
11
-
12
- ## Purpose
13
-
14
- `hstack-help` is the read-only situation-awareness Skill. Its job is to answer three questions without writing anything: where is the team in their hstack-governed work, what is healthy / unhealthy, and what commands are available to run right now. It invokes no subagent. It writes no artifact. It is safe to run any time, by any team member, on any branch.
15
-
16
- ## When to invoke
17
-
18
- Invoke when:
19
- - You open the repo after a break and need a refresher.
20
- - A cofounder or new contributor is orienting themselves.
21
- - Something feels off (a Skill halted, a status seems wrong) and you want a system-level view before debugging.
22
- - Mid-change, before invoking the next workflow Skill, when you want to confirm preconditions are met without trial-and-error halts.
23
-
24
- Safe to run repeatedly. Output is computed from current disk state.
25
-
26
- ## Inputs
27
-
28
- - No flag (default): full three-section status report.
29
- - `--change <id>`: detailed view of one change-spec, including the phase DAG.
30
- - `--commands`: print only the Skills cheat sheet (no current-state computation).
31
- - `--explain <concept>`: look up a concept from the kernel, `hstack/templates/`, the validator registry, or the glossary. Examples: `--explain invariant`, `--explain tenant-isolation`, `--explain trivial-tag`.
32
- - `--validate`: run `node hstack/scripts/validate-spec.mjs` against every artifact under `hstack/` and report violations.
33
-
34
- ## Preconditions
35
-
36
- Minimal. The Skill is best-effort and degrades gracefully:
37
-
38
- - Verify `hstack/` exists. If not, print "hstack is not installed in this repo. See `hstack/README.md` if vendoring, or run the vendoring procedure from the framework source."
39
- - Verify `hstack/config.yaml` exists. If not (init not started), print "hstack is installed but not initialized. Run `/hstack:init` to bootstrap. Other Skills will halt until init completes."
40
- - Beyond that, the Skill tolerates missing or partial artifacts — they show up in the report as "not present" or "draft", which is useful information, not an error.
41
-
42
- ## Orchestration steps
43
-
44
- No subagents are invoked. Every step is a direct file read or shell call.
45
-
46
- ### Default mode (no flag)
47
-
48
- 1. **Section 1 — Where you are.**
49
- - Read `hstack/config.yaml` for `init-status` and the active MCP set.
50
- - Glob `hstack/specs/changes/*/spec.md`. For each, read frontmatter (`id`, `status`, `surfaces`, `owner`, `internal-tooling`, `enables`, `enabled-by`, `trivial`, `parent-change`). Filter to non-terminal status (anything before `shipped`, `archived`).
51
- - For each in-flight change, classify and surface the no-story carve-out when present:
52
- - Category A (`internal-tooling: true`) → annotate "[Category A — internal tooling]".
53
- - Category B (`enables` non-empty) → annotate "[Category B — enables → <comma-separated downstream ids>]". For each downstream id, also note its on-disk status (or "not yet scaffolded" — informational, not a blocker; reconciliation happens at downstream `/hstack:change-new` time).
54
- - `enabled-by` non-empty → annotate "[Realizes ← <comma-separated upstream ids>]" so the reverse direction of the chain is visible.
55
- - SP-13 violation (both `internal-tooling: true` AND `enables` non-empty) → flag explicitly as an error.
56
- - For each in-flight change, compute the **next blocking action**:
57
- - `status: draft` → "Author via `spec-author` directly (or run `/hstack:story-draft` first if user-facing)."
58
- - `status: ready-to-plan` and missing conditional artifacts → name them; suggest the appropriate Skill (`/hstack:test-plan` first if missing — it gates the planner, `/hstack:security-review`, `/hstack:data-review` if db, `/hstack:ui-brief` if ui, `/hstack:change-plan`).
59
- - `status: ready-for-implementation` and plan has un-completed phases → "/hstack:implement <id> <next-task-id>" with the next phase id computed from `plan.steps-completed`.
60
- - `status: in-progress` → continue implementing remaining phases; verify after.
61
- - `status: ready-for-review` and no `verification.md` at passed → "/hstack:verify <id>".
62
- - `status: ready-for-review` and no `adversarial-review.md` at `findings-resolved` → "/hstack:adversarial-review <id> (FRESH SESSION REQUIRED)".
63
- - `status: ready-to-ship` → "/hstack:ship <id>" (if pr-body not yet produced) or "open/merge the PR, then run /hstack:finalize <id>" (if pr-body exists).
64
- - `status: shipped` and `resolves-tech-debt` is non-empty but referenced TDs are still at `in-progress` → "/hstack:finalize <id>" (finalize is incomplete; this is an inconsistent state).
65
- - Glob `hstack/adr/ADR-*.md`, count those at `status: proposed`. List ids.
66
- - Glob `hstack/tech-debt/TD-*.md`. For `status: open`: count and list the top 3 by severity, with the suggested command `/hstack:tech-debt-resolve <td-id>` for each. For `status: in-progress`: list each with its resolving change-spec id (from the Resolution Log) and the change-spec's current status — flag any inconsistency where the change-spec is `shipped` but the TD is still `in-progress` as "run /hstack:finalize <change-id> to complete resolution".
67
- - Glob `hstack/research/sessions/*.md`, count those within the 30-day retention window. List the most recent 3.
68
- - **Context docs.** Walk the canonical list from the kernel's "Product context" section: `vision`, `glossary`, `roadmap`, `personas/`, `data-architecture`, `tech-stack`, `ci-cd`, `infrastructure`, `threat-model`, `hardening-checklist`, `incident-runbook`. For each, classify:
69
- - Missing entirely → "Run `/hstack:configure --interview <name>` (or `/hstack:init` if `init-status != complete`)."
70
- - Status not `current` (e.g., `drafted`, `needs-refresh`) → flag with the same routing.
71
- Author routing mirrors `/hstack:configure` §`--interview`:
72
- - `vision`, `glossary`, `roadmap`, `personas`, `data-architecture`, `tech-stack`, `ci-cd` → `product-manager`.
73
- - `infrastructure`, `incident-runbook` → `spec-author`.
74
- - `threat-model`, `hardening-checklist` → `security-reviewer`.
75
- - Glob `hstack/specs/*/spec.md`, list any module-spec at `status: needs-refresh`.
76
-
77
- 2. **Section 2 — Health.**
78
- - MCPs: read `hstack/context/mcp-status.md` for wired vs degraded.
79
- - **Branch hygiene.** Run `git branch --show-current`. For each in-flight non-trivial change-spec, the expected branch is `change/<change-id>` per the kernel's branch-hygiene rule. Compare:
80
- - Current branch is `main` AND ≥ 1 non-trivial in-flight change exists → flag explicitly: "On `main` with in-flight non-trivial change `<id>`; expected `change/<id>`. Run `/hstack:branch <id>` to switch."
81
- - Current branch matches the expected `change/<id>` of one in-flight change → "Branch `change/<id>` matches in-flight change `<id>`."
82
- - Current branch is `change/<other-id>` and `<other-id>` is no longer in-flight (shipped or archived) → "On `change/<other-id>` (shipped); ready to start something new."
83
- - Trivial-only in-flight changes → no branch warning (trivial may commit on main).
84
- - Git state: `git status --short` count. Flag uncommitted hstack-relevant files.
85
- - Last hstack commit: `git log -1 --format='%h %s (%cr)' -- hstack/`. Shows when hstack-touching work last landed.
86
- - Local-ahead-of-remote: `git rev-list --count @{u}..HEAD 2>/dev/null` (silently skip if no upstream).
87
-
88
- 3. **Section 3 — Commands you can run right now.**
89
- - List every Skill grouped by category (setup, workflow, cross-cutting).
90
- - For each, compute a marker:
91
- - `READY` — preconditions detectable as met.
92
- - `BLOCKED: <reason>` — name the missing precondition.
93
- - `N/A — context` — e.g., `/hstack:ui-brief` for a repo with no in-flight ui-surface change.
94
- - For Skills that take arguments, show a parameterized example using the most likely current value (e.g., the active in-flight change-id).
95
-
96
- ### `--change <id>` mode
97
-
98
- Read the **frontmatter** of every artifact in `hstack/specs/changes/<id>/` — the DAG below is computed entirely from `status`, `steps-completed` and `blocked-on`, so no artifact body is read (kernel § Reading artifacts). Open a body only when the engineer asks a follow-up the frontmatter cannot answer. Render the phase DAG as ASCII with status per node:
99
-
100
- ```
101
- spec [ready-for-implementation]
102
- ├── test-plan [passed] ✓
103
- ├── ui-brief [drafted] ✓
104
- ├── figma-handoff [ready] ✓
105
- ├── data-review [passed] ✓
106
- ├── security-review [concerns-acknowledged] ✓
107
- └── plan [in-progress]
108
- steps-completed: phase-1, phase-2, phase-3 of phase-1..phase-5
109
- next phase: phase-4-wire (depends on phase-3 ✓)
110
- verification [not present]
111
- adversarial-review [not present]
112
- ```
113
-
114
- Below the DAG, the explicit next-action recommendation.
115
-
116
- ### `--commands` mode
117
-
118
- Just the Skills cheat sheet. No state computation. Useful when typing in muscle memory.
119
-
120
- ### `--explain <concept>` mode
121
-
122
- Grep `hstack/KERNEL.md`, `hstack/context/glossary.md`, and `hstack/templates/*.md` for the concept, and run `node hstack/scripts/validate-spec.mjs --rules` when the concept looks like a rule id (`SP-*`, `TD-*`, `AR-*`, …). Print the most relevant paragraph plus a pointer to the source file. If the concept is not found in any source, print: "Not in the kernel, the glossary, the templates, or the validator registry. Ask in natural language and I'll pull from kernel context."
123
-
124
- ### `--validate` mode
125
-
126
- Run `node hstack/scripts/validate-spec.mjs` against every artifact under `hstack/`. Group failures by validation-rule id (SP-*, PL-*, AR-*, etc.) and name the offending file. Read-only — does not auto-fix anything.
127
-
128
- ## Outputs
129
-
130
- - Console-rendered status report. No disk writes, no commits, and no network: the report is computed from local file reads and git alone, never from an MCP call.
131
- - Where an artifact's status is ambiguous, the report prints the ambiguity. It never invents a next action to fill the gap.
132
- - No mutation of any artifact frontmatter.
133
-
134
- ## Auto-commit triggers
135
-
136
- None. This Skill is strictly read-only.
137
-
138
- ## Idempotency contract
139
-
140
- Trivially idempotent. Re-runs produce a fresh report from current disk state. No persisted state, no side effects.
141
-
142
- ## Stop conditions
143
-
144
- Beyond the kernel's general stop conditions:
145
-
146
- - The `--explain <concept>` lookup finds no match in any canonical source. Print the "not found" message and exit cleanly — not a failure.
147
- - `--validate` mode requires the validator script. If absent, print a clear "validator not yet implemented" message (it's a known TODO) and skip the validation; the other modes still work.
148
-
149
- ## Failure modes
150
-
151
- - **Cofounder runs the Skill before vendoring is complete.** Print the install pointer; do not try to compute a status report.
152
- - **Many in-flight change-specs with conflicting next-action recommendations.** Just list them all; let the engineer prioritize.
153
- - **Git state cannot be read (not a git repo).** Skip the git-related health lines; surface a "git not initialized" note.
@@ -1,155 +0,0 @@
1
- ---
2
- name: hstack-implement
3
- description: Use when a change-spec is at `ready-for-implementation` and one named phase of the plan should be executed. The only Skill that causes code to be written, one task at a time, scope-locked to `in-scope`.
4
- tools:
5
- - Read
6
- - Write
7
- - Edit
8
- - Grep
9
- - Glob
10
- - Bash
11
- - Task
12
- - "node hstack/scripts/validate-spec.mjs — validates plan.steps-completed updates against PL-03/PL-04/PL-05"
13
- - "{{TODO-OTHER: in-scope-enforcement guard — runtime check at every Edit/Write that refuses paths outside change-spec.in-scope; v1 implemented inside the implementer subagent's prompt; v2 substrate moves to a subagent-runtime hook}}"
14
- ---
15
-
16
- ## Purpose
17
-
18
- `hstack-implement` is the only Skill that causes code to be written. It orchestrates the `implementer` subagent against one named task from the plan. It is the workflow's last line of gating before code lands on disk: it re-checks every upstream gate, enumerates the kernel's forbidden tools, and refuses to invoke the implementer when preconditions are not met.
19
-
20
- ## When to invoke
21
-
22
- Invoke once the change-spec is at `status: ready-for-implementation` (which means every upstream gate is terminal: test-plan at `passed` or `concerns-acknowledged`, plan at `ready`, security-review at `passed` or `concerns-acknowledged`, data-review at `passed` or `concerns-acknowledged` when applicable, ui-brief at `drafted` and figma-handoff at `ready` when applicable, user-stories non-empty UNLESS `internal-tooling: true` UNLESS `enables` non-empty). One invocation per phase. Re-invoke for each subsequent phase.
23
-
24
- ## Inputs
25
-
26
- - `<change-id>` (required, positional): the change-spec id.
27
- - `<task-id>` (required, positional): the phase id (e.g., `phase-3-component`). Must match an existing `step-id` in the plan body.
28
-
29
- ## Preconditions
30
-
31
- Before any work — the Skill re-checks every gate even when the change-spec carries `status: ready-for-implementation`, because frontmatter can drift. Every check below reads **frontmatter only**, except the two that name a body section (the plan's phase ids and Files Touched); the Skill does not load artifact bodies, because the `implementer` subagent loads what it needs from its own session-start list (kernel § Reading artifacts):
32
-
33
- - Change-spec at `hstack/specs/changes/<change-id>/spec.md`. `status` must be `ready-for-implementation` or `in-progress`. `Invariants` ≥ 3 bullets, `in-scope` non-empty, every `in-scope` glob resolves.
34
- - Plan at `hstack/specs/changes/<change-id>/plan.md` at `status: ready` or `in-progress`. `<task-id>` must match a phase id in the plan body. `Files Touched` for the phase must be a strict subset of `in-scope`.
35
- - **Test-plan at `hstack/specs/changes/<change-id>/test-plan.md` at `status: passed` or `concerns-acknowledged`.** The implementer reads it at session start and writes the tests it specifies; without a terminal test-plan, the implementer halts.
36
- - Security-review at `status: passed` or `concerns-acknowledged`.
37
- - Data-review at `status: passed` or `concerns-acknowledged` when `surfaces` includes `db`.
38
- - ui-brief at `status: drafted` and figma-handoff at `status: ready` when `surfaces` includes `ui`.
39
- - User-stories non-empty UNLESS `internal-tooling: true` (Category A — engineering-only) UNLESS `enables` non-empty (Category B — foundational prerequisite; user value lives in the named downstream change-spec). SP-13: `internal-tooling: true` and `enables` non-empty are mutually exclusive; if both are set, halt with an SP-13 violation message and direct the engineer to `spec-author` to pick one.
40
- - The relevant module-spec at `status: current`.
41
- - **Branch state.** Run `git branch --show-current`. If the current branch is `main` (or the configured default) AND `change-spec.trivial` is not `true`, HARD HALT with: "Refusing to implement on `main` — change-spec `<id>` is not marked trivial. Check out `change/<id>` first, or run `/hstack:branch <id>` to create-and-switch." Trivial changes (`trivial: true`) may proceed on main per the kernel's trivial-changes carve-out. This check enforces the kernel's branch-hygiene contract at the last moment before code lands.
42
-
43
- Enumerate the kernel's forbidden tool surfaces explicitly before invoking the subagent — defense in depth with the implementer's own check:
44
-
45
- - `service_role` Supabase keys in agent-touching code paths.
46
- - Raw shell (`psql`, `bash`, `sh`) executed against production or remote Supabase. Local Supabase only.
47
- - `supabase db push` / `supabase db reset` against any remote project. Local stack only.
48
- - Pipedream Connect against live customer accounts without per-invocation explicit human approval.
49
- - MCPs not in the consuming repo's configured allow set.
50
- - `--no-verify` or other hook-bypassing git flags.
51
- - `--update-snapshots`, `jest --updateSnapshot`, `vitest -u`, or any equivalent bulk snapshot-update flag.
52
- - Destructive git operations (`git push --force`, `git reset --hard`, `git checkout .`) without explicit per-invocation authorization.
53
- - Modifications to existing test files without per-test authorization via the test-immutability protocol (step 8).
54
-
55
- If the named phase appears to require any of the above, halt before invoking — surface the violation, ask the engineer to either reshape the phase or authorize per-invocation.
56
-
57
- ## Orchestration steps
58
-
59
- 0. **Open the phase window (mechanical, no LLM turn, no commit).** The moment the preconditions above pass and *before* any subagent invocation, run `python3 hstack/scripts/telemetry/session_id.py` and keep its `session_id` and `now` values — they become `session_id` and `phase_opened_at` in the sidecar below (ADR-0009). On failure or a null session id, hold `null` for both and continue.
60
-
61
- 1. **Re-verify gates.** Run the precondition checks above. Any failure halts the Skill with a precise message naming the failing artifact and field.
62
-
63
- 2. **Invoke `implementer`.** Use the Task tool with `subagent_type: implementer` and context = [kernel, change-spec, plan, test-plan, security-review, data-review when present, ui-brief and figma-handoff when present, module-spec, tech-stack]. The subagent loads only the In-Scope file list for code reading; everything outside the canonical session-start context plus In-Scope is refused per the kernel.
64
-
65
- 3. **Phase execution.** The subagent executes one phase per invocation — the named task, then stop, never anticipating the next phase. It writes the code diff scoped to the phase's Files Touched, updates `plan.steps-completed` to include `<task-id>` when the phase completes, and writes the tests named in the test-plan sections the phase's Test Strategy references. Test names, file paths, and assertion shape come from the test-plan; the implementer does not rename or omit tests.
66
-
67
- 4. **Database workflow enforcement.** For phases touching schema: the subagent creates migration files via `supabase migration new <descriptive_name>` and never invents a filename; enables RLS in the same migration as a new table; regenerates types via `supabase gen types typescript --local > types/database.types.ts`. Never `supabase db push` / `supabase db reset` against a remote project.
68
-
69
- 5. **Trigger.dev v4 only.** For phases touching trigger code, the subagent uses `@trigger.dev/sdk` task / schemaTask; never `client.defineJob` (v2 deprecated). `triggerAndWait` returns a `Result`; `result.ok` is checked before reading `result.output`.
70
-
71
- 6. **Scope-amendment halt.** If the subagent would touch a file outside `in-scope`, it halts and emits a scope-amendment request to the conversation. The Skill does not extend `in-scope` unilaterally. The engineer invokes `spec-author` (typically via direct request, not a Skill) to amend the change-spec, the Skill re-runs, the subagent re-loads.
72
-
73
- 7. **Hook failures.** If a pre-commit hook fails on the auto-commit, the subagent investigates and fixes the underlying issue; does not bypass via `--no-verify`. If the fix would require out-of-scope edits, halt with a scope-amendment request.
74
-
75
- 8. **Test-immutability protocol.** When the subagent determines an existing test file must be modified, deleted, or have a snapshot updated, it halts before touching the file and runs the kernel's authorization protocol: surface the test name, the reason, the proposed change, and the alternatives; wait for the canonical phrase verbatim (`Ok to change test <name>`, `Ok to delete test <name>`, `Ok to update snapshot <name>`, `Ok to refresh fixture <name>`); echo the phrase in the commit message body and add a footnote under the relevant phase in `plan.md`. Authorization is per-test and per-conversation; a blanket "fix the tests" is refused, and bulk snapshot-update flags are forbidden regardless of scope. The Skill enforces this defense-in-depth — if a subagent's diff shows a modified pre-existing test file without a matching authorization in the conversation, the Skill blocks the commit.
76
-
77
- 9. **Validate.** Run `node hstack/scripts/validate-spec.mjs <path>` against the plan — PL-03 (every `steps-completed` entry matches a plan phase id), PL-04 (every Files Touched path is a subset of `in-scope`), PL-05 (plan status gating).
78
-
79
- ## Outputs
80
-
81
- - Code diffs in the consuming repo, matching the phase's Files Touched.
82
- - Test files written or updated per the phase's Test Strategy.
83
- - `plan.md` updated with `<task-id>` appended to `steps-completed`; `blocked-on: null` (or set to a phase id when interactive blocker stops progress).
84
- - One git commit on the active working branch naming `<change-id>` and `<task-id>`.
85
-
86
- The change-spec is never written by the implementer or by this Skill (architecture amendment A3).
87
-
88
- ## Auto-commit triggers
89
-
90
- - One commit when the phase completes and `steps-completed` advances. Commit message: `implement(<change-id>) <task-id>`.
91
- - An additional commit when `plan.status` advances to `completed` after the final phase.
92
-
93
- ## Telemetry sidecar
94
-
95
- At the phase-completion auto-commit above, write `hstack/specs/changes/<change-id>/.telemetry/implement-<task-id>.json` in the same `git add && git commit` as the canonical phase commit. The sidecar is derivative of git + frontmatter (see `hstack/templates/telemetry-sidecar.md`). Schema:
96
-
97
- ```json
98
- {
99
- "schema_version": 2,
100
- "skill": "hstack-implement",
101
- "change_id": "<change-id>",
102
- "session_id": "<session id from step 0, or null>",
103
- "phase_opened_at": "<ISO-8601 from step 0, or null>",
104
- "phase_closed_at": "<ISO-8601, now — same write as this sidecar, or null>",
105
- "phase_id": "<task-id>",
106
- "started_at": "<ISO-8601, session start of this phase>",
107
- "completed_at": "<ISO-8601, now>",
108
- "files_touched_count": <int>,
109
- "tests_written_count": <int, new test files only>,
110
- "scope_amendment_emitted": <bool>,
111
- "halt_reasons": [<kernel halt-sentinel enum values, if any>],
112
- "test_immutability_authorizations": [<canonical phrase strings, if any>]
113
- }
114
- ```
115
-
116
- `.telemetry/` is git-ignored in the consuming repo. The sidecar write must not introduce any new LLM turn or confirmation gate — it is a deterministic write bundled with the existing commit. If the sidecar write fails, log and continue; the canonical commit must still land.
117
-
118
- The three phase-window fields (`session_id`, `phase_opened_at`, `phase_closed_at`) come from step 0 and from this write. Their rules — best-effort, unmeasured rather than zero, never a halt — are stated once in `hstack/templates/telemetry-sidecar.md` § The phase window, which is the canonical schema and wins over any Skill.
119
-
120
- ## Session boundary
121
-
122
- `implement` is a natural session cut: the auto-commit above left `plan.md` (`steps-completed`) and the committed code on disk, so the conversation holds nothing the next phase needs. The cut-notice format, the kickoff-prompt template and the context-block rules are in `KERNEL.md` § Session boundaries; this Skill's two variables are:
123
-
124
- ```
125
- HSTACK-CUT: implement complete — cut recommended before the next phase, or verify once every phase is done.
126
- ```
127
-
128
- and the next command, `/hstack:implement <next-phase-id> <change-id>`.
129
-
130
- ## Idempotency contract
131
-
132
- - Re-running with the same `<task-id>` after the phase already landed: the subagent reads `steps-completed`, recognizes the phase as done, and produces a no-op diff. Re-running on a partially applied phase: the subagent reads current file state and applies only the remaining diff.
133
- - Re-running on a phase whose dependencies are not yet complete (`depends-on` references a phase not in `steps-completed`): the subagent halts and surfaces the missing dependency.
134
-
135
- ## Stop conditions
136
-
137
- Beyond the kernel's general stop conditions:
138
-
139
- - A modification outside `in-scope` is needed. Halt; emit scope-amendment request.
140
- - An invariant would be weakened, dropped, or modified.
141
- - A required upstream artifact is non-terminal.
142
- - A forbidden tool would be used (see enumeration above).
143
- - A load-bearing MCP is unreachable mid-phase.
144
- - The change requires a migration against a remote environment.
145
- - A pre-commit or pre-push hook fails after investigation — halt and surface; do not bypass.
146
- - An existing test would need to be modified, deleted, or have its snapshot updated, and the human has not yet typed the canonical authorization phrase.
147
- - The engineer has not authorized a destructive git operation that the situation seems to call for.
148
- - An ambiguity in the plan or change-spec would require the implementer to make a design call beyond its role.
149
-
150
- ## Failure modes
151
-
152
- - **Phase depends-on a phase not yet in `steps-completed`.** Halt and surface the dependency.
153
- - **Type regen fails after a migration.** The phase is incomplete; `steps-completed` is not advanced; halt and surface.
154
- - **Tests written but failing.** Halt at `steps-completed` not advanced; the engineer either re-invokes after fixing or amends the plan via the planner.
155
- - **Validator fails PL-04.** A Files Touched path crept outside `in-scope` — halt; this should have been caught upstream.
@@ -1,125 +0,0 @@
1
- ---
2
- name: hstack-kernel-fit-promote
3
- description: Use to elevate an `open` or `acknowledged` kernel-fit finding into an ADR (or a tech-debt item) and write the reciprocal back-reference. The third step of the kernel-fit loop, after `/hstack:kernel-fit-scan` and `/hstack:kernel-fit-triage`.
4
- tools:
5
- - Read
6
- - Write
7
- - Edit
8
- - Grep
9
- - Glob
10
- - Bash
11
- - Task
12
- - "node hstack/scripts/validate-spec.mjs — validates the finding back-reference and the new ADR/TD frontmatter (KF-04 reciprocity, AD-01..AD-04 for ADR, TD-01..TD-04 for tech-debt)"
13
- ---
14
-
15
- ## Purpose
16
-
17
- `hstack-kernel-fit-promote` elevates a kernel-fit finding to a durable kernel-change artifact (ADR by default; tech-debt as a secondary path). It is the only Skill that flips a kernel-fit finding to `status: promoted`. The Skill is a mechanical wrapper per ADR-0001: it constructs the seed material from the finding's body and invokes the appropriate authoring Skill, then performs the reciprocal back-reference write directly. No subagent is invoked by this Skill itself — the authoring Skill it routes to (`/hstack:adr-new` or `/hstack:tech-debt-new`) invokes `spec-author` for the open-ended sections.
18
-
19
- The contract the user explicitly required at design time: **no agent creates an ADR without a human gate.** Here the human gate is `spec-author`'s Nygard interview, which the engineer walks every section of before the ADR's `status: accepted` write lands. The promote Skill never auto-creates an ADR — it routes; the engineer confirms.
20
-
21
- ## When to invoke
22
-
23
- Invoke when:
24
-
25
- - A kernel-fit finding at `status: open` or `acknowledged` warrants a kernel change and the engineer is ready to author the ADR (or capture the tech-debt). The team has discussed the finding; the proposed direction is approximately right; the engineer is ready to commit time to the interview.
26
- - The finding's Counter-explanations have been considered and the team has decided they do not weaken the finding enough to dismiss.
27
-
28
- Do NOT invoke when:
29
-
30
- - The finding is at `confidence: low`. Low-confidence findings should be either dismissed (with substantive rationale) or left at `open` until the next scan accumulates evidence enough to upgrade them. Promoting `low` skips the implicit signal the analyst encoded.
31
- - The finding has just been written and not yet triaged. Take 24–48 hours to think; the kernel is a high-stakes artifact and the cost of a bad ADR cascades.
32
- - A scan run has just superseded the finding (`status: superseded`). Promote the superseding finding instead.
33
-
34
- ## Inputs
35
-
36
- - `<finding-id>` (required, positional): the finding id, e.g. `KF-0001-category-a-claim-spans-production` or the short form `KF-0001`.
37
- - `--slug <text>` (required): kebab-case slug for the destination artifact. Passed through to the authoring Skill (`/hstack:adr-new --slug <text>` or `/hstack:tech-debt-new --slug <text>`).
38
- - `--target <adr | tech-debt>` (optional, default `adr`): destination artifact type. ADR is the primary path; tech-debt is the secondary path for findings that name a gap but do not yet have a defensible Decision section.
39
-
40
- ## Preconditions
41
-
42
- - `hstack/kernel-fit/findings/<finding-id>*.md` exists. If missing, halt.
43
- - The finding is at `status: open` or `status: acknowledged`. If at any other status (`dismissed`, `promoted`, `superseded`, `archived`), halt with the current status named.
44
- - `--slug` is non-empty and matches `^[a-z][a-z0-9-]*$`.
45
- - `--target` is in the controlled enum (`adr` or `tech-debt`).
46
- - The downstream Skill (`hstack-adr-new` or `hstack-tech-debt-new`) is reachable from the consuming repo's `.claude/skills/`. (Auto-wired via the symlink delta on `npx hstack update`; this check is a defense against drift.)
47
-
48
- ## Orchestration steps
49
-
50
- 1. **Resolve and read the finding.** Glob `hstack/kernel-fit/findings/<finding-id>*.md`; on zero or multiple matches, halt. Parse frontmatter; verify status precondition. Print the finding body in full — the engineer reviews before committing the time to the interview.
51
-
52
- 2. **Construct the seed material.** Extract three sections from the finding body verbatim:
53
- - `## Evidence` (the bullet list with inline citations)
54
- - `## Kernel surface implicated` (the single-sentence pointer)
55
- - `## Proposed direction` (the one paragraph sketch)
56
-
57
- Compose them into a "Seeded from kernel-fit finding <KF-id>" preface plus the three section bodies, verbatim. This preface becomes the Context seed for the downstream authoring Skill. The Counter-explanations section is NOT seeded — the engineer's Decision section must engage with the kernel-change question fresh, not pre-anchored by the analyst's challenge-prompt output.
58
-
59
- 3. **Confirm before routing.** Print the proposed slug, the target (adr or tech-debt), and the seed preface. Ask "Route to /hstack:<target>-new with this seed? (Y/n)". Default Yes. On `n`, abort without writing.
60
-
61
- 4. **Route to the authoring Skill.** Always through `/hstack:adr-new` or `/hstack:tech-debt-new`, never by invoking `spec-author` directly — routing is what keeps the authoring Skills' challenge prompts and validation rules in the path.
62
-
63
- For `--target adr` (default):
64
- - Invoke `/hstack:adr-new --from-kernel-fit <finding-id> --slug <slug>` via the Task tool or Skill orchestration mechanism. `spec-author` walks the six Nygard sections; the seeded Context is the engineer's starting material to review and revise.
65
- - On the engineer's confirmation at `status: accepted`, `adr-new` writes the ADR file with `promoted-from-kernel-fit: [<finding-id>]` in its frontmatter and auto-commits with message `adr(ADR-NNNN-<slug>): accepted`.
66
- - The ADR commit lands first. The back-reference commit lands second. See Failure modes for the recoverable carve-out.
67
-
68
- For `--target tech-debt`:
69
- - Invoke `/hstack:tech-debt-new --from-kernel-fit <finding-id> --slug <slug>`. `spec-author` walks the six TD sections; the seeded Context is split into Why we took the shortcut, What it costs us, and Fix sketch as appropriate.
70
- - On terminal-state, `tech-debt-new` writes the TD file with `introduced-by: kernel-fit:<finding-id>` (the kernel-fit-origin variant of the TD `introduced-by` field; documented as a v1 carve-out — the existing field accepts a `kernel-fit:` prefix to disambiguate from change-spec origins) and auto-commits.
71
-
72
- 5. **Capture the new artifact id.** Parse the downstream Skill's terminal commit message for `ADR-NNNN-<slug>` or `TD-NNNN-<slug>`. On parse failure (downstream Skill halted mid-interview), the promote Skill halts too — re-invocation will resume from the same step once the downstream Skill completes.
73
-
74
- 6. **Write the reciprocal back-reference on the finding.** Per ADR-0001 (mechanical writes by the Skill orchestrator), the promote Skill performs the `Edit` itself. These four fields plus the Triage Log append are the only writes permitted here; the finding's body — Evidence, Kernel surface, Proposed direction, Counter-explanations, Confidence rationale — is the analyst's and is immutable from this Skill:
75
- - `promoted-to: adr:ADR-NNNN-<slug>` (or `tech-debt:TD-NNNN-<slug>`)
76
- - `status: <prev> → promoted`
77
- - `owner: <git-handle>` (if not already set by triage)
78
- - `updated: <today>`
79
- - Append to `## Triage Log`: `- \`status: <prev> → promoted\` on <today> by <owner>. Promoted to: <promoted-to>. Triggered by \`/hstack:kernel-fit-promote <id> --slug <slug>\`.`
80
-
81
- Defensive log-header check per the kernel: if `## Triage Log` is absent, append it before writing the entry.
82
-
83
- 7. **Print the proposed-diff preview** for the back-reference edit (per the kernel's mechanical-operations confirmation gate). Ask "Apply back-reference and flip status to promoted? (Y/n)". Default Yes.
84
-
85
- 8. **Edit + validate + commit.** On `Y`:
86
- - `Edit` the finding file.
87
- - Run `node hstack/scripts/validate-spec.mjs <path>` against the finding. KF-04 (promoted requires `promoted-to` non-null AND referenced ADR/TD exists) must pass; the reciprocity check verifies the ADR's `promoted-from-kernel-fit` contains this finding's id.
88
- - On validation pass: `git add` the finding file and commit with message `kernel-fit(<finding-id>): promoted to <promoted-to>`.
89
- - On validation failure: halt; revert via `git checkout -- <finding-file>`. The ADR commit from step 4 has already landed and is correct — re-invoke promote (it is idempotent on the finding's promoted status, and the back-reference write will retry).
90
-
91
- 9. **Confirm completion.** Print "Promote complete. Finding <finding-id> is now `promoted` with `promoted-to: <promoted-to>`. The kernel change lives in <promoted-to>; this finding is now read-only from kernel-fit's perspective (further edits would require a new finding via the next scan)."
92
-
93
- ## Outputs
94
-
95
- - A new ADR at `hstack/adr/ADR-NNNN-<slug>.md` OR a new TD at `hstack/tech-debt/TD-NNNN-<slug>.md` (via the downstream authoring Skill).
96
- - An edit to `hstack/kernel-fit/findings/<finding-id>*.md` setting `promoted-to` and `status: promoted`, plus a Triage Log entry.
97
- - Two commits — one from the authoring Skill (ADR or TD), one from this Skill (finding back-reference).
98
-
99
- ## Auto-commit triggers
100
-
101
- - Two commits per promote: the authoring Skill's own commit at the ADR or TD terminal state, and this Skill's own commit at the finding's `status: promoted` flip.
102
-
103
- ## Idempotency contract
104
-
105
- - Re-running on a finding already at `status: promoted`: the Skill prints "already promoted to <promoted-to>" and exits no-op.
106
- - Re-running after step 4 succeeded but step 8 failed (the recoverable carve-out): the Skill detects the ADR or TD exists with the correct `promoted-from-kernel-fit` (or `introduced-by: kernel-fit:<id>`), skips re-invoking the authoring Skill, and goes straight to step 6 (back-reference write). Convergence in one re-invocation.
107
- - Re-running on a `dismissed` or `superseded` finding: halt with the status named. The engineer cannot promote a finding that has been ruled out or restated.
108
-
109
- ## Stop conditions
110
-
111
- Beyond the kernel's general stop conditions:
112
-
113
- - The finding does not exist, or is at a terminal-from-promote status (`dismissed`, `promoted`, `superseded`, `archived`). Halt with the status named.
114
- - `--slug` is missing or malformed. Halt with the regex shown.
115
- - `--target` is not in the enum. Halt with usage.
116
- - The downstream authoring Skill halts mid-interview (`spec-author` could not produce two consequences for the ADR Consequences challenge, or the engineer aborted). Propagate the halt; re-invoke when ready.
117
- - The downstream artifact's commit cannot be parsed for its id at step 5 (e.g., the authoring Skill committed under a non-canonical message format). Halt with a diagnostic and let the engineer reconcile.
118
- - The validator fails at step 8 because the back-reference is inconsistent with the ADR's `promoted-from-kernel-fit` array. Halt and reconcile — most likely cause is the engineer aborted the authoring Skill before reciprocal write, leaving inconsistent on-disk state.
119
-
120
- ## Failure modes
121
-
122
- - **Recoverable two-commit carve-out (analogous to `/hstack:finalize` in-progress carve-out).** The kernel's atomicity rule (KERNEL.md `## Mechanical operations § Atomicity for reciprocal pairs`) requires both halves of a reciprocal write to land in the same commit. The finalize Skill carves out an exception for multi-TD resolutions where intermediate state is intentional and recoverable by re-running. Promote adopts the same shape: the ADR (or TD) commit and the finding back-reference commit are separate, and an interruption between them is recoverable by re-running this Skill. During the window between the two commits, on-disk state shows the ADR with `promoted-from-kernel-fit: [<id>]` and the finding still at `status: open` or `acknowledged` — this is intentional and re-runnable. The Forbidden-no-matter-what kernel bullet about reciprocal-pair atomicity applies to **standing** state (post-promote), not the transient window during a single promote invocation. v2 substrate could add `--defer-commit` to the authoring Skills so both writes land atomically; v1 accepts the two-commit pattern for honest implementation reality.
123
- - **Authoring Skill writes the wrong `promoted-from-kernel-fit` id.** Defense: this Skill's validation at step 8 cross-checks. If the ADR's array does not contain the finding id, the back-reference write is refused and the engineer reconciles by editing the ADR's frontmatter (this is itself a mechanical write per ADR-0001; manual `git commit --amend` is the recovery path, but the engineer should prefer re-running promote after correcting the ADR).
124
- - **Drive-by promote.** The Skill's preflight does not detect promote attempts on `low`-confidence findings — the engineer is trusted to make this judgment. If a pattern of `low`-confidence promotes emerges, that itself becomes a future kernel-fit detection pattern (KF-Pn: "engineers promote findings the analyst rated low").
125
- - **Engineer wants to promote two findings to one ADR.** Not supported in v1. Run promote twice with the same `--slug` — the second invocation will halt because the slug collides on `adr-new`'s precondition check. The engineer's recovery is to dismiss one of the findings with a rationale ("subsumed by KF-other-id promoting under slug X") and promote only the canonical one.