Ralph-Loop++
An advanced Claude Code plugin for autonomous, long-running optimization tasks using the Ralph Wiggum technique with parallel workers and git worktree isolation.
What is Ralph-Loop++?
Ralph-Loop++ extends the Ralph Wiggum technique to create a sophisticated multi-agent optimization system. Give it an abstract but measurable goal in natural language, and it will:
- Create a verification test to measure your optimization target
- Spawn parallel workers in isolated git worktrees
- Iterate autonomously until the goal is achieved
- Evaluate solutions for quality and "spirit" compliance
- Integrate cleanly following your codebase conventions
- Create a PR with the optimized code
Installation
Add the marketplace:
/plugin marketplace add ponderingBGI/ralph-loop-pp
Install ralph-loop++:
/plugin install ralph-loop-pp@ralph-loop-pp
Install the required Ralph Wiggum plugin:
/plugin install ralph-wiggum@claude-plugins-official
Usage
Just describe what you want to optimize in natural language:
# Performance optimization
/optimize Reduce the API response time for /users endpoint to under 50ms p95 latency
# Memory optimization
/optimize Improve GPU memory efficiency for the renderer - target under 800MB peak
# Bug fixing
/optimize Fix the flaky tests in the auth module so they pass consistently
# Code quality
/optimize Increase test coverage for the payment module to at least 90%
# General improvement
/optimize Make the dashboard load faster - it currently takes 3 seconds
Other Commands
/optimize-status # Check current progress
/cancel-optimize # Stop all workers and clean up
How It Works
Architecture
User Task → Orchestrator → Test Architect → Parallel Workers
↓ ↓ ↓
Evaluates Creates Test Ralph Loop
↓ ↓ (max 20 iter)
Integrator ← Accept/Refine ← Metric Check
↓
Clean Code → Commit → PR
Agents
| Agent | Role |
|---|
| Orchestrator | Parses request, coordinates workflow, manages state |
| Test Architect | Creates verification tests that measure the target metric |
| Worker | Explores solutions in isolated worktree using Ralph loop |
| Evaluator | Assesses worker solutions for quality and "spirit" |
| Integrator | Creates clean, production-ready implementation |
Workflow
- Parse: The orchestrator extracts goals from your natural language request
- Test: A verification test is created to measure the target metric
- Explore: 2-3 workers try different approaches in isolated worktrees
- Iterate: Each worker runs in a Ralph loop (up to 20 iterations)
- Evaluate: Solutions are checked for quality and genuine improvement
- Integrate: The best approach is reimplemented following codebase conventions
- Commit: Changes are committed and optionally a PR is created
Features
Natural Language Interface
No flags or complex syntax - just describe what you want to achieve.
Parallel Workers
Multiple workers explore different approaches simultaneously. The evaluator picks the best solution or combines insights.
Git Worktree Isolation
Workers operate in isolated worktrees, so experiments don't affect your main codebase.
Spirit Compliance
The evaluator checks that solutions genuinely achieve the goal rather than "gaming" the metric.
Automatic Tool Selection
The orchestrator curates which tools each worker can access based on the task, preventing misuse.
State Persistence
Progress is saved to .claude/ralph-plus.local.md, enabling recovery if interrupted.
Configuration
Ralph-Loop++ works with your existing Claude Code setup:
- MCP Servers: Uses whatever you have configured (Context7 and Exa recommended for research)
- Permissions: Inherits from your project's settings
- Git: Respects your git configuration and hooks
Examples
Performance Optimization
/optimize Reduce API response time for /users endpoint to under 50ms
What happens:
- Creates a benchmark test hitting the endpoint
- Worker 1 tries connection pooling
- Worker 2 tries query optimization
- Evaluator selects best approach
- Integrator creates clean implementation
- PR created with performance comparison
Memory Leak Fix
/optimize Fix the memory leak in WebSocket connection handler - target under 100MB growth over 1000 connections
What happens:
- Creates a stress test measuring memory growth
- Workers investigate and fix different leak sources
- Multiple cycles as evaluator finds edge cases
- Final implementation with proper cleanup patterns
State File
Progress is tracked in .claude/ralph-plus.local.md: