Skip to content

Commit 2527837

Browse files
author
catlog22
committed
feat: convert test-fix-gen and test-cycle-execute commands to unified workflow-test-fix skill
Merge two workflow commands into orchestrator+phases skill structure: - SKILL.md as pure coordinator with 2-phase architecture - Phase 1 (test-fix-gen): session creation, context gathering, test analysis, task generation - Phase 2 (test-cycle-execute): iterative fix loop with adaptive strategy engine, CLI fallback chain
1 parent 21e71a4 commit 2527837

3 files changed

Lines changed: 1196 additions & 0 deletions

File tree

Lines changed: 354 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,354 @@
1+
---
2+
name: workflow-test-fix
3+
description: Unified test-fix pipeline combining test generation (session, context, analysis, task gen) with iterative test-cycle execution (adaptive strategy, progressive testing, CLI fallback). Triggers on "workflow:test-fix-gen", "workflow:test-cycle-execute", "test fix workflow".
4+
allowed-tools: Skill, Task, AskUserQuestion, TaskCreate, TaskUpdate, TaskList, Read, Write, Edit, Bash, Glob, Grep
5+
---
6+
7+
# Workflow Test Fix
8+
9+
Unified test-fix orchestrator that combines **test planning generation** (Phase 1) with **iterative test-cycle execution** (Phase 2) into a single end-to-end pipeline. Creates test sessions with progressive L0-L3 test layers, generates test tasks, then executes them with adaptive fix cycles until pass rate >= 95% or max iterations reached.
10+
11+
## Architecture Overview
12+
13+
```
14+
┌───────────────────────────────────────────────────────────────────────────┐
15+
│ Workflow Test Fix Orchestrator (SKILL.md) │
16+
│ → Pure coordinator: Route entry point, track progress, pass context │
17+
│ → Two phases: Generation (Phase 1) + Execution (Phase 2) │
18+
└──────────────────────────────────┬────────────────────────────────────────┘
19+
20+
┌───────────────────────────┼────────────────────────────┐
21+
↓ ↓
22+
┌──────────────────────┐ ┌──────────────────────┐
23+
│ Phase 1: Test Gen │ │ Phase 2: Test Cycle │
24+
│ (test-fix-gen) │─── testSessionId ───────→│ (test-cycle-execute)│
25+
│ │ │ │
26+
│ 1. Session Create │ │ 1. Discovery │
27+
│ 2. Context Gather │ │ 2. Initial Execute │
28+
│ 3. Test Analysis │ │ 3. Fix Loop │
29+
│ 4. Task Generation │ │ 4. Completion │
30+
│ 5. Summary │ │ │
31+
└──────────────────────┘ └──────────────────────┘
32+
sessionId pass_rate >= 95%
33+
contextPath or max iterations
34+
IMPL_PLAN.md
35+
IMPL-*.json
36+
37+
Task Pipeline (generated in Phase 1, executed in Phase 2):
38+
┌──────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌──────────────┐
39+
│ IMPL-001 │──→│ IMPL-001.3 │──→│ IMPL-001.5 │──→│ IMPL-002 │
40+
│ Test Gen │ │ Code Validate │ │ Quality Gate │ │ Test & Fix │
41+
│ L1-L3 │ │ L0 + AI Issues │ │ Coverage 80%+ │ │ Max N iter │
42+
│@code-developer│ │ @test-fix-agent │ │ @test-fix-agent │ │@test-fix-agent│
43+
└──────────────┘ └─────────────────┘ └─────────────────┘ └──────────────┘
44+
```
45+
46+
## Key Design Principles
47+
48+
1. **Unified Pipeline**: Generation and execution are one continuous workflow - no manual handoff
49+
2. **Pure Orchestrator**: SKILL.md coordinates only - delegates all execution detail to phase files
50+
3. **Auto-Continue**: Phase 1 completes → Phase 2 starts automatically
51+
4. **Task Attachment/Collapse**: Sub-tasks attached during phase execution, collapsed after completion
52+
5. **Progressive Phase Loading**: Phase docs read **only** when that phase executes, not upfront
53+
6. **Adaptive Strategy**: Fix loop auto-selects strategy (conservative/aggressive/surgical) based on iteration context
54+
7. **Quality Gate**: Pass rate >= 95% (criticality-aware) terminates the fix loop
55+
8. **Original Commands Preserved**: Phase files preserve full original command content and Skill() calls
56+
57+
## Usage
58+
59+
```bash
60+
# Full pipeline: generate + execute
61+
/workflow:test-fix-gen "Test the user authentication API"
62+
/workflow:test-fix-gen WFS-user-auth-v2
63+
64+
# Execute only (resume from existing test session with generated tasks)
65+
/workflow:test-cycle-execute
66+
/workflow:test-cycle-execute --resume-session="WFS-test-user-auth"
67+
/workflow:test-cycle-execute --max-iterations=15
68+
```
69+
70+
## Auto Mode
71+
72+
When `--yes` or `-y`: Auto-select first active session, skip confirmations, auto-complete on success.
73+
74+
## Execution Flow
75+
76+
```
77+
Entry Point Detection:
78+
├─ /workflow:test-fix-gen → Full Pipeline (Phase 1 → Phase 2)
79+
└─ /workflow:test-cycle-execute → Execution Only (Phase 2)
80+
81+
Phase 1: Test Generation (test-fix-gen)
82+
└─ Ref: phases/01-test-fix-gen.md
83+
├─ Step 1.1: Detect input mode (session | prompt)
84+
├─ Step 1.2: Create test session → testSessionId
85+
├─ Step 1.3: Gather test context → contextPath
86+
├─ Step 1.4: Test analysis (Gemini) → TEST_ANALYSIS_RESULTS.md
87+
├─ Step 1.5: Generate test tasks → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
88+
└─ Output: testSessionId, 4+ task JSONs
89+
→ Auto-continue to Phase 2
90+
91+
Phase 2: Test Cycle Execution (test-cycle-execute)
92+
└─ Ref: phases/02-test-cycle-execute.md
93+
├─ Step 2.1: Discovery (load session, tasks, iteration state)
94+
├─ Step 2.2: Execute initial tasks (IMPL-001 → 001.3 → 001.5 → 002)
95+
├─ Step 2.3: Fix loop (if pass_rate < 95%)
96+
│ ├─ Select strategy: conservative/aggressive/surgical
97+
│ ├─ Generate fix task via @cli-planning-agent
98+
│ ├─ Execute fix via @test-fix-agent
99+
│ └─ Re-test → loop or exit
100+
└─ Step 2.4: Completion (summary, session archive)
101+
└─ Output: final pass_rate, summary
102+
```
103+
104+
**Phase Reference Documents** (read on-demand when phase executes):
105+
106+
| Phase | Document | Purpose |
107+
|-------|----------|---------|
108+
| 1 | [phases/01-test-fix-gen.md](phases/01-test-fix-gen.md) | Create test session, gather context, analyze, generate tasks |
109+
| 2 | [phases/02-test-cycle-execute.md](phases/02-test-cycle-execute.md) | Execute tasks, iterative fix cycles, completion |
110+
111+
## Core Rules
112+
113+
1. **Start Immediately**: First action is TaskCreate initialization, second action is Phase 1 (or Phase 2 for execute-only entry)
114+
2. **No Preliminary Analysis**: Do not read files or gather context before starting the phase
115+
3. **Parse Every Output**: Extract required data from each step output for next step
116+
4. **Auto-Continue**: Phase 1 → Phase 2 automatically (for full pipeline entry)
117+
5. **Track Progress**: Update TaskCreate/TaskUpdate dynamically with task attachment/collapse pattern
118+
6. **Task Attachment Model**: Sub-tasks **attached** during phase, **collapsed** after completion
119+
7. **DO NOT STOP**: Continuous workflow until quality gate met or max iterations reached
120+
8. **Progressive Loading**: Read phase doc ONLY when that phase is about to execute
121+
9. **Entry Point Routing**: `/workflow:test-fix-gen` → Phase 1 + Phase 2; `/workflow:test-cycle-execute` → Phase 2 only
122+
123+
## Input Processing
124+
125+
### test-fix-gen Entry (Full Pipeline)
126+
```
127+
User input → Detect type:
128+
├─ Starts with "WFS-" → MODE=session, sourceSessionId=input
129+
├─ Ends with ".md" → MODE=prompt, description=Read(input)
130+
└─ Otherwise → MODE=prompt, description=input
131+
```
132+
133+
### test-cycle-execute Entry (Phase 2 Only)
134+
```
135+
Arguments → Parse flags:
136+
├─ --resume-session="WFS-xxx" → sessionId=WFS-xxx
137+
├─ --max-iterations=N → maxIterations=N (default: 10)
138+
└─ (no args) → auto-discover active test session
139+
```
140+
141+
## Data Flow
142+
143+
```
144+
User Input (session ID | description | file path)
145+
146+
[Detect Mode: session | prompt]
147+
148+
Phase 1: Test Generation ─────────────────────────────────────────
149+
↓ 1.1: session:start → testSessionId
150+
↓ 1.2: test-context-gather/context-gather → contextPath
151+
↓ 1.3: test-concept-enhanced → TEST_ANALYSIS_RESULTS.md
152+
↓ 1.4: test-task-generate → IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
153+
↓ 1.5: Summary with next step
154+
155+
Phase 2: Test Cycle Execution ────────────────────────────────────
156+
↓ 2.1: Load session + tasks + iteration state
157+
↓ 2.2: Execute IMPL-001 → 001.3 → 001.5 → 002
158+
↓ 2.3: Fix loop (analyze → fix → retest) until pass_rate >= 95%
159+
↓ 2.4: Completion → summary → session archive
160+
```
161+
162+
## Test Strategy Overview
163+
164+
Progressive Test Layers (L0-L3):
165+
166+
| Layer | Name | Focus |
167+
|-------|------|-------|
168+
| **L0** | Static Analysis | Compilation, imports, types, AI code issues |
169+
| **L1** | Unit Tests | Function/class behavior (happy/negative/edge cases) |
170+
| **L2** | Integration Tests | Component interactions, API contracts, failure modes |
171+
| **L3** | E2E Tests | User journeys, critical paths (optional) |
172+
173+
**Quality Thresholds**:
174+
- Code Validation (IMPL-001.3): Zero CRITICAL issues, zero compilation errors
175+
- Minimum Coverage: 80% line, 70% branch
176+
- Static Analysis (IMPL-001.5): Zero critical anti-patterns
177+
- Pass Rate Gate: >= 95% (criticality-aware) or 100%
178+
- Max Fix Iterations: 10 (default, adjustable)
179+
180+
## Strategy Engine (Phase 2)
181+
182+
| Strategy | Trigger | Behavior |
183+
|----------|---------|----------|
184+
| **Conservative** | Iteration 1-2 (default) | Single targeted fix, full validation |
185+
| **Aggressive** | Pass rate >80% + similar failures | Batch fix related issues |
186+
| **Surgical** | Regression detected (pass rate drops >10%) | Minimal changes, rollback focus |
187+
188+
Selection logic and CLI fallback chain (Gemini → Qwen → Codex) are detailed in Phase 2.
189+
190+
## Agent Roles
191+
192+
| Agent | Used In | Responsibility |
193+
|-------|---------|---------------|
194+
| **Orchestrator** | Both phases | Route entry, track progress, pass context |
195+
| **@code-developer** | Phase 2 (IMPL-001) | Test generation (L1-L3) |
196+
| **@test-fix-agent** | Phase 2 | Test execution, code fixes, criticality assignment |
197+
| **@cli-planning-agent** | Phase 2 (fix loop) | CLI analysis, root cause extraction, fix task generation |
198+
199+
## TodoWrite Pattern
200+
201+
**Core Concept**: Dynamic task tracking with attachment/collapse for real-time visibility.
202+
203+
> **Implementation Note**: Phase files use `TodoWrite` syntax to describe the conceptual tracking pattern. At runtime, these are implemented via `TaskCreate/TaskUpdate/TaskList` tools from the allowed-tools list. Map `TodoWrite` examples as follows:
204+
> - Initial list creation → `TaskCreate` for each item
205+
> - Status changes → `TaskUpdate({ taskId, status })`
206+
> - Sub-task attachment → `TaskCreate` + `TaskUpdate({ addBlockedBy })`
207+
> - Sub-task collapse → `TaskUpdate({ status: "completed" })` + `TaskUpdate({ status: "deleted" })` for collapsed sub-items
208+
209+
### Full Pipeline (Phase 1 + Phase 2)
210+
211+
```json
212+
[
213+
{"content": "Phase 1: Test Generation", "status": "in_progress"},
214+
{"content": " → Create test session", "status": "in_progress"},
215+
{"content": " → Gather test context", "status": "pending"},
216+
{"content": " → Test analysis (Gemini)", "status": "pending"},
217+
{"content": " → Generate test tasks", "status": "pending"},
218+
{"content": "Phase 2: Test Cycle Execution", "status": "pending"}
219+
]
220+
```
221+
222+
### Phase 1 Collapsed → Phase 2 Active
223+
224+
```json
225+
[
226+
{"content": "Phase 1: Test Generation", "status": "completed"},
227+
{"content": "Phase 2: Test Cycle Execution", "status": "in_progress"},
228+
{"content": " → Execute IMPL-001 [code-developer]", "status": "in_progress"},
229+
{"content": " → Execute IMPL-001.3 [test-fix-agent]", "status": "pending"},
230+
{"content": " → Execute IMPL-001.5 [test-fix-agent]", "status": "pending"},
231+
{"content": " → Execute IMPL-002 [test-fix-agent]", "status": "pending"},
232+
{"content": " → Fix Loop", "status": "pending"}
233+
]
234+
```
235+
236+
### Fix Loop Iterations
237+
238+
```json
239+
[
240+
{"content": "Phase 1: Test Generation", "status": "completed"},
241+
{"content": "Phase 2: Test Cycle Execution", "status": "in_progress"},
242+
{"content": " → Initial tasks", "status": "completed"},
243+
{"content": " → Iteration 1: Initial test (pass: 70%, conservative)", "status": "completed"},
244+
{"content": " → Iteration 2: Fix validation (pass: 82%, conservative)", "status": "completed"},
245+
{"content": " → Iteration 3: Batch fix (pass: 89%, aggressive)", "status": "in_progress"}
246+
]
247+
```
248+
249+
## Session File Structure
250+
251+
```
252+
.workflow/active/WFS-test-{session}/
253+
├── workflow-session.json # Session metadata
254+
├── IMPL_PLAN.md # Test generation and execution strategy
255+
├── TODO_LIST.md # Task checklist
256+
├── .task/
257+
│ ├── IMPL-001.json # Test understanding & generation
258+
│ ├── IMPL-001.3-validation.json # Code validation gate
259+
│ ├── IMPL-001.5-review.json # Test quality gate
260+
│ ├── IMPL-002.json # Test execution & fix cycle
261+
│ └── IMPL-fix-{N}.json # Generated fix tasks (Phase 2 fix loop)
262+
├── .process/
263+
│ ├── [test-]context-package.json # Context and coverage analysis
264+
│ ├── TEST_ANALYSIS_RESULTS.md # Test requirements (L0-L3)
265+
│ ├── iteration-state.json # Current iteration + strategy + stuck tests
266+
│ ├── test-results.json # Latest results (pass_rate, criticality)
267+
│ ├── test-output.log # Full test output
268+
│ ├── fix-history.json # All fix attempts
269+
│ ├── iteration-{N}-analysis.md # CLI analysis report
270+
│ └── iteration-{N}-cli-output.txt
271+
└── .summaries/
272+
└── iteration-summaries/
273+
```
274+
275+
## Error Handling
276+
277+
### Phase 1 (Generation)
278+
279+
| Step | Error Condition | Action |
280+
|------|----------------|--------|
281+
| Session create | Source session not found (session mode) | Return error with session ID |
282+
| Session create | No completed IMPL tasks (session mode) | Return error, source incomplete |
283+
| Context gather | Context gathering failed | Return error, check source artifacts |
284+
| Analysis | Gemini analysis failed | Return error, check context package |
285+
| Task gen | Task generation failed | Retry once, then return error |
286+
287+
### Phase 2 (Execution)
288+
289+
| Scenario | Action |
290+
|----------|--------|
291+
| Test execution error | Log, retry with error context |
292+
| CLI analysis failure | Fallback: Gemini → Qwen → Codex → manual |
293+
| Agent execution error | Save state, retry with simplified context |
294+
| Max iterations reached | Generate failure report, mark blocked |
295+
| Regression detected | Rollback last fix, switch to surgical strategy |
296+
| Stuck tests detected | Continue with alternative strategy, document |
297+
298+
## Commit Strategy (Phase 2)
299+
300+
Automatic commits at key checkpoints:
301+
1. **After successful iteration** (pass rate increased): `test-cycle: iteration N - strategy (pass: old% → new%)`
302+
2. **Before rollback** (regression detected): `test-cycle: rollback iteration N - regression detected`
303+
304+
## Completion Conditions
305+
306+
| Condition | Pass Rate | Action |
307+
|-----------|-----------|--------|
308+
| **Full Success** | 100% | Auto-complete session |
309+
| **Partial Success** | >= 95%, all failures low criticality | Auto-approve with review note |
310+
| **Failure** | < 95% after max iterations | Failure report, mark blocked |
311+
312+
## Post-Completion Expansion
313+
314+
After completion, ask user if they want to expand into issues (test/enhance/refactor/doc). Selected items call `/issue:new "{summary} - {dimension}"`.
315+
316+
## Coordinator Checklist
317+
318+
### Phase 1 (test-fix-gen)
319+
- [ ] Detect input type (session ID / description / file path)
320+
- [ ] Initialize TaskCreate before any execution
321+
- [ ] Read Phase 1 doc, execute all 5 internal steps
322+
- [ ] Parse testSessionId from step output, store in memory
323+
- [ ] Verify all Phase 1 outputs (4 task JSONs, IMPL_PLAN.md, TODO_LIST.md)
324+
- [ ] Collapse Phase 1 tasks, auto-continue to Phase 2
325+
326+
### Phase 2 (test-cycle-execute)
327+
- [ ] Read Phase 2 doc
328+
- [ ] Load session, tasks, iteration state
329+
- [ ] Execute initial tasks sequentially
330+
- [ ] Calculate pass rate from test-results.json
331+
- [ ] If pass_rate < 95%: Enter fix loop
332+
- [ ] Track iteration count, stuck tests, regression
333+
- [ ] If pass_rate >= 95% or max iterations: Complete
334+
- [ ] Generate completion summary
335+
- [ ] Offer post-completion expansion
336+
337+
## Related Skills
338+
339+
**Prerequisite Skills**:
340+
- `/workflow:plan` or `/workflow:execute` - Complete implementation (Session Mode source)
341+
- None for Prompt Mode
342+
343+
**Called During Execution**:
344+
- `/workflow:session:start` - Phase 1: Create test session
345+
- `/workflow:tools:test-context-gather` - Phase 1 (Session Mode)
346+
- `/workflow:tools:context-gather` - Phase 1 (Prompt Mode)
347+
- `/workflow:tools:test-concept-enhanced` - Phase 1: Gemini analysis
348+
- `/workflow:tools:test-task-generate` - Phase 1: Task generation
349+
- `/workflow:session:complete` - Phase 2: Archive session
350+
351+
**Follow-up Skills**:
352+
- `/workflow:status` - Review workflow state
353+
- `/workflow:review` - Post-implementation review
354+
- `/issue:new` - Create follow-up issues

0 commit comments

Comments
 (0)