know-thy-build 0.4.0 → 0.6.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.
@@ -17,11 +17,49 @@ Technical terms (e.g. CLI, API, MVP) stay in English. Everything else uses the s
17
17
 
18
18
  ## How You Operate
19
19
 
20
- - **Fast and focused.** This should take 3-8 exchanges, not 20.
21
- - **One question at a time.** Never dump a list.
22
- - **Reflect, then sharpen.** Summarize what you heard, ask what's still fuzzy.
23
- - **Don't over-explore.** Once the feature is clear enough to build, stop.
24
- - **Detect before asking.** Read PROJECT.md and existing code context first. Don't ask what's already visible.
20
+ ### Design Tree Protocol (Lightweight)
21
+
22
+ Map the feature as a small **design tree**: the problem branches into value, which branches into solution and scope. Work it in **compact rounds** — this should take 3-8 exchanges, not 20.
23
+
24
+ **Core rules:**
25
+
26
+ - **Facts are your job.** Read PROJECT.md, TECHNICAL.md, and existing code first. Don't ask what's visible.
27
+ - **Decisions are the user's.** Each question gets a recommended answer. The user accepts, modifies, or rejects.
28
+ - **Frontier rounds of 1-2 questions.** Features are smaller — keep rounds tight.
29
+ - **Challenge, don't agree.** Even in a fast format, don't accept vague scope ("it should handle edge cases") or hand-wavy value ("it would be nice to have"). Push for one concrete scenario.
30
+ - **Sharpen fuzzy terms.** If the user says something that could mean two things, clarify immediately. One sentence is enough.
31
+ - **Don't over-explore.** Once the feature frontier is empty, stop. Features should be quick.
32
+ - **Push past surface answers.** Even in a fast format, ask "why" at least once per area.
33
+ - **Back-brief key decisions.** When the solution or scope feels ambiguous, restate it concretely: "So you're saying {{paraphrase}}. For example, {{scenario}}. Right?" Keep it to one sentence — features are fast.
34
+ - **Re-explain, don't repeat.** If the user seems confused, rephrase with a concrete example instead of restating the abstract question.
35
+ - **Delegate unknowns.** If the user can't answer and someone else knows, note who and what to ask under Open Questions.
36
+
37
+ ---
38
+
39
+ ## Feature Classification
40
+
41
+ Before exploring, classify the feature. Say the classification out loud so the user can override:
42
+
43
+ | Class | Signal | Depth |
44
+ |-------|--------|-------|
45
+ | **Spike** | "Can we...?", "Is it possible...?", feasibility question | 1-2 exchanges. Output is an answer, not a spec. No feature file. |
46
+ | **Bounded** | Small change to existing code. The flow being changed already exists. | 3-5 exchanges. Quick spec, focus on scope + done-when. |
47
+ | **Architectural** | New subsystem, structural change, or affects multiple components. | 5-8 exchanges. Full exploration of all areas. |
48
+
49
+ **When in doubt, take the heavier class.** The ratchet is one-way: hidden complexity discovered mid-conversation upgrades the class — stop, say so, and step up. Nothing downgrades mid-conversation.
50
+
51
+ A spike's output is a recommendation, not a feature spec. If the spike reveals something worth building, that's a new feature — classify it fresh.
52
+
53
+ ## Rationalization Prevention
54
+
55
+ ### Red Flags
56
+
57
+ | Thought | Reality |
58
+ |---------|---------|
59
+ | "This feature is obvious, I can skip Problem/Value" | If the value is obvious, stating it takes 10 seconds. If it's not, you just caught a bad feature. |
60
+ | "The scope is clear from the description" | Scope without explicit "Excludes" is unbounded. |
61
+ | "Done-when is implied by the solution" | Implied criteria get forgotten. Write them as a checklist. |
62
+ | "This is too small for a spec" | Small features get the bounded classification, not a skip. |
25
63
 
26
64
  ---
27
65
 
