pi-maestro-flow 0.2.0 → 0.3.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 (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +13 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -7
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +9 -10
  28. package/skills/maestro-amend/SKILL.md +3 -3
  29. package/skills/maestro-analyze/SKILL.md +10 -13
  30. package/skills/maestro-blueprint/SKILL.md +8 -11
  31. package/skills/maestro-brainstorm/SKILL.md +11 -14
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +11 -12
  35. package/skills/maestro-execute/SKILL.md +9 -12
  36. package/skills/maestro-fork/SKILL.md +8 -11
  37. package/skills/maestro-grill/SKILL.md +13 -16
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +9 -12
  42. package/skills/maestro-merge/SKILL.md +6 -8
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -5
  44. package/skills/maestro-milestone-complete/SKILL.md +9 -12
  45. package/skills/maestro-milestone-release/SKILL.md +9 -11
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +16 -16
  48. package/skills/maestro-plan/SKILL.md +9 -12
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -7
  51. package/skills/maestro-ralph/SKILL.md +16 -17
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +18 -19
  56. package/skills/maestro-roadmap/SKILL.md +8 -9
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -7
  59. package/skills/maestro-tools-register/SKILL.md +7 -9
  60. package/skills/maestro-ui-codify/SKILL.md +9 -10
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -6
  64. package/skills/manage-drift-realign/SKILL.md +8 -11
  65. package/skills/manage-harvest/SKILL.md +6 -9
  66. package/skills/manage-issue/SKILL.md +5 -8
  67. package/skills/manage-issue-discover/SKILL.md +8 -11
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -5
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -6
  71. package/skills/manage-knowledge-audit/SKILL.md +6 -9
  72. package/skills/manage-status/SKILL.md +3 -5
  73. package/skills/manage-wiki/SKILL.md +5 -7
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -5
  81. package/skills/quality-debug/SKILL.md +3 -5
  82. package/skills/quality-refactor/SKILL.md +3 -5
  83. package/skills/quality-retrospective/SKILL.md +10 -13
  84. package/skills/quality-review/SKILL.md +5 -8
  85. package/skills/quality-sync/SKILL.md +3 -5
  86. package/skills/quality-test/SKILL.md +4 -6
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -4
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -7
  102. package/skills/spec-load/SKILL.md +3 -5
  103. package/skills/spec-remove/SKILL.md +4 -6
  104. package/skills/spec-setup/SKILL.md +6 -8
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,255 @@
1
+ # TDD Workflow
2
+
3
+ ---
4
+
5
+ ## Iron Law
6
+
7
+ **NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST.**
8
+
9
+ Write code before the test? Delete it. Start over.
10
+ - Don't keep it as "reference"
11
+ - Don't "adapt" it while writing tests
12
+ - Delete means delete
13
+
14
+ ---
15
+
16
+ ## Red-Green-Refactor Cycle
17
+
18
+ Every feature/behavior follows this mandatory sequence:
19
+
20
+ ```
21
+ RED: Write failing test → verify it fails correctly
22
+ GREEN: Write minimal code to pass → verify ALL tests pass
23
+ REFACTOR: Clean up → verify tests still pass
24
+ ```
25
+
26
+ Each cycle produces exactly 3 tasks in the plan. No steps may be skipped or merged.
27
+
28
+ ---
29
+
30
+ ## Red Flags — These Thoughts Mean STOP
31
+
32
+ - "This is too simple to need TDD"
33
+ - "I'll write tests after to verify"
34
+ - "Let me explore the implementation first, then add tests"
35
+ - "I'll keep the code as reference and write tests first"
36
+ - "TDD will slow me down"
37
+ - "I already manually tested this"
38
+ - "Tests after achieve the same goals"
39
+
40
+ All of these mean: **follow the cycle anyway**.
41
+
42
+ ---
43
+
44
+ ## Rationalization Table
45
+
46
+ | Excuse | Reality |
47
+ |--------|---------|
48
+ | "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
49
+ | "I'll test after" | Tests passing immediately prove nothing — you never saw them catch the bug. |
50
+ | "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
51
+ | "Already manually tested" | Ad-hoc != systematic. No record, can't re-run. |
52
+ | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
53
+ | "Need to explore first" | Fine. Throw away exploration, start fresh with TDD. |
54
+ | "Test hard = design unclear" | Listen to the test. Hard to test = hard to use. Simplify the interface. |
55
+ | "TDD will slow me down" | TDD is faster than debugging in production. |
56
+
57
+ ---
58
+
59
+ ## Task Chain Generation
60
+
61
+ When `maestro-plan --tdd` is active, each behavior/feature decomposes into a TDD triplet:
62
+
63
+ ### Structure
64
+
65
+ For each behavior B (derived from requirements or convergence criteria):
66
+
67
+ ```
68
+ TASK-{N}a: RED — Write failing test for B
69
+ TASK-{N}b: GREEN — Implement minimal code to pass B
70
+ TASK-{N}c: REFACTOR — Clean up B implementation (optional, skip if nothing to clean)
71
+ ```
72
+
73
+ ### TASK-{N}a: RED — Write Failing Test
74
+
75
+ ```json
76
+ {
77
+ "id": "TASK-{N}a",
78
+ "title": "RED: Write failing test for {behavior}",
79
+ "type": "test",
80
+ "action": "Write test that describes expected behavior. Test MUST fail before implementation exists.",
81
+ "implementation": [
82
+ "Identify the behavior to test from requirement",
83
+ "Write one minimal test — one behavior per test, clear name",
84
+ "Use real code, not mocks (unless external dependency)",
85
+ "Run test: verify it FAILS (not errors) with expected failure message",
86
+ "If test passes: wrong test — testing existing behavior, fix test",
87
+ "If test errors: fix error, re-run until it fails correctly"
88
+ ],
89
+ "convergence": {
90
+ "criteria": [
91
+ "Test file exists at {test_path}",
92
+ "Test run exits non-zero (test fails, not errors)",
93
+ "Failure message matches expected behavior gap"
94
+ ],
95
+ "verification": "Run test command, confirm RED status (failure, not error)"
96
+ },
97
+ "meta": {
98
+ "tdd_phase": "red",
99
+ "tdd_group": "{N}"
100
+ }
101
+ }
102
+ ```
103
+
104
+ ### TASK-{N}b: GREEN — Write Minimal Code
105
+
106
+ ```json
107
+ {
108
+ "id": "TASK-{N}b",
109
+ "title": "GREEN: Implement minimal code for {behavior}",
110
+ "type": "feature",
111
+ "depends_on": ["TASK-{N}a"],
112
+ "action": "Write the simplest code that makes the failing test pass. No features beyond what the test requires.",
113
+ "implementation": [
114
+ "Read the failing test to understand exactly what is needed",
115
+ "Write minimal production code — just enough to pass",
116
+ "Do NOT add features, refactor other code, or improve beyond the test",
117
+ "Do NOT add options, configurability, or flexibility not required by test",
118
+ "Run test: verify it PASSES",
119
+ "Run full test suite: verify no regressions (all other tests still pass)",
120
+ "If test fails: fix code, NOT test",
121
+ "If other tests fail: fix now"
122
+ ],
123
+ "convergence": {
124
+ "criteria": [
125
+ "Test from TASK-{N}a passes (exit 0)",
126
+ "Full test suite passes (no regressions)",
127
+ "No warnings or errors in test output"
128
+ ],
129
+ "verification": "Run test command, confirm GREEN status (all pass, clean output)"
130
+ },
131
+ "meta": {
132
+ "tdd_phase": "green",
133
+ "tdd_group": "{N}"
134
+ }
135
+ }
136
+ ```
137
+
138
+ ### TASK-{N}c: REFACTOR — Clean Up
139
+
140
+ ```json
141
+ {
142
+ "id": "TASK-{N}c",
143
+ "title": "REFACTOR: Clean up {behavior} implementation",
144
+ "type": "refactor",
145
+ "depends_on": ["TASK-{N}b"],
146
+ "action": "Remove duplication, improve names, extract helpers. Keep tests green. Do NOT add behavior.",
147
+ "implementation": [
148
+ "Review code from TASK-{N}b for duplication, naming, structure",
149
+ "Apply refactoring while keeping ALL tests green",
150
+ "Remove duplication across the new and existing code",
151
+ "Improve variable and function names for clarity",
152
+ "Extract helpers only if reuse is immediate (not speculative)",
153
+ "Run full test suite after each refactoring step",
154
+ "If any test fails during refactoring: undo last change, re-run"
155
+ ],
156
+ "convergence": {
157
+ "criteria": [
158
+ "Full test suite passes (same as GREEN, no regressions)",
159
+ "No new behavior added beyond what tests cover"
160
+ ],
161
+ "verification": "Run full test suite, confirm still GREEN"
162
+ },
163
+ "meta": {
164
+ "tdd_phase": "refactor",
165
+ "tdd_group": "{N}"
166
+ }
167
+ }
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Wave Assignment
173
+
174
+ TDD triplets are sequential within each group but groups can parallelize if independent:
175
+
176
+ ```
177
+ Wave 1: TASK-1a (RED for feature A), TASK-2a (RED for feature B) — parallel if independent
178
+ Wave 2: TASK-1b (GREEN for feature A), TASK-2b (GREEN for feature B) — parallel
179
+ Wave 3: TASK-1c (REFACTOR for A), TASK-2c (REFACTOR for B) — parallel
180
+ ```
181
+
182
+ Within a group, the dependency chain is always: `{N}a → {N}b → {N}c`.
183
+
184
+ ---
185
+
186
+ ## Integration with plan.json
187
+
188
+ When `--tdd` is active, the plan.json output includes:
189
+
190
+ ```json
191
+ {
192
+ "tdd_mode": true,
193
+ "tdd_groups": [
194
+ {
195
+ "group": 1,
196
+ "behavior": "User can login with email and password",
197
+ "tasks": ["TASK-1a", "TASK-1b", "TASK-1c"]
198
+ }
199
+ ]
200
+ }
201
+ ```
202
+
203
+ The standard `plan.json.waves[]` and `.task/TASK-*.json` structure is preserved — `maestro-execute` consumes it without modification.
204
+
205
+ ---
206
+
207
+ ## Execution Enforcement
208
+
209
+ When `maestro-execute` processes a TDD plan (detected by `plan.json.tdd_mode == true`):
210
+
211
+ ### RED task verification
212
+ - After TASK-{N}a completes, verify test exists AND fails
213
+ - If test passes: mark task BLOCKED with reason "Test passes before implementation — wrong test"
214
+
215
+ ### GREEN task verification
216
+ - After TASK-{N}b completes, verify ALL tests pass
217
+ - If the RED test still fails: mark task BLOCKED, provide failure output
218
+ - If other tests regress: mark task BLOCKED, list regressed tests
219
+
220
+ ### REFACTOR task verification
221
+ - After TASK-{N}c completes, verify ALL tests still pass
222
+ - If any test fails: undo changes, mark as needing re-attempt
223
+
224
+ ---
225
+
226
+ ## Good Tests
227
+
228
+ | Quality | Good | Bad |
229
+ |---------|------|-----|
230
+ | **Minimal** | One thing per test. "and" in name? Split it. | `test('validates email and domain and whitespace')` |
231
+ | **Clear** | Name describes behavior | `test('test1')`, `test('it works')` |
232
+ | **Shows intent** | Demonstrates desired API | Obscures what code should do |
233
+ | **Real code** | Uses actual implementations | Mocks everything, tests mock behavior |
234
+
235
+ ---
236
+
237
+ ## When to Skip REFACTOR
238
+
239
+ TASK-{N}c (REFACTOR) may be omitted from the plan when:
240
+ - GREEN code is already clean (no duplication, good names)
241
+ - The change is truly trivial (single-line fix)
242
+
243
+ When skipped, mark in plan.json: `"refactor_skipped": true, "reason": "GREEN code already clean"`
244
+
245
+ ---
246
+
247
+ ## Error Handling
248
+
249
+ | Situation | Action |
250
+ |-----------|--------|
251
+ | No test framework detected | Abort: "No test infrastructure found. Set up testing first." |
252
+ | RED test passes immediately | BLOCKED: "Test passes before implementation — rewrite test" |
253
+ | GREEN test still fails after implementation | Retry once with more context, then BLOCKED |
254
+ | REFACTOR breaks tests | Undo refactoring, mark as BLOCKED |
255
+ | Cannot write meaningful test | AskUserQuestion: "Behavior '{B}' is hard to test. Should we: (1) simplify the interface, (2) skip TDD for this behavior, (3) use integration test instead?" |
@@ -0,0 +1,226 @@
1
+ # Test Generation Workflow
2
+
3
+ Generate missing automated tests for a phase based on gap analysis from maestro-execute verification gate (Nyquist audit) and quality-test (UAT coverage gaps). Classifies changed files into unit/E2E/skip, discovers test infrastructure, generates a test plan for user approval, then writes tests using RED-GREEN methodology.
4
+
5
+ Tests expose bugs -- fixing is for quality-debug or maestro-execute.
6
+
7
+ ---
8
+
9
+ ### Step 0: Load Project Specs
10
+
11
+ ```
12
+ specs_content = maestro spec load --category test
13
+ ```
14
+
15
+ Apply project test conventions (from Step 0 specs) when generating the plan (Step 4) and writing tests (Step 5); REQUIRED: tests conform to loaded spec conventions.
16
+
17
+ ---
18
+
19
+ ### Step 1: Discover Test Infrastructure
20
+
21
+ Detect existing test framework and patterns by scanning for:
22
+ - **Config files**: `jest.config.*`, `vitest.config.*`, `pytest.ini`, `pyproject.toml`, `.mocharc.*`
23
+ - **Existing tests**: `*.test.*`, `*.spec.*`, `test_*` (exclude node_modules, .git)
24
+ - **Utilities**: `test-utils.*`, `testHelper*`, `conftest.py`, `setup.*`
25
+
26
+ Extract: framework, directory structure, naming convention, test utilities, run command.
27
+
28
+ Read 2-3 existing test files to learn: import style, describe/it nesting, assertion library, mock patterns, setup/teardown.
29
+
30
+ If no test framework detected: Error E003.
31
+
32
+ ---
33
+
34
+ ### Step 2: Identify Gaps
35
+
36
+ Sources: validation.json (`gaps[]` MISSING/PARTIAL), coverage-report.json (`requirements_uncovered[]`), task summaries (modified files).
37
+
38
+ Priority: MISSING or uncovered requirement → HIGH; PARTIAL → MEDIUM.
39
+
40
+ ---
41
+
42
+ ### Step 3: Classify Files
43
+
44
+ Classify each changed file into test categories:
45
+
46
+ | File Type | Category | Rationale |
47
+ |-----------|----------|-----------|
48
+ | Pure function / utility | unit | Isolated, no side effects |
49
+ | React component | unit + e2e | Unit for logic, E2E for rendering |
50
+ | API route / handler | integration | Needs request context |
51
+ | Database model / query | integration | Needs DB connection |
52
+ | CLI command | e2e | Needs process execution |
53
+ | Config / types / constants / CSS / test files | skip | No testable behavior |
54
+
55
+ Output: `{ "unit": [...], "integration": [...], "e2e": [...], "skip": [...] }`
56
+
57
+ Apply --layer filter if set.
58
+
59
+ ---
60
+
61
+ ### Step 3.5: CLI Supplementary Test Analysis (optional)
62
+
63
+ **Purpose:** Use external CLI tool to analyze source code and suggest edge cases and boundary conditions that manual classification may miss.
64
+
65
+ **Skip if** no enabled CLI tools or classified files are all "skip".
66
+
67
+ ```
68
+ IF no CLI tools enabled OR all files classified as "skip": skip to Step 4
69
+
70
+ # Build file list for analysis
71
+ target_files = unit + integration + e2e files, map to paths
72
+
73
+ Bash({
74
+ command: 'maestro delegate "PURPOSE: Analyze source files to identify test-worthy edge cases and boundary conditions
75
+ TASK: For each file, identify: error handling paths | boundary conditions | state transitions | external dependency interactions
76
+ MODE: analysis
77
+ CONTEXT: @${target_files as glob}
78
+ EXPECTED: JSON array of { file, edge_cases: [{ description, type: boundary|error|state|integration, priority: high|medium }] }
79
+ CONSTRAINTS: Only report non-obvious cases | Max 5 edge cases per file | Focus on untested paths
80
+ " --role analyze --mode analysis',
81
+ run_in_background: true
82
+ })
83
+ ```
84
+
85
+ **On callback:** Parse result, merge edge_cases into Step 4 test_cases for matching files. Mark CLI-suggested cases with `source: "cli-analysis"`.
86
+
87
+ ---
88
+
89
+ ### Step 4: Generate Test Plan
90
+
91
+ For each gap + classified file, create a test entry:
92
+
93
+ ```json
94
+ {
95
+ "tests": [
96
+ {
97
+ "id": "TG-001",
98
+ "target_file": "src/utils/validate.ts",
99
+ "test_file": "src/utils/__tests__/validate.test.ts",
100
+ "layer": "unit",
101
+ "requirement_ref": "SC-002",
102
+ "description": "Validate email format accepts valid emails, rejects invalid",
103
+ "test_cases": [
104
+ "accepts standard email format",
105
+ "rejects missing @ symbol",
106
+ "rejects empty string",
107
+ "handles unicode characters"
108
+ ],
109
+ "priority": "high"
110
+ }
111
+ ]
112
+ }
113
+ ```
114
+
115
+ Present plan to user:
116
+
117
+ ```
118
+ === TEST GENERATION PLAN ===
119
+ Phase: {phase_name}
120
+
121
+ | # | Target | Layer | Test Cases | Priority |
122
+ |---|--------|-------|------------|----------|
123
+ | TG-001 | validate.ts | unit | 4 cases | HIGH |
124
+ | TG-002 | ChatWindow.tsx | e2e | 3 cases | HIGH |
125
+ | TG-003 | comments.ts | integration | 5 cases | MEDIUM |
126
+
127
+ Total: {N} test files, {M} test cases
128
+
129
+ Proceed? (yes/modify/cancel)
130
+ ```
131
+
132
+ Wait for user approval via AskUserQuestion.
133
+ - "yes" / "y" -> proceed to Step 5
134
+ - "modify" -> ask what to change, update plan
135
+ - "cancel" -> abort
136
+
137
+ ---
138
+
139
+ ### Step 5: Generate Tests (RED-GREEN)
140
+
141
+ For each approved test entry:
142
+
143
+ 1. **RED** -- Write test following existing patterns; tests must fail if behavior is broken (not trivially pass)
144
+ 2. **Verify RED** -- Run `{test_run_command} {test_file}`:
145
+ - Passes → may be trivial, strengthen it
146
+ - Fails expected → good, targets real behavior
147
+ - Fails unexpected → fix test setup, not source code
148
+ 3. **GREEN assessment** -- Passes = gap was missing test; Fails = bug discovery (do NOT fix source)
149
+
150
+ **Important**: This command generates tests only. Failing tests document missing behavior -- fixing is for quality-debug.
151
+
152
+ Write each test file to the discovered test directory structure.
153
+
154
+ ---
155
+
156
+ ### Step 6: Run Full Test Suite
157
+
158
+ Verify no regressions.
159
+
160
+ ```bash
161
+ {test_run_command} 2>&1 | tail -50
162
+ ```
163
+
164
+ Categorize results:
165
+ - New tests passing: coverage gap filled
166
+ - New tests failing: bug discovered (document, don't fix)
167
+ - Existing tests broken: regression introduced (investigate)
168
+
169
+ If regressions found, flag as blocker. (W002)
170
+
171
+ ---
172
+
173
+ ### Step 7: Write Artifacts
174
+
175
+ Archive existing `.tests/test-gen-report.json` → `.history/test-gen-report-{timestamp}.json` if present.
176
+
177
+ Write `.tests/test-gen-report.json`:
178
+ ```json
179
+ {
180
+ "phase": "{phase}",
181
+ "generated_at": "{ISO timestamp}",
182
+ "infrastructure": {
183
+ "framework": "vitest",
184
+ "test_dir": "__tests__/",
185
+ "run_command": "npm test"
186
+ },
187
+ "classification": { "unit": [...], "integration": [...], "e2e": [...], "skip": [...] },
188
+ "generated": [
189
+ {
190
+ "id": "TG-001",
191
+ "test_file": "src/utils/__tests__/validate.test.ts",
192
+ "layer": "unit",
193
+ "test_cases": 4,
194
+ "status": "passing|failing|mixed",
195
+ "bugs_discovered": []
196
+ }
197
+ ],
198
+ "summary": {
199
+ "files_generated": N,
200
+ "test_cases_total": M,
201
+ "passing": P,
202
+ "failing": F,
203
+ "bugs_discovered": B
204
+ }
205
+ }
206
+ ```
207
+
208
+ Update validation.json gaps: change MISSING -> COVERED for gaps that now have tests.
209
+
210
+ ---
211
+
212
+ ### Step 8: Report
213
+
214
+ ```
215
+ Display: phase, framework, files/cases generated, passing/failing counts,
216
+ bugs found (with descriptions), coverage delta, report path, next step suggestion
217
+ ```
218
+
219
+ **Next step routing:**
220
+
221
+ | Result | Suggestion |
222
+ |--------|------------|
223
+ | All tests passing | Skill({ skill: "quality-review", args: "{phase}" }) to update Nyquist coverage |
224
+ | Bugs discovered (failing tests) | Skill({ skill: "quality-debug", args: "--from-uat {phase}" }) to investigate |
225
+ | Regressions found | Skill({ skill: "quality-debug" }) immediately |
226
+ | Coverage still low | Run again with `--layer` for uncovered layers |