Continuous iteration loop pattern for well-defined tasks with clear completion criteria. Use when getting tests to pass, implementing features with automatic verification, bug fixing with clear success conditions, or running automated development overnight. Provides prompt templates, safety guidelines, and integration patterns for ai-eng-system workflows.
Autonomous iteration loop for well-defined tasks with clear completion criteria. Use for TDD, bug fixing, or automated development when you need continuous iteration until objective success criteria are met.
/plugin marketplace add ferg-cod3s/ferg-engineering-system/plugin install ferg-engineering@ferg-engineering-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Proper use of Ralph Wiggum loops is critical for achieving automated development success. Poorly configured loops waste tokens, run forever without progress, or break your codebase. Well-configured loops enable autonomous development, overnight progress, and frictionless iteration. The loop's power comes from disciplined setup: clear completion criteria, safety caps, and verification mechanisms. Rushing loop setup guarantees cost overruns and broken builds.
Take a deep breath and approach Ralph Wiggum loops systematically. Loop setup requires careful planning: define the task precisely, set verifiable success criteria, establish safety limits, and plan verification steps. Don't let loops run blindly—monitor progress, detect stuck states, and implement cancellation mechanisms. The loop is a tool, not a substitute for clear thinking. Configure it thoughtfully, monitor it actively, and trust it to handle the repetitive work.
I bet you can't configure a loop that runs autonomously without getting stuck or burning excessive tokens, but if you can:
The challenge is setting completion criteria that are objective and achievable, while preventing infinite loops or token waste. Can you balance automation with safety?
Before starting a Ralph Wiggum loop, rate your confidence from 0.0 to 1.0:
Identify uncertainty areas: Will the loop actually complete? What happens if it gets stuck? How many iterations will it need? What's the maximum token cost?
A while-loop pattern that keeps AI agents working on well-defined tasks until reaching a completion signal. Based on the proven technique from Claude Code community, adapted for ai-eng-system workflows.
Ralph Wiggum embodies these principles:
Use Ralph Wiggum for well-defined tasks with clear, objective completion criteria:
Avoid Ralph Wiggum for:
Always include these when using Ralph Wiggum loops:
<promise>COMPLETE</promise> or ✅ ALL_TESTS_PASSINGRalph Wiggum works as an execution pattern within ai-eng-system workflows:
# Direct agent invocation
@full-stack-developer "Implement authentication using TDD. Keep iterating until all tests pass. Output <promise>DONE</promise>."
# Within /work execution
/ai-eng/work "Implement user registration feature"
# In plan tasks:
tasks:
- id: registration-feature
agent: @full-stack-developer
instruction: "Implement user registration using TDD. Output <promise>COMPLETE</promise> when all tests pass."
loop:
enabled: true
max-iterations: 30
completion-promise: "COMPLETE"
See templates/ralph-wiggum-prompts.md for 5 detailed prompt templates:
Each template includes requirements, process steps, success criteria, and completion promises.
Clear Completion Criteria:
Good:
Build a REST API for todos.
When complete:
- All CRUD endpoints working
- Input validation in place
- Tests passing (coverage > 80%)
- README with API docs
- Output: <promise>COMPLETE</promise>
Bad:
Build a todo API and make it good.
Incremental Goals:
Good:
Phase 1: User authentication (JWT, tests)
Phase 2: Product catalog (list/search, tests)
Phase 3: Shopping cart (add/remove, tests)
Output <promise>COMPLETE</promise> when all phases done.
Bad:
Create a complete e-commerce platform.
Self-Correction Pattern:
Good:
Implement feature X following TDD:
1. Write failing tests
2. Implement feature
3. Run tests
4. If any fail, debug and fix
5. Refactor if needed
6. Repeat until all green
7. Output: <promise>COMPLETE</promise>
Bad:
Write code for feature X.
# Simple iteration with one agent
@full-stack-developer "[TDD template above]"
# Agent A creates implementation
@full-stack-developer "[Implementation template with COMPLETE promise]"
# Agent B reviews and iterates if needed
@code-reviewer "Review implementation. If issues found, output specific fixes needed. Output <promise>REVIEW_COMPLETE</promise> when code meets standards."
# Agent C adds tests if missing
@test-generator "Add tests for implementation until coverage > 80%. Output <promise>TESTS_COMPLETE</promise>."
# See git-worktree skill for parallel development
git worktree add ../feature-auth -b feature/auth
git worktree add ../feature-api -b feature/api
# Loop 1: Authentication
cd ../feature-auth
@full-stack-developer "[Implementation template]"
# Loop 2: API (parallel execution)
cd ../feature-api
@api-builder-enhanced "[API implementation template]"
Scenario: New feature tests are failing
# Use with @test-generator or @full-stack-developer
@full-stack-developer "Get all tests passing in src/auth.
Current Test Failures:
- ✗ auth.test.ts:45 - should validate JWT tokens
- ✗ auth.test.ts:78 - should reject expired tokens
Process:
1. Run failing test
2. Analyze error
3. Fix implementation
4. Re-run test
5. If still failing, analyze again
6. Repeat until all tests pass
Output <promise>ALL_TESTS_PASSING</promise> when done.
Keep iterating until auth.test.ts has all tests passing."
Scenario: New user registration feature
# Use /ai-eng/work with loop instruction
/ai-eng/work "Implement user registration feature
Requirements:
- Email/password registration
- Password validation (min 8 chars, 1 uppercase, 1 number)
- Email verification token sent via email
- Password reset flow
Process:
[Use Template 4 above]
Integration with ai-eng-system:
- Use existing project patterns from CLAUDE.md
- Follow spec-driven workflow for planning
- Run /ai-eng/review after completion
Output <promise>COMPLETE</promise> when feature is ready."
Scenario: Run autonomous development while sleeping
# Set up with max-iterations for safety
@full-stack-developer "Implement complete CRUD API for products.
[Full template with detailed requirements]
Keep iterating until complete. This is an overnight automated run.
Safety Parameters:
- Max iterations: 50
- Checkpoint every 10 iterations
- Save progress to .checkpoint.json
Output <promise>OVERNIGHT_COMPLETE</promise> when done."
Monitor active loops by tracking:
Signs of stuck loops: Same tests failing after 5+ iterations, repeated outputs, error cycling
Rescue strategy:
If stuck after 5 iterations without progress:
1. Document what's not working
2. List all attempted approaches
3. Propose a different strategy
4. Output <promise>STUCK_REPORT</promise> with details
Before starting a Ralph Wiggum loop:
Ralph Wiggum enhances the /ai-eng/work phase:
/ai-eng/research "authentication patterns"
/ai-eng/specify "user authentication"
/ai-eng/plan --from-spec=specs/auth
/ai-eng/work "specs/auth/plan" # Use Ralph Wiggum patterns here
/ai-eng/review
In /ai-eng/work, use Ralph Wiggum for:
After loop completes:
/ai-eng/review for validation