rslph
Ralph Wiggum Loop - Autonomous AI Coding Agent
rslph is a Rust CLI application that implements the Ralph Wiggum Loop pattern: an autonomous AI coding agent that breaks down complex tasks into iterative steps and executes them using Claude AI. Each iteration starts with fresh context to prevent context pollution while preserving accumulated learnings through a persistent progress file. Features a rich TUI for real-time monitoring of execution.
Features
- Fresh Context Per Iteration - Each iteration resets Claude's context, preventing context window exhaustion while maintaining progress through the persistent progress file
- Progress File as Memory - Accumulated learnings survive across iterations, allowing Claude to learn from past attempts and avoid repeating failures
- Rich TUI Interface - Real-time monitoring with live Claude output, collapsible message threads, keyboard navigation, and Claude Code-style visual design
- VCS Auto-Commit - Automatic Git or Sapling commits after each iteration, creating a clear audit trail
- Flexible Configuration - Configure via TOML config file, environment variables, or CLI flags with clear precedence rules
- Built-in Evaluation Framework - Benchmark agent performance with hidden test suites and multi-trial statistics
- Multiple Prompt Modes - Choose between basic rslph prompts, GSD-adapted prompts, or strict test-driven development flow
- Token Tracking - Monitor Claude API token usage (input, output, cache creation, cache reads) across iterations
Prerequisites
Before installing rslph, ensure you have:
- Rust toolchain - Install from rustup.rs
- Claude CLI - Install and authenticate the Claude CLI tool
# Install Claude CLI (instructions at https://github.com/anthropics/anthropic-cli) # Authenticate - Git or Sapling VCS - For auto-commit functionality
Installation
From Source
# Clone the repository
# Build release binary
# Binary will be at: target/release/rslph
# Optional: Add to PATH or create symlink
From crates.io
Quick Start
-
Create a plan from an idea:
This generates a structured
progress.mdfile with tasks. -
Execute the plan autonomously:
Watch in the TUI as Claude iterates through tasks, commits changes, and completes the plan.
What happens:
- Claude reads the plan and current codebase
- Executes the next task, updates code
- Commits changes to Git/Sapling
- Updates
progress.mdwith results - Repeats until
RALPH_DONEmarker appears or max iterations reached - Each iteration has fresh context but sees accumulated progress
Commands Reference
rslph plan
Transform an idea into a structured progress file that the build command can execute.
Arguments:
<PLAN>- Path to plan file or inline text describing your goal
Options:
--adaptive- Enable adaptive mode with clarifying questions for detailed plans--mode <MODE>- Prompt mode:basic,gsd, orgsd_tdd(default: basic)--no-tui- Disable TUI and use plain output--config <CONFIG>- Override config file path--claude-path <PATH>- Override Claude CLI path--max-iterations <N>- Override max iterations setting
Examples:
# Inline plan
# From file
# With adaptive mode for complex plans
# Using GSD test-driven mode
rslph build
Execute tasks from a progress file iteratively with fresh context.
Arguments:
<PLAN>- Path to progress file (typicallyprogress.md)
Options:
--once- Run only a single iteration (for debugging)--dry-run- Preview what would happen without executing--max-iterations <N>- Override max iterations (default: 20)--mode <MODE>- Prompt mode:basic,gsd, orgsd_tdd--no-tui- Disable TUI interface--config <CONFIG>- Override config file path--claude-path <PATH>- Override Claude CLI path
Examples:
# Normal execution with TUI
# Single iteration for testing
# Preview without execution
# With custom iteration limit
TUI Controls:
q- Quitj/k- Scroll down/upPageUp/PageDown- Page navigationt- Toggle thinking blocks collapsed/expandedc- Toggle conversation view (split screen with all messages)
rslph eval
Run evaluation benchmarks in isolated environments with hidden test suites.
Arguments:
[PROJECT]- Project to evaluate (built-in or directory path)
Options:
--list- List available built-in projects--trials <N>- Number of independent trials to run (default: 1)--modes <MODES>- Comma-separated modes to compare:basic,gsd,gsd_tdd--keep- Keep temporary workspace after completion (for debugging)--max-iterations <N>- Override max iterations--no-tui- Disable TUI dashboard--config <CONFIG>- Override config file path
Built-in Projects:
calculator- Simple calculator with arithmetic operationsfizzbuzz- FizzBuzz implementation with test cases
Examples:
# List available projects
# Single evaluation
# Multiple trials for statistics
# Compare prompt modes
# Evaluate custom project with tests
Output:
- Results saved to JSON:
~/.rslph/evals/eval-results-{project}-{date}.json - Statistics: pass rate, avg tokens, iteration count with min/max/mean/variance
- Multi-mode comparison tables when using
--modes
Configuration
Config File Location
rslph uses XDG-compliant configuration:
~/.config/rslph/config.toml
Create this file to customize default behavior.
Example Configuration
# Path to Claude CLI executable (resolved via 'which' if relative)
= "claude"
# Maximum iterations before stopping (default: 20)
= 20
# Enable TUI mode by default (default: true)
= true
# Number of recent messages to display in TUI (default: 10)
= 10
# Timeout in seconds for each iteration (default: 600)
= 600
# Maximum retries for timed-out iterations (default: 3)
= 3
# Default prompt mode (basic, gsd, gsd_tdd)
= "basic"
# Directory for eval workspaces and results (default: ~/.rslph/evals)
= "~/.rslph/evals"
# Notification interval - every N iterations (default: 10)
= 10
# Number of recent threads to display (default: 5)
= 5
# Shell for notify script execution (default: /bin/sh)
= "/bin/sh"
# Optional: Override plan/build prompt files
# plan_prompt = "/path/to/custom_plan_prompt.md"
# build_prompt = "/path/to/custom_build_prompt.md"
Environment Variables
Override config with environment variables using the RSLPH_ prefix:
Configuration Precedence
Settings are applied in this order (later overrides earlier):
- Default values (hardcoded in the application)
- Config file (
~/.config/rslph/config.toml) - Environment variables (
RSLPH_*) - CLI flags (highest precedence)
Prompt Modes
rslph supports three prompt engineering approaches:
basic (Default)
The original rslph prompts focused on iterative task execution with progress file updates.
- Best for: General-purpose autonomous coding tasks
- Backward compatible with existing workflows
- Use when: You want tried-and-tested prompts
gsd (Get Shit Done)
GSD-adapted prompts with structured XML format and "must-haves" specification.
- Best for: Complex multi-phase projects with clear requirements
- Features: Explicit success criteria, structured output, must-haves tracking
- Use when: You have well-defined requirements and want structured execution
gsd_tdd (Test-Driven Development)
Strict test-driven development flow with three-phase cycle (write test → implement → refactor).
- Best for: Projects requiring high code quality and test coverage
- Features: Enforced red-green-refactor cycle, automatic test infrastructure setup
- Use when: Building libraries, APIs, or critical functionality requiring tests
Select mode:
# Via CLI flag
# Via config file
# config.toml: prompt_mode = "gsd_tdd"
# Via environment
How It Works
The Ralph Wiggum Loop is named after The Simpsons character who persists despite setbacks. It emphasizes iterative self-correction over single-pass perfection.
The Loop Pattern
-
Plan Phase:
- Claude transforms your idea into a structured progress file
- Tasks are broken down into concrete, executable steps
- Success criteria and verification steps are defined
-
Build Phase (iteration loop):
- Read: Claude reads the progress file + current codebase
- Execute: Completes the next task, modifying code as needed
- Commit: Changes are committed to VCS with descriptive message
- Update: Progress file is updated with results and learnings
- Check: If
RALPH_DONEmarker appears, loop exits successfully - Repeat: Fresh context for next iteration (no context pollution)
Key Insight: Progress File as Memory
The progress file is the sole memory mechanism between iterations:
- Each iteration Claude starts with fresh context (no accumulated tokens)
- Progress file contains accumulated learnings (what was tried, what worked, what failed)
- Claude reads this file every iteration, learning from past attempts
- Best of both worlds: fresh context + persistent memory
VCS Integration
After each successful iteration, rslph automatically commits:
git commit -m "Iteration 3: Implemented user authentication handler"
This creates an audit trail and allows easy rollback if needed.
Project Structure
After running rslph, your project might look like:
my-project/
├── progress.md # Generated by 'plan', updated by 'build'
├── src/ # Your code (created/modified by Claude)
│ ├── main.py
│ └── auth.py
└── .git/ # VCS commits after each iteration
Advanced Usage
Custom Prompt Files
Override default prompts by setting paths in config:
= "~/.config/rslph/my_plan_prompt.md"
= "~/.config/rslph/my_build_prompt.md"
This allows power users to customize Claude's instructions.
Evaluation Workflow
Benchmark your prompt engineering:
# Compare all modes across 5 trials
# Analyze results JSON
|
Results include:
- Pass rate (tests passed / total tests)
- Token usage statistics (mean, variance, min, max)
- Iteration count statistics
- Per-trial detailed logs
Debugging Failed Builds
# Run single iteration to see exact failure
# Keep workspace for inspection
# Disable TUI for clean logs
|
Troubleshooting
Claude CLI hangs
If the Claude CLI hangs, this is a known issue:
- Ensure your Claude CLI is up to date
- Check authentication:
claude auth
Timeout errors
If iterations timeout (default 600s):
# Increase timeout in config.toml
= 1200 # 20 minutes
= 5
VCS not auto-committing
Ensure Git or Sapling is initialized:
# or
rslph auto-detects VCS and commits after each iteration.
License
[License information - add your chosen license here]
Contributing
Contributions welcome! This project uses:
- Language: Rust (edition 2021)
- TUI: ratatui
- Config: figment (TOML)
- CLI: clap
- Testing: E2E tests with fake Claude simulation
Acknowledgments
- Pattern origin: Geoffrey Huntley's Ralph Wiggum Loop concept (late 2025)
- Reference implementation: portableralph
- Claude AI: Anthropic's Claude powers the autonomous execution
Built with Rust. Powered by Claude. Inspired by Ralph Wiggum's persistence.