workflow-test-fix-cycle
npx skills add https://github.com/catlog22/claude-code-workflow --skill workflow-test-fix-cycle
Agent 安装分布
Skill 文档
Workflow Test-Fix Cycle
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).
Architecture Overview
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â Workflow Test-Fix Cycle Orchestrator (SKILL.md) â
â â Full pipeline: Test generation + Iterative execution â
â â Phase dispatch: Read phase docs, execute, pass context â
âââââââââââââââââ¬âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
â
ââââââââââââââ´âââââââââââââââââââââââââ
â â
âââââââââââââââââââââââââââ âââââââââââââââââââââââââââââââ
â Phase 1: Test-Fix Gen â â Phase 2: Test-Cycle Execute â
â phases/01-test-fix-gen â â phases/02-test-cycle-execute â
â 5 sub-phases: â â 3 stages: â
â â Create Session â â â Discovery â
â â¡ Gather Context â â â¡ Main Loop (iterate) â
â ⢠Test Analysis (Gemini)â â ⢠Completion â
â ⣠Generate Tasks â â â
â ⤠Summary â â Agents (via spawn_agent): â
â â â @cli-planning-agent â
â Agents (via spawn_agent)â â @test-fix-agent â
â @test-context-search â â â
â @context-search â â Strategy: conservative â â
â @cli-execution â â aggressive â surgical â
â @action-planning â â â
ââââââââââ¬âââââââââââââââââ ââââââââââââââ¬âââââââââââââââââââ
â â
IMPL-001..002.json Pass Rate >= 95%
TEST_ANALYSIS_RESULTS.md Auto-complete session
Task Pipeline:
ââââââââââââââââ âââââââââââââââââââ âââââââââââââââââââ ââââââââââââââââ
â IMPL-001 ââââââ IMPL-001.3 ââââââ IMPL-001.5 ââââââ IMPL-002 â
â Test Gen â â Code Validate â â Quality Gate â â Test & Fix â
â L1-L3 â â L0 + AI Issues â â Coverage 80%+ â â Max 10 iter â
â@code-developerâ â @test-fix-agent â â @test-fix-agent â â@test-fix-agentâ
ââââââââââââââââ âââââââââââââââââââ âââââââââââââââââââ ââââââââââââââââ
â
Fix Loop: â
ââââââââââââââââââââ
â
ââââââââââââ
â @cli-planâââââ IMPL-fix-N.json
â agent â
ââââââââââââ¤
â@test-fix âââââ Apply & re-test
â agent â
ââââââââââââ
Key Design Principles
- Two-Phase Pipeline: Generation (Phase 1) creates session + tasks, Execution (Phase 2) runs iterative fix cycles
- Pure Orchestrator: Dispatch to phase docs, parse outputs, pass context between phases
- Auto-Continue: Full pipeline runs autonomously once triggered
- Subagent Lifecycle: Explicit lifecycle management with spawn_agent â wait â close_agent
- Progressive Test Layers: L0 (Static) â L1 (Unit) â L2 (Integration) â L3 (E2E)
- AI Code Issue Detection: Validates against common AI-generated code problems
- Intelligent Strategy Engine: conservative â aggressive â surgical based on iteration context
- CLI Fallback Chain: Gemini â Qwen â Codex for analysis resilience
- Progressive Testing: Affected tests during iterations, full suite for final validation
- Role Path Loading: Subagent roles loaded via path reference in MANDATORY FIRST STEPS
Auto Mode
This workflow is fully autonomous – Phase 1 generates test session and tasks, Phase 2 executes iterative fix cycles, all without user intervention until pass rate >= 95% or max iterations reached.
Subagent API Reference
spawn_agent
Create a new subagent with task assignment.
const agentId = spawn_agent({
message: `
## TASK ASSIGNMENT
### MANDATORY FIRST STEPS (Agent Execute)
1. **Read role definition**: ~/.codex/agents/{agent-type}.md (MUST read first)
2. Read: ${projectRoot}/.workflow/project-tech.json
3. Read: ${projectRoot}/.workflow/project-guidelines.json
## TASK CONTEXT
${taskContext}
## DELIVERABLES
${deliverables}
`
})
wait
Get results from subagent (only way to retrieve results).
const result = wait({
ids: [agentId],
timeout_ms: 600000 // 10 minutes
})
if (result.timed_out) {
// Handle timeout - can continue waiting or send_input to prompt completion
}
send_input
Continue interaction with active subagent (for clarification or follow-up).
send_input({
id: agentId,
message: `
## CLARIFICATION ANSWERS
${answers}
## NEXT STEP
Continue with plan generation.
`
})
close_agent
Clean up subagent resources (irreversible).
close_agent({ id: agentId })
Usage
workflow-test-fix-cycle <input> [options]
# Input (Phase 1 - Test Generation)
source-session-id WFS-* session ID (Session Mode - test validation for completed implementation)
feature description Text description of what to test (Prompt Mode)
/path/to/file.md Path to requirements file (Prompt Mode)
# Options (Phase 2 - Cycle Execution)
--max-iterations=N Custom iteration limit (default: 10)
# Examples
workflow-test-fix-cycle WFS-user-auth-v2 # Session Mode
workflow-test-fix-cycle "Test the user authentication API endpoints in src/auth/api.ts" # Prompt Mode - text
workflow-test-fix-cycle ./docs/api-requirements.md # Prompt Mode - file
workflow-test-fix-cycle "Test user registration" --max-iterations=15 # With custom iterations
# Resume (Phase 2 only - session already created)
workflow-test-fix-cycle --resume-session="WFS-test-user-auth" # Resume interrupted session
Quality Gate: Test pass rate >= 95% (criticality-aware) or 100% Max Iterations: 10 (default, adjustable) CLI Tools: Gemini â Qwen â Codex (fallback chain)
Test Strategy Overview
Progressive Test Layers (L0-L3):
| Layer | Name | Focus |
|---|---|---|
| L0 | Static Analysis | Compilation, imports, types, AI code issues |
| L1 | Unit Tests | Function/class behavior (happy/negative/edge cases) |
| L2 | Integration Tests | Component interactions, API contracts, failure modes |
| L3 | E2E Tests | User journeys, critical paths (optional) |
Key Features:
- AI Code Issue Detection – Validates against common AI-generated code problems (hallucinated imports, placeholder code, mock leakage, etc.)
- Project Type Detection – Applies appropriate test templates (React, Node API, CLI, Library, etc.)
- Quality Gates – IMPL-001.3 (code validation) and IMPL-001.5 (test quality) ensure high standards
Detailed specifications: See the test-task-generate workflow tool for complete L0-L3 requirements and quality thresholds.
Execution Flow
Input â Detect Mode (session | prompt | resume)
â
ââ resume mode â Skip to Phase 2
â
ââ session/prompt mode â Phase 1
â
Phase 1: Test-Fix Generation (phases/01-test-fix-gen.md)
ââ Sub-phase 1.1: Create Test Session â testSessionId
ââ Sub-phase 1.2: Gather Test Context (spawn_agent) â contextPath
ââ Sub-phase 1.3: Test Generation Analysis (spawn_agent â Gemini) â TEST_ANALYSIS_RESULTS.md
ââ Sub-phase 1.4: Generate Test Tasks (spawn_agent) â IMPL-*.json, IMPL_PLAN.md, TODO_LIST.md
ââ Sub-phase 1.5: Phase 1 Summary
â
Phase 2: Test-Cycle Execution (phases/02-test-cycle-execute.md)
ââ Discovery: Load session, tasks, iteration state
ââ Main Loop (for each task):
â ââ Execute â Test â Calculate pass_rate
â ââ 100% â SUCCESS: Next task
â ââ 95-99% + low criticality â PARTIAL SUCCESS: Approve
â ââ <95% â Fix Loop:
â ââ Select strategy: conservative/aggressive/surgical
â ââ spawn_agent(@cli-planning-agent) â IMPL-fix-N.json
â ââ spawn_agent(@test-fix-agent) â Apply fix & re-test
â ââ Re-test â Back to decision
ââ Completion: Final validation â Summary â Auto-complete session
Core Rules
- Start Immediately: First action is progress tracking initialization
- No Preliminary Analysis: Do not read files before Phase 1
- Parse Every Output: Extract data from each phase for the next
- Auto-Continue: After each phase finishes, automatically execute next pending phase
- Phase Loading: Read phase doc on-demand (
phases/01-*.md,phases/02-*.md) - Task Attachment Model: Sub-tasks ATTACH â execute â COLLAPSE
- CRITICAL: DO NOT STOP: Continuous pipeline until Phase 2 completion
- Phase Transition: After Phase 1 summary, immediately begin Phase 2
- Explicit Lifecycle: Always close_agent after wait completes to free resources
Phase Execution
Phase 1: Test-Fix Generation
Read: phases/01-test-fix-gen.md
5 sub-phases that create a test session and generate task JSONs:
- Create Test Session â
testSessionId - Gather Test Context (spawn_agent â wait â close_agent) â
contextPath - Test Generation Analysis (spawn_agent â wait â close_agent) â
TEST_ANALYSIS_RESULTS.md - 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 - Phase 1 Summary (internal – transitions to Phase 2)
Agents Used (via spawn_agent):
test-context-search-agent(~/.codex/agents/test-context-search-agent.md) – Context gathering (Session Mode)context-search-agent(~/.codex/agents/context-search-agent.md) – Context gathering (Prompt Mode)cli-execution-agent(~/.codex/agents/cli-execution-agent.md) – Test analysis with Geminiaction-planning-agent(~/.codex/agents/action-planning-agent.md) – Task JSON generation
Phase 2: Test-Cycle Execution
Read: phases/02-test-cycle-execute.md
3-stage iterative execution with adaptive strategy:
- Discovery – Load session, tasks, iteration state
- Main Loop – Execute tasks â Test â Analyze failures â Fix â Re-test
- Completion – Final validation â Summary â Auto-complete session
Agents Used (via spawn_agent):
cli-planning-agent(~/.codex/agents/cli-planning-agent.md) – Failure analysis, root cause extraction, fix task generationtest-fix-agent(~/.codex/agents/test-fix-agent.md) – Test execution, code fixes, criticality assignment
Strategy Engine: conservative (iteration 1-2) â aggressive (pass >80%) â surgical (regression)
Output Artifacts
Directory Structure
{projectRoot}/.workflow/active/WFS-test-[session]/
âââ workflow-session.json # Session metadata
âââ IMPL_PLAN.md # Test generation and execution strategy
âââ TODO_LIST.md # Task checklist
âââ .task/
â âââ IMPL-001.json # Test understanding & generation
â âââ IMPL-001.3-validation.json # Code validation gate
â âââ IMPL-001.5-review.json # Test quality gate
â âââ IMPL-002.json # Test execution & fix cycle
â âââ IMPL-fix-{N}.json # Generated fix tasks (Phase 2)
âââ .process/
â âââ [test-]context-package.json # Context and coverage analysis
â âââ TEST_ANALYSIS_RESULTS.md # Test requirements and strategy (L0-L3)
â âââ iteration-state.json # Current iteration + strategy + stuck tests
â âââ test-results.json # Latest results (pass_rate, criticality)
â âââ test-output.log # Full test output
â âââ fix-history.json # All fix attempts
â âââ iteration-{N}-analysis.md # CLI analysis report
â âââ iteration-{N}-cli-output.txt
âââ .summaries/iteration-summaries/
Progress Tracking Pattern
Phase 1 (Generation):
[
{ content: "Phase 1: Test-Fix Generation", status: "in_progress" },
{ content: " 1.1 Create Test Session", status: "completed" },
{ content: " 1.2 Gather Test Context", status: "in_progress" },
{ content: " 1.3 Test Generation Analysis", status: "pending" },
{ content: " 1.4 Generate Test Tasks", status: "pending" },
{ content: " 1.5 Phase Summary", status: "pending" },
{ content: "Phase 2: Test-Cycle Execution", status: "pending" }
]
Phase 2 (Execution):
[
{ content: "Phase 1: Test-Fix Generation", status: "completed" },
{ content: "Phase 2: Test-Cycle Execution", status: "in_progress" },
{ content: " Execute IMPL-001: Generate tests [code-developer]", status: "completed" },
{ content: " Execute IMPL-002: Test & Fix Cycle [ITERATION]", status: "in_progress" },
{ content: " â Iteration 1: Initial test (pass: 70%, conservative)", status: "completed" },
{ content: " â Iteration 2: Fix validation (pass: 82%, conservative)", status: "completed" },
{ content: " â Iteration 3: Batch fix auth (pass: 89%, aggressive)", status: "in_progress" }
]
Update Rules:
- Phase 1: Attach/collapse sub-phase tasks within Phase 1
- Phase 2: Add iteration items with strategy and pass rate
- Mark completed after each phase/iteration
- Update parent task when all complete
Error Handling
| Phase | Scenario | Action |
|---|---|---|
| 1.1 | Source session not found (session mode) | Return error with session ID |
| 1.1 | No completed IMPL tasks (session mode) | Return error, source incomplete |
| 1.2 | Context gathering failed | Return error, check source artifacts |
| 1.2 | Agent timeout | Retry with extended timeout, close_agent, then return error |
| 1.3 | Gemini analysis failed | Return error, check context package |
| 1.4 | Task generation failed | Retry once, then return error |
| 2 | Test execution error | Log, retry with error context |
| 2 | CLI analysis failure | Fallback: Gemini â Qwen â Codex â manual |
| 2 | Agent execution error | Save state, close_agent, retry with simplified context |
| 2 | Max iterations reached | Generate failure report, mark blocked |
| 2 | Regression detected | Rollback last fix, switch to surgical strategy |
| 2 | Stuck tests detected | Continue with alternative strategy, document in failure report |
Lifecycle Error Handling:
try {
const agentId = spawn_agent({ message: "..." });
const result = wait({ ids: [agentId], timeout_ms: 600000 });
// ... process result ...
close_agent({ id: agentId });
} catch (error) {
if (agentId) close_agent({ id: agentId });
throw error;
}
Coordinator Checklist
Phase 1 (Generation):
- Detect input type (session ID / description / file path / resume)
- Initialize progress tracking with 2 top-level phases
- Read
phases/01-test-fix-gen.mdfor detailed sub-phase execution - Execute 5 sub-phases with spawn_agent â wait â close_agent lifecycle
- Verify all Phase 1 outputs (4+ task JSONs, IMPL_PLAN.md, TODO_LIST.md)
- Ensure all agents are closed after each sub-phase completes
Phase 2 (Execution):
- Read
phases/02-test-cycle-execute.mdfor detailed execution logic - Load session state and task queue
- Execute iterative test-fix cycles with spawn_agent â wait â close_agent
- Track iterations in progress tracking
- Auto-complete session on success (pass rate >= 95%)
- Ensure all agents are closed after each iteration
Resume Mode:
- If
--resume-sessionprovided, skip Phase 1 - Load existing session directly into Phase 2
Related Skills
Prerequisite Skills:
workflow:planorworkflow:execute– Complete implementation (Session Mode)- None for Prompt Mode
Phase 1 Agents (used by phases/01-test-fix-gen.md via spawn_agent):
test-context-search-agent(~/.codex/agents/test-context-search-agent.md) – Test coverage analysis (Session Mode)context-search-agent(~/.codex/agents/context-search-agent.md) – Codebase analysis (Prompt Mode)cli-execution-agent(~/.codex/agents/cli-execution-agent.md) – Test requirements with Geminiaction-planning-agent(~/.codex/agents/action-planning-agent.md) – Task JSON generation
Phase 2 Agents (used by phases/02-test-cycle-execute.md via spawn_agent):
cli-planning-agent(~/.codex/agents/cli-planning-agent.md) – CLI analysis, root cause extraction, task generationtest-fix-agent(~/.codex/agents/test-fix-agent.md) – Test execution, code fixes, criticality assignment
Follow-up:
- Session auto-complete on success
- Issue creation for follow-up work (post-completion expansion)