- Overview
- How They Work
- Comparison
- When to Use Each
- Case Study: Angular to React Migration
- Best Practices
- Sources
Claude Code is Anthropic's official CLI tool that operates as an interactive agentic coding assistant. It maintains conversation context, uses human-in-the-loop governance, and spawns specialized subagents for different tasks.
Philosophy: "Give Claude the tools programmers use"
Key characteristics:
- Single main loop with human approval at each step
- Maintains conversation history and todo lists
- Uses 50%+ Haiku calls for supporting tasks (cost optimization)
- Rejects RAG in favor of ripgrep/glob search
- Spawns specialized subagents (Explore, Plan, general-purpose)
The Ralph Wiggum technique is an autonomous iteration pattern that runs AI coding agents repeatedly until completion criteria are met. Named after The Simpsons character—perpetually confused but never stopping.
Philosophy: "The loop is the hero, not the model"
Key characteristics:
- Stateless bash loop that runs until completion
- Context resets each iteration (stateless resampling)
- State lives in filesystem/git only
- No human intervention between iterations
- Uses completion promises (e.g.,
<promise>COMPLETE</promise>)
Basic pattern:
while :; do cat PROMPT.md | claude-code ; done┌─────────────────────────────────────────────────────────┐
│ Claude Code Agent │
├─────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Gather │ -> │ Take │ -> │ Verify │ │
│ │ Context │ │ Action │ │ Work │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ^ │ │
│ │ v │
│ └──────────── Repeat ─────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Subagents │ │
│ │ ┌─────────┐ ┌─────────┐ ┌─────────────────┐ │ │
│ │ │ Explore │ │ Plan │ │ General Purpose │ │ │
│ │ └─────────┘ └─────────┘ └─────────────────┘ │ │
│ └─────────────────────────────────────────────────┘ │
│ │
│ Human Approval Required at Each Step │
└─────────────────────────────────────────────────────────┘
Tool hierarchy:
- Low-level: Bash, Read, Write
- Medium-level: Edit, Grep, Glob
- High-level: Task, WebFetch, TodoWrite
┌─────────────────────────────────────────────────────────┐
│ Ralph Wiggum Loop │
├─────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Bash Loop │ │
│ │ while :; do │ │
│ │ cat PROMPT.md | claude-code │ │
│ │ # Stop hook checks for completion promise │ │
│ │ done │ │
│ └──────────────────────────────────────────────────┘ │
│ │ │
│ v │
│ ┌──────────────────────────────────────────────────┐ │
│ │ State Management │ │
│ │ ┌─────────────┐ ┌─────────────────┐ │ │
│ │ │ Git History │ │ Modified Files │ │ │
│ │ └─────────────┘ └─────────────────┘ │ │
│ │ Context resets each iteration │ │
│ │ State persists in filesystem only │ │
│ └──────────────────────────────────────────────────┘ │
│ │
│ No Human Intervention Between Iterations │
└─────────────────────────────────────────────────────────┘
Stateless resampling: Instead of maintaining growing conversation history (which leads to context rot), the system resets the context window every iteration. The agent maintains state only through the filesystem and version control.
| Aspect | Claude Code Agent | Ralph Wiggum Loop |
|---|---|---|
| Nature | Interactive assistant | Autonomous iteration pattern |
| Architecture | Single loop + human approval | Stateless bash loop |
| State Management | Maintains conversation context | Resets each iteration |
| Human Oversight | Required at each step | None between iterations |
| Session Duration | Minutes to hours (interactive) | Hours to days (autonomous) |
| Cost Model | Pay per interaction | Pay per iteration ($50-100+ for long runs) |
| Failure Mode | Graceful (asks for help) | Overbaking (destructive cycles) |
| Ambiguity Handling | Asks clarifying questions | Fails or loops infinitely |
Claude Code Agent:
- Context-aware across conversation
- Human governance at each step
- Subagent specialization (different models for different tasks)
- Graceful handling of ambiguity
- Cost-optimized through Haiku delegation
- Maintains todo lists for complex tasks
Ralph Wiggum Loop:
- Runs autonomously for hours/days
- Stateless resampling prevents context rot
- Scales to massive refactors
- Works overnight (YC teams shipped 6 repos for ~$297)
- Built entire programming language (Cursed Lang) through iteration
- Deterministic loops in undeterministic environment
Claude Code Agent:
- Limited autonomy (requires human approval)
- Not suited for overnight batch work
- Session-based design
- Context window limits for very long tasks
Ralph Wiggum Loop:
- "Overbaking" failure mode on impossible tasks
- Vague requirements cause infinite loops
- Can compound errors if intermediate states break CI
- Costs add up fast (50 iterations = $50-100+)
- Requires Principal Skinner harness for production safety
- No judgment for architectural decisions
| Use Case | Best Choice | Reason |
|---|---|---|
| Interactive development | Claude Code | Context maintenance, course correction |
| Large refactors (clear criteria) | Ralph Wiggum | Runs for hours; measurable outcomes |
| Exploratory work | Claude Code | Requires judgment and clarification |
| Framework migrations | Ralph Wiggum | Deterministic goal |
| Security-sensitive code | Claude Code | Human oversight on each action |
| TDD workflows | Ralph Wiggum | Iterate until tests green |
| Architectural decisions | Claude Code | Requires human reasoning |
| Greenfield with defined endpoints | Ralph Wiggum | Clear success criteria |
| Debugging unknown issues | Claude Code | Exploratory reasoning needed |
| Overnight batch work | Ralph Wiggum | Autonomous execution |
| Production deployments | Claude Code + Skinner | Governance required |
Ralph works when you can define objective, measurable completion:
# Good criteria (measurable)
"All tests pass with >80% coverage"
"TypeScript compilation succeeds with no errors"
"All files in src/utils have JSDoc comments"
"Migrate all Jest tests to Vitest - npm test passes"
# Bad criteria (ambiguous)
"Make it better"
"Improve performance"
"Clean up the code"
"Fix the bugs"
For production use of Ralph Wiggum, implement governance:
- Deterministic tool lanes — Intercept every command before OS execution
- Behavioral circuit breakers — Trigger human-in-the-loop for suspicious patterns
- Distinct agent identity — Unique SSH keys for attribution
- Cost limits — Stop after N iterations or $X spent
Angular → React isn't a syntax swap—it's an architectural rewrite:
| Angular Concept | React Equivalent | Requires Judgment? |
|---|---|---|
| Modules + DI | Context/Hooks | Yes |
| RxJS Observables | React Query/hooks | Yes |
| Two-way binding | Controlled components | Yes |
| Angular Services | Custom hooks/Context | Yes |
| Template syntax | JSX | Partially automatable |
| NgRx | Redux/Zustand/Jotai | Yes |
| Angular Router | React Router | Yes |
| Angular Forms | React Hook Form | Partially automatable |
Human-in-the-loop for decisions:
Questions to resolve:
- State management: Redux vs Zustand vs Context?
- Data fetching: React Query vs SWR vs custom hooks?
- Routing: React Router v6 patterns?
- Styling: CSS modules vs Tailwind vs styled-components?
- Component structure and folder organization?
- Testing strategy: Jest + RTL? Vitest?
- Set up React project with chosen tooling
- Create shared utilities, hooks, context providers
- Set up routing skeleton
- Configure build/test infrastructure
- Establish component patterns
These sub-tasks have measurable success criteria:
| Task | Ralph Wiggum Prompt | Success Criteria |
|---|---|---|
| Utility functions | "Migrate all utils from src/app/utils to src/utils, TypeScript compatible" |
All tests pass |
| API services | "Convert Angular HTTP services to React Query hooks" | Type-check + tests pass |
| Presentational components | "Convert components in src/app/components/ui to React functional components" |
Storybook renders |
| Form validation | "Convert Angular reactive forms to React Hook Form" | Form tests pass |
| Pipes to utilities | "Convert all Angular pipes to utility functions" | Unit tests pass |
Example Ralph commands:
# Convert services to React Query hooks
/ralph-loop "Convert all Angular services in src/app/services/ to React Query hooks.
Each service should become a custom hook in src/hooks/.
Maintain the same API contract. Run npm test after each file."
--max-iterations 30
# Migrate utility functions
/ralph-loop "Migrate all utility functions from src/app/utils to src/utils.
Convert to TypeScript with proper types.
Success: npm run typecheck && npm test pass."
--max-iterations 20- Wire components together
- Handle edge cases
- Debug state management issues
- Performance optimization
- E2E testing
| Phase | Approach | Approx Cost |
|---|---|---|
| Architecture decisions | Claude Code | $10-30 |
| Scaffolding | Claude Code | $20-50 |
| Utility/service migration | Ralph Wiggum | $50-150 per batch |
| Component conversion | Ralph Wiggum | $100-300 |
| Integration/debugging | Claude Code | $50-100 |
| Total | Hybrid | $230-630 |
- Tests keep failing after 5+ iterations → switch to Claude Code
- Agent is refactoring unrelated code → stop immediately
- Architectural patterns emerging that weren't discussed → human review
- Costs exceeding $100 per sub-task → scope too large, break down
- CI broken for multiple iterations → manual intervention needed
- Use todo lists for complex multi-step tasks
- Leverage subagents for specialized work (Explore, Plan)
- Read before editing — never modify unseen code
- Keep sessions focused — one major task per session
- Use plan mode for architectural decisions
- Start small — 10-20 iterations initially, not 50
- Define objective criteria — "tests pass" not "looks good"
- Keep CI green — broken intermediate states compound
- Monitor costs — set spending limits
- Use progress.txt — track iteration outcomes
- Implement Principal Skinner — governance for production
- Claude Code for "what" and "why" — decisions, architecture
- Ralph Wiggum for "do this N times" — repetitive conversion
- Human checkpoints between phases
- Clear handoff criteria between approaches
- Cost budgets per phase
- The Ralph Wiggum Approach - DEV Community
- Inventing the Ralph Wiggum Loop | Geoffrey Huntley
- What makes Claude Code so good - MinusX
- Supervising Ralph: Principal Skinner Pattern
- A Brief History of Ralph - HumanLayer
- Claude Code Ralph Wiggum Plugin
- Building agents with Claude Agent SDK
- Claude Code Frameworks & Sub-Agents Guide
Generated: January 2026