mindsystem-cc 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +501 -0
  3. package/agents/ms-codebase-mapper.md +739 -0
  4. package/agents/ms-debugger.md +1184 -0
  5. package/agents/ms-designer.md +414 -0
  6. package/agents/ms-executor.md +760 -0
  7. package/agents/ms-integration-checker.md +423 -0
  8. package/agents/ms-milestone-auditor.md +448 -0
  9. package/agents/ms-mock-generator.md +182 -0
  10. package/agents/ms-plan-checker.md +746 -0
  11. package/agents/ms-research-synthesizer.md +248 -0
  12. package/agents/ms-researcher.md +962 -0
  13. package/agents/ms-roadmapper.md +606 -0
  14. package/agents/ms-verifier.md +779 -0
  15. package/agents/ms-verify-fixer.md +124 -0
  16. package/bin/install.js +296 -0
  17. package/commands/ms/add-phase.md +207 -0
  18. package/commands/ms/add-todo.md +182 -0
  19. package/commands/ms/audit-milestone.md +318 -0
  20. package/commands/ms/check-phase.md +162 -0
  21. package/commands/ms/check-todos.md +217 -0
  22. package/commands/ms/complete-milestone.md +137 -0
  23. package/commands/ms/create-roadmap.md +273 -0
  24. package/commands/ms/debug.md +149 -0
  25. package/commands/ms/define-requirements.md +121 -0
  26. package/commands/ms/design-phase.md +341 -0
  27. package/commands/ms/discuss-milestone.md +48 -0
  28. package/commands/ms/discuss-phase.md +60 -0
  29. package/commands/ms/do-work.md +90 -0
  30. package/commands/ms/execute-phase.md +289 -0
  31. package/commands/ms/help.md +623 -0
  32. package/commands/ms/insert-phase.md +227 -0
  33. package/commands/ms/list-phase-assumptions.md +50 -0
  34. package/commands/ms/map-codebase.md +71 -0
  35. package/commands/ms/new-milestone.md +193 -0
  36. package/commands/ms/new-project.md +338 -0
  37. package/commands/ms/pause-work.md +123 -0
  38. package/commands/ms/plan-milestone-gaps.md +285 -0
  39. package/commands/ms/plan-phase.md +105 -0
  40. package/commands/ms/progress.md +370 -0
  41. package/commands/ms/remove-phase.md +338 -0
  42. package/commands/ms/research-phase.md +175 -0
  43. package/commands/ms/research-project.md +339 -0
  44. package/commands/ms/resume-work.md +40 -0
  45. package/commands/ms/review-design.md +484 -0
  46. package/commands/ms/simplify-flutter.md +193 -0
  47. package/commands/ms/update.md +159 -0
  48. package/commands/ms/verify-work.md +92 -0
  49. package/commands/ms/whats-new.md +124 -0
  50. package/mindsystem/references/checkpoints.md +788 -0
  51. package/mindsystem/references/continuation-format.md +255 -0
  52. package/mindsystem/references/debugging/debugging-mindset.md +11 -0
  53. package/mindsystem/references/debugging/hypothesis-testing.md +11 -0
  54. package/mindsystem/references/debugging/investigation-techniques.md +11 -0
  55. package/mindsystem/references/debugging/verification-patterns.md +11 -0
  56. package/mindsystem/references/debugging/when-to-research.md +11 -0
  57. package/mindsystem/references/git-integration.md +254 -0
  58. package/mindsystem/references/goal-backward.md +286 -0
  59. package/mindsystem/references/mock-patterns.md +294 -0
  60. package/mindsystem/references/plan-format.md +473 -0
  61. package/mindsystem/references/principles.md +73 -0
  62. package/mindsystem/references/questioning.md +140 -0
  63. package/mindsystem/references/research-pitfalls.md +233 -0
  64. package/mindsystem/references/scope-estimation.md +256 -0
  65. package/mindsystem/references/tdd.md +263 -0
  66. package/mindsystem/references/verification-patterns.md +595 -0
  67. package/mindsystem/templates/DEBUG.md +159 -0
  68. package/mindsystem/templates/UAT.md +403 -0
  69. package/mindsystem/templates/adhoc-summary.md +153 -0
  70. package/mindsystem/templates/codebase/architecture.md +255 -0
  71. package/mindsystem/templates/codebase/concerns.md +310 -0
  72. package/mindsystem/templates/codebase/conventions.md +307 -0
  73. package/mindsystem/templates/codebase/integrations.md +280 -0
  74. package/mindsystem/templates/codebase/stack.md +186 -0
  75. package/mindsystem/templates/codebase/structure.md +285 -0
  76. package/mindsystem/templates/codebase/testing.md +480 -0
  77. package/mindsystem/templates/config.json +26 -0
  78. package/mindsystem/templates/context.md +140 -0
  79. package/mindsystem/templates/continue-here.md +78 -0
  80. package/mindsystem/templates/debug-subagent-prompt.md +91 -0
  81. package/mindsystem/templates/design-iteration.md +208 -0
  82. package/mindsystem/templates/design.md +417 -0
  83. package/mindsystem/templates/discovery.md +146 -0
  84. package/mindsystem/templates/milestone-archive.md +123 -0
  85. package/mindsystem/templates/milestone-context.md +93 -0
  86. package/mindsystem/templates/milestone.md +115 -0
  87. package/mindsystem/templates/phase-prompt.md +574 -0
  88. package/mindsystem/templates/project.md +184 -0
  89. package/mindsystem/templates/requirements.md +231 -0
  90. package/mindsystem/templates/research-project/ARCHITECTURE.md +204 -0
  91. package/mindsystem/templates/research-project/FEATURES.md +147 -0
  92. package/mindsystem/templates/research-project/PITFALLS.md +200 -0
  93. package/mindsystem/templates/research-project/STACK.md +120 -0
  94. package/mindsystem/templates/research-project/SUMMARY.md +170 -0
  95. package/mindsystem/templates/research-subagent-prompt.md +92 -0
  96. package/mindsystem/templates/research.md +529 -0
  97. package/mindsystem/templates/roadmap.md +214 -0
  98. package/mindsystem/templates/state.md +224 -0
  99. package/mindsystem/templates/summary.md +269 -0
  100. package/mindsystem/templates/user-setup.md +323 -0
  101. package/mindsystem/templates/verification-report.md +322 -0
  102. package/mindsystem/workflows/complete-milestone.md +759 -0
  103. package/mindsystem/workflows/create-milestone.md +203 -0
  104. package/mindsystem/workflows/debug.md +14 -0
  105. package/mindsystem/workflows/define-requirements.md +330 -0
  106. package/mindsystem/workflows/diagnose-issues.md +241 -0
  107. package/mindsystem/workflows/discovery-phase.md +293 -0
  108. package/mindsystem/workflows/discuss-milestone.md +310 -0
  109. package/mindsystem/workflows/discuss-phase.md +237 -0
  110. package/mindsystem/workflows/do-work.md +359 -0
  111. package/mindsystem/workflows/execute-phase.md +644 -0
  112. package/mindsystem/workflows/execute-plan.md +1828 -0
  113. package/mindsystem/workflows/generate-mocks.md +187 -0
  114. package/mindsystem/workflows/list-phase-assumptions.md +178 -0
  115. package/mindsystem/workflows/map-codebase.md +289 -0
  116. package/mindsystem/workflows/plan-phase.md +876 -0
  117. package/mindsystem/workflows/research-phase.md +17 -0
  118. package/mindsystem/workflows/research-project.md +23 -0
  119. package/mindsystem/workflows/resume-project.md +311 -0
  120. package/mindsystem/workflows/transition.md +564 -0
  121. package/mindsystem/workflows/verify-phase.md +629 -0
  122. package/mindsystem/workflows/verify-work.md +823 -0
  123. package/package.json +32 -0
  124. package/scripts/generate-phase-patch.sh +169 -0
  125. package/scripts/ms-lookup/README.md +112 -0
  126. package/scripts/ms-lookup/ms_lookup/__init__.py +3 -0
  127. package/scripts/ms-lookup/ms_lookup/__main__.py +6 -0
  128. package/scripts/ms-lookup/ms_lookup/backends/__init__.py +6 -0
  129. package/scripts/ms-lookup/ms_lookup/backends/context7.py +219 -0
  130. package/scripts/ms-lookup/ms_lookup/backends/perplexity.py +145 -0
  131. package/scripts/ms-lookup/ms_lookup/cache.py +48 -0
  132. package/scripts/ms-lookup/ms_lookup/cli.py +219 -0
  133. package/scripts/ms-lookup/ms_lookup/config.py +23 -0
  134. package/scripts/ms-lookup/ms_lookup/errors.py +24 -0
  135. package/scripts/ms-lookup/ms_lookup/output.py +49 -0
  136. package/scripts/ms-lookup/ms_lookup/tokens.py +56 -0
  137. package/scripts/ms-lookup/pyproject.toml +17 -0
  138. package/scripts/ms-lookup/uv.lock +207 -0
  139. package/scripts/ms-lookup-wrapper.sh +21 -0
@@ -0,0 +1,823 @@
1
+ <purpose>
2
+ Validate built features through batched testing with mock support and inline fixing. Creates UAT.md that tracks test progress, supports mock generation for UI state testing, and fixes issues immediately while context is fresh.
3
+
4
+ Complete verify-and-fix session: by session end, everything verified, issues fixed, tests passing.
5
+ </purpose>
6
+
7
+ <execution_context>
8
+ @~/.claude/mindsystem/workflows/generate-mocks.md
9
+ @~/.claude/mindsystem/references/mock-patterns.md
10
+ </execution_context>
11
+
12
+ <template>
13
+ @~/.claude/mindsystem/templates/UAT.md
14
+ </template>
15
+
16
+ <philosophy>
17
+ **Verify and fix in one session.**
18
+
19
+ Old flow: verify → log gaps → /clear → plan-phase --gaps → execute → verify again
20
+ New flow: verify → investigate → fix → re-test → continue
21
+
22
+ **Mocks enable testing unreachable states.**
23
+
24
+ Error displays, premium features, empty lists — all require specific backend conditions. Mocks let you toggle states and test immediately.
25
+
26
+ **Keep mocks and fixes separate.**
27
+
28
+ Mocks are uncommitted scaffolding. Fixes are clean commits. Git stash keeps them separated.
29
+
30
+ **Fix while context is hot.**
31
+
32
+ When you find an issue, you have the mock state active, the test fresh in mind, and the user ready to re-test. Fix it now, not later.
33
+ </philosophy>
34
+
35
+ <process>
36
+
37
+ <step name="check_dirty_tree" priority="first">
38
+ **Before anything else, check for uncommitted changes.**
39
+
40
+ ```bash
41
+ git status --porcelain
42
+ ```
43
+
44
+ **If output is non-empty (dirty tree):**
45
+
46
+ Present options via AskUserQuestion:
47
+ ```
48
+ questions:
49
+ - question: "You have uncommitted changes. How should I handle them before starting UAT?"
50
+ header: "Git state"
51
+ options:
52
+ - label: "Stash changes"
53
+ description: "git stash push -m 'pre-verify-work' — I'll restore them after UAT"
54
+ - label: "Commit first"
55
+ description: "Let me commit these changes before we start"
56
+ - label: "Abort"
57
+ description: "Cancel UAT, I'll handle my changes manually"
58
+ multiSelect: false
59
+ ```
60
+
61
+ **Handle response:**
62
+ - "Stash changes" → `git stash push -m "pre-verify-work"`, record `pre_work_stash: "pre-verify-work"` for later
63
+ - "Commit first" → Prompt user to commit, then continue
64
+ - "Abort" → Exit gracefully
65
+
66
+ **If clean tree:** Continue to next step.
67
+ </step>
68
+
69
+ <step name="check_active_session">
70
+ **Check for active UAT sessions:**
71
+
72
+ ```bash
73
+ find .planning/phases -name "*-UAT.md" -type f 2>/dev/null | head -5
74
+ ```
75
+
76
+ **If active sessions exist AND no $ARGUMENTS provided:**
77
+
78
+ Read each file's frontmatter (status, phase, current_batch) and present:
79
+
80
+ ```
81
+ ## Active UAT Sessions
82
+
83
+ | # | Phase | Status | Current Batch | Progress |
84
+ |---|-------|--------|---------------|----------|
85
+ | 1 | 04-comments | testing | 2 of 4 | 5/12 |
86
+ | 2 | 05-auth | testing | 1 of 3 | 0/8 |
87
+
88
+ Reply with a number to resume, or provide a phase number to start new.
89
+ ```
90
+
91
+ Wait for user response.
92
+ - Number (1, 2) → Load that file, go to `resume_from_file`
93
+ - Phase number → Treat as new session
94
+
95
+ **If active sessions AND $ARGUMENTS provided:**
96
+ - Check if session exists for that phase
97
+ - If yes: offer to resume or restart
98
+ - If no: continue to `find_summaries`
99
+
100
+ **If no active sessions AND no $ARGUMENTS:**
101
+ ```
102
+ No active UAT sessions.
103
+
104
+ Provide a phase number to start testing (e.g., /ms:verify-work 4)
105
+ ```
106
+
107
+ **If no active sessions AND $ARGUMENTS provided:** Continue to `find_summaries`
108
+ </step>
109
+
110
+ <step name="find_summaries">
111
+ **Find SUMMARY.md files for the phase:**
112
+
113
+ ```bash
114
+ PHASE_DIR=$(ls -d .planning/phases/${PHASE_ARG}* 2>/dev/null | head -1)
115
+ ls "$PHASE_DIR"/*-SUMMARY.md 2>/dev/null
116
+ ```
117
+
118
+ Read each SUMMARY.md to extract testable deliverables.
119
+ </step>
120
+
121
+ <step name="extract_tests">
122
+ **Extract testable deliverables from SUMMARY.md files:**
123
+
124
+ Parse for:
125
+ 1. **Accomplishments** — Features/functionality added
126
+ 2. **User-facing changes** — UI, workflows, interactions
127
+
128
+ Focus on USER-OBSERVABLE outcomes, not implementation details.
129
+
130
+ For each deliverable, create test entry:
131
+ - name: Brief test name
132
+ - expected: Observable behavior (specific, what user should see)
133
+
134
+ **Examples:**
135
+ - Accomplishment: "Added comment threading with infinite nesting"
136
+ → Test: "Reply to a Comment"
137
+ → Expected: "Clicking Reply opens inline composer. Submitting shows reply nested under parent."
138
+
139
+ Skip internal/non-observable items (refactors, type changes, etc.).
140
+ </step>
141
+
142
+ <step name="classify_tests">
143
+ **Classify all tests by mock requirements:**
144
+
145
+ For each test, analyze the expected behavior to determine:
146
+ 1. **mock_required**: Does this need special backend state?
147
+ 2. **mock_type**: Freeform string describing needed state (e.g., "error_state", "premium_user", "empty_response")
148
+ 3. **dependencies**: Other tests this depends on (infer from descriptions)
149
+
150
+ **Classification heuristics:**
151
+
152
+ | Expected behavior contains | Likely mock_type |
153
+ |---------------------------|------------------|
154
+ | "error", "fails", "invalid" | error_state |
155
+ | "premium", "pro", "paid", "subscription" | premium_user |
156
+ | "empty", "no results", "placeholder" | empty_response |
157
+ | "loading", "spinner", "skeleton" | loading_state |
158
+ | "offline", "no connection" | offline_state |
159
+ | Normal happy path | no mock needed |
160
+
161
+ **Dependency inference:**
162
+ - "Reply to comment" depends on "View comments"
163
+ - "Delete account" depends on "Login"
164
+ - Tests mentioning prior state depend on tests that create that state
165
+
166
+ Build classification list:
167
+ ```yaml
168
+ tests:
169
+ - name: "Login success"
170
+ mock_required: false
171
+ mock_type: null
172
+ dependencies: []
173
+
174
+ - name: "Login error message"
175
+ mock_required: true
176
+ mock_type: "error_state"
177
+ dependencies: ["login_flow"]
178
+
179
+ - name: "Premium badge display"
180
+ mock_required: true
181
+ mock_type: "premium_user"
182
+ dependencies: ["login_flow"]
183
+ ```
184
+ </step>
185
+
186
+ <step name="create_batches">
187
+ **Group tests into batches:**
188
+
189
+ **Rules:**
190
+ 1. Group by mock_type (tests needing same mock state go together)
191
+ 2. Respect dependencies (if B depends on A, A must be in same or earlier batch)
192
+ 3. Max 4 tests per batch (AskUserQuestion limit)
193
+ 4. No-mock tests first (run before any mock setup)
194
+ 5. Order mock states logically: success → error → empty → loading
195
+
196
+ **Batch structure:**
197
+ ```yaml
198
+ batches:
199
+ - batch: 1
200
+ name: "No Mocks Required"
201
+ mock_type: null
202
+ tests: [1, 2, 3]
203
+
204
+ - batch: 2
205
+ name: "Error States"
206
+ mock_type: "error_state"
207
+ tests: [4, 5, 6, 7]
208
+
209
+ - batch: 3
210
+ name: "Premium Features"
211
+ mock_type: "premium_user"
212
+ tests: [8, 9, 10]
213
+ ```
214
+ </step>
215
+
216
+ <step name="create_uat_file">
217
+ **Create UAT file with full structure:**
218
+
219
+ ```bash
220
+ mkdir -p "$PHASE_DIR"
221
+ ```
222
+
223
+ Create file at `.planning/phases/XX-name/{phase}-UAT.md`:
224
+
225
+ ```markdown
226
+ ---
227
+ status: testing
228
+ phase: XX-name
229
+ source: [list of SUMMARY.md files]
230
+ started: [ISO timestamp]
231
+ updated: [ISO timestamp]
232
+ current_batch: 1
233
+ mock_stash: null
234
+ pre_work_stash: [from dirty tree handling, or null]
235
+ ---
236
+
237
+ ## Progress
238
+
239
+ total: [N]
240
+ tested: 0
241
+ passed: 0
242
+ issues: 0
243
+ fixing: 0
244
+ pending: [N]
245
+ skipped: 0
246
+
247
+ ## Current Batch
248
+
249
+ batch: 1 of [total_batches]
250
+ name: "[batch name]"
251
+ mock_type: [mock_type or null]
252
+ tests: [test numbers]
253
+ status: pending
254
+
255
+ ## Tests
256
+
257
+ ### 1. [Test Name]
258
+ expected: [observable behavior]
259
+ mock_required: [true/false]
260
+ mock_type: [type or null]
261
+ result: [pending]
262
+
263
+ ### 2. [Test Name]
264
+ ...
265
+
266
+ ## Fixes Applied
267
+
268
+ [none yet]
269
+
270
+ ## Batches
271
+
272
+ ### Batch 1: [Name]
273
+ tests: [1, 2, 3]
274
+ status: pending
275
+ mock_type: null
276
+
277
+ ### Batch 2: [Name]
278
+ tests: [4, 5, 6, 7]
279
+ status: pending
280
+ mock_type: error_state
281
+
282
+ ...
283
+
284
+ ## Assumptions
285
+
286
+ [none yet]
287
+ ```
288
+
289
+ Proceed to `execute_batch`.
290
+ </step>
291
+
292
+ <step name="execute_batch">
293
+ **Execute current batch:**
294
+
295
+ Read current batch from UAT.md.
296
+
297
+ **1. Handle mock generation (if needed):**
298
+
299
+ If `mock_type` is not null AND different from previous batch:
300
+ - Discard old mocks if any (use stash name from `mock_stash` in UAT.md frontmatter):
301
+ ```bash
302
+ MOCK_STASH=$(git stash list | grep "mocks-batch" | head -1 | cut -d: -f1)
303
+ [ -n "$MOCK_STASH" ] && git stash drop "$MOCK_STASH"
304
+ ```
305
+ - Go to `generate_mocks`
306
+
307
+ If `mock_type` is null or same as previous:
308
+ - Skip mock generation
309
+ - Go to `present_tests`
310
+
311
+ **2. Present tests:**
312
+ Go to `present_tests`
313
+ </step>
314
+
315
+ <step name="generate_mocks">
316
+ **Generate mocks for current batch:**
317
+
318
+ Present mock generation options:
319
+ ```
320
+ ## Batch [N]: [Name]
321
+
322
+ **Mock required:** [mock_type description]
323
+
324
+ This batch tests states that require mock data. Options:
325
+
326
+ 1. Generate mocks (Recommended) — I'll create the override files
327
+ 2. I'll set up mocks manually — Skip generation, you handle it
328
+ 3. Skip this batch — Log all tests as assumptions
329
+ ```
330
+
331
+ **If "Generate mocks":**
332
+
333
+ Spawn mock generator:
334
+ ```
335
+ Task(
336
+ prompt="""
337
+ Generate mocks for manual UAT testing.
338
+
339
+ Project: {from PROJECT.md}
340
+ Phase: {phase_name}
341
+ Mock type: {mock_type}
342
+
343
+ Tests requiring this mock:
344
+ {test list with expected behaviors}
345
+
346
+ Follow patterns from @~/.claude/mindsystem/workflows/generate-mocks.md
347
+ """,
348
+ subagent_type="ms-mock-generator",
349
+ description="Generate {mock_type} mocks"
350
+ )
351
+ ```
352
+
353
+ After mock generator returns:
354
+
355
+ 1. Update UAT.md: `mock_stash: null` (mocks are uncommitted, not stashed yet)
356
+ 2. Present toggle instructions from mock generator
357
+ 3. Ask user to confirm mocks are active:
358
+
359
+ ```
360
+ questions:
361
+ - question: "I've created the mock files. Have you enabled the mocks and verified they're working?"
362
+ header: "Mocks ready"
363
+ options:
364
+ - label: "Yes, mocks are active"
365
+ description: "I've toggled the flags and hot reloaded"
366
+ - label: "Having trouble"
367
+ description: "Something isn't working with the mocks"
368
+ multiSelect: false
369
+ ```
370
+
371
+ **If "I'll set up manually":**
372
+ - Present what mock state is needed
373
+ - Wait for user to confirm ready
374
+
375
+ **If "Skip this batch":**
376
+ - Prompt for reason: "Why are you skipping this batch?"
377
+ - Mark all tests in batch as `skipped` with user's reason
378
+ - Append to Assumptions section
379
+ - Proceed to next batch
380
+
381
+ Proceed to `present_tests`.
382
+ </step>
383
+
384
+ <step name="present_tests">
385
+ **Present batch tests via AskUserQuestion:**
386
+
387
+ Collect tests for current batch (only `[pending]` and `blocked` results).
388
+
389
+ Build AskUserQuestion with up to 4 questions:
390
+ ```
391
+ questions:
392
+ - question: "Test {N}: {name} — {expected}"
393
+ header: "Test {N}"
394
+ options:
395
+ - label: "Pass"
396
+ description: "Works as expected"
397
+ - label: "Can't test"
398
+ description: "Blocked by a previous failure"
399
+ - label: "Skip"
400
+ description: "Assume it works (can't test this state)"
401
+ multiSelect: false
402
+ ```
403
+
404
+ The "Other" option is auto-added for issue descriptions.
405
+
406
+ **Tip for users:** To skip with custom reason, select "Other" and start with `Skip:` — e.g., `Skip: Requires paid API key`.
407
+
408
+ Update Current Batch section:
409
+ ```
410
+ ## Current Batch
411
+
412
+ batch: [N] of [total]
413
+ name: "[name]"
414
+ mock_type: [type]
415
+ tests: [numbers]
416
+ status: testing
417
+ ```
418
+
419
+ Wait for user responses.
420
+ Proceed to `process_batch_responses`.
421
+ </step>
422
+
423
+ <step name="process_batch_responses">
424
+ **Process batch responses:**
425
+
426
+ For each question:
427
+
428
+ | User Selected | Action |
429
+ |---------------|--------|
430
+ | "Pass" | result: pass |
431
+ | "Can't test" | result: blocked (re-test later) |
432
+ | "Skip" | result: skipped, add to Assumptions |
433
+ | "Other: Skip: {reason}" | result: skipped with custom reason, add to Assumptions |
434
+ | "Other: {text}" | result: issue, add `fix_status: investigating`, `retry_count: 0`, go to `investigate_issue` |
435
+
436
+ **Severity inference (for issues):**
437
+
438
+ | User description contains | Severity |
439
+ |---------------------------|----------|
440
+ | crash, error, exception, fails completely, unusable | blocker |
441
+ | doesn't work, nothing happens, wrong behavior, missing | major |
442
+ | slow, weird, off, minor, small | minor |
443
+ | color, font, spacing, alignment, visual | cosmetic |
444
+ | Default | major |
445
+
446
+ **Update UAT.md after processing all responses in batch:**
447
+ - Update each test's result
448
+ - Update Progress counts
449
+ - Update Batches section
450
+ - Update timestamp
451
+
452
+ **For each issue found:** Go to `investigate_issue` before processing next test.
453
+ </step>
454
+
455
+ <step name="investigate_issue">
456
+ **Investigate reported issue:**
457
+
458
+ **1. Lightweight investigation (2-3 tool calls):**
459
+
460
+ ```
461
+ # Example investigation:
462
+ 1. Grep for error message or component name
463
+ 2. Read the most likely file (from test classification)
464
+ 3. Check git log for recent changes to relevant files
465
+ ```
466
+
467
+ **2. Determine if cause is found:**
468
+
469
+ **If cause found AND fix is simple (single file, straightforward change):**
470
+ - Propose fix in plain language:
471
+ ```
472
+ Found the issue. In `ErrorBanner.tsx` line 42, the error message is
473
+ hardcoded to "Something went wrong" instead of using the actual error
474
+ from the API response.
475
+
476
+ I'll change it to use `error.message` from props.
477
+
478
+ Apply this fix?
479
+ ```
480
+ - Present options: [Yes / Let me see the code first / Different approach]
481
+ - If approved: Go to `apply_fix`
482
+
483
+ **If cause found BUT fix is complex (multiple files, architectural):**
484
+ - Report finding
485
+ - Spawn ms-verify-fixer subagent (go to `escalate_to_fixer`)
486
+
487
+ **If cause NOT found after 2-3 checks:**
488
+ - Escalate to fixer subagent (go to `escalate_to_fixer`)
489
+ </step>
490
+
491
+ <step name="apply_fix">
492
+ **Apply fix inline:**
493
+
494
+ **1. Stash mocks (if active):**
495
+ ```bash
496
+ git stash push -m "mocks-batch-{N}"
497
+ ```
498
+ Update UAT.md: `mock_stash: "mocks-batch-{N}"`
499
+
500
+ **2. Make the fix:**
501
+ - Edit the file(s)
502
+ - Test that fix compiles/runs
503
+
504
+ **3. Commit with proper message:**
505
+ ```bash
506
+ git add [specific files]
507
+ git commit -m "fix({phase}-uat): {description}"
508
+ ```
509
+
510
+ **4. Record in UAT.md:**
511
+ - Update test: `fix_status: applied`, `fix_commit: {hash}`
512
+ - Append to Fixes Applied section:
513
+ ```yaml
514
+ - commit: {hash}
515
+ test: {N}
516
+ description: "{what was fixed}"
517
+ files: [{changed files}]
518
+ ```
519
+
520
+ **5. Restore mocks:**
521
+ ```bash
522
+ git stash pop
523
+ ```
524
+
525
+ **Handle stash conflict:**
526
+ ```bash
527
+ # If conflict, take fix version
528
+ git checkout --theirs <conflicted-file>
529
+ git add <conflicted-file>
530
+ ```
531
+ Log that mock was discarded for that file.
532
+
533
+ **6. Request re-test:**
534
+ ```
535
+ Fix applied. Please re-test: {specific instruction}
536
+
537
+ [Pass / Still broken / New issue]
538
+ ```
539
+
540
+ Go to `handle_retest`.
541
+ </step>
542
+
543
+ <step name="escalate_to_fixer">
544
+ **Spawn fixer subagent for complex issue:**
545
+
546
+ **1. Stash mocks (if active):**
547
+ ```bash
548
+ git stash push -m "mocks-batch-{N}"
549
+ ```
550
+
551
+ **2. Spawn ms-verify-fixer:**
552
+ ```
553
+ Task(
554
+ prompt="""
555
+ You are a GSD verify-fixer. Investigate this issue, find the root cause, implement a fix, and commit it.
556
+
557
+ ## Issue
558
+
559
+ **Test:** {test_name}
560
+ **Expected:** {expected_behavior}
561
+ **Actual:** {user_reported_behavior}
562
+ **Severity:** {inferred_severity}
563
+
564
+ ## Context
565
+
566
+ **Phase:** {phase_name}
567
+ **Mock state active:** {mock_type or "none"}
568
+ **Relevant files (suspected):** {file_list}
569
+
570
+ ## What was already checked
571
+
572
+ {lightweight_investigation_results}
573
+
574
+ ## Your task
575
+
576
+ 1. Investigate to find root cause
577
+ 2. Implement minimal fix
578
+ 3. Commit with message: fix({phase}-uat): {description}
579
+ 4. Return FIX COMPLETE or INVESTIGATION INCONCLUSIVE
580
+
581
+ Mocks are stashed — working tree is clean.
582
+ """,
583
+ subagent_type="ms-verify-fixer",
584
+ description="Fix: {test_name}"
585
+ )
586
+ ```
587
+
588
+ **3. Handle fixer return:**
589
+
590
+ **If FIX COMPLETE:**
591
+ - Update UAT.md with fix details
592
+ - Restore mocks: `git stash pop`
593
+ - Handle conflicts as in `apply_fix`
594
+ - Request re-test
595
+
596
+ **If INVESTIGATION INCONCLUSIVE:**
597
+ - Restore mocks: `git stash pop`
598
+ - Present options:
599
+ ```
600
+ Investigation didn't find root cause.
601
+
602
+ Options:
603
+ 1. Try different approach — I'll investigate from another angle
604
+ 2. Skip as assumption — Log and move on
605
+ 3. Manual investigation — You'll look into this yourself
606
+ ```
607
+ - Handle response accordingly
608
+ </step>
609
+
610
+ <step name="handle_retest">
611
+ **Handle re-test result:**
612
+
613
+ Present re-test question:
614
+ ```
615
+ questions:
616
+ - question: "Re-test: {test_name} — Does it work now?"
617
+ header: "Re-test"
618
+ options:
619
+ - label: "Pass"
620
+ description: "Fixed! Works correctly now"
621
+ - label: "Still broken"
622
+ description: "Same issue persists"
623
+ - label: "New issue"
624
+ description: "Original fixed but found different problem"
625
+ multiSelect: false
626
+ ```
627
+
628
+ **If Pass:**
629
+ - Update test: `result: pass`, `fix_status: verified`
630
+ - Continue to next issue or next batch
631
+
632
+ **If Still broken (retry_count < 2):**
633
+ - Increment `retry_count` in UAT.md test entry
634
+ - Go back to `investigate_issue` with new context
635
+
636
+ **If Still broken (retry_count >= 2):**
637
+ - Present options:
638
+ ```
639
+ Fix didn't resolve the issue after 2 attempts.
640
+
641
+ Options:
642
+ 1. Try different approach — Investigate from scratch
643
+ 2. Escalate to subagent — Fresh context might help
644
+ 3. Skip as assumption — Log and move on
645
+ ```
646
+ - "Try different" → Reset investigation, try again
647
+ - "Escalate" → Go to `escalate_to_fixer`
648
+ - "Skip" → Mark as skipped assumption
649
+
650
+ **If New issue:**
651
+ - Mark original as pass
652
+ - Record new issue and go to `investigate_issue`
653
+ </step>
654
+
655
+ <step name="resume_from_file">
656
+ **Resume testing from UAT file:**
657
+
658
+ Read full UAT file.
659
+
660
+ Check `mock_stash` — if exists, offer to restore:
661
+ ```
662
+ Found stashed mocks: {mock_stash}
663
+
664
+ 1. Restore mocks — Continue where we left off
665
+ 2. Discard mocks — Start batch fresh
666
+ ```
667
+
668
+ Find current position:
669
+ - current_batch
670
+ - Tests with `[pending]` or `blocked` or `fixing` status
671
+
672
+ Announce:
673
+ ```
674
+ Resuming: Phase {phase} UAT
675
+ Batch: {current} of {total}
676
+ Progress: {tested}/{total}
677
+ Issues being fixed: {fixing count}
678
+ ```
679
+
680
+ If `fix_status: fixing` exists, go to `handle_retest` for that issue.
681
+ Otherwise, go to `execute_batch`.
682
+ </step>
683
+
684
+ <step name="batch_complete">
685
+ **Handle batch completion:**
686
+
687
+ **1. Check for blocked tests that can now be retested:**
688
+
689
+ Before marking batch complete, check if any tests have `result: blocked`.
690
+ If blocked tests exist AND no issues remain in `fixing` status:
691
+ - Re-present the blocked tests via `present_tests`
692
+ - Blocked tests were waiting on other issues to be fixed first
693
+
694
+ **2. Update Batches section (when no blocked tests remain):**
695
+
696
+ ```yaml
697
+ ### Batch {N}: [Name]
698
+ tests: [...]
699
+ status: complete
700
+ mock_type: [...]
701
+ passed: {count}
702
+ issues: {count}
703
+ ```
704
+
705
+ **If more batches remain:**
706
+ - Increment current_batch
707
+ - Check if next batch needs different mock_type
708
+ - If different: discard old mocks, generate new
709
+ - Go to `execute_batch`
710
+
711
+ **If all batches complete:**
712
+ - Go to `complete_session`
713
+ </step>
714
+
715
+ <step name="complete_session">
716
+ **Complete UAT session:**
717
+
718
+ **1. Discard mocks:**
719
+ ```bash
720
+ # Find and drop the specific mock stash (not just the top one)
721
+ MOCK_STASH=$(git stash list | grep "mocks-batch" | head -1 | cut -d: -f1)
722
+ [ -n "$MOCK_STASH" ] && git stash drop "$MOCK_STASH"
723
+ ```
724
+
725
+ **2. Generate UAT fixes patch (if fixes were made):**
726
+ ```bash
727
+ ~/.claude/mindsystem/scripts/generate-phase-patch.sh ${PHASE_NUMBER} --suffix=uat-fixes
728
+ ```
729
+ Output: `.planning/phases/{phase_dir}/{phase}-uat-fixes.patch`
730
+
731
+ **3. Restore user's pre-existing work (if stashed):**
732
+ ```bash
733
+ # Find and pop the specific pre-work stash
734
+ PRE_WORK_STASH=$(git stash list | grep "pre-verify-work" | head -1 | cut -d: -f1)
735
+ [ -n "$PRE_WORK_STASH" ] && git stash pop "$PRE_WORK_STASH"
736
+ ```
737
+
738
+ **4. Update UAT.md:**
739
+ - status: complete
740
+ - Clear current_batch, mock_stash
741
+ - Final Progress counts
742
+
743
+ **5. Commit UAT.md:**
744
+ ```bash
745
+ git add ".planning/phases/XX-name/{phase}-UAT.md"
746
+ git commit -m "test({phase}): complete UAT - {passed} passed, {fixed} fixed, {skipped} assumptions"
747
+ ```
748
+
749
+ **6. Present summary:**
750
+ ```
751
+ ## UAT Complete: Phase {phase}
752
+
753
+ | Result | Count |
754
+ |--------|-------|
755
+ | Passed | {N} |
756
+ | Fixed | {N} |
757
+ | Assumptions | {N} |
758
+
759
+ Fixes applied: {N} commits
760
+ Patch file: .planning/phases/{phase_dir}/{phase}-uat-fixes.patch
761
+
762
+ To review fixes: cat {patch_path}
763
+ ```
764
+ </step>
765
+
766
+ </process>
767
+
768
+ <update_rules>
769
+ **Write UAT.md after:**
770
+ - Each batch of responses processed
771
+ - Each fix applied
772
+ - Each re-test completed
773
+ - Session complete
774
+
775
+ | Section | Rule | When |
776
+ |---------|------|------|
777
+ | Frontmatter.status | OVERWRITE | Phase transitions |
778
+ | Frontmatter.current_batch | OVERWRITE | Batch transitions |
779
+ | Frontmatter.mock_stash | OVERWRITE | Stash operations |
780
+ | Frontmatter.updated | OVERWRITE | Every write |
781
+ | Progress | OVERWRITE | After each test result |
782
+ | Current Batch | OVERWRITE | Batch transitions |
783
+ | Tests.{N}.result | OVERWRITE | When user responds |
784
+ | Tests.{N}.fix_status | OVERWRITE | During fix flow |
785
+ | Tests.{N}.fix_commit | OVERWRITE | After fix committed |
786
+ | Tests.{N}.retry_count | OVERWRITE | On re-test failure |
787
+ | Fixes Applied | APPEND | After each fix committed |
788
+ | Batches.{N}.status | OVERWRITE | Batch transitions |
789
+ | Assumptions | APPEND | When test skipped |
790
+ </update_rules>
791
+
792
+ <severity_inference>
793
+ **Infer severity from user's natural language:**
794
+
795
+ | User describes | Infer |
796
+ |----------------|-------|
797
+ | Crash, error, exception, fails completely, unusable | blocker |
798
+ | Doesn't work, nothing happens, wrong behavior, missing | major |
799
+ | Works but..., slow, weird, off, minor, small | minor |
800
+ | Color, font, spacing, alignment, looks off | cosmetic |
801
+
802
+ Default: **major** (safe default)
803
+
804
+ **Never ask "how severe is this?"** — just infer and move on.
805
+ </severity_inference>
806
+
807
+ <success_criteria>
808
+ - [ ] Dirty tree handled at start
809
+ - [ ] Tests classified by mock requirements
810
+ - [ ] Batches created respecting dependencies and mock types
811
+ - [ ] Mocks generated when needed with toggle instructions
812
+ - [ ] Tests presented in batches of 4
813
+ - [ ] Issues investigated with lightweight check (2-3 calls)
814
+ - [ ] Simple issues fixed inline with proper commit
815
+ - [ ] Complex issues escalated to fixer subagent
816
+ - [ ] Re-test retries (2 max, tracked via retry_count) before offering options
817
+ - [ ] Blocked tests re-presented after blocking issues resolved
818
+ - [ ] Stash conflicts auto-resolved to fix version
819
+ - [ ] Mocks discarded on completion
820
+ - [ ] UAT fixes patch generated
821
+ - [ ] User's pre-existing work restored
822
+ - [ ] UAT.md committed with final summary
823
+ </success_criteria>