@@ -89,64 +127,232 @@ Find the highest existing number and increment by 1. Zero-pad to 3 digits. If `d
89
127
 
90
128
  ### Areas to Explore
91
129
 
92
- These are NOT a rigid sequence. Follow the conversation. Most features only need 2-3 of these to be clear.
130
+ Follow the conversation, not a rigid sequence. Most features need only 2-3 areas.
131
+
132
+ **Area dependency map (2-pass + optional design):**
133
+ ```
134
+ Pass 1: Problem ──→ Value ──→ User Stories (lightweight) ──→ Solution ──→ Scope
135
+ │ │
136
+ └──→ Success Metric Approach (optional)
137
+
138
+ Pass 2: ──→ Acceptance Criteria (per story: Given-When-Then → AC → edge cases → verification)
139
+
140
+ Pass 3 (UI features only): ──→ Design Intent (action → outcome → decision → QA verification)
141
+ ```
142
+
143
+ User Stories are captured early (before Solution) to inform what to build. Acceptance Criteria are detailed later (after Scope) because you need to know the solution and boundaries to define concrete verification. Design Intent is captured last — only for features with user-facing UI — so developers know WHY the UI is shaped this way and QA knows what to verify visually.
93
144
 
94
145
  #### Problem — What's broken or missing?
95
146
 
96
- > Discover: The specific pain this feature addresses. This is not the project-level problem (that's in PROJECT.md) — this is the concrete gap or friction that triggered "we need this feature."
147
+ > The specific pain this feature addresses not the project-level problem (that's in PROJECT.md).
148
+
149
+ **Prerequisites:** None.
97
150
 
98
- - What's not working right now? What's the user struggling with?
99
- - What happens today without this feature? (workaround, manual step, error, confusion...)
100
- - Who hits this problem and how often?
151
+ | Question | Depends on | Type |
152
+ |----------|-----------|------|
153
+ | What's not working right now? | — | Decision |
154
+ | What happens today without this? (workaround, manual step...) | what-broken | Fact (scan code) + Decision |
155
+ | Who hits this and how often? | what-broken | Decision |
156
+
157
+ **Done when:** Frontier empty — the gap is concrete.
101
158
 
102
159
  #### Value — Why is this worth building?
103
160
 
104
- > Discover: The value this feature delivers and how it connects to the bigger picture.
161
+ **Prerequisites:** Problem settled.
162
+
163
+ | Question | Depends on | Type |
164
+ |----------|-----------|------|
165
+ | What changes for the user when this exists? | Problem | Decision |
166
+ | How does this connect to PROJECT.md vision? | Problem | Fact (read PROJECT.md) + Decision |
167
+ | Cost of inaction? | user-change | Decision |
168
+
169
+ **Done when:** Frontier empty — value is clear.
170
+
171
+ #### Success Metric — How do we know this feature succeeded?
172
+
173
+ > Optional for Bounded features. Required for Architectural features. "Done When" is a build criterion. Success Metric is a launch criterion.
174
+
175
+ **Prerequisites:** Value settled.
176
+
177
+ | Question | Depends on | Type |
178
+ |----------|-----------|------|
179
+ | After launch, what number changes? (usage count, time saved, error reduction...) | Value | Decision |
180
+ | What's the baseline today, and what's the target? | metric | Decision |
181
+
182
+ Slots to fill:
183
+ - `{{feature_metric}}`: `{{baseline}}` → `{{target}}`
184
+
185
+ **Done when:** Frontier empty — at least one measurable outcome exists. Skip for Bounded features if the user declines.
186
+
187
+ #### User Stories — What does the user actually do? (Pass 1: lightweight)
188
+
189
+ > Bridge between Value and Solution. Captures WHAT the user does, not HOW we build it. These stories will be enriched with Given-When-Then scenarios and acceptance criteria in Pass 2, after Solution and Scope are defined.
190
+
191
+ **Prerequisites:** Value settled. Read PROJECT.md Personas section to identify the relevant persona.
192
+
193
+ | Question | Depends on | Type |
194
+ |----------|-----------|------|
195
+ | Which persona from PROJECT.md uses this feature? | Value | Fact (read PROJECT.md Personas) |
196
+ | What does that persona want to accomplish? | persona | Decision |
197
+ | Walk through the scenario — what happens step by step? | want | Decision |
198
+ | Is there a secondary scenario or edge case worth capturing? | scenario | Decision |
199
+
200
+ Format each story as:
201
+ ```
202
+ As a {{persona}}, I want {{action}} so that {{benefit}}.
203
+ ```
204
+
205
+ Slots to fill:
206
+ - 1-3 user stories (title + As a / I want / so that)
207
+ - Brief scenario sketch per story (will be formalized into Given-When-Then in Pass 2)
105
208
 
106
- - What changes for the user when this exists?
107
- - How does this connect to the project's vision or principles in PROJECT.md?
108
- - What happens if we don't build it? Is there a cost of inaction?
209
+ **Done when:** Frontier empty at least one user story with a concrete scenario exists. Don't over-detail here — Pass 2 adds the rigor.
109
210
 
110
211
  #### Solution — How does this solve it?
111
212
 
112
- > Discover: The concrete thing to implement. Not implementation details, but the user-facing shape of the solution.
213
+ **Prerequisites:** Value settled.
113
214
 
114
- - What does this feature do, in one sentence?
115
- - What does the user see/experience when it's working?
116
- - Is there an existing pattern in the codebase this builds on?
215
+ | Question | Depends on | Type |
216
+ |----------|-----------|------|
217
+ | What does this feature do, in one sentence? | Value | Decision |
218
+ | What does the user see/experience? | one-sentence | Decision |
219
+ | Existing pattern in codebase to build on? | one-sentence | Fact (scan code) |
220
+
221
+ **Done when:** Frontier empty — solution is concrete.
117
222
 
118
223
  #### Scope — Where are the edges?
119
224
 
120
- > Discover: What's in and what's out.
225
+ **Prerequisites:** Solution settled.
226
+
227
+ | Question | Depends on | Type |
228
+ |----------|-----------|------|
229
+ | What's included? | Solution | Decision |
230
+ | What's explicitly NOT included? (This is required, not optional — unbounded scope is the #1 feature killer) | includes | Decision |
231
+ | Smallest useful version? | includes, excludes | Decision |
232
+
233
+ **Done when:** Frontier empty — both Includes AND Excludes are defined. Scope without explicit "Excludes" is unbounded.
234
+
235
+ #### Acceptance Criteria — The derivation chain (Pass 2)
236
+
237
+ > This is where User Stories get teeth. Return to each story from Pass 1 and formalize: Given-When-Then scenario → acceptance criteria → edge cases → verification method. Each AC bullet is a test case. Each verification note is a QA checklist item.
238
+
239
+ **Prerequisites:** Scope settled. All User Stories from Pass 1 are available.
240
+
241
+ **Process:** For each User Story, walk through this chain:
242
+
243
+ | Step | Question | Depends on | Type |
244
+ |------|----------|-----------|------|
245
+ | 1 | Formalize the scenario: Given [precondition], When [action], Then [result] | Story from Pass 1 | Decision |
246
+ | 2 | What must be true for this story to be "done"? (one criterion per bullet) | scenario | Decision |
247
+ | 3 | What happens when something goes wrong? (invalid input, empty state, timeout, permission denied...) | happy-path AC | Decision |
248
+ | 4 | Are there boundary conditions? (first item, last item, zero items, max items...) | happy-path AC | Decision |
249
+ | 5 | How would you verify each criterion? (manual check, automated test, visual inspection...) | all ACs | Decision |
250
+
251
+ Format the output per story:
252
+ ```
253
+ ### Story: {{story_title}}
254
+
255
+ **Scenario:**
256
+ - Given: {{precondition}}
257
+ - When: {{user_action}}
258
+ - Then: {{expected_result}}
259
+
260
+ **Acceptance Criteria:**
261
+ - [ ] {{happy_path_criterion}} — verify: {{method}}
262
+ - [ ] {{edge_case}} — verify: {{method}}
263
+ - [ ] {{error_state}} — verify: {{method}}
264
+ ```
265
+
266
+ **Done when:** Every User Story has:
267
+ - A Given-When-Then scenario
268
+ - At least one happy-path AC
269
+ - At least one edge case or error state AC
270
+ - A verification method per AC
121
271
 
122
- - What's included in this feature?
123
- - What's explicitly NOT included (even if related)?
124
- - What's the smallest version that would be useful?
272
+ #### Design Intent How does the UI guide the user? (Pass 3, UI features only)
125
273
 
126
- #### DoneHow do we know it's finished?
274
+ > Bridge between acceptance criteria and implementation. Captures WHY each UI decision was made so developers know what to build, and QA knows what to verify. **Skip entirely for non-UI features (backend, data, infra).**
127
275
 
128
- > Discover: Acceptance criteria.
276
+ **Prerequisites:** Scope and Acceptance Criteria settled. Feature has user-facing interaction.
129
277
 
130
- - What must be true for this to be "done"?
131
- - How would you verify it works?
278
+ If the feature has no UI component, skip silently and proceed to Approach or generation.
279
+
280
+ **Process:** For each User Story's primary interaction, define the intent chain:
281
+
282
+ | Step | Expected User Action | Ideal Outcome | Design Decision | QA Verification |
283
+ |------|---------------------|---------------|-----------------|-----------------|
284
+ | {{N}} | {{what user does}} | {{what should happen}} | {{how the UI achieves this}} | {{how to verify}} |
285
+
286
+ Then catalog the essential states:
287
+
288
+ | State | Trigger | What the user sees |
289
+ |-------|---------|-------------------|
290
+ | Empty | {{trigger}} | {{description — how it guides user to first action}} |
291
+ | Error | {{trigger}} | {{description + recovery path}} |
292
+
293
+ Frontier questions:
294
+
295
+ | Question | Depends on | Type |
296
+ |----------|-----------|------|
297
+ | For the primary action in each story: what does the user see, do, and expect? | AC settled | Decision |
298
+ | What does the empty state look like? What guides the user to their first action? | solution | Decision |
299
+ | What does the error state look like? How does the user recover? | AC edge cases | Decision |
300
+ | Is there anything non-obvious about the visual flow that a developer would miss without this context? | all above | Decision |
301
+
302
+ **Done when:** Every story's primary interaction has an intent row. At least Empty and Error states are defined. This is the lightweight version — for deep UX analysis (heuristic evaluation, prototyping, accessibility audit), run `/know-thy-build:designer` on this feature.
132
303
 
133
304
  #### Approach — Any technical considerations?
134
305
 
135
306
  > Optional. Only explore if the user has thoughts or if it's non-obvious.
136
307
 
137
- - Any preferred approach or constraint?
138
- - Anything tricky to watch out for?
308
+ **Prerequisites:** Solution settled.
309
+
310
+ | Question | Depends on | Type |
311
+ |----------|-----------|------|
312
+ | Preferred approach or constraint? | Solution | Decision |
313
+ | Anything tricky to watch out for? | approach | Fact (scan code) + Decision |
314
+
315
+ **Done when:** Frontier empty, or user declines to explore.
316
+
317
+ ### Quick Perspective Check
318
+
319
+ Before generating, do one fast stress-test (skip if everything is obviously solid):
320
+
321
+ ```
322
+ 🔍 **Quick check:**
323
+
324
+ **Interrogator**: {{is the scope actually tight, or is there a hidden rabbit hole?}}
325
+ **End-user**: {{will the user actually notice/care about this feature?}}
326
+
327
+ Good to go?
328
+ ```
139
329
 
140
330
  ### When to Generate
141
331
 
142
- Offer to generate **as soon as the feature is clear enough to build.** Signs:
332
+ Offer to generate when **all applicable passes are complete.**
333
+
334
+ Concrete checklist:
143
335
 
144
- - You can describe the feature in 2-3 sentences
145
- - The scope is bounded
146
- - There are concrete acceptance criteria
147
- - The user's answers are getting shorter
336
+ **Pass 1 (story solution scope):**
337
+ - [ ] Problem frontier empty — gap is concrete
338
+ - [ ] Value frontier empty — worth is clear
339
+ - [ ] User Stories at least one story with As a / I want / so that
340
+ - [ ] Solution frontier empty — what to build is defined
341
+ - [ ] Scope has both "Includes" AND "Excludes" defined
342
+ - [ ] Success Metric defined (required for Architectural, optional for Bounded)
148
343
 
149
- Don't drag the conversation. Features should be quick.
344
+ **Pass 2 (acceptance criteria per story):**
345
+ - [ ] Every User Story has a Given-When-Then scenario
346
+ - [ ] Every story has at least one happy-path AC with verification method
347
+ - [ ] Every story has at least one edge case or error state AC
348
+ - [ ] Quick perspective check passed (or skipped because obviously solid)
349
+
350
+ **Pass 3 (design intent — UI features only):**
351
+ - [ ] Design Intent Map covers each story's primary interaction (or skipped: non-UI feature)
352
+ - [ ] Empty and Error states defined
353
+ - [ ] For Architectural features with complex UI: suggest `/know-thy-build:designer` for deep dive
354
+
355
+ Don't drag the conversation. Features should be quick — but not shallow.
150
356
 
151
357
  ### Generate Feature Spec
152
358
 
@@ -160,17 +366,60 @@ Write to `docs/features/{{NNN}}.md`:
160
366
  id: {{number}}
161
367
  title: {{short_title}}
162
368
  status: complete
369
+ priority: {{P0|P1|P2}}
370
+ class: {{Spike|Bounded|Architectural}}
371
+ depends_on: [{{feature_ids}}]
372
+ persona: {{primary_persona_name from PROJECT.md}}
373
+ gate:
374
+ worktree: null
375
+ architect: pending
376
+ designer: pending # set to 'skipped' for non-UI features
377
+ qa: pending
378
+ assumptions:
379
+ - "{{assumption}}"
163
380
  date: {{date}}
164
381
  generatedBy: know-thy-build-feature
165
382
  ---
166
383
  ```
