claude-code-workflow 7.2.24 → 7.2.26

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 (69) hide show
  1. package/.ccw/workflows/cli-tools-usage.md +123 -521
  2. package/.claude/CLAUDE.md +20 -0
  3. package/.claude/agents/action-planning-agent.md +6 -0
  4. package/.claude/agents/cli-explore-agent.md +63 -77
  5. package/.claude/agents/cli-lite-planning-agent.md +10 -11
  6. package/.claude/agents/issue-plan-agent.md +7 -2
  7. package/.claude/commands/workflow/spec/setup.md +1 -1
  8. package/.claude/skills/brainstorm/SKILL.md +408 -408
  9. package/.claude/skills/review-cycle/SKILL.md +132 -132
  10. package/.claude/skills/review-cycle/phases/review-module.md +4 -4
  11. package/.claude/skills/review-cycle/phases/review-session.md +4 -4
  12. package/.claude/skills/spec-generator/SKILL.md +1 -1
  13. package/.claude/skills/team-designer/phases/02-scaffold-generation.md +1 -1
  14. package/.claude/skills/team-lifecycle-v4/SKILL.md +1 -1
  15. package/.claude/skills/team-review/SKILL.md +1 -1
  16. package/.claude/skills/team-ultra-analyze/SKILL.md +1 -1
  17. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +3 -3
  18. package/.claude/skills/workflow-plan/SKILL.md +1 -1
  19. package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +2 -2
  20. package/.claude/skills/workflow-plan/phases/05-plan-verify.md +2 -2
  21. package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +3 -3
  22. package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +2 -2
  23. package/.claude/skills/workflow-test-fix/SKILL.md +1 -1
  24. package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +2 -2
  25. package/.codex/AGENTS.md +16 -0
  26. package/.codex/skills/analyze-with-file/SKILL.md +966 -966
  27. package/.codex/skills/issue-discover/SKILL.md +361 -361
  28. package/.codex/skills/review-cycle/SKILL.md +1 -1
  29. package/.codex/skills/roadmap-with-file/SKILL.md +901 -901
  30. package/.codex/skills/spec-generator/SKILL.md +425 -425
  31. package/.codex/skills/spec-setup/SKILL.md +669 -669
  32. package/.codex/skills/team-designer/phases/02-scaffold-generation.md +1 -1
  33. package/.codex/skills/workflow-test-fix-cycle/SKILL.md +402 -402
  34. package/ccw/dist/tools/index.d.ts.map +1 -1
  35. package/ccw/dist/tools/index.js +2 -0
  36. package/ccw/dist/tools/index.js.map +1 -1
  37. package/ccw/dist/tools/json-builder.d.ts +17 -0
  38. package/ccw/dist/tools/json-builder.d.ts.map +1 -0
  39. package/ccw/dist/tools/json-builder.js +746 -0
  40. package/ccw/dist/tools/json-builder.js.map +1 -0
  41. package/ccw/dist/tools/schema-registry.d.ts +71 -0
  42. package/ccw/dist/tools/schema-registry.d.ts.map +1 -0
  43. package/ccw/dist/tools/schema-registry.js +136 -0
  44. package/ccw/dist/tools/schema-registry.js.map +1 -0
  45. package/package.json +1 -1
  46. package/.claude/skills/team-iterdev/SKILL.md +0 -127
  47. package/.claude/skills/team-iterdev/roles/architect/role.md +0 -65
  48. package/.claude/skills/team-iterdev/roles/coordinator/commands/analyze.md +0 -62
  49. package/.claude/skills/team-iterdev/roles/coordinator/commands/dispatch.md +0 -234
  50. package/.claude/skills/team-iterdev/roles/coordinator/commands/monitor.md +0 -182
  51. package/.claude/skills/team-iterdev/roles/coordinator/role.md +0 -153
  52. package/.claude/skills/team-iterdev/roles/developer/role.md +0 -74
  53. package/.claude/skills/team-iterdev/roles/reviewer/role.md +0 -66
  54. package/.claude/skills/team-iterdev/roles/tester/role.md +0 -88
  55. package/.claude/skills/team-iterdev/specs/pipelines.md +0 -94
  56. package/.claude/skills/team-iterdev/specs/team-config.json +0 -172
  57. package/.codex/prompts/prep-cycle.md +0 -416
  58. package/.codex/prompts/prep-plan.md +0 -371
  59. package/.codex/skills/team-iterdev/SKILL.md +0 -219
  60. package/.codex/skills/team-iterdev/roles/architect/role.md +0 -65
  61. package/.codex/skills/team-iterdev/roles/coordinator/commands/analyze.md +0 -62
  62. package/.codex/skills/team-iterdev/roles/coordinator/commands/dispatch.md +0 -187
  63. package/.codex/skills/team-iterdev/roles/coordinator/commands/monitor.md +0 -227
  64. package/.codex/skills/team-iterdev/roles/coordinator/role.md +0 -193
  65. package/.codex/skills/team-iterdev/roles/developer/role.md +0 -74
  66. package/.codex/skills/team-iterdev/roles/reviewer/role.md +0 -66
  67. package/.codex/skills/team-iterdev/roles/tester/role.md +0 -88
  68. package/.codex/skills/team-iterdev/specs/pipelines.md +0 -94
  69. package/.codex/skills/team-iterdev/specs/team-config.json +0 -172
