hstack 0.4.0 → 0.5.1
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.
- package/CHANGELOG.md +47 -0
- package/README.md +56 -14
- package/VERSION +1 -1
- package/package.json +1 -1
- package/template/.claude/agents/app-architect.md +154 -0
- package/template/.claude/agents/data-architect.md +147 -0
- package/template/.claude/agents/product-discovery.md +165 -0
- package/template/.claude/agents/stack-architect.md +137 -0
- package/template/.claude/agents/verifier.md +6 -2
- package/template/.claude/skills/hstack-app-architecture/SKILL.md +109 -0
- package/template/.claude/skills/{hstack-init → hstack-brownfield-init}/SKILL.md +17 -11
- package/template/.claude/skills/hstack-data-architecture/SKILL.md +100 -0
- package/template/.claude/skills/hstack-greenfield-init/SKILL.md +150 -0
- package/template/.claude/skills/hstack-product-discovery/SKILL.md +101 -0
- package/template/.claude/skills/hstack-scaffold/SKILL.md +140 -0
- package/template/.claude/skills/hstack-stack-decide/SKILL.md +108 -0
- package/template/.claude/skills/hstack-verify/SKILL.md +15 -4
- package/template/CLAUDE.md +20 -6
- package/template/templates/app-architecture.md +102 -0
- package/template/templates/bootstrap.md +105 -0
- package/template/templates/data-architecture.md +147 -13
- package/template/templates/discovery/brainstorm.md +69 -0
- package/template/templates/discovery/forcing-questions.md +76 -0
- package/template/templates/discovery/project-brief.md +53 -0
- package/template/templates/product-brief.md +56 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hstack-data-architecture
|
|
3
|
+
description: |
|
|
4
|
+
Use this skill when the engineer wants to produce or refresh `hstack/context/data-architecture.md` — the deep five-section foundational data-layer design (Tenancy, Entities, RLS, RAG, Migration Sketches). The Skill is Phase 2 of `/hstack:greenfield-init`, the data-architecture step of `/hstack:brownfield-init`, or a standalone atom for refreshing a single section after drift. It invokes the `data-architect` subagent and routes downstream phases to halt at `HSTACK-HALT: reason=upstream-drift` when contradictions surface. Examples:
|
|
5
|
+
|
|
6
|
+
<example>
|
|
7
|
+
Context: Phase 2 of greenfield-init opens after product-brief is current.
|
|
8
|
+
user: "/hstack:data-architecture"
|
|
9
|
+
assistant: "Loading product-brief, vision, mvp-scope, personas. Section 1 — Tenancy — is load-bearing: I'll walk Patterns A/B/C explicitly and refuse to advance until the tenant definition is concrete with a rationale tied to a persona. Subsequent sections (Entities, RLS, RAG, Migration Sketches) build on it."
|
|
10
|
+
<commentary>
|
|
11
|
+
Tenancy ambiguity is the #1 multi-tenant SaaS failure mode. The atom enforces concreteness at Section 1 before any downstream section can stabilize.
|
|
12
|
+
</commentary>
|
|
13
|
+
</example>
|
|
14
|
+
|
|
15
|
+
<example>
|
|
16
|
+
Context: An app-architect drift challenge revealed a missing entity in data-architecture. The engineer routes back.
|
|
17
|
+
user: "/hstack:data-architecture --section entities"
|
|
18
|
+
assistant: "Section-targeted entry. I'll fast-jump to Section 2 Entities for the missing entity, but the end-of-atom coherence check still runs across all five sections before commit — section edits cannot silently break other sections."
|
|
19
|
+
<commentary>
|
|
20
|
+
Section-targeted re-entry is precision when needed, but coherence is non-negotiable. The end-of-atom check is the v1 guarantee against drift-from-edit.
|
|
21
|
+
</commentary>
|
|
22
|
+
</example>
|
|
23
|
+
tools:
|
|
24
|
+
- Read
|
|
25
|
+
- Write
|
|
26
|
+
- Edit
|
|
27
|
+
- Grep
|
|
28
|
+
- Glob
|
|
29
|
+
- Bash
|
|
30
|
+
- Task
|
|
31
|
+
- "{{TODO-MCP: Supabase MCP — live schema introspection in extract mode}}"
|
|
32
|
+
- "{{TODO-SCRIPT: hstack/scripts/validate-spec.ts — frontmatter validator}}"
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Purpose
|
|
36
|
+
|
|
37
|
+
`hstack-data-architecture` is the atom that produces or refreshes `hstack/context/data-architecture.md` via the `data-architect` subagent. The artifact is the foundational design of the data layer in five sections; downstream subagents (`data-specialist` for per-change reviews, `implementer` for migration writing) read it as canonical posture.
|
|
38
|
+
|
|
39
|
+
## When to invoke
|
|
40
|
+
|
|
41
|
+
- Phase 2 of `/hstack:greenfield-init` (elicit mode).
|
|
42
|
+
- Delegated by `/hstack:brownfield-init` mini-session 5a (extract mode).
|
|
43
|
+
- Standalone via `/hstack:data-architecture [--mode extract|elicit] [--section <name>]` for refresh or single-section edits.
|
|
44
|
+
- Routed-into-from-downstream when `/hstack:app-architecture` finds a state-ownership gap that requires an entity addition (the bidirectional drift recovery path).
|
|
45
|
+
|
|
46
|
+
## Inputs
|
|
47
|
+
|
|
48
|
+
- `--mode extract | elicit` — defaults: `extract` if the live schema is reachable via Supabase MCP or migration files exist; `elicit` otherwise.
|
|
49
|
+
- `--section <name>` — one of `tenancy | entities | rls | rag | migrations`. Fast-jumps but re-runs end-of-atom coherence.
|
|
50
|
+
|
|
51
|
+
## Preconditions
|
|
52
|
+
|
|
53
|
+
- `hstack/config.yaml` at `init-status: minimal-complete` or later.
|
|
54
|
+
- `hstack/context/product/product-brief.md` at `status: current`. The brief is upstream; entities trace to it. If brief is at `draft` or `needs-refresh`, halt with `HSTACK-HALT: reason=upstream-non-terminal`.
|
|
55
|
+
- `hstack/templates/data-architecture.md` present.
|
|
56
|
+
- In extract mode, the Supabase MCP is reachable OR `supabase/migrations/` exists OR equivalent schema source is reachable; otherwise halt.
|
|
57
|
+
|
|
58
|
+
## Orchestration steps
|
|
59
|
+
|
|
60
|
+
1. **Detect mode + entry.** Read disk state. If artifact at `current` and no `--section` and no `--force`: print summary, exit no-op.
|
|
61
|
+
2. **Invoke `data-architect` subagent.** Via the Task tool with `subagent_type: data-architect`. Pass mode, optional section, the canonical session-start context, and (in extract mode) the live-schema introspection results.
|
|
62
|
+
3. **Walk sections.** The subagent walks Section 1 first (Tenancy is gate). For section-targeted entry, jumps directly. Each confirmed section writes to disk + auto-commits.
|
|
63
|
+
4. **Run drift challenge prompts.** Each section ends with a drift challenge before confirmation. A real drift halts with `HSTACK-HALT: reason=upstream-drift` and offers (a) revise this section, (b) re-enter the upstream atom (`/hstack:product-discovery` or `/hstack:configure vision`), (c) log as ADR via `/hstack:adr-new`.
|
|
64
|
+
5. **End-of-atom coherence check.** Even on section-targeted entry, the subagent re-runs all five drift challenges before terminal commit. Any unanswered challenge blocks the commit.
|
|
65
|
+
|
|
66
|
+
## Outputs
|
|
67
|
+
|
|
68
|
+
- `hstack/context/data-architecture.md` at `status: current` with `assumes-database: postgres` in frontmatter (or alternative with rationale).
|
|
69
|
+
- `hstack/.session-state/<session-id>.yaml` (transient).
|
|
70
|
+
|
|
71
|
+
## Auto-commit triggers
|
|
72
|
+
|
|
73
|
+
- Each confirmed section writes immediately and auto-commits.
|
|
74
|
+
- Artifact reaches `status: current` → final commit with the coherence-check evidence in the body.
|
|
75
|
+
|
|
76
|
+
## Idempotency contract
|
|
77
|
+
|
|
78
|
+
- Artifact at `current` + no `--section` + no `--force`: print summary, exit no-op.
|
|
79
|
+
- Artifact at `draft` or partial: read disk + session-state, resume at next non-confirmed section.
|
|
80
|
+
- Artifact at `needs-refresh`: walk all sections in confirm-or-revise mode.
|
|
81
|
+
|
|
82
|
+
## Stop conditions
|
|
83
|
+
|
|
84
|
+
- Product-brief at non-terminal status.
|
|
85
|
+
- Section 1 Tenancy answer is vague after one re-ask.
|
|
86
|
+
- A drift challenge surfaces an unresolved contradiction.
|
|
87
|
+
- Extract mode invoked but no schema source reachable.
|
|
88
|
+
- The `assumes-database: postgres` value contradicts an in-flight stack decision.
|
|
89
|
+
|
|
90
|
+
## Failure modes
|
|
91
|
+
|
|
92
|
+
- **Subagent unreachable.** Persist session state; retry later.
|
|
93
|
+
- **Supabase MCP unreachable in extract mode.** If migrations or other schema source exist, the subagent falls back to those. Otherwise halt with `HSTACK-HALT: reason=mcp-unreachable` per the kernel's load-bearing-MCP rule.
|
|
94
|
+
|
|
95
|
+
## Anti-patterns
|
|
96
|
+
|
|
97
|
+
- Never write migration `.sql` files from this Skill. Sketches only; the implementer writes the files during bootstrap or per-change.
|
|
98
|
+
- Never bypass the Section 1 Tenancy gate.
|
|
99
|
+
- Never let the end-of-atom coherence check be skipped on section-targeted re-entry.
|
|
100
|
+
- Never silently honor a database change that contradicts `assumes-database`. Halt and surface; route through stack-architect or refresh this artifact deliberately.
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hstack-greenfield-init
|
|
3
|
+
description: |
|
|
4
|
+
Use this skill when an engineer is starting a **new project from an empty repository** and wants hstack discipline baked in from line zero. Greenfield-init is the sibling of `/hstack:brownfield-init`: where brownfield extracts existing context, greenfield elicits it. The Skill composes the discovery atoms in order (product-discovery → data-architecture → app-architecture → stack-decide → threat-model/hardening → scaffold), with hard gates between phases and bidirectional drift recovery for downstream phases that surface upstream gaps. Total elapsed time is 4–8 hours of conversation spread across as many sessions as the engineer wants — every phase ends at a commit point and is interruptible. Until greenfield-init completes through Phase 6 (scaffold), no per-change workflow Skill works; the repo is bootable only after scaffold lands. Examples:
|
|
5
|
+
|
|
6
|
+
<example>
|
|
7
|
+
Context: A founder runs `npx hstack@latest greenfield-init` against an empty repository.
|
|
8
|
+
user: "/hstack:greenfield-init"
|
|
9
|
+
assistant: "I'll walk you through 6 phases. Phase 1 (product discovery) opens first — pick a technique: Brainstorm, Forcing-Questions, or Project-Brief. Each phase ends at a commit point; you can park and resume any time. Total elapsed time is founder-paced, typically 4–8 hours of conversation across multiple sessions."
|
|
10
|
+
<commentary>
|
|
11
|
+
Greenfield is deliberately slower than brownfield because every layer is being created from elicitation rather than extracted from existing source. The Skill is structured as 6 hard-gated phases; each phase delegates to a standalone atom or subagent.
|
|
12
|
+
</commentary>
|
|
13
|
+
</example>
|
|
14
|
+
|
|
15
|
+
<example>
|
|
16
|
+
Context: Greenfield-init was started yesterday; Phases 1–3 are committed; the engineer wants to resume.
|
|
17
|
+
user: "/hstack:greenfield-init"
|
|
18
|
+
assistant: "I see Phases 1–3 at `status: current` on disk. Resuming at Phase 4 — stack-decide. Loading product-brief, data-architecture, app-architecture, and the default-stack declaration from hstack/config.yaml."
|
|
19
|
+
<commentary>
|
|
20
|
+
Idempotency is the same contract as brownfield-init: read disk state, recognize completed phases, resume at the first incomplete one. No re-interview of committed phases.
|
|
21
|
+
</commentary>
|
|
22
|
+
</example>
|
|
23
|
+
tools:
|
|
24
|
+
- Read
|
|
25
|
+
- Write
|
|
26
|
+
- Edit
|
|
27
|
+
- Grep
|
|
28
|
+
- Glob
|
|
29
|
+
- Bash
|
|
30
|
+
- Task
|
|
31
|
+
- "{{TODO-SCRIPT: hstack/scripts/validate-spec.ts — frontmatter validator}}"
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Purpose
|
|
35
|
+
|
|
36
|
+
`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.
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
## When to invoke
|
|
41
|
+
|
|
42
|
+
Invoke when:
|
|
43
|
+
|
|
44
|
+
- The consuming repo has no source code (or only an `hstack/` install and standard hidden files like `.git/`, `.gitignore`).
|
|
45
|
+
- The engineer wants discipline (ADRs, RLS posture, declared LLM/code split) baked in from line zero rather than retrofitted later.
|
|
46
|
+
|
|
47
|
+
Do NOT invoke when:
|
|
48
|
+
|
|
49
|
+
- The repo has existing source code — use `/hstack:brownfield-init` instead.
|
|
50
|
+
- 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.).
|
|
51
|
+
|
|
52
|
+
## Inputs
|
|
53
|
+
|
|
54
|
+
- No positional arguments. The Skill drives entirely from on-disk state and conversation.
|
|
55
|
+
- Optional `--resume` is implicit: every phase reads disk state at session start and continues from the first incomplete artifact.
|
|
56
|
+
|
|
57
|
+
## Preconditions
|
|
58
|
+
|
|
59
|
+
Before any work:
|
|
60
|
+
|
|
61
|
+
- 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.
|
|
62
|
+
- Verify `hstack/` exists with `CLAUDE.md`, `templates/`, `.claude/`. If missing, halt and ask the engineer to run `npx hstack@latest init`.
|
|
63
|
+
- Probe Claude Code's MCP configuration and draft `hstack/context/mcp-status.md`.
|
|
64
|
+
- If `hstack/.session-state/` contains prior greenfield-init state, confirm resumption with the engineer.
|
|
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`.
|
|
69
|
+
|
|
70
|
+
### Phase 0 — Config skeleton
|
|
71
|
+
|
|
72
|
+
Same interview as brownfield-init Mini-session 0: story store, personas store, design system (per-resource), module-to-area mapping (will be populated from app-architecture in Phase 3), adversarial-review floor, agent ledger, active MCP set. Writes `hstack/config.yaml` with `schemaVersion: 1` and `init-status: minimal-complete`. Default-stack declaration is **set to the engineer's preferences** in this phase, so Phase 4 can fast-path. Commit.
|
|
73
|
+
|
|
74
|
+
### Phase 1 — Product discovery
|
|
75
|
+
|
|
76
|
+
Invokes `/hstack:product-discovery` in elicit mode (no source documents). The atom:
|
|
77
|
+
|
|
78
|
+
- Prompts the engineer to pick a technique (Brainstorm / Forcing-Questions / Project-Brief).
|
|
79
|
+
- Runs the technique to completion, producing `hstack/context/product/product-brief.md` at `status: current`.
|
|
80
|
+
- Auto-routes to `product-manager` to refresh `vision.md`, `mvp-scope.md`, `personas/`, `glossary.md` from the brief.
|
|
81
|
+
|
|
82
|
+
Greenfield-init proceeds to Phase 2 only when the brief AND all four refreshed context docs are at `status: current`.
|
|
83
|
+
|
|
84
|
+
### Phase 2 — Data architecture
|
|
85
|
+
|
|
86
|
+
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.
|
|
87
|
+
|
|
88
|
+
### Phase 3 — App architecture
|
|
89
|
+
|
|
90
|
+
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.
|
|
91
|
+
|
|
92
|
+
### Phase 4 — Stack decisions
|
|
93
|
+
|
|
94
|
+
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.
|
|
95
|
+
|
|
96
|
+
### Phase 5 — Threat model + hardening
|
|
97
|
+
|
|
98
|
+
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.
|
|
99
|
+
|
|
100
|
+
### Phase 6 — Scaffold
|
|
101
|
+
|
|
102
|
+
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.
|
|
103
|
+
|
|
104
|
+
After Phase 6, `hstack/config.yaml`'s `init-status` advances to `complete` and the per-change workflow Skills become available.
|
|
105
|
+
|
|
106
|
+
## Outputs
|
|
107
|
+
|
|
108
|
+
- `hstack/config.yaml` at `init-status: complete`.
|
|
109
|
+
- `hstack/context/product/product-brief.md` at `current` (Phase 1).
|
|
110
|
+
- `hstack/context/vision.md`, `mvp-scope.md`, `personas/*`, `glossary.md` at `current` (Phase 1 auto-route).
|
|
111
|
+
- `hstack/context/data-architecture.md` at `current` (Phase 2).
|
|
112
|
+
- `hstack/context/app-architecture.md` at `current` plus module-spec stubs (Phase 3).
|
|
113
|
+
- `hstack/adr/ADR-*` files — rollup + per-layer (Phase 4).
|
|
114
|
+
- `hstack/context/threat-model.md`, `hardening-checklist.md`, `infrastructure.md`, `incident-runbook.md` (Phase 5).
|
|
115
|
+
- The bootstrap change-spec at `shipped` plus the actual source files, migrations, CI config, and module shells in the consuming repo (Phase 6).
|
|
116
|
+
|
|
117
|
+
## Auto-commit triggers
|
|
118
|
+
|
|
119
|
+
- `hstack/config.yaml` reaches `init-status: minimal-complete` (end of Phase 0).
|
|
120
|
+
- Each phase's terminal artifact reaches `status: current` (end of Phases 1–5).
|
|
121
|
+
- Each phase of the bootstrap change-spec's plan completes (Phase 6 per-phase commits).
|
|
122
|
+
- The bootstrap change-spec reaches `shipped` (end of Phase 6).
|
|
123
|
+
- `hstack/config.yaml`'s `init-status` advances to `complete` (after Phase 6 ships).
|
|
124
|
+
|
|
125
|
+
## Idempotency contract
|
|
126
|
+
|
|
127
|
+
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.
|
|
128
|
+
|
|
129
|
+
## Stop conditions
|
|
130
|
+
|
|
131
|
+
Beyond the kernel's general stop conditions, this Skill halts when:
|
|
132
|
+
|
|
133
|
+
- The repo is not empty at session start.
|
|
134
|
+
- 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.
|
|
135
|
+
- 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.
|
|
136
|
+
- The engineer signals end-of-session — persist state, exit cleanly.
|
|
137
|
+
|
|
138
|
+
## Failure modes
|
|
139
|
+
|
|
140
|
+
- **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.
|
|
141
|
+
- **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`.
|
|
142
|
+
- **Stack-architect contradicts data-architecture's Postgres assumption.** Phase 4 halts and surfaces; the engineer either revises data-architecture or revises the stack choice.
|
|
143
|
+
|
|
144
|
+
## Anti-patterns
|
|
145
|
+
|
|
146
|
+
- Never invoke greenfield-init against a non-empty repo. The contract assumes elicit-mode atoms throughout; running against existing source produces incoherent artifacts.
|
|
147
|
+
- Never collapse the six phases into one long block. The phase structure is the resumability contract AND the gate-discipline contract.
|
|
148
|
+
- Never skip Phase 5 (threat-model + hardening) to get to Phase 6 faster. Bootstrap inherits the security posture; scaffolding without it produces a repo with implicit-not-explicit hardening.
|
|
149
|
+
- Never bypass the bidirectional drift recovery. When a downstream phase finds an upstream gap, the upstream MUST be refreshed before downstream resumes; silent override produces contradictions.
|
|
150
|
+
- Never advance `init-status: complete` while any phase artifact is below `current` or while the bootstrap change-spec is below `shipped`.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hstack-product-discovery
|
|
3
|
+
description: |
|
|
4
|
+
Use this skill when the engineer wants to produce or refresh `hstack/context/product/product-brief.md` — the durable thinking artifact that captures the project's product reasoning. The Skill is Phase 1 of `/hstack:greenfield-init` (elicit mode), an optional enrichment phase of `/hstack:brownfield-init` when source docs are thin (extract mode), or a standalone atom for retroactive brief authoring. It invokes the `product-discovery` subagent in one of three engineer-chosen techniques (Brainstorm, Forcing-Questions, Project-Brief), produces a single synthesis at `hstack/context/product/product-brief.md`, and auto-routes to `product-manager` for downstream context-doc refresh. Examples:
|
|
5
|
+
|
|
6
|
+
<example>
|
|
7
|
+
Context: Phase 1 of greenfield-init opens. The engineer types `/hstack:product-discovery` directly.
|
|
8
|
+
user: "/hstack:product-discovery"
|
|
9
|
+
assistant: "Pick a technique: [1] Brainstorm — facilitated ideation; [2] Forcing-Questions — reframe-driven probing (Gstack-style); [3] Project-Brief — structured walk. Default mode is elicit (no source docs). The brief lives at hstack/context/product/product-brief.md and is parkable any time."
|
|
10
|
+
<commentary>
|
|
11
|
+
The technique choice is the engineer's, not the agent's. Each technique's script is in hstack/templates/discovery/<technique>.md. Mid-technique switching is allowed but halts to confirm — mixing technique outputs produces an incoherent brief.
|
|
12
|
+
</commentary>
|
|
13
|
+
</example>
|
|
14
|
+
|
|
15
|
+
<example>
|
|
16
|
+
Context: A brownfield repo's brief never landed during init; /hstack:help flagged the missing artifact.
|
|
17
|
+
user: "/hstack:product-discovery --mode extract"
|
|
18
|
+
assistant: "Extract mode. I'll read existing vision.md, README, and any product docs you point me at, propose the brief sections from what I find, and walk you through confirm-or-revise. The three required forcing prompts still run — extract mode does not bypass blind-spot probes."
|
|
19
|
+
<commentary>
|
|
20
|
+
Extract+confirm mode is how brownfield enrichment works. The unification of modes is load-bearing: the brief produced is the same artifact whether elicited or extracted, so downstream phases load it identically.
|
|
21
|
+
</commentary>
|
|
22
|
+
</example>
|
|
23
|
+
tools:
|
|
24
|
+
- Read
|
|
25
|
+
- Write
|
|
26
|
+
- Edit
|
|
27
|
+
- Grep
|
|
28
|
+
- Glob
|
|
29
|
+
- Bash
|
|
30
|
+
- Task
|
|
31
|
+
- "{{TODO-SCRIPT: hstack/scripts/validate-spec.ts — frontmatter validator}}"
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Purpose
|
|
35
|
+
|
|
36
|
+
`hstack-product-discovery` is the atom that produces `hstack/context/product/product-brief.md` via the `product-discovery` subagent. It is the canonical authoring path for the brief; the brief never lands via a generic spec-author interview.
|
|
37
|
+
|
|
38
|
+
## When to invoke
|
|
39
|
+
|
|
40
|
+
- Phase 1 of `/hstack:greenfield-init` (elicit mode, no source).
|
|
41
|
+
- Optional enrichment within `/hstack:brownfield-init` when existing product docs are thin and the engineer wants the deeper reframe-style brief.
|
|
42
|
+
- Standalone via `/hstack:product-discovery [--mode extract|elicit] [--section <name>]` for retroactive brief authoring on any repo.
|
|
43
|
+
|
|
44
|
+
## Inputs
|
|
45
|
+
|
|
46
|
+
- `--mode extract | elicit` — defaults: `elicit` if no source docs are reachable; `extract` if a `product-brief.md` exists or the engineer points at source documents.
|
|
47
|
+
- `--section <name>` — optional, fast-jumps to a specific section for refresh. Re-runs the end-of-atom check across all sections before commit.
|
|
48
|
+
|
|
49
|
+
## Preconditions
|
|
50
|
+
|
|
51
|
+
- `hstack/config.yaml` exists and `init-status` is at least `minimal-complete` — the atom does not run standalone until config exists.
|
|
52
|
+
- `hstack/CLAUDE.md` and `hstack/templates/product-brief.md` are present.
|
|
53
|
+
- `hstack/templates/discovery/{brainstorm,forcing-questions,project-brief}.md` are present.
|
|
54
|
+
- In extract mode, at least one source document must be reachable; otherwise halt and ask the engineer to either supply source pointers or fall back to elicit mode.
|
|
55
|
+
|
|
56
|
+
## Orchestration steps
|
|
57
|
+
|
|
58
|
+
1. **Detect mode.** Read disk state. If `hstack/context/product/product-brief.md` exists at `status: current` and no `--section` flag, this is a refresh confirmation — print summary and exit unless engineer opts into full re-interview.
|
|
59
|
+
2. **Pick technique** (elicit mode only). Prompt the engineer to choose Brainstorm / Forcing-Questions / Project-Brief. Persist the choice as `technique-used` in the brief frontmatter.
|
|
60
|
+
3. **Invoke `product-discovery` subagent.** Via the Task tool with `subagent_type: product-discovery`. Pass mode, technique, optional section, and the canonical session-start context (kernel, template, technique script, source docs in extract mode).
|
|
61
|
+
4. **Walk sections.** The subagent runs the chosen technique's script and walks the brief sections with confirmation gates. Each confirmed section writes to disk and auto-commits.
|
|
62
|
+
5. **Run forcing prompts.** The three required reframes (Who pays? What's the wedge? What would falsify this?) fire before terminal state regardless of technique.
|
|
63
|
+
6. **Auto-route at terminal state.** When the brief reaches `status: current`, the Skill prints the auto-route message (with alternative-path commands) and hands off to `product-manager` via the Task tool with `subagent_type: product-manager` to refresh `vision.md`, `mvp-scope.md`, `personas/`, `glossary.md`. If the engineer types `skip-routing`, the Skill commits the brief and exits cleanly — downstream Skills will halt on missing context docs.
|
|
64
|
+
|
|
65
|
+
## Outputs
|
|
66
|
+
|
|
67
|
+
- `hstack/context/product/product-brief.md` at `status: current`.
|
|
68
|
+
- `hstack/.session-state/<session-id>.yaml` (transient).
|
|
69
|
+
- Via auto-route: `vision.md`, `mvp-scope.md`, `personas/*`, `glossary.md` refreshed (unless skip-routing).
|
|
70
|
+
|
|
71
|
+
## Auto-commit triggers
|
|
72
|
+
|
|
73
|
+
- Each confirmed section writes immediately and auto-commits.
|
|
74
|
+
- Brief reaches `status: current` → final commit with the auto-route message in the body.
|
|
75
|
+
- Downstream refreshes by `product-manager` each auto-commit per the product-manager subagent's contract.
|
|
76
|
+
|
|
77
|
+
## Idempotency contract
|
|
78
|
+
|
|
79
|
+
- Brief at `current` + no `--section` + no `--force`: print summary, exit no-op.
|
|
80
|
+
- Brief at `draft` or partial: read disk + session-state, resume at next non-confirmed section.
|
|
81
|
+
- Brief at `needs-refresh` (flipped by `/hstack:configure` because upstream changed): walk all sections in confirm-or-revise mode.
|
|
82
|
+
|
|
83
|
+
## Stop conditions
|
|
84
|
+
|
|
85
|
+
- A required source document in extract mode is unreachable.
|
|
86
|
+
- Forcing-prompt answer is too vague after one re-ask. The subagent halts with `HSTACK-HALT: reason=ambiguous-spec` or `missing-context`.
|
|
87
|
+
- Mid-technique switch requested.
|
|
88
|
+
- Engineer signals end-of-session.
|
|
89
|
+
- Downstream auto-route fails (e.g., `product-manager` cannot reach the configured personas store). The Skill surfaces the failure; the brief stays at `current`, downstream context docs stay at their prior status until the engineer resolves.
|
|
90
|
+
|
|
91
|
+
## Failure modes
|
|
92
|
+
|
|
93
|
+
- **Subagent unreachable.** Persist session state; retry later.
|
|
94
|
+
- **Auto-route partial failure.** If `product-manager` succeeds on vision but fails on personas (e.g., Notion MCP unreachable), the partial state is on disk; re-running auto-route via `/hstack:configure personas --from-brief` recovers.
|
|
95
|
+
|
|
96
|
+
## Anti-patterns
|
|
97
|
+
|
|
98
|
+
- Never write to `vision.md`, `mvp-scope.md`, `personas/`, `glossary.md` from this Skill directly. Those refreshes belong to `product-manager` via the auto-route.
|
|
99
|
+
- Never bypass the three required forcing prompts, even in Project-Brief mode (the lightest touch).
|
|
100
|
+
- Never silently switch techniques mid-session.
|
|
101
|
+
- Never advance the brief to `current` while the Explicitly NOT section has fewer than two bullets.
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hstack-scaffold
|
|
3
|
+
description: |
|
|
4
|
+
Use this skill as Phase 6 of `/hstack:greenfield-init` to bootstrap the consuming repository from empty to bootable. The Skill generates a **bootstrap change-spec** from `hstack/templates/bootstrap.md` (a change-spec variant with `area: bootstrap`, `surfaces: [infra]`), enumerates `in-scope` explicitly from the upstream artifacts (Module Map from app-architecture, Migration Sketches from data-architecture, stack ADRs from Phase 4), runs `data-review` and `security-review` in `--mode foundational` against the proposed posture, then drives the implementer through the planner's phased execution to produce the actual source files, migrations, CI config, and module shells. This is the only Skill (besides `/hstack:greenfield-init` which composes it) that ends with executable code landing in the consuming repo as part of init. Examples:
|
|
5
|
+
|
|
6
|
+
<example>
|
|
7
|
+
Context: Phases 1–5 of greenfield-init are complete; all context artifacts and stack ADRs are at terminal status.
|
|
8
|
+
user: "/hstack:scaffold"
|
|
9
|
+
assistant: "Generating bootstrap change-spec at hstack/specs/changes/<YYYY-MM>-bootstrap/spec.md. in-scope enumerated from app-architecture Section 1 (module shells) + data-architecture Section 5 (migration files) + standard infra files (package.json, tsconfig, CI workflow). Running foundational-mode security-review and data-review against the proposed posture. Then planner phases → implementer phase-by-phase → verifier. At terminal state the repo is bootable; build and test commands exit 0."
|
|
10
|
+
<commentary>
|
|
11
|
+
Scaffold's distinct property: it scores against a proposed posture (no diff yet) using --mode foundational on security-reviewer and data-specialist. After the bootstrap ships, those reviewers go back to per-change diff-scoring mode.
|
|
12
|
+
</commentary>
|
|
13
|
+
</example>
|
|
14
|
+
|
|
15
|
+
<example>
|
|
16
|
+
Context: Scaffold was started two days ago; phase-3 (module shells) landed but phase-4 (CI workflow) hit a verifier failure.
|
|
17
|
+
user: "/hstack:scaffold"
|
|
18
|
+
assistant: "Resuming the bootstrap change-spec. plan.md shows phase-3 complete; phase-4 had verifier discrepancies. Re-running /hstack:verify on phase-4 outputs to identify what failed; then either re-implementing phase-4 (if the implementer's output was incorrect) or revising the plan (if the expectation was wrong)."
|
|
19
|
+
<commentary>
|
|
20
|
+
Scaffold inherits the standard per-change idempotency contract because bootstrap IS a change-spec. The planner and implementer's existing resume semantics apply unchanged.
|
|
21
|
+
</commentary>
|
|
22
|
+
</example>
|
|
23
|
+
tools:
|
|
24
|
+
- Read
|
|
25
|
+
- Write
|
|
26
|
+
- Edit
|
|
27
|
+
- Grep
|
|
28
|
+
- Glob
|
|
29
|
+
- Bash
|
|
30
|
+
- Task
|
|
31
|
+
- "{{TODO-SKILL: /hstack:change-new — scaffolds the bootstrap change-spec folder}}"
|
|
32
|
+
- "{{TODO-SKILL: /hstack:test-plan — produces test-plan.md for the bootstrap}}"
|
|
33
|
+
- "{{TODO-SKILL: /hstack:security-review — invoked in --mode foundational}}"
|
|
34
|
+
- "{{TODO-SKILL: /hstack:data-review — invoked in --mode foundational}}"
|
|
35
|
+
- "{{TODO-SKILL: /hstack:change-plan — invokes planner}}"
|
|
36
|
+
- "{{TODO-SKILL: /hstack:implement — invokes implementer phase-by-phase}}"
|
|
37
|
+
- "{{TODO-SKILL: /hstack:verify — invokes verifier after the last implement phase}}"
|
|
38
|
+
- "{{TODO-SKILL: /hstack:adversarial-review — runs in a fresh session for the bootstrap}}"
|
|
39
|
+
- "{{TODO-SKILL: /hstack:ship — final scorecard; bootstrap ships with a PR like any change}}"
|
|
40
|
+
- "{{TODO-SKILL: /hstack:finalize — post-merge cleanup}}"
|
|
41
|
+
- "{{TODO-SCRIPT: hstack/scripts/validate-spec.ts — frontmatter validator}}"
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Purpose
|
|
45
|
+
|
|
46
|
+
`hstack-scaffold` is the Phase 6 execution Skill of `/hstack:greenfield-init`. It bridges discovery to working code: the upstream phases (product-brief, data-architecture, app-architecture, stack ADRs, threat-model, hardening-checklist, infrastructure, incident-runbook) declare the design; this Skill executes it. The execution path is the **standard per-change workflow** applied to a one-off change-spec with `area: bootstrap` — there is no special-cased "bootstrap workflow"; the kernel's per-change discipline applies in full, with two adjustments: (a) `security-review` and `data-review` run in `--mode foundational` (score against proposed posture, not diff), and (b) the change-spec uses the `hstack/templates/bootstrap.md` variant.
|
|
47
|
+
|
|
48
|
+
## When to invoke
|
|
49
|
+
|
|
50
|
+
- Phase 6 of `/hstack:greenfield-init` (the orchestrator calls this Skill after Phase 5 terminates).
|
|
51
|
+
- Standalone is **not** supported in v1 — scaffold runs once per project lifetime and assumes the full upstream discovery layer is at terminal status. Standalone invocation halts with a directive to run `/hstack:greenfield-init` instead.
|
|
52
|
+
|
|
53
|
+
## Inputs
|
|
54
|
+
|
|
55
|
+
- No positional arguments. The Skill reads upstream artifacts and the bootstrap-change-spec scaffolding from disk.
|
|
56
|
+
|
|
57
|
+
## Preconditions
|
|
58
|
+
|
|
59
|
+
- All of the following at `status: current`:
|
|
60
|
+
- `hstack/context/product/product-brief.md`
|
|
61
|
+
- `hstack/context/data-architecture.md`
|
|
62
|
+
- `hstack/context/app-architecture.md`
|
|
63
|
+
- `hstack/context/threat-model.md`, `hardening-checklist.md`, `infrastructure.md`, `incident-runbook.md`
|
|
64
|
+
- `hstack/context/tech-stack.md`, `ci-cd.md`
|
|
65
|
+
- Stack ADRs from Phase 4 at `status: accepted`.
|
|
66
|
+
- `hstack/templates/bootstrap.md` present.
|
|
67
|
+
- The consuming repo has no source code beyond `hstack/` and standard hidden files. If non-empty, halt — scaffold is a greenfield-only operation.
|
|
68
|
+
|
|
69
|
+
## Orchestration steps
|
|
70
|
+
|
|
71
|
+
1. **Generate the bootstrap change-spec.** Invoke `/hstack:change-new` with `area: bootstrap` and a derived id (`<YYYY-MM>-bootstrap`). The change-spec folder is scaffolded with `spec.md` pre-populated from `hstack/templates/bootstrap.md`. The Skill then performs mechanical writes to populate:
|
|
72
|
+
- `in-scope`: enumerated from app-architecture Module Map (one entry per module directory) + data-architecture Migration Sketches (one entry per `m_NNNN_*.sql`) + standard infra files (`package.json`, `tsconfig.json`, build config, CI workflow path, etc.). The enumeration is explicit; `["."]` is not permitted.
|
|
73
|
+
- `related-adrs`: the full list of Phase 4 stack ADRs.
|
|
74
|
+
- `threat-model-delta: true`.
|
|
75
|
+
The change-spec lands at `status: draft` after this step; `spec-author` walks it to `ready-to-plan` via a confirmation interview (the engineer reviews the enumerated `in-scope` and confirms or revises).
|
|
76
|
+
|
|
77
|
+
2. **Test plan.** Invoke `/hstack:test-plan` for the bootstrap. The test-strategist produces `test-plan.md` covering build / lint / typecheck / migration / RLS-enforcement smoke tests. Bootstrap test plans bias toward operational-correctness assertions (build exits 0, migrations apply cleanly, RLS denies cross-tenant access) rather than feature behavior.
|
|
78
|
+
|
|
79
|
+
3. **Foundational-mode security-review.** Invoke `/hstack:security-review` with the security-reviewer in `--mode foundational`. The reviewer scores against the proposed posture (threat-model + hardening-checklist + the stack ADRs) rather than against a diff. Output: `security-review.md` at `status: passed` or `concerns-noted` per the standard contract.
|
|
80
|
+
|
|
81
|
+
4. **Foundational-mode data-review.** Invoke `/hstack:data-review` with the data-specialist in `--mode foundational`. The reviewer scores the migration sketches from data-architecture Section 5 against RLS coverage rules (DR-02) and tenant-isolation rules (DR-03), scoring proposed-DDL rather than live schema. Output: `data-review.md` at `status: passed` or `concerns-noted`.
|
|
82
|
+
|
|
83
|
+
5. **Plan.** Invoke `/hstack:change-plan`. The planner produces `plan.md` with atomic phases. A typical bootstrap plan sequence:
|
|
84
|
+
- Phase 1: install dependencies (`npm install` / `pnpm install` / equivalent).
|
|
85
|
+
- Phase 2: initialize framework scaffold (e.g., Next.js boilerplate, tsconfig, eslint config).
|
|
86
|
+
- Phase 3: land migration files in `supabase/migrations/` per data-architecture Section 5.
|
|
87
|
+
- Phase 4: scaffold module shells per app-architecture Section 1 (one directory per module with index.ts plus any per-module config).
|
|
88
|
+
- Phase 5: wire CI workflow per `ci-cd.md`.
|
|
89
|
+
- Phase 6: smoke tests (build, lint, typecheck, run RLS-denial test).
|
|
90
|
+
Each phase declares its verifier expectations explicitly.
|
|
91
|
+
|
|
92
|
+
6. **Implement.** Invoke `/hstack:implement <bootstrap-id> <phase-id>` once per plan phase. Each invocation runs the implementer scope-locked to the `in-scope` enumeration. The implementer creates files (no edits — bootstrap is greenfield) and auto-commits at phase completion.
|
|
93
|
+
|
|
94
|
+
7. **Verify.** Invoke `/hstack:verify` after the last implement phase. The verifier runs the canonical commands from `ci-cd.md` and compares against per-phase Verifier Expectations.
|
|
95
|
+
|
|
96
|
+
8. **Adversarial review.** Direct the engineer to open a fresh Claude Code session and run `/hstack:adversarial-review`. Bootstrap inherits the standard fresh-session contract (kernel rule).
|
|
97
|
+
|
|
98
|
+
9. **Ship + finalize.** After adversarial review reaches `findings-resolved`, `/hstack:ship` produces the PR description. The engineer opens the PR, gets it merged, then runs `/hstack:finalize` to advance the bootstrap change-spec from `ready-to-ship` to `shipped` (no tech-debt resolution applies for bootstrap). `hstack/config.yaml`'s `init-status` flips to `complete` in the same finalize commit.
|
|
99
|
+
|
|
100
|
+
## Outputs
|
|
101
|
+
|
|
102
|
+
- A complete bootstrap change-spec folder at `hstack/specs/changes/<YYYY-MM>-bootstrap/` with `spec.md`, `test-plan.md`, `security-review.md`, `data-review.md`, `plan.md`, `verification.md`, `adversarial-review.md`, `pr-body.md`.
|
|
103
|
+
- The consuming repo's actual source files, migrations, CI workflow, build config, and per-module shells.
|
|
104
|
+
- `hstack/config.yaml` at `init-status: complete`.
|
|
105
|
+
|
|
106
|
+
## Auto-commit triggers
|
|
107
|
+
|
|
108
|
+
- Bootstrap change-spec advances through standard status transitions (`draft → ready-to-plan → ready-for-implementation → ready-for-review → ready-to-ship → shipped`); each transition auto-commits per the kernel.
|
|
109
|
+
- Each plan phase auto-commits when implementer completes it.
|
|
110
|
+
- `hstack/config.yaml` flips to `init-status: complete` in the finalize commit alongside the change-spec's advance to `shipped`.
|
|
111
|
+
|
|
112
|
+
## Idempotency contract
|
|
113
|
+
|
|
114
|
+
Scaffold inherits the standard per-change idempotency contract because bootstrap IS a change-spec:
|
|
115
|
+
|
|
116
|
+
- Re-running `/hstack:scaffold` reads the bootstrap change-spec's status and resumes at the next non-terminal artifact.
|
|
117
|
+
- Plan phases that have committed are skipped; only the first incomplete phase runs.
|
|
118
|
+
- A failed verifier produces `verification.md` at `status: failed-with-discrepancies`; re-running `/hstack:scaffold` does NOT silently retry — it surfaces the discrepancies and waits for the engineer to either re-implement the failing phase or revise the plan.
|
|
119
|
+
|
|
120
|
+
## Stop conditions
|
|
121
|
+
|
|
122
|
+
- Any upstream artifact at non-terminal status.
|
|
123
|
+
- The consuming repo is non-empty at scaffold start.
|
|
124
|
+
- Foundational-mode security-review or data-review lands at `concerns-noted` with unresolved CONCERNS. The engineer either resolves the concerns (revises threat-model / hardening / migration sketches) or accepts them via the standard concerns-acknowledgement path.
|
|
125
|
+
- Implementer halts mid-phase (file already exists outside in-scope, verifier expectation unsatisfiable, etc.). Standard implementer halt semantics apply.
|
|
126
|
+
- The engineer signals end-of-session — the standard per-change idempotency picks up on resume.
|
|
127
|
+
|
|
128
|
+
## Failure modes
|
|
129
|
+
|
|
130
|
+
- **Foundational-mode reviewer halts.** Foundational mode is honor-system in v1 — the reviewer is asked to score a proposed posture, not a diff. If the reviewer cannot honestly score (e.g., the threat-model is too thin), the reviewer halts with `HSTACK-HALT: reason=upstream-non-terminal` and routes the engineer back to `/hstack:configure threat-model`.
|
|
131
|
+
- **Implementer scope-lock fires on a path NOT in the enumerated in-scope.** This is a scaffold-spec gap, not an implementer bug. The Skill halts; the engineer revises `in-scope` (mechanical edit by the engineer per the kernel's scope-amendment path) and re-runs `/hstack:implement` for the affected phase.
|
|
132
|
+
- **CI runs from `ci-cd.md` haven't been authored yet for fresh projects.** The bootstrap change-spec's test-plan must define the canonical commands; otherwise verifier has nothing to run. The Skill checks this at preconditions.
|
|
133
|
+
|
|
134
|
+
## Anti-patterns
|
|
135
|
+
|
|
136
|
+
- Never run scaffold against a non-empty repo. Scaffold is greenfield-only; mixing modes produces incoherent in-scope enumeration.
|
|
137
|
+
- Never set `in-scope: ["."]`. Explicit file enumeration is the contract; the implementer's scope-lock does meaningful work only against an explicit list.
|
|
138
|
+
- Never skip foundational-mode security-review / data-review to "save time." Those gates are the v1 substrate for getting hardening and RLS posture right from line zero.
|
|
139
|
+
- Never bypass adversarial-review for the bootstrap. Bootstrap inherits the fresh-session contract from the kernel; ship without it is forbidden.
|
|
140
|
+
- Never flip `init-status: complete` while the bootstrap change-spec is below `shipped`.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hstack-stack-decide
|
|
3
|
+
description: |
|
|
4
|
+
Use this skill when the engineer wants to decide stack choices and capture each as an ADR. The Skill is Phase 4 of `/hstack:greenfield-init`, the stack-decision step of `/hstack:brownfield-init` when stack ADRs are missing, or a standalone atom for mid-project layer swaps (replacing auth, switching the database, rotating the hosting provider). It invokes the `stack-architect` subagent for the technical-discovery interview, then routes each layer's decision through `/hstack:adr-new` (which invokes `spec-author`) with pre-populated Context / Decision / Alternatives. The Consequences challenge prompt fires fresh on every ADR regardless of pre-population. Examples:
|
|
5
|
+
|
|
6
|
+
<example>
|
|
7
|
+
Context: Phase 4 of greenfield-init opens after app-architecture is current. hstack/config.yaml's default-stack declaration is set.
|
|
8
|
+
user: "/hstack:stack-decide"
|
|
9
|
+
assistant: "Loading brief, data-architecture, app-architecture, default-stack declaration. Defaults cover framework / database / hosting / auth — I'll fast-path those to a single rollup ADR. Observability is undeclared in config; I'll deep-dive on that layer. Expected: 2 ADRs (rollup + observability) routed through spec-author."
|
|
10
|
+
<commentary>
|
|
11
|
+
Default-stack fast-path collapses 80% of the interview when defaults match. Only layers explicitly flagged for deep-dive or undeclared in config get the full constraint interview.
|
|
12
|
+
</commentary>
|
|
13
|
+
</example>
|
|
14
|
+
|
|
15
|
+
<example>
|
|
16
|
+
Context: Mid-project, the team decides to replace Supabase Auth with Clerk.
|
|
17
|
+
user: "/hstack:stack-decide --layer auth"
|
|
18
|
+
assistant: "Standalone mode. Loading the existing auth ADR, threat-model, hardening-checklist. Constraint interview first (engineering capacity, scale horizon, compliance posture), then surfacing 2–3 Clerk alternatives, then routing to spec-author for the new ADR with supersedes: [<predecessor>]. The predecessor's reciprocal superseded-by writes atomically with the new ADR."
|
|
19
|
+
<commentary>
|
|
20
|
+
Standalone mode runs against a single layer. The supersedes / superseded-by reciprocal pair is mandatory; spec-author handles both halves atomically per the kernel's reciprocal-pair atomicity rule.
|
|
21
|
+
</commentary>
|
|
22
|
+
</example>
|
|
23
|
+
tools:
|
|
24
|
+
- Read
|
|
25
|
+
- Write
|
|
26
|
+
- Edit
|
|
27
|
+
- Grep
|
|
28
|
+
- Glob
|
|
29
|
+
- Bash
|
|
30
|
+
- Task
|
|
31
|
+
- "{{TODO-SKILL: /hstack:adr-new — invoked via spec-author handoff for ADR authoring}}"
|
|
32
|
+
- "{{TODO-SKILL: /hstack:research — invoked for unfamiliar-territory deep-dives}}"
|
|
33
|
+
- "{{TODO-SCRIPT: hstack/scripts/validate-spec.ts — frontmatter validator}}"
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Purpose
|
|
37
|
+
|
|
38
|
+
`hstack-stack-decide` is the atom that produces stack ADRs via the `stack-architect` subagent. It does NOT write to `hstack/adr/` directly; the kernel rule reserves ADR authoring for `spec-author`. Stack-architect produces pre-populated Context / Decision / Alternatives content; spec-author runs the Nygard interview in confirm-or-revise mode with the Consequences challenge firing fresh.
|
|
39
|
+
|
|
40
|
+
## When to invoke
|
|
41
|
+
|
|
42
|
+
- Phase 4 of `/hstack:greenfield-init`.
|
|
43
|
+
- The stack-decision step of `/hstack:brownfield-init` when no stack ADRs exist.
|
|
44
|
+
- Standalone via `/hstack:stack-decide [--layer <name>]` for mid-project layer swaps.
|
|
45
|
+
|
|
46
|
+
## Inputs
|
|
47
|
+
|
|
48
|
+
- `--layer <name>` — optional, standalone mode. Runs against a single declared layer (`framework | database | auth | hosting | observability | <custom>`). In greenfield/brownfield mode, the Skill walks all declared layers.
|
|
49
|
+
|
|
50
|
+
## Preconditions
|
|
51
|
+
|
|
52
|
+
- `hstack/config.yaml` at `init-status: minimal-complete` or later, with the default-stack declaration present (set in greenfield-init Phase 0 or via `/hstack:configure default-stack`).
|
|
53
|
+
- `hstack/context/app-architecture.md` at `status: current` (greenfield/brownfield mode). In standalone mode, the atom may run without app-architecture only if the layer being swapped doesn't depend on architecture decisions (rare).
|
|
54
|
+
- `hstack/templates/adr.md` present.
|
|
55
|
+
- Existing ADRs read at session start to set the next sequential ADR id and detect supersession candidates.
|
|
56
|
+
|
|
57
|
+
## Orchestration steps
|
|
58
|
+
|
|
59
|
+
1. **Detect mode.** Greenfield/brownfield: walk all declared layers. Standalone: run against the named `--layer`.
|
|
60
|
+
2. **Invoke `stack-architect` subagent.** Via the Task tool with `subagent_type: stack-architect`. Pass mode, layer scope, the canonical session-start context.
|
|
61
|
+
3. **For each layer (greenfield/brownfield mode):**
|
|
62
|
+
- **Default check.** stack-architect reads `hstack/config.yaml`'s declared default for this layer.
|
|
63
|
+
- **Fast-path confirmation.** If the engineer accepts the default, the layer is added to a pending rollup ADR.
|
|
64
|
+
- **Deep-dive.** If the engineer chooses to deep-dive, stack-architect runs the constraint interview (scale, ops capacity, compliance, AI-native specifics), surfaces 2–3 candidate options with tradeoff axes, and lets the engineer choose.
|
|
65
|
+
- **ADR handoff.** stack-architect prepares the Context / Decision / Alternatives sections, then invokes `/hstack:adr-new` via the Task tool (which invokes `spec-author`). spec-author runs confirm-or-revise on the prepared content. The Consequences challenge prompt fires fresh per the kernel's Nygard challenge rule.
|
|
66
|
+
4. **Rollup ADR (greenfield/brownfield mode).** After per-layer ADRs land, the Skill produces one rollup ADR via `/hstack:adr-new` naming every defaulted layer with the constraint check that confirmed each.
|
|
67
|
+
5. **Standalone mode** runs the same constraint interview + spec-author handoff for the single `--layer`. The new ADR carries `supersedes: [<predecessor>]`; the predecessor gets the reciprocal `superseded-by` written atomically by spec-author.
|
|
68
|
+
6. **Config update (optional).** After ADRs land, the Skill asks the engineer whether any layer's choice diverged from the prior default in a way they want project-wide. If yes, the Skill proposes a `hstack/config.yaml` update via the proposed-diff preview + Y/n gate, then commits the config update as a mechanical operation.
|
|
69
|
+
|
|
70
|
+
## Outputs
|
|
71
|
+
|
|
72
|
+
- One rollup ADR plus N per-layer ADRs (greenfield/brownfield mode), or one new ADR with `supersedes` (standalone mode), all at `status: accepted`.
|
|
73
|
+
- Updated `hstack/config.yaml` default-stack declaration (optional, only if changed).
|
|
74
|
+
- `hstack/.session-state/<session-id>.yaml` (transient).
|
|
75
|
+
|
|
76
|
+
## Auto-commit triggers
|
|
77
|
+
|
|
78
|
+
- Each ADR commits via `/hstack:adr-new`'s standard pattern (single auto-commit per ADR).
|
|
79
|
+
- Standalone mode's supersedes / superseded-by reciprocal pair commits atomically in one git commit per the kernel.
|
|
80
|
+
- Config update (if any) commits as a separate mechanical operation.
|
|
81
|
+
|
|
82
|
+
## Idempotency contract
|
|
83
|
+
|
|
84
|
+
- If a layer's current ADR is at `accepted` and the engineer's constraints + default-stack haven't changed: skip the layer.
|
|
85
|
+
- If a deep-dive interview was started but no ADR landed (engineer parked mid-interview): resume the interview from session-state.
|
|
86
|
+
- Re-running standalone mode for a layer whose ADR is already at `accepted` and no supersession is requested: print summary, exit no-op.
|
|
87
|
+
|
|
88
|
+
## Stop conditions
|
|
89
|
+
|
|
90
|
+
- App-architecture at non-terminal status (greenfield/brownfield mode).
|
|
91
|
+
- A chosen option contradicts an upstream invariant (e.g., DB without RLS conflicts with `data-architecture.md`'s tenant-scoped posture). Halt with `HSTACK-HALT: reason=upstream-drift`.
|
|
92
|
+
- A research session is needed (unfamiliar territory) but the engineer has not authorized `/hstack:research`.
|
|
93
|
+
- Standalone mode supersedes an ADR at a non-accepted status.
|
|
94
|
+
- The Postgres assumption in `data-architecture.md` is being contradicted. Halt and surface.
|
|
95
|
+
|
|
96
|
+
## Failure modes
|
|
97
|
+
|
|
98
|
+
- **spec-author handoff fails partway** (e.g., Consequences challenge produces a finding the engineer doesn't accept). The pending ADR sits at `draft`; the engineer either revises or routes through `/hstack:configure adr-author <id>` per spec-author's recovery path.
|
|
99
|
+
- **Research subagent unavailable when needed.** Persist constraint interview state; resume later.
|
|
100
|
+
|
|
101
|
+
## Anti-patterns
|
|
102
|
+
|
|
103
|
+
- Never write to `hstack/adr/` from this Skill directly. ADR authoring is `spec-author`'s exclusive ownership per kernel rule.
|
|
104
|
+
- Never let pre-population skip the Consequences challenge prompt. Pre-population covers Context / Decision / Alternatives; Consequences fires fresh.
|
|
105
|
+
- Never propose stack options before constraints are concrete.
|
|
106
|
+
- Never bypass the upstream check (app-architecture must be `current` in greenfield/brownfield mode).
|
|
107
|
+
- Never silently honor a non-Postgres DB choice when `data-architecture.md`'s `assumes-database: postgres` says otherwise. Halt and surface.
|
|
108
|
+
- Never split the supersedes / superseded-by reciprocal pair across two commits in standalone mode.
|