167
384
 
168
- During conversation, use `status: drafting`. On finalization, set to `complete`.
385
+ **Gate initialization rules:**
386
+ - **Spike**: No gate field. Spikes produce answers, not implementations.
387
+ - **Bounded (non-UI)**: `architect: pending`, `designer: skipped`, `qa: pending`
388
+ - **Bounded (UI)**: `architect: pending`, `designer: pending`, `qa: pending`
389
+ - **Architectural**: All `pending`
390
+
391
+ **Priority guide:**
392
+ - **P0**: Must-have for MVP. Without this, the project doesn't deliver its core value.
393
+ - **P1**: Important. Significantly improves the experience but the project works without it.
394
+ - **P2**: Nice-to-have. Enhances polish or covers edge cases.
395
+
396
+ Ask the user to assign priority during the Value area. If they resist, recommend based on the feature's connection to PROJECT.md vision.
397
+
398
+ During conversation, use `status: drafting` with area tracking:
399
+ ```yaml
400
+ ---
401
+ id: {{number}}
402
+ title: {{short_title_or_TBD}}
403
+ status: drafting
404
+ priority: {{P0|P1|P2}}
405
+ depends_on: [{{feature_ids}}]
406
+ persona: {{primary_persona_name}}
407
+ areasExplored:
408
+ problem: { decisions: 2 }
409
+ value: { decisions: 1 }
410
+ areasRemaining: [user-stories, solution, scope, done]
411
+ assumptions:
412
+ - "{{assumption}}"
413
+ date: {{date}}
414
+ generatedBy: know-thy-build-feature
415
+ ---
416
+ ```
169
417
 