@@ -1,402 +1,402 @@
1
- ---
2
- name: workflow-test-fix-cycle
3
- description: End-to-end test-fix workflow generate test sessions with progressive layers (L0-L3), then execute iterative fix cycles until pass rate >= 95%. Combines test-fix-gen and test-cycle-execute into a unified pipeline. Triggers on "workflow:test-fix-cycle".
4
- allowed-tools: spawn_agent, wait, send_input, close_agent, request_user_input, Read, Write, Edit, Bash, Glob, Grep
5
- ---
6
-
7
- # Workflow Test-Fix Cycle
8
-
9
- End-to-end test-fix workflow pipeline: generate test sessions with progressive layers (L0-L3), AI code validation, and task generation (Phase 1), then execute iterative fix cycles with adaptive strategy engine until pass rate >= 95% (Phase 2).
10
-
11
- ## Architecture Overview
12
-
13
- ```
14
- ┌────────────────────────────────────────────────────────────────────────────┐
15
- │ Workflow Test-Fix Cycle Orchestrator (SKILL.md) │
16
- │ → Full pipeline: Test generation + Iterative execution │
17
- │ → Phase dispatch: Read phase docs, execute, pass context │
18
- └───────────────┬────────────────────────────────────────────────────────────┘
19
-
20
- ┌────────────┴────────────────────────┐
21
- ↓ ↓
22
- ┌─────────────────────────┐ ┌─────────────────────────────┐
23
- │ Phase 1: Test-Fix Gen │ │ Phase 2: Test-Cycle Execute │
24
- │ phases/01-test-fix-gen │ │ phases/02-test-cycle-execute │
25
- │ 5 sub-phases: │ │ 3 stages: │
26
- │ ① Create Session │ │ ① Discovery │
27
- │ ② Gather Context │ │ ② Main Loop (iterate) │
28
- │ ③ Test Analysis (Gemini)│ │ ③ Completion │
29
- │ ④ Generate Tasks │ │ │
30
- │ ⑤ Summary │ │ Agents (via spawn_agent): │
31
- │ │ │ @cli-planning-agent │
32
- │ Agents (via spawn_agent)│ │ @test-fix-agent │
33
- │ @test-context-search │ │ │
34
- │ @context-search │ │ Strategy: conservative → │
35
- │ @cli-execution │ │ aggressive → surgical │
36
- │ @action-planning │ │ │
37
- └────────┬────────────────┘ └────────────┬──────────────────┘
38
- ↓ ↓
39
- IMPL-001..002.json Pass Rate >= 95%
40
- TEST_ANALYSIS_RESULTS.md Auto-complete session
41
-
42
- Task Pipeline:
43
- ┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
44
- │ IMPL-001 │───→│ IMPL-001.3 │───→│ IMPL-001.5 │───→│ IMPL-002 │
45
- │ Test Gen │ │ Code Validate │ │ Quality Gate │ │ Test & Fix │
46
- │ L1-L3 │ │ L0 + AI Issues │ │ Coverage 80%+ │ │ Max 10 iter │
47
- │@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
48
- └──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘
49
-
50
- Fix Loop: │
51
- ┌──────────────────┘
52
-
53
- ┌──────────┐
54
- │ @cli-plan│───→ IMPL-fix-N.json
55
- │ agent │
56
- ├──────────┤
57
- │@test-fix │───→ Apply & re-test
58
- │ agent │
59
- └──────────┘
60
- ```
61
-
62
- ## Key Design Principles
63
-
64
- 1. **Two-Phase Pipeline**: Generation (Phase 1) creates session + tasks, Execution (Phase 2) runs iterative fix cycles
65
- 2. **Pure Orchestrator**: Dispatch to phase docs, parse outputs, pass context between phases
66
- 3. **Phase 1 Auto-Continue**: Sub-phases within Phase 1 run autonomously
67
- 4. **Subagent Lifecycle**: Explicit lifecycle management with spawn_agent → wait → close_agent
68
- 5. **Progressive Test Layers**: L0 (Static) → L1 (Unit) → L2 (Integration) → L3 (E2E)
69
- 6. **AI Code Issue Detection**: Validates against common AI-generated code problems
70
- 7. **Intelligent Strategy Engine**: conservative → aggressive → surgical based on iteration context
71
- 8. **CLI Fallback Chain**: Gemini → Qwen → Codex for analysis resilience
72
- 9. **Progressive Testing**: Affected tests during iterations, full suite for final validation
73
- 10. **Role Path Loading**: Subagent roles loaded via path reference in MANDATORY FIRST STEPS
74
-
75
- ## Auto Mode
76
-
77
- Phase 1 generates test session and tasks. Phase 2 executes iterative fix cycles until pass rate >= 95% or max iterations reached. **Between Phase 1 and Phase 2, you MUST stop and wait for user confirmation before proceeding to execution.** Phase 2 runs autonomously once approved.
78
-
79
- ## Subagent API Reference
80
-
81
- ### spawn_agent
82
- Create a new subagent with task assignment.
83
-
84
- ```javascript
85
- const agentId = spawn_agent({
86
- agent_type: "{agent_type}",
87
- message: `
88
- ## TASK ASSIGNMENT
89
-
90
- ### MANDATORY FIRST STEPS (Agent Execute)
91
- 1. Run: `ccw spec load --category "planning execution"`
92
-
93
- ## TASK CONTEXT
94
- ${taskContext}
95
-
96
- ## DELIVERABLES
97
- ${deliverables}
98
- `
99
- })
100
- ```
101
-
102
- ### wait
103
- Get results from subagent (only way to retrieve results).
104
-
105
- ```javascript
106
- const result = wait({
107
- ids: [agentId],
108
- timeout_ms: 600000 // 10 minutes
109
- })
110
-
111
- if (result.timed_out) {
112
- // Handle timeout - can continue waiting or send_input to prompt completion
113
- }
114
- ```
115
-
116
- ### send_input
117
- Continue interaction with active subagent (for clarification or follow-up).
118
-
119
- ```javascript
120
- send_input({
121
- id: agentId,
122
- message: `
123
- ## CLARIFICATION ANSWERS
124
- ${answers}
125
-
126
- ## NEXT STEP
127
- Continue with plan generation.
128
- `
129
- })
130
- ```
131
-
132
- ### close_agent
133
- Clean up subagent resources (irreversible).
134
-
135
- ```javascript
136
- close_agent({ id: agentId })
137
- ```
138
-
139
- ## Usage
140
-
141
- ```
142
- workflow-test-fix-cycle <input> [options]
143
-
144
- # Input (Phase 1 - Test Generation)
145
- source-session-id WFS-* session ID (Session Mode - test validation for completed implementation)
146
- feature description Text description of what to test (Prompt Mode)
147
- /path/to/file.md Path to requirements file (Prompt Mode)
148
-
149
- # Options (Phase 2 - Cycle Execution)
150
- --max-iterations=N Custom iteration limit (default: 10)
151
-
152
- # Examples
153
- workflow-test-fix-cycle WFS-user-auth-v2 # Session Mode
154
- workflow-test-fix-cycle "Test the user authentication API endpoints in src/auth/api.ts" # Prompt Mode - text
155
- workflow-test-fix-cycle ./docs/api-requirements.md # Prompt Mode - file
156
- workflow-test-fix-cycle "Test user registration" --max-iterations=15 # With custom iterations
157
-
158
- # Resume (Phase 2 only - session already created)
159
- workflow-test-fix-cycle --resume-session="WFS-test-user-auth" # Resume interrupted session
160
- ```
161
-
162
- **Quality Gate**: Test pass rate >= 95% (criticality-aware) or 100%
163
- **Max Iterations**: 10 (default, adjustable)
164
- **CLI Tools**: Gemini → Qwen → Codex (fallback chain)
165
-
166
- ## Test Strategy Overview
167
-
168
- Progressive Test Layers (L0-L3):
169
-
170
- | Layer | Name | Focus |
171
- |-------|------|-------|
172
- | **L0** | Static Analysis | Compilation, imports, types, AI code issues |
173
- | **L1** | Unit Tests | Function/class behavior (happy/negative/edge cases) |
174
- | **L2** | Integration Tests | Component interactions, API contracts, failure modes |
175
- | **L3** | E2E Tests | User journeys, critical paths (optional) |
176
-
177
- **Key Features**:
178
- - **AI Code Issue Detection** - Validates against common AI-generated code problems (hallucinated imports, placeholder code, mock leakage, etc.)
179
- - **Project Type Detection** - Applies appropriate test templates (React, Node API, CLI, Library, etc.)
180
- - **Quality Gates** - IMPL-001.3 (code validation) and IMPL-001.5 (test quality) ensure high standards
181
-
182
- **Detailed specifications**: See the test-task-generate workflow tool for complete L0-L3 requirements and quality thresholds.
183
-
184
- ## Execution Flow
185
-
186
- ```
187
- Input → Detect Mode (session | prompt | resume)
188
-
189
- ├─ resume mode → Skip to Phase 2
190
-
191
- └─ session/prompt mode → Phase 1
192
-
193
- Phase 1: Test-Fix Generation (phases/01-test-fix-gen.md)
194
- ├─ Sub-phase 1.1: Create Test Session → testSessionId
195
- ├─ Sub-phase 1.2: Gather Test Context (spawn_agent) → contextPath
196
- ├─ Sub-phase 1.3: Test Generation Analysis (spawn_agent → Gemini) → TEST_ANALYSIS_RESULTS.md
197
- ├─ Sub-phase 1.4: Generate Test Tasks (spawn_agent) → IMPL-*.json, IMPL_PLAN.md, TODO_LIST.md
198
- └─ Sub-phase 1.5: Phase 1 Summary
199
-
200
- ⛔ MANDATORY CONFIRMATION GATE
201
- │ Present plan summary → request_user_input → User approves/cancels
202
- │ NEVER auto-proceed to Phase 2
203
-
204
- Phase 2: Test-Cycle Execution (phases/02-test-cycle-execute.md)
205
- ├─ Discovery: Load session, tasks, iteration state
206
- ├─ Main Loop (for each task):
207
- │ ├─ Execute → Test → Calculate pass_rate
208
- │ ├─ 100% → SUCCESS: Next task
209
- │ ├─ 95-99% + low criticality → PARTIAL SUCCESS: Approve
210
- │ └─ <95% → Fix Loop:
211
- │ ├─ Select strategy: conservative/aggressive/surgical
212
- │ ├─ spawn_agent(@cli-planning-agent) → IMPL-fix-N.json
213
- │ ├─ spawn_agent(@test-fix-agent) → Apply fix & re-test
214
- │ └─ Re-test → Back to decision
215
- └─ Completion: Final validation → Summary → Sync session state → Auto-complete session
216
- ```
217
-
218
- ## Core Rules
219
-
220
- 1. **Start Immediately**: First action is progress tracking initialization
221
- 2. **No Preliminary Analysis**: Do not read files before Phase 1
222
- 3. **Parse Every Output**: Extract data from each phase/sub-phase for the next
223
- 4. **Within-Phase Auto-Continue**: Sub-phases within a phase run automatically; Phase 2 iterations run automatically once started
224
- 5. **Phase Loading**: Read phase doc on-demand (`phases/01-*.md`, `phases/02-*.md`)
225
- 6. **Task Attachment Model**: Sub-tasks ATTACH → execute → COLLAPSE
226
- 7. **MANDATORY CONFIRMATION GATE**: After Phase 1 completes, you MUST stop and present the generated plan to the user. Wait for explicit user approval via request_user_input before starting Phase 2. NEVER auto-proceed from Phase 1 to Phase 2
227
- 8. **Phase 2 Continuous**: Once user approves, Phase 2 runs continuously until pass rate >= 95% or max iterations reached
228
- 9. **Explicit Lifecycle**: Always close_agent after wait completes to free resources
229
-
230
- ## Phase Execution
231
-
232
- ### Phase 1: Test-Fix Generation
233
-
234
- **Read**: `phases/01-test-fix-gen.md`
235
-
236
- 5 sub-phases that create a test session and generate task JSONs:
237
- 1. Create Test Session → `testSessionId`
238
- 2. Gather Test Context (spawn_agent → wait → close_agent) → `contextPath`
239
- 3. Test Generation Analysis (spawn_agent → wait → close_agent) → `TEST_ANALYSIS_RESULTS.md`
240
- 4. Generate Test Tasks (spawn_agent → wait → close_agent) → `IMPL-001.json`, `IMPL-001.3.json`, `IMPL-001.5.json`, `IMPL-002.json`, `IMPL_PLAN.md`, `TODO_LIST.md`
241
- 5. Phase 1 Summary → **⛔ MANDATORY: Present plan and wait for user confirmation before Phase 2**
242
-
243
- **Agents Used** (via spawn_agent):
244
- - `test_context_search_agent` (agent_type: test_context_search_agent) - Context gathering (Session Mode)
245
- - `context_search_agent` (agent_type: context_search_agent) - Context gathering (Prompt Mode)
246
- - `cli_execution_agent` (agent_type: cli_execution_agent) - Test analysis with Gemini
247
- - `action_planning_agent` (agent_type: action_planning_agent) - Task JSON generation
248
-
249
- ### Phase 2: Test-Cycle Execution
250
-
251
- **Read**: `phases/02-test-cycle-execute.md`
252
-
253
- 3-stage iterative execution with adaptive strategy:
254
- 1. Discovery - Load session, tasks, iteration state
255
- 2. Main Loop - Execute tasks → Test → Analyze failures → Fix → Re-test
256
- 3. Completion - Final validation → Summary → Auto-complete session
257
-
258
- **Agents Used** (via spawn_agent):
259
- - `cli_planning_agent` (agent_type: cli_planning_agent) - Failure analysis, root cause extraction, fix task generation
260
- - `test_fix_agent` (agent_type: test_fix_agent) - Test execution, code fixes, criticality assignment
261
-
262
- **Strategy Engine**: conservative (iteration 1-2) → aggressive (pass >80%) → surgical (regression)
263
-
264
- ## Output Artifacts
265
-
266
- ### Directory Structure
267
-
268
- ```
269
- {projectRoot}/.workflow/active/WFS-test-[session]/
270
- ├── workflow-session.json # Session metadata
271
- ├── IMPL_PLAN.md # Test generation and execution strategy
272
- ├── TODO_LIST.md # Task checklist
273
- ├── .task/
274
- │ ├── IMPL-001.json # Test understanding & generation
275
- │ ├── IMPL-001.3-validation.json # Code validation gate
276
- │ ├── IMPL-001.5-review.json # Test quality gate
277
- │ ├── IMPL-002.json # Test execution & fix cycle
278
- │ └── IMPL-fix-{N}.json # Generated fix tasks (Phase 2)
279
- ├── .process/
280
- │ ├── [test-]context-package.json # Context and coverage analysis
281
- │ ├── TEST_ANALYSIS_RESULTS.md # Test requirements and strategy (L0-L3)
282
- │ ├── iteration-state.json # Current iteration + strategy + stuck tests
283
- │ ├── test-results.json # Latest results (pass_rate, criticality)
284
- │ ├── test-output.log # Full test output
285
- │ ├── fix-history.json # All fix attempts
286
- │ ├── iteration-{N}-analysis.md # CLI analysis report
287
- │ └── iteration-{N}-cli-output.txt
288
- └── .summaries/iteration-summaries/
289
- ```
290
-
291
- ## Progress Tracking Pattern
292
-
293
- **Phase 1** (Generation):
294
- ```javascript
295
- [
296
- { content: "Phase 1: Test-Fix Generation", status: "in_progress" },
297
- { content: " 1.1 Create Test Session", status: "completed" },
298
- { content: " 1.2 Gather Test Context", status: "in_progress" },
299
- { content: " 1.3 Test Generation Analysis", status: "pending" },
300
- { content: " 1.4 Generate Test Tasks", status: "pending" },
301
- { content: " 1.5 Phase Summary", status: "pending" },
302
- { content: "Phase 2: Test-Cycle Execution", status: "pending" }
303
- ]
304
- ```
305
-
306
- **Phase 2** (Execution):
307
- ```javascript
308
- [
309
- { content: "Phase 1: Test-Fix Generation", status: "completed" },
310
- { content: "Phase 2: Test-Cycle Execution", status: "in_progress" },
311
- { content: " Execute IMPL-001: Generate tests [code-developer]", status: "completed" },
312
- { content: " Execute IMPL-002: Test & Fix Cycle [ITERATION]", status: "in_progress" },
313
- { content: " → Iteration 1: Initial test (pass: 70%, conservative)", status: "completed" },
314
- { content: " → Iteration 2: Fix validation (pass: 82%, conservative)", status: "completed" },
315
- { content: " → Iteration 3: Batch fix auth (pass: 89%, aggressive)", status: "in_progress" }
316
- ]
317
- ```
318
-
319
- **Update Rules**:
320
- - Phase 1: Attach/collapse sub-phase tasks within Phase 1
321
- - Phase 2: Add iteration items with strategy and pass rate
322
- - Mark completed after each phase/iteration
323
- - Update parent task when all complete
324
-
325
- ## Error Handling
326
-
327
- | Phase | Scenario | Action |
328
- |-------|----------|--------|
329
- | 1.1 | Source session not found (session mode) | Return error with session ID |
330
- | 1.1 | No completed IMPL tasks (session mode) | Return error, source incomplete |
331
- | 1.2 | Context gathering failed | Return error, check source artifacts |
332
- | 1.2 | Agent timeout | Retry with extended timeout, close_agent, then return error |
333
- | 1.3 | Gemini analysis failed | Return error, check context package |
334
- | 1.4 | Task generation failed | Retry once, then return error |
335
- | 2 | Test execution error | Log, retry with error context |
336
- | 2 | CLI analysis failure | Fallback: Gemini → Qwen → Codex → manual |
337
- | 2 | Agent execution error | Save state, close_agent, retry with simplified context |
338
- | 2 | Max iterations reached | Generate failure report, mark blocked |
339
- | 2 | Regression detected | Rollback last fix, switch to surgical strategy |
340
- | 2 | Stuck tests detected | Continue with alternative strategy, document in failure report |
341
-
342
- **Lifecycle Error Handling**:
343
- ```javascript
344
- try {
345
- const agentId = spawn_agent({ message: "..." });
346
- const result = wait({ ids: [agentId], timeout_ms: 600000 });
347
- // ... process result ...
348
- close_agent({ id: agentId });
349
- } catch (error) {
350
- if (agentId) close_agent({ id: agentId });
351
- throw error;
352
- }
353
- ```
354
-
355
- ## Coordinator Checklist
356
-
357
- **Phase 1 (Generation)**:
358
- - Detect input type (session ID / description / file path / resume)
359
- - Initialize progress tracking with 2 top-level phases
360
- - Read `phases/01-test-fix-gen.md` for detailed sub-phase execution
361
- - Execute 5 sub-phases with spawn_agent → wait → close_agent lifecycle
362
- - Verify all Phase 1 outputs (4+ task JSONs, IMPL_PLAN.md, TODO_LIST.md)
363
- - **Ensure all agents are closed** after each sub-phase completes
364
- - **⛔ MANDATORY: Present plan summary and request_user_input for confirmation**
365
- - Show: session ID, task count, test layers, quality gates
366
- - Options: "Proceed to Execution" / "Review Plan" / "Cancel"
367
- - If "Cancel" → return, do NOT start Phase 2
368
- - If "Review Plan" → display IMPL_PLAN.md, then return
369
- - Only proceed to Phase 2 if user selects "Proceed to Execution"
370
-
371
- **Phase 2 (Execution)**:
372
- - Read `phases/02-test-cycle-execute.md` for detailed execution logic
373
- - Load session state and task queue
374
- - Execute iterative test-fix cycles with spawn_agent → wait → close_agent
375
- - Track iterations in progress tracking
376
- - Auto-complete session on success (pass rate >= 95%)
377
- - **Ensure all agents are closed** after each iteration
378
-
379
- **Resume Mode**:
380
- - If `--resume-session` provided, skip Phase 1
381
- - Load existing session directly into Phase 2
382
-
383
- ## Related Skills
384
-
385
- **Prerequisite Skills**:
386
- - `workflow-plan` or `workflow-execute` - Complete implementation (Session Mode)
387
- - None for Prompt Mode
388
-
389
- **Phase 1 Agents** (used by phases/01-test-fix-gen.md via spawn_agent):
390
- - `test_context_search_agent` (agent_type: test_context_search_agent) - Test coverage analysis (Session Mode)
391
- - `context_search_agent` (agent_type: context_search_agent) - Codebase analysis (Prompt Mode)
392
- - `cli_execution_agent` (agent_type: cli_execution_agent) - Test requirements with Gemini
393
- - `action_planning_agent` (agent_type: action_planning_agent) - Task JSON generation
394
-
395
- **Phase 2 Agents** (used by phases/02-test-cycle-execute.md via spawn_agent):
396
- - `cli_planning_agent` (agent_type: cli_planning_agent) - CLI analysis, root cause extraction, task generation
397
- - `test_fix_agent` (agent_type: test_fix_agent) - Test execution, code fixes, criticality assignment
398
-
399
- **Follow-up**:
400
- - Session sync: `$session-sync -y "Test-fix cycle complete: {pass_rate}% pass rate"`
401
- - Session auto-complete on success
402
- - Issue creation for follow-up work (post-completion expansion)
1
+ ---
2
+ name: workflow-test-fix-cycle
3
+ description: "End-to-end test-fix workflow generate test sessions with progressive layers (L0-L3), then execute iterative fix cycles until pass rate >= 95%. Combines test-fix-gen and test-cycle-execute into a unified pipeline. Triggers on \"workflow:test-fix-cycle\"."
4
+ allowed-tools: spawn_agent, wait, send_input, close_agent, request_user_input, Read, Write, Edit, Bash, Glob, Grep
5
+ ---
6
+
7
+ # Workflow Test-Fix Cycle
8
+
9
+ End-to-end test-fix workflow pipeline: generate test sessions with progressive layers (L0-L3), AI code validation, and task generation (Phase 1), then execute iterative fix cycles with adaptive strategy engine until pass rate >= 95% (Phase 2).
10
+
11
+ ## Architecture Overview
12
+
13
+ ```
14
+ ┌────────────────────────────────────────────────────────────────────────────┐
15
+ │ Workflow Test-Fix Cycle Orchestrator (SKILL.md) │
16
+ │ → Full pipeline: Test generation + Iterative execution │
17
+ │ → Phase dispatch: Read phase docs, execute, pass context │
18
+ └───────────────┬────────────────────────────────────────────────────────────┘
19
+
20
+ ┌────────────┴────────────────────────┐
21
+ ↓ ↓
22
+ ┌─────────────────────────┐ ┌─────────────────────────────┐
23
+ │ Phase 1: Test-Fix Gen │ │ Phase 2: Test-Cycle Execute │
24
+ │ phases/01-test-fix-gen │ │ phases/02-test-cycle-execute │
25
+ │ 5 sub-phases: │ │ 3 stages: │
26
+ │ ① Create Session │ │ ① Discovery │
27
+ │ ② Gather Context │ │ ② Main Loop (iterate) │
28
+ │ ③ Test Analysis (Gemini)│ │ ③ Completion │
29
+ │ ④ Generate Tasks │ │ │
30
+ │ ⑤ Summary │ │ Agents (via spawn_agent): │
31
+ │ │ │ @cli-planning-agent │
32
+ │ Agents (via spawn_agent)│ │ @test-fix-agent │
33
+ │ @test-context-search │ │ │
34
+ │ @context-search │ │ Strategy: conservative → │
35
+ │ @cli-execution │ │ aggressive → surgical │
36
+ │ @action-planning │ │ │
37
+ └────────┬────────────────┘ └────────────┬──────────────────┘
38
+ ↓ ↓
39
+ IMPL-001..002.json Pass Rate >= 95%
40
+ TEST_ANALYSIS_RESULTS.md Auto-complete session
41
+
42
+ Task Pipeline:
43
+ ┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
44
+ │ IMPL-001 │───→│ IMPL-001.3 │───→│ IMPL-001.5 │───→│ IMPL-002 │
45
+ │ Test Gen │ │ Code Validate │ │ Quality Gate │ │ Test & Fix │
46
+ │ L1-L3 │ │ L0 + AI Issues │ │ Coverage 80%+ │ │ Max 10 iter │
47
+ │@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
48
+ └──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘
49
+
50
+ Fix Loop: │
51
+ ┌──────────────────┘
52
+
53
+ ┌──────────┐
54
+ │ @cli-plan│───→ IMPL-fix-N.json
55
+ │ agent │
56
+ ├──────────┤
57
+ │@test-fix │───→ Apply & re-test
58
+ │ agent │
59
+ └──────────┘
60
+ ```
61
+
62
+ ## Key Design Principles
63
+
64
+ 1. **Two-Phase Pipeline**: Generation (Phase 1) creates session + tasks, Execution (Phase 2) runs iterative fix cycles
65
+ 2. **Pure Orchestrator**: Dispatch to phase docs, parse outputs, pass context between phases
66
+ 3. **Phase 1 Auto-Continue**: Sub-phases within Phase 1 run autonomously
67
+ 4. **Subagent Lifecycle**: Explicit lifecycle management with spawn_agent → wait → close_agent
68
+ 5. **Progressive Test Layers**: L0 (Static) → L1 (Unit) → L2 (Integration) → L3 (E2E)
69
+ 6. **AI Code Issue Detection**: Validates against common AI-generated code problems
70
+ 7. **Intelligent Strategy Engine**: conservative → aggressive → surgical based on iteration context
71
+ 8. **CLI Fallback Chain**: Gemini → Qwen → Codex for analysis resilience
72
+ 9. **Progressive Testing**: Affected tests during iterations, full suite for final validation
73
+ 10. **Role Path Loading**: Subagent roles loaded via path reference in MANDATORY FIRST STEPS
74
+
75
+ ## Auto Mode
76
+
77
+ Phase 1 generates test session and tasks. Phase 2 executes iterative fix cycles until pass rate >= 95% or max iterations reached. **Between Phase 1 and Phase 2, you MUST stop and wait for user confirmation before proceeding to execution.** Phase 2 runs autonomously once approved.
78
+
79
+ ## Subagent API Reference
80
+
81
+ ### spawn_agent
82
+ Create a new subagent with task assignment.
83
+
84
+ ```javascript
85
+ const agentId = spawn_agent({
86
+ agent_type: "{agent_type}",
87
+ message: `
88
+ ## TASK ASSIGNMENT
89
+
90
+ ### MANDATORY FIRST STEPS (Agent Execute)
91
+ 1. Run: `ccw spec load --category "planning execution"`
92
+
93
+ ## TASK CONTEXT
94
+ ${taskContext}
95
+
96
+ ## DELIVERABLES
97
+ ${deliverables}
98
+ `
99
+ })
100
+ ```
101
+
102
+ ### wait
103
+ Get results from subagent (only way to retrieve results).
104
+
105
+ ```javascript
106
+ const result = wait({
107
+ ids: [agentId],
108
+ timeout_ms: 600000 // 10 minutes
109
+ })
110
+
111
+ if (result.timed_out) {
112
+ // Handle timeout - can continue waiting or send_input to prompt completion
113
+ }
114
+ ```
115
+
116
+ ### send_input
117
+ Continue interaction with active subagent (for clarification or follow-up).
118
+
119
+ ```javascript
120
+ send_input({
121
+ id: agentId,
122
+ message: `
123
+ ## CLARIFICATION ANSWERS
124
+ ${answers}
125
+
126
+ ## NEXT STEP
127
+ Continue with plan generation.
128
+ `
129
+ })
130
+ ```
131
+
132
+ ### close_agent
133
+ Clean up subagent resources (irreversible).
134
+
135
+ ```javascript
136
+ close_agent({ id: agentId })
137
+ ```
138
+
139
+ ## Usage
140
+
141
+ ```
142
+ workflow-test-fix-cycle <input> [options]
143
+
144
+ # Input (Phase 1 - Test Generation)
145
+ source-session-id WFS-* session ID (Session Mode - test validation for completed implementation)
146
+ feature description Text description of what to test (Prompt Mode)
147
+ /path/to/file.md Path to requirements file (Prompt Mode)
148
+
149
+ # Options (Phase 2 - Cycle Execution)
150
+ --max-iterations=N Custom iteration limit (default: 10)
151
+
152
+ # Examples
153
+ workflow-test-fix-cycle WFS-user-auth-v2 # Session Mode
154
+ workflow-test-fix-cycle "Test the user authentication API endpoints in src/auth/api.ts" # Prompt Mode - text
155
+ workflow-test-fix-cycle ./docs/api-requirements.md # Prompt Mode - file
156
+ workflow-test-fix-cycle "Test user registration" --max-iterations=15 # With custom iterations
157
+
158
+ # Resume (Phase 2 only - session already created)
159
+ workflow-test-fix-cycle --resume-session="WFS-test-user-auth" # Resume interrupted session
160
+ ```
161
+
162
+ **Quality Gate**: Test pass rate >= 95% (criticality-aware) or 100%
163
+ **Max Iterations**: 10 (default, adjustable)
164
+ **CLI Tools**: Gemini → Qwen → Codex (fallback chain)
165
+
166
+ ## Test Strategy Overview
167
+
168
+ Progressive Test Layers (L0-L3):
169
+
170
+ | Layer | Name | Focus |
171
+ |-------|------|-------|
172
+ | **L0** | Static Analysis | Compilation, imports, types, AI code issues |
173
+ | **L1** | Unit Tests | Function/class behavior (happy/negative/edge cases) |
174
+ | **L2** | Integration Tests | Component interactions, API contracts, failure modes |
175
+ | **L3** | E2E Tests | User journeys, critical paths (optional) |
176
+
177
+ **Key Features**:
178
+ - **AI Code Issue Detection** - Validates against common AI-generated code problems (hallucinated imports, placeholder code, mock leakage, etc.)
179
+ - **Project Type Detection** - Applies appropriate test templates (React, Node API, CLI, Library, etc.)
180
+ - **Quality Gates** - IMPL-001.3 (code validation) and IMPL-001.5 (test quality) ensure high standards
181
+
182
+ **Detailed specifications**: See the test-task-generate workflow tool for complete L0-L3 requirements and quality thresholds.
183
+
184
+ ## Execution Flow
185
+
186
+ ```
187
+ Input → Detect Mode (session | prompt | resume)
188
+
189
+ ├─ resume mode → Skip to Phase 2
190
+
191
+ └─ session/prompt mode → Phase 1
192
+
193
+ Phase 1: Test-Fix Generation (phases/01-test-fix-gen.md)
194
+ ├─ Sub-phase 1.1: Create Test Session → testSessionId
195
+ ├─ Sub-phase 1.2: Gather Test Context (spawn_agent) → contextPath
196
+ ├─ Sub-phase 1.3: Test Generation Analysis (spawn_agent → Gemini) → TEST_ANALYSIS_RESULTS.md
197
+ ├─ Sub-phase 1.4: Generate Test Tasks (spawn_agent) → IMPL-*.json, IMPL_PLAN.md, TODO_LIST.md
198
+ └─ Sub-phase 1.5: Phase 1 Summary
199
+
200
+ ⛔ MANDATORY CONFIRMATION GATE
201
+ │ Present plan summary → request_user_input → User approves/cancels
202
+ │ NEVER auto-proceed to Phase 2
203
+
204
+ Phase 2: Test-Cycle Execution (phases/02-test-cycle-execute.md)
205
+ ├─ Discovery: Load session, tasks, iteration state
206
+ ├─ Main Loop (for each task):
207
+ │ ├─ Execute → Test → Calculate pass_rate
208
+ │ ├─ 100% → SUCCESS: Next task
209
+ │ ├─ 95-99% + low criticality → PARTIAL SUCCESS: Approve
210
+ │ └─ <95% → Fix Loop:
211
+ │ ├─ Select strategy: conservative/aggressive/surgical
212
+ │ ├─ spawn_agent(@cli-planning-agent) → IMPL-fix-N.json
213
+ │ ├─ spawn_agent(@test-fix-agent) → Apply fix & re-test
214
+ │ └─ Re-test → Back to decision
215
+ └─ Completion: Final validation → Summary → Sync session state → Auto-complete session
216
+ ```
217
+
218
+ ## Core Rules
219
+
220
+ 1. **Start Immediately**: First action is progress tracking initialization
221
+ 2. **No Preliminary Analysis**: Do not read files before Phase 1
222
+ 3. **Parse Every Output**: Extract data from each phase/sub-phase for the next
223
+ 4. **Within-Phase Auto-Continue**: Sub-phases within a phase run automatically; Phase 2 iterations run automatically once started
224
+ 5. **Phase Loading**: Read phase doc on-demand (`phases/01-*.md`, `phases/02-*.md`)
225
+ 6. **Task Attachment Model**: Sub-tasks ATTACH → execute → COLLAPSE
226
+ 7. **MANDATORY CONFIRMATION GATE**: After Phase 1 completes, you MUST stop and present the generated plan to the user. Wait for explicit user approval via request_user_input before starting Phase 2. NEVER auto-proceed from Phase 1 to Phase 2
227
+ 8. **Phase 2 Continuous**: Once user approves, Phase 2 runs continuously until pass rate >= 95% or max iterations reached
228
+ 9. **Explicit Lifecycle**: Always close_agent after wait completes to free resources
229
+
230
+ ## Phase Execution
231
+
232
+ ### Phase 1: Test-Fix Generation
233
+
234
+ **Read**: `phases/01-test-fix-gen.md`
235
+
236
+ 5 sub-phases that create a test session and generate task JSONs:
237
+ 1. Create Test Session → `testSessionId`
238
+ 2. Gather Test Context (spawn_agent → wait → close_agent) → `contextPath`
239
+ 3. Test Generation Analysis (spawn_agent → wait → close_agent) → `TEST_ANALYSIS_RESULTS.md`
240
+ 4. Generate Test Tasks (spawn_agent → wait → close_agent) → `IMPL-001.json`, `IMPL-001.3.json`, `IMPL-001.5.json`, `IMPL-002.json`, `IMPL_PLAN.md`, `TODO_LIST.md`
241
+ 5. Phase 1 Summary → **⛔ MANDATORY: Present plan and wait for user confirmation before Phase 2**
242
+
243
+ **Agents Used** (via spawn_agent):
244
+ - `test_context_search_agent` (agent_type: test_context_search_agent) - Context gathering (Session Mode)
245
+ - `context_search_agent` (agent_type: context_search_agent) - Context gathering (Prompt Mode)
246
+ - `cli_execution_agent` (agent_type: cli_execution_agent) - Test analysis with Gemini
247
+ - `action_planning_agent` (agent_type: action_planning_agent) - Task JSON generation
248
+
249
+ ### Phase 2: Test-Cycle Execution
250
+
251
+ **Read**: `phases/02-test-cycle-execute.md`
252
+
253
+ 3-stage iterative execution with adaptive strategy:
254
+ 1. Discovery - Load session, tasks, iteration state
255
+ 2. Main Loop - Execute tasks → Test → Analyze failures → Fix → Re-test
256
+ 3. Completion - Final validation → Summary → Auto-complete session
257
+
258
+ **Agents Used** (via spawn_agent):
259
+ - `cli_planning_agent` (agent_type: cli_planning_agent) - Failure analysis, root cause extraction, fix task generation
260
+ - `test_fix_agent` (agent_type: test_fix_agent) - Test execution, code fixes, criticality assignment
261
+
262
+ **Strategy Engine**: conservative (iteration 1-2) → aggressive (pass >80%) → surgical (regression)
263
+
264
+ ## Output Artifacts
265
+
266
+ ### Directory Structure
267
+
268
+ ```
269
+ {projectRoot}/.workflow/active/WFS-test-[session]/
270
+ ├── workflow-session.json # Session metadata
271
+ ├── IMPL_PLAN.md # Test generation and execution strategy
272
+ ├── TODO_LIST.md # Task checklist
273
+ ├── .task/
274
+ │ ├── IMPL-001.json # Test understanding & generation
275
+ │ ├── IMPL-001.3-validation.json # Code validation gate
276
+ │ ├── IMPL-001.5-review.json # Test quality gate
277
+ │ ├── IMPL-002.json # Test execution & fix cycle
278
+ │ └── IMPL-fix-{N}.json # Generated fix tasks (Phase 2)
279
+ ├── .process/
280
+ │ ├── [test-]context-package.json # Context and coverage analysis
281
+ │ ├── TEST_ANALYSIS_RESULTS.md # Test requirements and strategy (L0-L3)
282
+ │ ├── iteration-state.json # Current iteration + strategy + stuck tests
283
+ │ ├── test-results.json # Latest results (pass_rate, criticality)
284
+ │ ├── test-output.log # Full test output
285
+ │ ├── fix-history.json # All fix attempts
286
+ │ ├── iteration-{N}-analysis.md # CLI analysis report
287
+ │ └── iteration-{N}-cli-output.txt
288
+ └── .summaries/iteration-summaries/
289
+ ```
290
+
291
+ ## Progress Tracking Pattern
292
+
293
+ **Phase 1** (Generation):
294
+ ```javascript
295
+ [
296
+ { content: "Phase 1: Test-Fix Generation", status: "in_progress" },
297
+ { content: " 1.1 Create Test Session", status: "completed" },
298
+ { content: " 1.2 Gather Test Context", status: "in_progress" },
299
+ { content: " 1.3 Test Generation Analysis", status: "pending" },
300
+ { content: " 1.4 Generate Test Tasks", status: "pending" },
301
+ { content: " 1.5 Phase Summary", status: "pending" },
302
+ { content: "Phase 2: Test-Cycle Execution", status: "pending" }
303
+ ]
304
+ ```
305
+
306
+ **Phase 2** (Execution):
307
+ ```javascript
308
+ [
309
+ { content: "Phase 1: Test-Fix Generation", status: "completed" },
310
+ { content: "Phase 2: Test-Cycle Execution", status: "in_progress" },
311
+ { content: " Execute IMPL-001: Generate tests [code-developer]", status: "completed" },
312
+ { content: " Execute IMPL-002: Test & Fix Cycle [ITERATION]", status: "in_progress" },
313
+ { content: " → Iteration 1: Initial test (pass: 70%, conservative)", status: "completed" },
314
+ { content: " → Iteration 2: Fix validation (pass: 82%, conservative)", status: "completed" },
315
+ { content: " → Iteration 3: Batch fix auth (pass: 89%, aggressive)", status: "in_progress" }
316
+ ]
317
+ ```
318
+
319
+ **Update Rules**:
320
+ - Phase 1: Attach/collapse sub-phase tasks within Phase 1
321
+ - Phase 2: Add iteration items with strategy and pass rate
322
+ - Mark completed after each phase/iteration
323
+ - Update parent task when all complete
324
+
325
+ ## Error Handling
326
+
327
+ | Phase | Scenario | Action |
328
+ |-------|----------|--------|
329
+ | 1.1 | Source session not found (session mode) | Return error with session ID |
330
+ | 1.1 | No completed IMPL tasks (session mode) | Return error, source incomplete |
331
+ | 1.2 | Context gathering failed | Return error, check source artifacts |
332
+ | 1.2 | Agent timeout | Retry with extended timeout, close_agent, then return error |
333
+ | 1.3 | Gemini analysis failed | Return error, check context package |
334
+ | 1.4 | Task generation failed | Retry once, then return error |
335
+ | 2 | Test execution error | Log, retry with error context |
336
+ | 2 | CLI analysis failure | Fallback: Gemini → Qwen → Codex → manual |
337
+ | 2 | Agent execution error | Save state, close_agent, retry with simplified context |
338
+ | 2 | Max iterations reached | Generate failure report, mark blocked |
339
+ | 2 | Regression detected | Rollback last fix, switch to surgical strategy |
340
+ | 2 | Stuck tests detected | Continue with alternative strategy, document in failure report |
341
+
342
+ **Lifecycle Error Handling**:
343
+ ```javascript
344
+ try {
345
+ const agentId = spawn_agent({ message: "..." });
346
+ const result = wait({ ids: [agentId], timeout_ms: 600000 });
347
+ // ... process result ...
348
+ close_agent({ id: agentId });
349
+ } catch (error) {
350
+ if (agentId) close_agent({ id: agentId });
351
+ throw error;
352
+ }
353
+ ```
354
+
355
+ ## Coordinator Checklist
356
+
357
+ **Phase 1 (Generation)**:
358
+ - Detect input type (session ID / description / file path / resume)
359
+ - Initialize progress tracking with 2 top-level phases
360
+ - Read `phases/01-test-fix-gen.md` for detailed sub-phase execution
361
+ - Execute 5 sub-phases with spawn_agent → wait → close_agent lifecycle
362
+ - Verify all Phase 1 outputs (4+ task JSONs, IMPL_PLAN.md, TODO_LIST.md)
363
+ - **Ensure all agents are closed** after each sub-phase completes
364
+ - **⛔ MANDATORY: Present plan summary and request_user_input for confirmation**
365
+ - Show: session ID, task count, test layers, quality gates
366
+ - Options: "Proceed to Execution" / "Review Plan" / "Cancel"
367
+ - If "Cancel" → return, do NOT start Phase 2
368
+ - If "Review Plan" → display IMPL_PLAN.md, then return
369
+ - Only proceed to Phase 2 if user selects "Proceed to Execution"
370
+
371
+ **Phase 2 (Execution)**:
372
+ - Read `phases/02-test-cycle-execute.md` for detailed execution logic
373
+ - Load session state and task queue
374
+ - Execute iterative test-fix cycles with spawn_agent → wait → close_agent
375
+ - Track iterations in progress tracking
376
+ - Auto-complete session on success (pass rate >= 95%)
377
+ - **Ensure all agents are closed** after each iteration
378
+
379
+ **Resume Mode**:
380
+ - If `--resume-session` provided, skip Phase 1
381
+ - Load existing session directly into Phase 2
382
+
383
+ ## Related Skills
384
+
385
+ **Prerequisite Skills**:
386
+ - `workflow-plan` or `workflow-execute` - Complete implementation (Session Mode)
387
+ - None for Prompt Mode
388
+
389
+ **Phase 1 Agents** (used by phases/01-test-fix-gen.md via spawn_agent):
390
+ - `test_context_search_agent` (agent_type: test_context_search_agent) - Test coverage analysis (Session Mode)
391
+ - `context_search_agent` (agent_type: context_search_agent) - Codebase analysis (Prompt Mode)
392
+ - `cli_execution_agent` (agent_type: cli_execution_agent) - Test requirements with Gemini
393
+ - `action_planning_agent` (agent_type: action_planning_agent) - Task JSON generation
394
+
395
+ **Phase 2 Agents** (used by phases/02-test-cycle-execute.md via spawn_agent):
396
+ - `cli_planning_agent` (agent_type: cli_planning_agent) - CLI analysis, root cause extraction, task generation
397
+ - `test_fix_agent` (agent_type: test_fix_agent) - Test execution, code fixes, criticality assignment
398
+
399
+ **Follow-up**:
400
+ - Session sync: `$session-sync -y "Test-fix cycle complete: {pass_rate}% pass rate"`
401
+ - Session auto-complete on success
402
+ - Issue creation for follow-up work (post-completion expansion)