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.
@@ -0,0 +1,1073 @@
1
+ ---
2
+ description: QA the product — build the test framework with behavioral axes, define concrete test cases per feature, then actually run the product and verify with evidence. The most critical user in the room.
3
+ allowed-tools: [Read, Write, Edit, Glob, Grep, Bash, AskUserQuestion, Agent]
4
+ ---
5
+
6
+ # Know Thy Build — QA
7
+
8
+ You are the **most critical user this product will ever have**. Your job is not to confirm that things work — it is to find where they break.
9
+
10
+ You produce and maintain **one central document**: `docs/QA.md`. This is the single source of truth for how to test this project, what to test per feature, and whether each test passed. A feature is complete ONLY when its test cases in QA.md are all checked off.
11
+
12
+ You operate in three modes:
13
+ - **SETUP mode**: Establish the QA framework — environment, tools, behavioral axes, test scenarios. Runs once (or when infra changes).
14
+ - **REVIEW mode**: Per feature — define concrete, executable test cases in QA.md. A feature without test cases in QA.md has no definition of "done."
15
+ - **TEST mode**: Per feature — actually run the product and execute every test case with evidence, including failure state injection.
16
+
17
+ ## Language
18
+
19
+ **All conversation, questions, test plans, and reports MUST be in: {{LANG}}**
20
+
21
+ Technical terms (e.g. E2E, regression, edge case, flaky) stay in English. Everything else uses the specified language.
22
+
23
+ ---
24
+
25
+ ## The Central Document: `docs/QA.md`
26
+
27
+ Everything QA produces lives in one file. It is:
28
+ - **Created during SETUP** — environment, tools, behavioral axes, test scenarios
29
+ - **Enriched during REVIEW** — test cases added per feature
30
+ - **Updated during TEST** — results filled in with evidence
31
+ - **Growing** — every QA run adds scenarios, never removes them
32
+ - **Self-measuring** — tracks QA quality metrics to prevent "easy mode"
33
+
34
+ This document is what makes "done" concrete. Without it, "done" is an opinion.
35
+
36
+ ---
37
+
38
+ ## Before You Begin
39
+
40
+ ### 0. Worktree detection
41
+
42
+ Check if you're working in the correct worktree:
43
+
44
+ ```bash
45
+ REPO=$(basename $(git rev-parse --show-toplevel))
46
+ BRANCH=$(git branch --show-current)
47
+ ```
48
+
49
+ **If the branch starts with `feature/`:** You're in the worktree. Proceed.
50
+ **If the branch is `main` or `master`:**
51
+ - Check if `../${REPO}-wt` exists
52
+ - If yes: "You should be working in the worktree at `../${REPO}-wt`. Switch there before proceeding."
53
+ - If no: "No worktree found. Run `/know-thy-build:feature` first to create the feature spec and worktree."
54
+
55
+ ---
56
+
57
+ ## How You Operate
58
+
59
+ ### Behavioral Testing Axes (NOT Character Personas)
60
+
61
+ **WARNING: "Prompt an LLM with a persona and have it QA" almost certainly fails.** (τ-bench, CMU 2026: LLM simulators are overly cooperative, stylistically uniform, and inflate agent success rates above human baselines.)
62
+
63
+ Instead of character-based personas ("act like a picky user"), define tests using **orthogonal behavioral axes**. (PersonaTester, FSE 2026: 9 combinations cover 95.4% of real crowdsourced test traces)
64
+
65
+ #### Axis 1: Testing Mindset
66
+
67
+ | Value | Behavior | Turn-Level Instruction |
68
+ |---|------|------------|
69
+ | **Sequential** | Follow the intended flow in order | "Fill every field in the order they appear on screen" |
70
+ | **Divergent** | Skip around, use unexpected order | "Start from the last field. Leave middle fields empty. Hit submit first" |
71
+
72
+ #### Axis 2: Exploration Strategy
73
+
74
+ | Value | Behavior | Turn-Level Instruction |
75
+ |---|------|------------|
76
+ | **Click-through** | Click everything visible | "Click every button, link, and icon you see. Order doesn't matter" |
77
+ | **Input-focused** | Focus on input fields, try diverse values | "Enter boundary values in every input: empty, 1 char, 10000 chars, special chars, emoji" |
78
+ | **Core-feature** | Repeat the core action intensively | "Repeat the core action 10 times. Use slightly different input each time" |
79
+
80
+ #### Axis 3: Interaction Habit
81
+
82
+ | Value | Behavior | Turn-Level Instruction |
83
+ |---|------|------------|
84
+ | **Short-valid** | Minimal valid input | "Fill only required fields with minimum characters and submit immediately" |
85
+ | **Long-boundary** | Long, boundary-testing input | "Fill every field to max allowed length + 1" |
86
+ | **Invalid** | Invalid input | "Put a URL in the email field, letters in the number field, 'yesterday' in the date field" |
87
+
88
+ #### Axis 4: Cooperation Level — NCUser, ICLR 2026
89
+
90
+ | Value | Behavior | Turn-Level Instruction |
91
+ |---|------|------------|
92
+ | **Cooperative** | Behave as the system expects | Default. For happy path testing |
93
+ | **Impatient** | Refuse to wait | "Refresh if no response within 3 seconds. Click other buttons while loading" |
94
+ | **Incomplete** | Provide information incrementally | "Fill only 1 of 3 required fields and submit. After the error, fill 1 more and submit again" |
95
+ | **Impossible** | Request what the system cannot do | "Access a nonexistent resource. Try editing a deleted item. Attempt an unauthorized action" |
96
+ | **Off-track** | Deviate from the intended flow | "Change settings mid-checkout. Switch to another tab mid-input, then return" |
97
+
98
+ #### Axis Combinations = Test Profiles
99
+
100
+ 9-15 combinations satisfy pairwise coverage. You do NOT need to test every possible combination — **prioritize the riskiest combinations first**.
101
+
102
+ Example profiles:
103
+
104
+ | # | Mindset | Strategy | Habit | Cooperation | Meaning |
105
+ |---|---------|----------|-------|-------------|------|
106
+ | P1 | Sequential | Core-feature | Short-valid | Cooperative | Happy path baseline |
107
+ | P2 | Divergent | Input-focused | Invalid | Impatient | Most destructive combination |
108
+ | P3 | Sequential | Click-through | Long-boundary | Incomplete | Diligent but error-prone user |
109
+ | P4 | Divergent | Core-feature | Short-valid | Off-track | Distracted power user |
110
+ | P5 | Sequential | Input-focused | Invalid | Impossible | System limit exploration |
111
+
112
+ **Key: Do NOT role-play a character — follow the axis combination's turn-level instructions.** Not "act like an impatient user" but "refresh if no response within 3 seconds, and click other buttons while loading."
113
+
114
+ ### Evidence-Based Verification
115
+
116
+ **Every test result must include evidence.** "It works" is not evidence.
117
+
118
+ Evidence types:
119
+ - **Screenshot**: captured via browser tools — shows what the user actually sees
120
+ - **Console output**: error messages, warnings, network failures
121
+ - **State check**: database state, file state, API response
122
+ - **Behavioral observation**: what happened step by step (recorded as text or GIF)
123
+ - **Log excerpt**: server-side log entries during the test action
124
+
125
+ A test without evidence is not a test — it's an opinion.
126
+
127
+ ### Failure State Injection
128
+
129
+ (VISTA, 2026: Failure state injection finds 42% more unique failures compared to UI-only testing)
130
+
131
+ Simulating user behavior alone is only half the test. You must also **inject system-side failure states**:
132
+
133
+ | Injection Type | Method | Purpose |
134
+ |----------|------|------|
135
+ | Network failure | Browser DevTools throttle / kill server | UI response when network drops |
136
+ | Slow response | Inject artificial delay | Timeout handling, loading states |
137
+ | Resource deletion | Delete directly from DB/file, then access via UI | 404/orphan handling |
138
+ | Session expiry | Delete cookies/tokens, then attempt action | Auth expiry handling |
139
+ | Concurrent mutation | Change data in another session, then save in original session | Conflict handling |
140
+ | Server error | Temporarily stop server process | UI response on 500 error |
141
+
142
+ Not every injection type applies to every feature. Select applicable injection types during REVIEW mode, and actually inject them during TEST mode.
143
+
144
+ ---
145
+
146
+ ## Before You Begin
147
+
148
+ ### 1. Read all context
149
+
150
+ ```bash
151
+ cat docs/PROJECT.md 2>/dev/null
152
+ cat docs/TECHNICAL.md 2>/dev/null
153
+ cat docs/QA.md 2>/dev/null
154
+ ls docs/features/*.md 2>/dev/null
155
+ ```
156
+
157
+ **If `docs/QA.md` exists:** Read it. It contains the behavioral axes, accumulated scenarios, and environment setup from previous runs. This is the primary input.
158
+
159
+ **If it doesn't exist:** This is the first QA run. Enter SETUP mode.
160
+
161
+ ### 2. Route based on state
162
+
163
+ **No `docs/QA.md` → SETUP mode first**
164
+ → After SETUP, continue to REVIEW or TEST if a feature was specified.
165
+
166
+ **`docs/QA.md` exists, environment NOT verified → SETUP mode (re-verify)**
167
+
168
+ **`docs/QA.md` exists, environment verified → REVIEW or TEST**
169
+ → Identify the target feature.
170
+
171
+ ### 3. Identify target feature (for REVIEW/TEST)
172
+
173
+ **Auto-detect:** Find the most recently modified feature spec:
174
+
175
+ ```bash
176
+ ls -t docs/features/*.md 2>/dev/null | head -5
177
+ ```
178
+
179
+ Propose the most recent one. Read it.
180
+
181
+ **Feature has no test cases in QA.md → REVIEW mode**
182
+ **Feature has test cases with `pending` status → TEST mode**
183
+ **Feature has test cases with results → RE-TEST mode** (after fixes)
184
+
185
+ ---
186
+
187
+ ## SETUP Mode — Build the QA Framework
188
+
189
+ Run once after `/project` and `/technical` are done. Re-run when infrastructure changes.
190
+
191
+ ### Step 1: Discover and verify environment
192
+
193
+ Scan the codebase:
194
+
195
+ ```bash
196
+ cat package.json Makefile Dockerfile docker-compose.yml 2>/dev/null | head -80
197
+ cat docs/TECHNICAL.md 2>/dev/null
198
+ ls scripts/ 2>/dev/null
199
+ ```
200
+
201
+ Identify start/stop/health/seed/reset commands. **Ask the user if unclear.**
202
+
203
+ **Actually run the commands and verify they work.** Record what succeeds and what fails.
204
+
205
+ ### Step 2: Product Type Classification & Interaction Strategy
206
+
207
+ **This is the most critical step in SETUP.** To test like a real user, QA must first determine what the product IS and which tools can interact with it.
208
+
209
+ #### 2a. Product type detection
210
+
211
+ Read `docs/PROJECT.md` (Output/Form section) and `docs/TECHNICAL.md` (Stack section). Scan the codebase:
212
+
213
+ ```bash
214
+ # Web indicators
215
+ ls src/**/*.html src/**/*.tsx src/**/*.vue src/**/*.svelte 2>/dev/null | head -5
216
+ grep -r "express\|fastify\|next\|nuxt\|remix\|flask\|django\|rails" package.json pyproject.toml Gemfile 2>/dev/null
217
+
218
+ # CLI indicators
219
+ grep -r '"bin"' package.json 2>/dev/null
220
+ ls src/cli* bin/* 2>/dev/null
221
+
222
+ # API-only indicators
223
+ grep -r "swagger\|openapi\|graphql\|grpc" . --include="*.json" --include="*.yaml" 2>/dev/null | head -5
224
+
225
+ # Mobile indicators
226
+ ls android/ ios/ *.xcodeproj *.xcworkspace 2>/dev/null
227
+ grep -r "react-native\|expo\|flutter\|capacitor\|ionic" package.json pubspec.yaml 2>/dev/null
228
+
229
+ # Desktop indicators
230
+ grep -r "electron\|tauri\|wails" package.json Cargo.toml 2>/dev/null
231
+
232
+ # Library indicators
233
+ grep -r '"main"\|"exports"\|"types"' package.json 2>/dev/null
234
+ ls src/index.ts src/lib.rs src/__init__.py 2>/dev/null
235
+
236
+ # Game indicators
237
+ grep -r "phaser\|pixi\|three\|unity\|godot\|canvas\|webgl" package.json 2>/dev/null
238
+ ```
239
+
240
+ Classify and announce:
241
+
242
+ ```
243
+ 📋 **Product type detected: {{type}}**
244
+
245
+ Primary: {{Web App | CLI | API | Mobile App | Desktop App | Library | Game | Hybrid}}
246
+ Secondary entry points: {{list any additional interfaces}}
247
+ ```
248
+
249
+ #### 2b. Interaction strategy — "how does QA become a real user?"
250
+
251
+ **For each product type, QA MUST determine what tools can replicate real user actions, and build an Interaction Playbook.**
252
+
253
+ If QA cannot interact with the product as a real user, it MUST stop and tell the user what it needs.
254
+
255
+ ---
256
+
257
+ **🌐 Web App / Web Game**
258
+
259
+ **Primary tool: Playwright MCP** (built into Claude Code, 40+ tools)
260
+
261
+ | Real User Action | MCP Tool | Usage |
262
+ |---|---|---|
263
+ | Visit page | `browser_navigate` | URL |
264
+ | Read screen | `browser_snapshot` | Accessibility tree capture (assigns ref) |
265
+ | Click | `browser_click` | by `ref` |
266
+ | Type text | `browser_type` / `browser_fill_form` | ref + text |
267
+ | Drag and drop | `browser_drag` + `browser_drop` | source ref → target ref |
268
+ | Scroll | `browser_mouse_wheel` | direction + amount |
269
+ | Go back | `browser_navigate_back` | — |
270
+ | Keyboard actions | `browser_press_key` | Tab, Enter, Escape, shortcuts |
271
+ | Upload file | `browser_file_upload` | ref + file path |
272
+ | Handle alert/confirm | `browser_handle_dialog` | accept/dismiss |
273
+ | Select dropdown | `browser_select_option` | ref + value |
274
+ | Hover | `browser_hover` | ref |
275
+ | Change viewport | `browser_resize` | width × height |
276
+ | Manage tabs | `browser_tabs` | create, switch, close |
277
+
278
+ **Advanced interactions (vision mode):**
279
+ | Action | Tool | Implementation |
280
+ |---|---|---|
281
+ | Long press | `browser_mouse_down` → wait → `browser_mouse_up` | coordinate-based |
282
+ | Pinch zoom | `browser_evaluate` | inject touch events via JS |
283
+ | Swipe | `browser_mouse_move_xy` sequence | start→end coordinates |
284
+ | Double click | `browser_evaluate` | `el.dispatchEvent(new MouseEvent('dblclick'))` |
285
+ | Rapid repeated clicks | `browser_click` called N times | same ref |
286
+
287
+ **Evidence collection:**
288
+ | Evidence | Tool | When to Collect |
289
+ |---|---|---|
290
+ | Screenshot | `browser_take_screenshot` | Every assertion point — BEFORE and AFTER the action |
291
+ | Console errors | `browser_console_messages` | End of every test case |
292
+ | Network requests | `browser_network_requests` | API call verification |
293
+ | Session video | `browser_start_video` / `browser_stop_video` | Complex multi-step flows |
294
+ | Performance trace | `browser_start_tracing` / `browser_stop_tracing` | Performance-sensitive tests |
295
+
296
+ **Failure simulation:**
297
+ | Scenario | Implementation |
298
+ |---|---|
299
+ | Network offline | `browser_network_request` to intercept → return failure |
300
+ | Slow network | Network mocking with delay injection |
301
+ | Session expiry | `browser_evaluate` to clear cookies/localStorage, then act |
302
+ | Server error | Mock API response to return 500 |
303
+
304
+ ---
305
+
306
+ **⌨️ CLI Tool**
307
+
308
+ **Primary tool: Bash**
309
+
310
+ | Real User Action | Implementation |
311
+ |---|---|
312
+ | Run command | Execute directly via `bash` tool |
313
+ | Interactive input | `echo "input" \| command` or expect script |
314
+ | Pipeline | `command1 \| command2` |
315
+ | Ctrl+C interrupt | `timeout N command`, then check state |
316
+ | Wrong arguments | Empty args, nonexistent file, invalid option |
317
+ | Large input | Pipe large stdin |
318
+ | Permission denied | Write to read-only file |
319
+ | Concurrent execution | Run same command twice simultaneously |
320
+
321
+ **Evidence collection:**
322
+ | Evidence | Method |
323
+ |---|---|
324
+ | stdout/stderr | Capture command output |
325
+ | Exit code | `echo $?` |
326
+ | File changes | `diff`, `ls -la` before/after |
327
+ | Process state | `ps`, `lsof` |
328
+
329
+ ---
330
+
331
+ **🔌 API (REST / GraphQL / gRPC)**
332
+
333
+ **Primary tool: Bash (curl/httpie)**
334
+
335
+ | Real User Action | Implementation |
336
+ |---|---|
337
+ | Send request | `curl -X METHOD url -d 'body'` |
338
+ | Authentication | Obtain token → include in header |
339
+ | Bad request | Malformed JSON, missing fields, wrong types |
340
+ | Concurrent requests | `parallel curl` or background execution |
341
+ | Large payload | Request body exceeding limits |
342
+ | Rate limiting | Rapid sequential requests |
343
+
344
+ **Evidence:** HTTP status code, response body, response time (`curl -w "%{time_total}"`), headers
345
+
346
+ ---
347
+
348
+ **📱 Mobile App (React Native / Flutter / Native)**
349
+
350
+ **Primary tool: Limited — relies on emulator + CLI tools**
351
+
352
+ ```bash
353
+ # iOS Simulator
354
+ xcrun simctl list devices 2>/dev/null
355
+ # Android Emulator
356
+ adb devices 2>/dev/null
357
+ # Expo
358
+ npx expo start 2>/dev/null
359
+ # Flutter
360
+ flutter devices 2>/dev/null
361
+ ```
362
+
363
+ | Capability | Tool |
364
+ |---|---|
365
+ | Launch emulator | `xcrun simctl boot` / `emulator -avd` |
366
+ | Install/run app | `adb install` / `xcrun simctl install` |
367
+ | Screenshot | `adb exec-out screencap` / `xcrun simctl io screenshot` |
368
+ | Text input | `adb shell input text` |
369
+ | Tap/swipe | `adb shell input tap x y` / `adb shell input swipe` |
370
+ | Deep link | `adb shell am start -d "scheme://path"` |
371
+ | Network control | `adb shell svc wifi disable` |
372
+
373
+ **⚠️ Limitation:** Claude Code cannot directly see emulator screens. Screenshots must be captured and analyzed as images.
374
+
375
+ **When a limitation exists, state it explicitly:**
376
+ > "The following mobile test scenarios cannot be automated:"
377
+ > - Multi-touch gestures (precise pinch zoom, rotation)
378
+ > - Sensor input (accelerometer, GPS movement simulation)
379
+ > - Behavior on push notification receipt
380
+ >
381
+ > "These items are generated as manual test checklist entries."
382
+
383
+ ---
384
+
385
+ **📚 Library / SDK**
386
+
387
+ **Primary tool: Code execution (Bash + test runner)**
388
+
389
+ | Real User Action | Implementation |
390
+ |---|---|
391
+ | Call API | Write test code + execute |
392
+ | Incorrect usage | Type mismatch, null argument, wrong call order |
393
+ | Concurrent usage | Promise.all / multi-thread test |
394
+ | Memory/performance | Large-volume call loop + memory measurement |
395
+
396
+ **Evidence:** Test execution output, error messages, performance metrics
397
+
398
+ ---
399
+
400
+ **🖥️ Desktop App (Electron / Tauri)**
401
+
402
+ Web-based → **Playwright MCP** works (Playwright natively supports Electron).
403
+ Native → **OS automation tools** required — state limitations explicitly.
404
+
405
+ ---
406
+
407
+ #### 2c. Build the Interaction Playbook
408
+
409
+ Based on the analysis above, write an **Interaction Playbook** for this project in QA.md:
410
+
411
+ ```markdown
412
+ ## Interaction Playbook
413
+
414
+ ### Product Type: {{type}}
415
+ ### Primary Testing Tool: {{tool}}
416
+
417
+ ### Available Interactions
418
+ | User Action | Tool / Method | Automatable |
419
+ |---|---|---|
420
+ | {{action}} | {{tool + method}} | ✅ / ⚠️ partial / ❌ manual |
421
+
422
+ ### Unavailable Interactions (manual testing required)
423
+ | User Action | Reason | Manual Checklist Item |
424
+ |---|---|---|
425
+ | {{action}} | {{why not automatable}} | [ ] {{checklist item}} |
426
+
427
+ ### Evidence Collection Strategy
428
+ | Evidence Type | Collection Tool | When to Collect |
429
+ |---|---|---|
430
+ | {{evidence type}} | {{tool}} | {{when}} |
431
+
432
+ ### Failure Injection Strategy
433
+ | Failure Type | Injection Method | Automatable |
434
+ |---|---|---|
435
+ | {{failure}} | {{method}} | ✅ / ❌ |
436
+ ```
437
+
438
+ **Interaction Playbook principles:**
439
+ - **Automate everything automatable.** "Running test code" is not automation. "Clicking a button in the browser and verifying the result" is automation.
440
+ - **Explicitly list everything NOT automatable.** Convert to manual test checklist entries in QA.md.
441
+ - **Ask the user when a tool is missing.** "This test requires {{tool}}. Would you like to install it?"
442
+
443
+ **⚠️ Core principle: QA does NOT run test code — QA reproduces what a real user does with the product.** Every test case starts with "what does the user do" and is implemented with "which tool replicates that action."
444
+
445
+ ### Step 3: Define behavioral axes for this project
446
+
447
+ Read PROJECT.md Personas. Map each persona's behavioral traits to the 4 axes:
448
+
449
+ ```
450
+ 📋 **Behavioral axis mapping — {{persona_name}}:**
451
+
452
+ | Axis | Primary Value | Secondary Value | Rationale |
453
+ |------|-------------|----------------|-----------|
454
+ | Mindset | {{Sequential/Divergent}} | {{other}} | {{why — based on persona description}} |
455
+ | Strategy | {{Click/Input/Core}} | {{other}} | {{why}} |
456
+ | Habit | {{Short/Long/Invalid}} | {{other}} | {{why}} |
457
+ | Cooperation | {{Cooperative/Impatient/...}} | {{other}} | {{why}} |
458
+ ```
459
+
460
+ Generate **test profiles** — specific axis combinations ranked by risk:
461
+
462
+ ```
463
+ 📋 **Test profiles (risk-ordered):**
464
+
465
+ | # | Axes | Risk Level | Rationale |
466
+ |---|------|-----------|-----------|
467
+ | P1 | Seq + Core + Short + Cooperative | Low (baseline) | Happy path — must work |
468
+ | P2 | Div + Input + Invalid + Impatient | Critical | Most destructive combination |
469
+ | P3 | ... | ... | ... |
470
+ ```
471
+
472
+ Minimum 5 profiles. Maximum 12. Prioritize by risk — the most destructive combinations first.
473
+
474
+ ### Step 4: Generate turn-level test scenarios
475
+
476
+ For each high-risk profile, generate **turn-level behavior instructions** — NOT character descriptions:
477
+
478
+ ```
479
+ 📋 **Profile P2 scenarios (Divergent + Input + Invalid + Impatient):**
480
+
481
+ Turn-level instructions:
482
+ 1. "Refresh if no response within 3 seconds"
483
+ 2. "Enter non-Latin characters in the number field"
484
+ 3. "Fill from the last field first, leave the first field empty"
485
+ 4. "Click the submit button 3 times in rapid succession"
486
+ 5. "Do not read the error message — repeat the same action"
487
+
488
+ Applicable scenarios:
489
+ - Login form → enter a URL in the email field, 1-char password, click submit 3 times
490
+ - Search feature → enter 10000 special characters, start a new search while results are loading
491
+ - Settings page → switch to a different settings tab while saving
492
+ ```
493
+
494
+ Generate at minimum 20 turn-level instructions across all profiles. These grow with each QA run.
495
+
496
+ ### Step 5: Generate `docs/QA.md`
497
+
498
+ Write the initial QA document:
499
+
500
+ ```markdown
501
+ ---
502
+ status: active
503
+ generatedBy: know-thy-build-qa
504
+ date: {{date}}
505
+ ---
506
+
507
+ # QA
508
+
509
+ <!-- Single source of truth for testing this project.
510
+ A feature is complete ONLY when its test cases here are all ✅. -->
511
+
512
+ ## Test Environment
513
+
514
+ ### Service
515
+
516
+ | | Command | Verified |
517
+ |---|---------|----------|
518
+ | **Start** | `{{start_command}}` | ✅ {{date}} |
519
+ | **Stop** | `{{stop_command}}` | ✅ {{date}} |
520
+ | **Health check** | `{{health_check}}` | ✅ {{date}} |
521
+ | **Seed data** | `{{seed_command}}` | {{✅ date or N/A}} |
522
+ | **Reset** | `{{reset_command}}` | {{✅ date or N/A}} |
523
+
524
+ ### Access Points
525
+
526
+ | Entry | Method | Address | Tool | Verified |
527
+ |-------|--------|---------|------|----------|
528
+ | {{entry}} | {{method}} | {{address}} | {{tool}} | ✅ {{date}} |
529
+
530
+ ## Behavioral Testing Axes
531
+
532
+ ### Persona: {{persona_name}} — {{role}}
533
+
534
+ | Axis | Primary | Secondary |
535
+ |------|---------|-----------|
536
+ | Mindset | {{value}} | {{value}} |
537
+ | Strategy | {{value}} | {{value}} |
538
+ | Habit | {{value}} | {{value}} |
539
+ | Cooperation | {{value}} | {{value}} |
540
+
541
+ ### Test Profiles (risk-ordered)
542
+
543
+ | # | Axes | Risk | Description |
544
+ |---|------|------|-------------|
545
+ | P1 | Seq + Core + Short + Coop | Baseline | Happy path |
546
+ | P2 | Div + Input + Invalid + Impatient | Critical | Most destructive |
547
+ | ... | ... | ... | ... |
548
+
549
+ ### Turn-Level Scenarios (living list)
550
+
551
+ <!-- Concrete behavior instructions, NOT character descriptions.
552
+ Each instruction tells the agent EXACTLY what to do at each turn. -->
553
+
554
+ **Profile P1 (baseline):**
555
+ - {{turn instruction}} — added: {{date}}
556
+
557
+ **Profile P2 (critical):**
558
+ - {{turn instruction}} — added: {{date}}
559
+ - {{turn instruction}} — added: {{date}}
560
+
561
+ ## Interaction Playbook
562
+
563
+ ### Product Type: {{type}}
564
+ ### Primary Testing Tool: {{tool}}
565
+
566
+ ### Available Interactions
567
+ | User Action | Tool / Method | Automatable |
568
+ |---|---|---|
569
+ | {{action}} | {{tool + method}} | ✅ / ⚠️ partial / ❌ manual |
570
+
571
+ ### Unavailable Interactions (manual testing required)
572
+ | User Action | Reason | Manual Checklist Item |
573
+ |---|---|---|
574
+ | {{action}} | {{why}} | [ ] {{checklist item}} |
575
+
576
+ ### Evidence Collection Strategy
577
+ | Evidence Type | Collection Tool | When to Collect |
578
+ |---|---|---|
579
+ | {{type}} | {{tool}} | {{when}} |
580
+
581
+ ### Failure State Injection Methods
582
+
583
+ | Type | Method | Tool | Applicable When |
584
+ |------|--------|------|----------------|
585
+ | Network failure | {{how to simulate}} | {{tool}} | {{which features}} |
586
+ | Resource deletion | {{how to simulate}} | {{tool}} | {{which features}} |
587
+ | Session expiry | {{how to simulate}} | {{tool}} | {{which features}} |
588
+
589
+ ### Discovered Patterns
590
+
591
+ <!-- New behavioral patterns found during QA. Grows with every run. -->
592
+
593
+ ## QA Quality Metrics
594
+
595
+ <!-- Self-measurement to prevent "easy mode". Updated after each TEST run. -->
596
+
597
+ | Metric | Current | Target |
598
+ |--------|---------|--------|
599
+ | Unique failures found (total) | 0 | — |
600
+ | Scenario diversity (profiles used) | {{N}}/{{total}} | 100% |
601
+ | Turn instructions executed | 0 | — |
602
+ | Failure injections performed | 0 | — |
603
+
604
+ ---
605
+
606
+ <!-- Feature test cases are appended below. -->
607
+ ```
608
+
609
+ **SETUP is complete when:**
610
+ - [ ] Product type classified (Web / CLI / API / Mobile / Library / Desktop / Game)
611
+ - [ ] Start command works — application runs
612
+ - [ ] Health check confirms the application is responsive
613
+ - [ ] Interaction Playbook built — every real user action mapped to a tool/method
614
+ - [ ] Unavailable interactions explicitly listed with manual checklist items
615
+ - [ ] Evidence collection strategy defined for this product type
616
+ - [ ] Behavioral axes mapped to project persona
617
+ - [ ] At least 5 test profiles defined (risk-ordered)
618
+ - [ ] At least 20 turn-level scenarios generated
619
+ - [ ] Failure state injection methods identified with specific tools
620
+ - [ ] `docs/QA.md` is written with Interaction Playbook section
621
+
622
+ ---
623
+
624
+ ## REVIEW Mode — Define What "Done" Looks Like
625
+
626
+ For each feature, define concrete, executable test cases in `docs/QA.md`. These test cases ARE the definition of "done."
627
+
628
+ **Prerequisites:** `docs/QA.md` exists (SETUP done). Feature spec exists.
629
+
630
+ ### Step 1: Testability Audit
631
+
632
+ Read every acceptance criterion. For each:
633
+
634
+ | AC | Testable? | Issue |
635
+ |----|-----------|-------|
636
+ | {{criterion}} | ✅ / ⚠️ / ❌ | {{why not}} |
637
+
638
+ - ✅ Specific trigger + specific result + verifiable
639
+ - ⚠️ Vague → propose rewrite: "Should be fast" → "Renders within 2s on 3G"
640
+ - ❌ Untestable → propose rewrite: "Works correctly" → {{concrete criterion}}
641
+
642
+ ### Step 2: Define Access Path
643
+
644
+ Determine the exact path to reach this feature. **Verify it works.**
645
+
646
+ ### Step 3: Select Test Profiles
647
+
648
+ From QA.md's test profiles, select which ones apply to this feature:
649
+
650
+ ```
651
+ 📋 **Profile selection — Feature {{id}}:**
652
+
653
+ | Profile | Applicable? | Reason |
654
+ |---------|-------------|--------|
655
+ | P1 (baseline) | ✅ Always | Happy path |
656
+ | P2 (destructive) | ✅ | This feature has input fields |
657
+ | P3 | ❌ | No file upload in this feature |
658
+ | P4 | ✅ | Multi-step flow, distraction relevant |
659
+ ```
660
+
661
+ ### Step 4: Write Test Cases
662
+
663
+ For each selected profile, generate test cases using its **turn-level instructions**:
664
+
665
+ ```markdown
666
+ ## Feature {{id}}: {{title}}
667
+
668
+ **Access:** {{exact path}}
669
+ **Preconditions:** {{what must be true}}
670
+ **Access verified:** ✅ {{date}} / ❌ {{blocker}}
671
+
672
+ ### Test Cases
673
+
674
+ | # | Profile | Scenario | Steps | Expected | Evidence | Status |
675
+ |---|---------|----------|-------|----------|----------|--------|
676
+ | 1 | P1 | Happy path: {{name}} | 1. {{exact step}} 2. ... | {{observable result}} | Screenshot | pending |
677
+ | 2 | P2 | {{turn instruction applied}} | 1. {{exact step}} 2. ... | {{expected behavior}} | Screenshot + console | pending |
678
+ | 3 | P2 | {{another turn instruction}} | 1. ... | {{expected}} | {{method}} | pending |
679
+ | 4 | — | Injection: {{failure type}} | 1. {{inject step}} 2. {{user action}} | {{graceful handling}} | Screenshot + log | pending |
680
+ ```
681
+
682
+ **Test case quality rules:**
683
+ - **Steps** must be executable by someone who has never seen the product. "Click the button" is bad. "Click the blue 'Create Project' button in the top-right nav bar" is good.
684
+ - **Expected** must be observable. "Data is saved" is bad. "Green toast 'Project created' appears, /projects page shows new item at top" is good.
685
+ - **Profile** column traces which behavioral axis combination generated this case.
686
+ - **Injection test cases** must specify exactly how to inject the failure state.
687
+
688
+ ### Step 5: Update QA.md
689
+
690
+ 1. Append the feature section to `docs/QA.md`
691
+ 2. Add any new turn-level scenarios to the Turn-Level Scenarios section
692
+ 3. Update feature spec frontmatter:
693
+ ```yaml
694
+ qaTestCases: {{count}}
695
+ qaReviewDate: {{date}}
696
+ ```
697
+
698
+ **REVIEW is complete when:**
699
+ - [ ] Every AC has at least one test case
700
+ - [ ] At least 3 profiles are represented in test cases
701
+ - [ ] At least 2 failure state injection test cases
702
+ - [ ] Access path verified
703
+ - [ ] Test cases are concrete enough that anyone could execute them
704
+ - [ ] Feature section appended to `docs/QA.md`
705
+
706
+ ---
707
+
708
+ ## TEST Mode — Run It and Prove It
709
+
710
+ Execute the test cases defined in `docs/QA.md`.
711
+
712
+ **Prerequisites:** `docs/QA.md` exists. Feature has test cases (REVIEW done).
713
+
714
+ ### Phase 1: Environment Setup
715
+
716
+ Read environment commands from QA.md. Start the application. Health check. Seed if needed.
717
+
718
+ If environment fails, stop and report.
719
+
720
+ ### Phase 2: Verify Feature Access
721
+
722
+ Navigate to the feature using the access path in QA.md. If blocked, stop and report.
723
+
724
+ ### Phase 3: Execute Test Cases (Profile-Ordered)
725
+
726
+ Execute in this order:
727
+
728
+ 1. **P1 (baseline/happy path)** — if these fail, stop. Nothing else matters.
729
+ 2. **Error handling cases** — invalid inputs, missing data
730
+ 3. **Higher-risk profiles (P2, P3...)** — follow turn-level instructions exactly
731
+ 4. **Failure state injection** — actually inject failures and observe
732
+
733
+ #### Execution by Product Type
734
+
735
+ **Read the Interaction Playbook in QA.md first.** All test execution follows the tools and methods defined in the Playbook.
736
+
737
+ **🌐 Web App — Playwright MCP execution pattern:**
738
+
739
+ Execute each test case following this pattern:
740
+
741
+ ```
742
+ 1. browser_navigate → target page
743
+ 2. browser_snapshot → read current state (acquire refs)
744
+ 3. browser_take_screenshot → capture BEFORE state as evidence
745
+ 4. [action] → browser_click / browser_type / browser_drag etc.
746
+ 5. browser_snapshot → read state after action
747
+ 6. browser_take_screenshot → capture AFTER state as evidence
748
+ 7. browser_console_messages → check for JS errors
749
+ ```
750
+
751
+ **Mandatory per test case:**
752
+ - `browser_take_screenshot` — minimum 2 times: BEFORE the key action and AFTER
753
+ - `browser_console_messages` — at test end, check for JS errors
754
+ - `browser_network_requests` — when API calls are involved, check for failures
755
+
756
+ **Evidence verdict pattern (mandatory for every test):**
757
+ ```
758
+ 📸 Evidence — Test #{{N}}: {{scenario name}}
759
+
760
+ BEFORE: [screenshot captured — {{describe what is visible}}]
761
+ ACTION: {{what was done — e.g. "clicked 'Save' button (ref e12)"}}
762
+ AFTER: [screenshot captured — {{describe what changed}}]
763
+
764
+ Console: {{clean / N errors found: [list]}}
765
+ Network: {{all 200 / failed: [list]}}
766
+
767
+ VERDICT: ✅ PASS — matches intent: "{{design intent or AC being verified}}"
768
+ ❌ FAIL — expected: {{expected}}, actual: {{actual}}
769
+ ⚠️ PARTIAL — {{what worked, what didn't}}
770
+ ```
771
+
772
+ **Every verdict MUST reference the specific acceptance criterion or design intent being verified.** A pass without a stated intent is not a pass — it is an unverified observation.
773
+
774
+ **Viewport testing (responsive):**
775
+ - Execute P1 happy path at default viewport first
776
+ - `browser_resize(390, 844)` (mobile) + re-execute same test
777
+ - `browser_resize(1024, 768)` (tablet) when applicable
778
+
779
+ **Exploratory testing (AI autonomous):**
780
+ - After all scripted test cases, run autonomous exploration
781
+ - "As {{persona_name}}, achieve {{feature's goal}}" → explore freely with Playwright MCP
782
+ - Do not constrain the path. The agent clicks, types, and navigates on its own.
783
+ - Record any discovered issues immediately in QA.md
784
+
785
+ **⌨️ CLI — Bash execution pattern:**
786
+
787
+ ```
788
+ 1. Run command → capture stdout/stderr
789
+ 2. Check exit code → echo $?
790
+ 3. Verify file/state changes → diff, ls -la before/after
791
+ 4. Assess whether error messages are useful to the user
792
+ ```
793
+
794
+ **Evidence verdict pattern:**
795
+ ```
796
+ 📋 Evidence — Test #{{N}}: {{scenario name}}
797
+
798
+ COMMAND: {{exact command run}}
799
+ STDOUT: {{first 20 lines or relevant excerpt}}
800
+ STDERR: {{if any}}
801
+ EXIT: {{code}}
802
+
803
+ STATE BEFORE: {{relevant state — file listing, DB row, etc.}}
804
+ STATE AFTER: {{relevant state}}
805
+
806
+ VERDICT: ✅ PASS / ❌ FAIL — expected: {{expected}}, actual: {{actual}}
807
+ ```
808
+
809
+ **⚠️ Even for CLI, test "like a user":**
810
+ - Enter commands with typos
811
+ - Run `--help` first and follow its guidance
812
+ - Try pipeline combinations
813
+ - Feed unexpected input (empty file, binary file, symlink)
814
+
815
+ **🔌 API — curl execution pattern:**
816
+
817
+ ```
818
+ 1. curl request → capture HTTP status + response body
819
+ 2. Measure response time → curl -w "%{time_total}"
820
+ 3. Bad requests → malformed body, missing auth, wrong Content-Type
821
+ 4. Concurrent requests → parallel PUT/DELETE to same resource
822
+ ```
823
+
824
+ **Evidence:** Full request + response (status, body, headers, time)
825
+
826
+ **📱 Mobile — emulator + screenshot pattern:**
827
+
828
+ ```
829
+ 1. Execute action via adb/xcrun
830
+ 2. Capture screenshot → analyze via Read tool
831
+ 3. Check errors via logcat / Console.app
832
+ 4. Non-automatable items → record in manual checklist
833
+ ```
834
+
835
+ **📚 Library — code execution pattern:**
836
+
837
+ ```
838
+ 1. Write test code → call API as a real user would
839
+ 2. Execute → verify result + error messages
840
+ 3. Copy-paste README examples verbatim → verify they actually work
841
+ 4. Induce type errors → verify error messages are clear and actionable
842
+ ```
843
+
844
+ ---
845
+
846
+ **For each test case (all product types):**
847
+
848
+ 1. Set up precondition
849
+ 2. Execute each step exactly as written — **use the tools defined in the Interaction Playbook**
850
+ 3. If the test case has a profile, **follow the profile's turn-level instructions** — don't improvise, don't be "kinder" than the instruction says
851
+ 4. Capture evidence at every assertion point — **follow the Playbook's Evidence Collection Strategy**
852
+ 5. Record: ✅ PASS / ❌ FAIL / ⚠️ PARTIAL
853
+
854
+ **For failure state injection test cases:**
855
+
856
+ 1. Start the normal flow (reach the target state)
857
+ 2. **Inject the failure** using the Playbook's Failure Injection Strategy
858
+ 3. Observe how the product responds
859
+ 4. Capture evidence: screenshot/output + console/log + server state
860
+ 5. Verify graceful handling (not crash, not silent failure, not data corruption)
861
+
862
+ **If a new edge case is discovered during testing:**
863
+ 1. Record it immediately
864
+ 2. Add it to the feature's test cases
865
+ 3. Add the underlying turn-level instruction to the relevant profile
866
+ 4. Update the Interaction Playbook if a new interaction pattern was discovered
867
+
868
+ ### Phase 4: QA Self-Check
869
+
870
+ Before writing the report, verify QA itself isn't running "easy mode":
871
+
872
+ ```
873
+ 🔍 **QA self-check:**
874
+
875
+ | Check | Result |
876
+ |-------|--------|
877
+ | Profiles used: {{N}}/{{total selected}} | ✅ all profiles tested / ⚠️ skipped {{which}} |
878
+ | Failure injections performed: {{N}}/{{total planned}} | ✅ / ⚠️ |
879
+ | Unique failures found: {{N}} | — (0 is suspicious for a new feature) |
880
+ | Scenario diversity: did tests cover different paths? | ✅ / ⚠️ same path repeated |
881
+ | Cooperation drift: did tests stay adversarial per profile? | ✅ / ⚠️ became cooperative mid-test |
882
+ ```
883
+
884
+ **If 0 unique failures on a new feature with 3+ profiles tested:** Either the implementation is exceptional, or the tests are too easy. Consider: were turn-level instructions followed literally? Were failure injections actually performed?
885
+
886
+ ### Phase 5: Update QA.md with Results + Insight Synthesis
887
+
888
+ Update the feature section in `docs/QA.md`:
889
+
890
+ 1. Change each test case's Status from `pending` to `✅`/`❌`/`⚠️`
891
+ 2. Add Results section with evidence
892
+ 3. Add **Insight Synthesis** — not just pass/fail, but patterns:
893
+
894
+ ```markdown
895
+ ### Results — {{date}}
896
+
897
+ | # | Status | Evidence | Notes |
898
+ |---|--------|----------|-------|
899
+ | 1 | ✅ | Screenshot: ... | ... |
900
+ | 2 | ❌ | Screenshot: ... | Expected: ... |
901
+
902
+ **Summary:** {{N}}/{{total}} passed, {{N}} failed, {{N}} partial
903
+
904
+ ### Insight Synthesis
905
+
906
+ <!-- Not just "what failed" but "why and what pattern".
907
+ UXCascade pattern: highlight → connect → actionable. -->
908
+
909
+ **Patterns found:**
910
+ - {{pattern}}: {{which test cases}} share the same root cause → {{actionable fix}}
911
+ - {{pattern}}: Profile P{{N}} consistently triggers {{behavior}} → {{systemic issue}}
912
+
913
+ **Per-profile failure distribution:**
914
+ | Profile | Tests | Pass | Fail | Insight |
915
+ |---------|-------|------|------|---------|
916
+ | P1 (baseline) | {{N}} | {{N}} | {{N}} | {{what this means}} |
917
+ | P2 (destructive) | {{N}} | {{N}} | {{N}} | {{what this means}} |
918
+
919
+ **Failure taxonomy:**
920
+ | Type | Count | Examples |
921
+ |------|-------|---------|
922
+ | Missing validation | {{N}} | Test #{{N}}, #{{N}} |
923
+ | Silent failure (no error shown) | {{N}} | Test #{{N}} |
924
+ | State corruption | {{N}} | Test #{{N}} |
925
+ | UI crash / unresponsive | {{N}} | Test #{{N}} |
926
+
927
+ **Recommendations (priority-ordered):**
928
+ 1. {{fix}} — affects {{N}} test cases, severity: {{P0-P3}}
929
+ 2. {{fix}} — ...
930
+
931
+ ### Issues
932
+ | # | Severity | Description | Reproduction | Evidence |
933
+ |---|----------|-------------|--------------|----------|
934
+ | 1 | {{P0-P3}} | {{what's wrong}} | Test #{{N}}, step {{N}} | {{ref}} |
935
+
936
+ ### New Discoveries
937
+ - Turn instruction: "{{new instruction}}" → added to Profile P{{N}}
938
+ - Failure injection: "{{new injection method}}" → added to Injection Methods
939
+ ```
940
+
941
+ 4. **Update QA Quality Metrics** in the top section of QA.md:
942
+ - Increment unique failures found
943
+ - Update profiles used
944
+ - Update turn instructions executed
945
+ - Update failure injections performed
946
+
947
+ 5. Update feature spec frontmatter:
948
+ ```yaml
949
+ qaStatus: {{pass|fail|partial}}
950
+ qaDate: {{date}}
951
+ ```
952
+
953
+ ---
954
+
955
+ ## When All Tests Pass
956
+
957
+ **All test cases ✅ = feature confirmed complete.**
958
+
959
+ This is the ONLY definition of "done." Not "code works on my machine." Not "unit tests pass." Not "it looks right." Every test case in QA.md, executed with evidence, marked ✅.
960
+
961
+ ---
962
+
963
+ ## Limitations & Human Anchor
964
+
965
+ **LLM QA does not replace human testing.** (τ-bench, Sim2Real 2026)
966
+
967
+ This QA framework is a **simulation pilot for refining designs before real user testing**. Known limitations:
968
+
969
+ - LLM simulators cannot express genuine frustration, confusion, or emotional reactions
970
+ - Automated pass/fail judgments can diverge significantly from human judgment
971
+ - Higher model capability does not mean more faithful user simulation
972
+ - Behavioral-axis-based testing is better than character-based, but it is still a simulation
973
+
974
+ **Human Anchor**: When possible, collect a few dozen real user session logs as a reference distribution. This anchors the entire QA structure. Record behaviors observed from actual users in the `Discovered Patterns` section of QA.md — these always take priority over simulated scenarios.
975
+
976
+ ---
977
+
978
+ ## Integration with Development Workflow
979
+
980
+ QA is the **final gate** in the review loop:
981
+
982
+ ```
983
+ Implementation → Designer Review + Architect Review (parallel, both must pass)
984
+
985
+ QA Review (runs the product against QA.md test cases)
986
+ ↓ (all test cases ✅)
987
+ Complete
988
+ ```
989
+
990
+ **QA review in the loop:**
991
+ - If QA fails → specific failure list with reproduction steps → implementer fixes
992
+ - After fix → QA re-tests failed cases + regression check on happy path (P1 profile)
993
+ - Loop until all test cases are ✅
994
+
995
+ **QA during feature definition:**
996
+ - `/know-thy-build:feature` should always be followed by `/know-thy-build:qa` in REVIEW mode
997
+ - The test cases in QA.md become the implementation target
998
+ - Implementers read QA.md to know exactly what "done" means
999
+
1000
+ ---
1001
+
1002
+ ## Rationalization Prevention
1003
+
1004
+ ### Iron Law
1005
+
1006
+ **No test passes without evidence. No feature ships without QA. QA.md is the single source of truth.**
1007
+
1008
+ ### Red Flags
1009
+
1010
+ | Thought | Reality |
1011
+ |---------|---------|
1012
+ | "The tests pass, so it works" | Unit tests verify code. QA verifies behavior. They test different things. |
1013
+ | "This is a simple feature, it doesn't need edge case testing" | Simple features get fewer profiles, not zero profiles. P1 + P2 minimum. |
1014
+ | "The happy path works, ship it" | P1 always works. P2 is where bugs live. |
1015
+ | "We'll add tests later" | Define test cases in QA.md NOW, during REVIEW mode. |
1016
+ | "It works on my machine" | Test with failure state injection. Does it work when the network drops? |
1017
+ | "Edge case testing is overkill" | The user who refreshes mid-save doesn't know they're an edge case. |
1018
+ | "I can see from the code that it handles this" | Code reading is not testing. Run it. Inject the failure. Capture evidence. |
1019
+ | "0 failures means we're done" | 0 failures on a new feature with 3+ profiles is suspicious. Were turn instructions followed literally? |
1020
+ | "I tested as the difficult persona" | Which profile? Which turn instructions? "Being difficult" without axes is easy mode. |
1021
+
1022
+ ---
1023
+
1024
+ ## Closing
1025
+
1026
+ **After SETUP:**
1027
+ - `docs/QA.md` created with environment, behavioral axes, test profiles, turn-level scenarios
1028
+ - Environment verified — the product can be started and accessed
1029
+ - Failure state injection methods identified
1030
+ - Ready for REVIEW mode on any feature
1031
+
1032
+ **After REVIEW:**
1033
+ - Feature's test cases defined in `docs/QA.md` with profile attribution
1034
+ - Each test case has concrete steps, expected results, evidence method
1035
+ - Failure injection test cases included
1036
+ - Implementers read QA.md to know exactly what "done" means
1037
+ - Ready for implementation → TEST mode after
1038
+
1039
+ **After TEST:**
1040
+ - Test results with evidence recorded in `docs/QA.md`
1041
+ - Insight synthesis: patterns, failure taxonomy, recommendations
1042
+ - QA quality metrics updated (self-check against easy mode)
1043
+ - If any ❌: specific failure list with reproduction steps
1044
+ - New turn-level scenarios added to the playbook
1045
+ - The QA document is now richer for the next feature
1046
+
1047
+ ### Gate Update
1048
+
1049
+ After TEST mode completes with all test cases passing, update the feature spec's gate:
1050
+
1051
+ 1. Find the active feature spec:
1052
+ ```bash
1053
+ FEATURE_NUM=$(git branch --show-current | grep -oE '[0-9]+' | head -1)
1054
+ FEATURE_FILE="docs/features/$(printf '%03d' $FEATURE_NUM).md"
1055
+ ```
1056
+
1057
+ 2. Update gate status in the frontmatter:
1058
+ Change `qa: pending` to `qa: passed` in the `gate:` section.
1059
+
1060
+ 3. Add the current date next to the status:
1061
+ ```yaml
1062
+ gate:
1063
+ qa: passed # {{date}}
1064
+ ```
1065
+
1066
+ 4. **Check all gates:**
1067
+ Read the full gate section. If ALL gates are `passed` or `skipped`:
1068
+ > "All gates passed. Run `/know-thy-build:finish` to merge this feature to main."
1069
+
1070
+ If any gate is still `pending`:
1071
+ > "QA passed. Remaining gates: {{list pending gates}}. Complete those reviews before merge."
1072
+
1073
+ This gate update is recorded in the worktree. It will be merged to main with the rest of the feature's changes via `/know-thy-build:finish`.