170
418
  **Rules:**
171
419
  - Only include content from the conversation. No generic filler.
172
420
  - Preserve the user's actual words.
173
421
  - **Omit sections that weren't discussed.** Shorter is better.
422
+ - **Include brief decision rationale** where a non-obvious choice was made.
174
423
  - The entire document MUST be written in {{LANG}}.
175
424
 
176
425
  **Template structure:**
@@ -188,6 +437,15 @@ During conversation, use `status: drafting`. On finalization, set to `complete`.
188
437
 
189
438
  <!-- What changes when this exists. Link to PROJECT.md vision/principles if relevant. -->
190
439
 
440
+ ## Success Metric
441
+
442
+ <!-- How we know this feature succeeded AFTER launch. Not build criteria — launch criteria.
443
+ Omit for Bounded features if not discussed. -->
444
+
445
+ | Metric | Baseline | Target |
446
+ |--------|----------|--------|
447
+ | {{feature_metric}} | {{baseline}} | {{target}} |
448
+
191
449
  ## Solution
192
450
 
193
451
  <!-- Concrete description of what gets built and how the user experiences it -->
@@ -198,18 +456,62 @@ During conversation, use `status: drafting`. On finalization, set to `complete`.
198
456
  <!-- Bulleted list -->
199
457
 
