// Execute iterative refinement workflows with validation loops until quality criteria are met. Use for test-fix cycles, code quality improvement, performance optimization, or any task requiring repeated action-validate-improve cycles.
| name | iterative-refinement |
| description | Execute iterative refinement workflows with validation loops until quality criteria are met. Use for test-fix cycles, code quality improvement, performance optimization, or any task requiring repeated action-validate-improve cycles. |
Execute workflows iteratively with systematic validation, progress tracking, and intelligent termination.
Use for tasks requiring iterative refinement:
Don't use for single-pass tasks, purely parallel work, or simple linear workflows.
Before starting iterations, consider researching:
Benefits:
When to research first:
Every iteration follows:
Establish before starting:
Success Criteria (specific and measurable):
Loop Limits:
Termination Mode:
For each iteration:
Iteration N:
- Action: [what was done]
- Results: [metrics/outcomes]
- Issues remaining: [count/description]
- Decision: [Continue/Success/Stop]
Each iteration needs:
This prevents repeating failed approaches.
If no progress for 2-3 iterations:
Loop Summary:
- Iterations: N
- Termination: [Success/Converged/Max/Stuck]
- Initial state: [metrics]
- Final state: [metrics]
- Improvement: [percentage/delta]
- Remaining issues: [list if any]
Bad: "Check if code is better" Good: "Run linter and count warnings"
Bad: "See if it's faster" Good: "Run benchmark: average response time over 100 requests"
Prefer scripts/tools over manual inspection:
Track measurable progress:
Task: Fix all failing tests
Configuration:
Execution:
I1: 42/50 → Fix 8 failures → Continue
I2: 48/50 → Fix 2 failures → Continue
I3: 50/50 → SUCCESS ✓
Task: Remove all linter warnings
Configuration:
Execution:
I1: 15 warnings → Fix → 6 warnings
I2: 6 warnings → Fix → 1 warning
I3: 1 warning → Fix → 0 warnings ✓
Task: Optimize response time
Configuration:
Execution:
I1: 320ms → Optimize → 180ms (44%)
I2: 180ms → Optimize → 95ms (47%)
I3: 95ms → Optimize → 48ms (49%)
SUCCESS (target met)
Task: Increase test coverage to 90%
Configuration:
Execution:
I1: 65% → Write tests → 72%
I2: 72% → Write tests → 81%
I3: 81% → Write tests → 88%
I4: 88% → Write tests → 91% ✓
For validation tools and commands for your language:
For complex workflows, convergence detection, and advanced patterns: See patterns.md
✓ Define clear, measurable success criteria ✓ Set reasonable max limits (5-15) ✓ Use automated validators ✓ Pass context between iterations ✓ Track concrete metrics ✓ Stop early when criteria met ✓ Detect convergence ✓ Document changes
✗ Use loops for single-pass tasks ✗ Set high limits (>20) without justification ✗ Skip validation between iterations ✗ Lose context between iterations ✗ Continue after success/convergence ✗ Ignore stuck signals ✗ Use vague criteria ✗ Miss early termination