Ralph (Ralph Wiggum Agent)
Multi-attempt task executor that breaks down product ideas into atomic tasks and iteratively executes them with quality checks.
When to Use
Use Ralph for:
- Multi-step buildouts with many moving parts (features, internal tools, microservices)
- Coordinated changes across multiple files or modules
- Tasks where quality matters more than raw speed
- Work where first attempts are expected to be imperfect
Avoid Ralph for:
- Tiny, one-off edits or simple questions
- Tasks requiring deterministic, single-shot behavior
Core Workflow
1. Generate PRD from initial idea
2. Break PRD into atomic implementation tasks
3. For each task:
a. Start fresh context window
b. Load: PRD + task + attempt notes
c. Execute task
d. Run quality check
e. If pass → next task
f. If fail → log notes, retry (max 10 attempts)
Phase 1: PRD Generation
Transform the initial idea into a structured PRD:
# PRD: [Feature Name]
## Problem Statement
[What problem does this solve?]
## Goals
- [Goal 1]
- [Goal 2]
## Requirements
### Functional
- [Requirement 1]
### Non-Functional
- [Performance, security, etc.]
## Success Criteria
- [How do we know it's done?]
Phase 2: Task Decomposition
Break the PRD into atomic, independently-executable tasks.
Task properties:
- Single, clear objective
- Testable completion criteria
- No dependencies on uncommitted work
- Small enough to complete in one session
Task format:
## Task [N]: [Title]
Objective: [What to accomplish]
Files: [Expected files to create/modify]
Acceptance: [How to verify completion]
Phase 3: Task Execution Loop
3a. Context Setup (Fresh Window)
Start each attempt with minimal context:
- PRD summary (not full document)
- Current task specification
- Attempt history (if retrying)
3b. Execution
Execute the task according to its specification.
3c. Quality Check
Verify explicitly:
- Does output meet acceptance criteria?
- Are there syntax/runtime errors?
- Does it integrate with existing code?
- Are edge cases handled?
3d. Pass/Fail Decision
On Pass: Mark complete, proceed to next task.
On Fail: Log observations and retry:
## Attempt [N] Notes
- What failed: [specific failure]
- Root cause: [analysis]
- Fix approach: [what to try next]
Attempt Management
Retry rules:
- Max 10 attempts per task
- Each attempt starts with fresh context
- Previous attempt notes inform next attempt
- Notes are cumulative but summarized
Escalation (after 10 failures):
- Report what was attempted
- Identify consistent failure patterns
- Suggest human intervention
Mental Model
| Role | Responsibility |
|---|---|
| Project Manager | Writes the PRD |
| Dispatcher | Splits PRD into minimal tasks |
| Worker | Executes tasks in clean workspaces |
| QA Engineer | Checks results, files retry notes |
Context Window Strategy
Why fresh windows per attempt:
- Reduces context bloat from stale edit history
- Keeps model focused on current task
- Prevents accumulated confusion from failed approaches
What carries forward:
- PRD (summarized)
- Task specification
- Compact attempt notes (learnings only)
What gets discarded:
- Previous attempt's full execution trace
- Intermediate debugging output
- Superseded code versions
Implementation
Use Claude Code's Task tool to spawn fresh context windows:
Task(
subagent_type: "general-purpose",
prompt: """
PRD Summary: [condensed PRD]
Current Task: [task specification]
Previous Attempts:
[attempt notes if any]
Execute this task and verify completion.
""",
description: "Execute task N attempt M"
)
Track progress with TodoWrite. Store attempt notes in working files for persistence across sessions.