200
458
  **Excludes:**
201
- <!-- Bulleted list, only if discussed -->
459
+ <!-- Bulleted list REQUIRED. Scope without Excludes is unbounded. -->
202
460
 
203
- ## Done When
461
+ ## User Stories & Acceptance Criteria
204
462
 
205
- <!-- Acceptance criteria as a checklist -->
206
- - [ ] {{criterion_1}}
207
- - [ ] {{criterion_2}}
463
+ <!-- The derivation chain: Story Scenario → AC → Verification.
464
+ Each AC bullet is a test case. Each verification note is a QA checklist item.
465
+ Persona references PROJECT.md Personas section. -->
466
+
467
+ ### Story 1: {{story_title}}
468
+
469
+ **As a** {{persona}}, **I want** {{action}} **so that** {{benefit}}.
470
+
471
+ **Scenario:**
472
+ - Given: {{precondition}}
473
+ - When: {{user_action}}
474
+ - Then: {{expected_result}}
475
+
476
+ **Acceptance Criteria:**
477
+ - [ ] {{happy_path_criterion}} — verify: {{method}}
478
+ - [ ] {{happy_path_criterion_2}} — verify: {{method}}
479
+
480
+ **Edge Cases & Errors:**
481
+ - [ ] {{edge_case}} — verify: {{method}}
482
+ - [ ] {{error_state}} — verify: {{method}}
483
+
484
+ ### Story 2: {{story_title}}
485
+ <!-- Repeat structure. Omit if only one story. -->
486
+
487
+ ## Design Intent
488
+
489
+ <!-- Optional: only for features with user-facing UI.
490
+ For deep UX analysis (heuristics, prototyping, accessibility), run /know-thy-build:designer.
491
+ Developer: read Decision column to know what to build and why.
492
+ QA: read Action + Outcome + Verification to derive test cases. -->
493
+
494
+ | Step | User Action | Ideal Outcome | Design Decision | QA Verification |
495
+ |------|-------------|---------------|-----------------|-----------------|
496
+ | {{N}} | {{action}} | {{outcome}} | {{decision}} | {{verification}} |
497
+
498
+ **Key States:**
499
+
500
+ | State | Trigger | User Sees |
501
+ |-------|---------|-----------|
502
+ | Empty | {{trigger}} | {{description}} |
503
+ | Error | {{trigger}} | {{description + recovery}} |
208
504
 
209
505
  ## Approach
210
506
 
211
507
  <!-- Technical notes, only if discussed -->
212
508
 
509
+ ## Assumptions
510
+
511
+ <!-- Beliefs that haven't been validated. Omit if none surfaced. -->
512
+
513
+ - {{assumption}} — if wrong: {{impact}}
514
+
213
515
  ---
214
516
 
215
517
  *Generated by know-thy-build-feature | {{date}}*
@@ -263,27 +565,145 @@ If the change is substantial, add a brief note at the bottom:
263
565
 
264
566
  ## Saving Progress
265
567
 
266
- If the conversation is interrupted before generation, save progress immediately:
568
+ If the conversation is interrupted before generation, save progress immediately using the drafting frontmatter format (with `areasExplored`, `areasRemaining`, and `assumptions`).
267
569
 
268
- ```yaml
269
- ---
270
- id: {{number}}
271
- title: {{short_title_or_TBD}}
272
- status: drafting
273
- date: {{date}}
274
- generatedBy: know-thy-build-feature
275
- ---
276
- ```
570
+ Write whatever content has been confirmed so far. The next `/know-thy-build:feature` run will detect the drafting state, read the area tracking, and offer to resume from where the frontier was.
571
+
572
+ ## Update Feature Registry
277
573
 
278
- Write whatever content has been confirmed so far. The next `/know-thy-build:feature` run will detect the drafting state and offer to resume.
574
+ After creating or editing a feature, update the Feature Registry in `docs/PROJECT.md`:
575
+
576
+ 1. Read `docs/PROJECT.md` and find the `## Feature Registry` section.
577
+ 2. If the section doesn't exist, append it (use the template from the project skill).
578
+ 3. Add or update the row for this feature:
579
+ ```
580
+ | {{id}} | [{{title}}](features/{{NNN}}.md) | {{priority}} | {{depends_on}} | {{status}} |
581
+ ```
582
+ 4. If `depends_on` references other features, verify those feature IDs exist.
583
+
584
+ This keeps PROJECT.md as the single entry point for the full project picture.
279
585
 
280
586
  ## Closing
281
587
 
282
- **After CREATE:**
588
+ **After CREATE (Spike):**
589
+ - No worktree, no gate, no implementation. The spike's output is an answer.
590
+ - Run `/know-thy-build:feature` again if the spike reveals something worth building.
591
+
592
+ **After CREATE (Bounded / Architectural):**
283
593
  - Feature spec has been saved to `docs/features/{{NNN}}.md`
284
- - They can start implementing whenever ready
285
- - Run `/know-thy-build:feature` again for the next feature
594
+ - Feature Registry in `docs/PROJECT.md` has been updated
595
+
596
+ ### Worktree Setup
597
+
598
+ 1. Detect the repo name:
599
+ ```bash
600
+ REPO=$(basename $(git rev-parse --show-toplevel))
601
+ WT_PATH="../${REPO}-wt"
602
+ ```
603
+
604
+ 2. Check for existing worktree:
605
+ ```bash
606
+ git worktree list
607
+ ls -d "$WT_PATH" 2>/dev/null
608
+ ```
609
+
610
+ 3. **If `$WT_PATH` already exists:**
611
+ > "Worktree `$WT_PATH` already exists (branch: {{branch}}). Options:"
612
+ > 1. Continue with existing worktree (previous feature is in progress)
613
+ > 2. Remove existing worktree and create new one
614
+ > 3. Skip worktree (work in main)
615
+
616
+ If user chooses option 1 or 3, skip creation. If option 2, run `git worktree remove "$WT_PATH"` first.
617
+
618
+ 4. **Create worktree:**
619
+ ```bash
620
+ git worktree add "$WT_PATH" -b "feature/{{NNN}}-{{short_title_kebab}}"
621
+ ```
622
+
623
+ 5. Confirm:
624
+ > "Worktree created at `$WT_PATH` on branch `feature/{{NNN}}-{{short_title_kebab}}`."
625
+
626
+ 6. Update feature spec frontmatter:
627
+ ```yaml
628
+ gate:
629
+ worktree: feature/{{NNN}}-{{short_title_kebab}}
630
+ ```
631
+
632
+ ### Sub-agent Dispatch
633
+
634
+ After worktree creation, dispatch a sub-agent to orchestrate the entire feature lifecycle in the worktree.
635
+
636
+ Use the **Agent tool** with `isolation: "worktree"` is NOT needed here — the worktree is already created manually above. Instead, dispatch the sub-agent with an explicit working directory.
637
+
638
+ **Sub-agent prompt:**
639
+
640
+ ```
641
+ You are the feature orchestrator for Feature {{NNN}}: {{title}}.
642
+ Your working directory is: {{WT_PATH}}
643
+
644
+ Read these files first:
645
+ - docs/PROJECT.md — project principles
646
+ - docs/TECHNICAL.md — technical decisions
647
+ - docs/features/{{NNN}}.md — this feature's spec and gate status
648
+
649
+ ## Your job: Define → Implement → Review → Finish
650
+
651
+ ### Phase 1: Define
652
+ Run each role to define their criteria for this feature:
653
+
654
+ 1. Run /know-thy-build:architect
655
+ - Reads the feature spec
656
+ - Designs structure: CRC cards, scaffolds, signature tests
657
+ - Creates stub files with PRE/POST/WHY/EXAMPLE comments
658
+ - Creates signature contract tests
659
+
660
+ 2. Run /know-thy-build:designer (skip if gate.designer is 'skipped')
661
+ - Reads the feature spec
662
+ - Defines design intent map, state catalog, micro-interactions
663
+ - Updates the feature spec with detailed design intent
664
+
665
+ 3. Run /know-thy-build:qa in REVIEW mode
666
+ - Reads the feature spec + architect scaffolds + design intent
667
+ - Defines concrete test cases in docs/QA.md
668
+ - Each test case has verification method and expected evidence
669
+
670
+ ### Phase 2: Implement
671
+ Fill the scaffolds:
672
+ - Read all stub files with // IMPLEMENT markers
673
+ - Implement each stub following PRE/POST/WHY contracts
674
+ - Run tests after each implementation to verify
675
+ - Do NOT modify signature contract tests (DO NOT MODIFY markers)
676
+
677
+ ### Phase 3: Review
678
+ Submit implementation for review by each role:
679
+
680
+ 1. Architect review:
681
+ - Verify code follows scaffolds, conventions, and TECHNICAL.md
682
+ - Check all signature tests pass
683
+ - Check no // IMPLEMENT markers remain
684
+ - Update docs/features/{{NNN}}.md: gate.architect → passed
685
+
686
+ 2. Designer review (skip if gate.designer is 'skipped'):
687
+ - Verify UI matches design intent map
688
+ - Check all states are handled (empty, error, loading, success)
689
+ - Update docs/features/{{NNN}}.md: gate.designer → passed
690
+
691
+ 3. QA TEST:
692
+ - Actually run the product
693
+ - Execute every test case from docs/QA.md for this feature
694
+ - Capture evidence (screenshots, console output, state checks)
695
+ - Update docs/features/{{NNN}}.md: gate.qa → passed
696
+
697
+ If any review fails → fix and re-submit. Loop until all gates pass.
698
+
699
+ ### Phase 4: Finish
700
+ When all gates are passed/skipped, run /know-thy-build:finish.
701
+ ```
702
+
703
+ > "Sub-agent dispatched to worktree. It will run define → implement → review → finish automatically."
704
+ > "You can continue working on other things in main, or run `/know-thy-build:feature` for the next feature."
286
705
 
287
706
  **After EDIT:**
288
707
  - Feature spec has been updated
708
+ - Feature Registry in `docs/PROJECT.md` has been updated if priority, status, or dependencies changed
289
709
  - Changes are recorded if substantial