"Me fail English? That's unpossible!" - Ralph Wiggum
An autonomous agent loop toolkit for Claude Code and Codex. Ralph iteratively picks tasks from an implementation plan, implements them, validates with configurable backpressure, commits, and continues without human intervention.
Based on The Ralph Playbook
- Autonomous Execution: Run implementation loops without manual intervention
- Multi-CLI Support: Works with Claude Code and OpenAI Codex
- Docker Sandboxing: Safe execution environment for autonomous runs
- Project Agnostic: Works with any tech stack
- Configurable Prompts: Customize planning and building behavior
# Clone the repository
git clone https://github.com/flowglad/ralph.git ~/.ralph
# Run the installer
~/.ralph/install.sh
# Reload your shell
source ~/.bashrc # or ~/.zshrccd ~/my-project
ralph initThis creates:
ralph.config- Project configurationralph/AGENTS.md- Project operations guideralph/plan.md- Implementation plan (human-readable, you edit this)ralph/prd.json- Task state tracking (machine-readable, Ralph manages this)ralph/specs/- Feature specificationsralph/PROMPT_*.md- Agent prompts
# Planning mode - analyze specs and create implementation plan
ralph plan
# Build mode - implement tasks from the plan
ralph
# Build with iteration limit
ralph 20
# Scoped planning for specific work
ralph plan-work "user authentication"If you already have an implementation plan in markdown, import it directly:
# 1. Initialize Ralph (if not already done)
ralph init
# 2. Import your markdown plan
ralph import ~/my-plan.md
# 3. Run planning to sync markdown to JSON tracking
ralph plan
# 4. Start building
ralphYour markdown plan can use any format - Ralph will read it and create JSON tasks:
# Implementation Plan
## Goal
Build user authentication system
## Tasks
### Pending
1. **Set up database schema** - Create users table with auth fields
- Related spec: `specs/auth.md`
2. **Implement registration** - POST /api/auth/register endpoint
- Depends on: database schema
3. **Add login/logout** - JWT-based session management
### Completed
- [x] Project setupHow it works:
ralph/plan.md- You write requirements here (human-friendly markdown)ralph/prd.json- Ralph tracks state here (machine-readable JSON)
Ralph keeps both in sync: reads requirements from plan.md, tracks completion status in prd.json. You can edit plan.md while Ralph runs to adjust priorities.
For autonomous runs with --dangerously-skip-permissions, use Docker for safety:
ralph --docker plan
ralph --docker 20ralph Build mode, unlimited iterations
ralph <n> Build mode, max n iterations
ralph plan Planning mode
ralph plan <n> Planning mode, max n iterations
ralph plan-work "<scope>" Scoped planning for specific work
ralph import <plan.md> Import existing markdown plan
ralph status Show current task status
ralph clean Remove completed tasks from tracking
ralph init Initialize Ralph in current project
ralph help Show help
Options:
--docker Run in Docker sandbox
- Read: Agent reads specs,
plan.md(requirements), andprd.json(state) - Choose: Agent selects the highest priority pending task (respecting dependencies)
- Implement: Agent writes code to complete the task per
plan.md - Validate: Agent runs tests, typecheck, lint
- Update: Agent marks task complete in both
prd.json(state) andplan.md(moves to Completed) - Commit: Agent commits changes with descriptive message
- Push: Loop pushes to remote and continues
| File | Purpose | Who Edits |
|---|---|---|
ralph/plan.md |
Requirements in human-readable markdown | You + Ralph |
ralph/prd.json |
State tracking (status, timestamps) | Ralph only |
This separation means:
- You write plans in familiar markdown
- Ralph tracks machine state in JSON
- Both stay in sync automatically
In planning mode, Ralph analyzes your specs and updates both plan.md and prd.json without making code changes. Use this to:
- Generate initial task list from specs
- Sync markdown plan to JSON tracking
- Discover gaps in specifications
In building mode, Ralph picks tasks from prd.json, reads details from plan.md, implements, validates, and commits. The loop continues until:
- All tasks are complete
- Max iterations reached
- Agent encounters an unrecoverable error
# CLI: claude or codex
RALPH_CLI="claude"
# Model to use
RALPH_MODEL="opus"
# Ralph directory location
RALPH_DIR="ralph"
# Custom goal for planning
RALPH_GOAL="Implement all specs"
# Additional CLI flags
RALPH_CLAUDE_FLAGS=""
RALPH_CODEX_FLAGS=""
# Debug mode
RALPH_DEBUG="false"Your project's operations guide. Document:
- How to build and run the project
- Validation commands (test, typecheck, lint)
- Codebase patterns to follow
- Tech stack information
Ralph updates this file with learnings during execution.
Create specifications in ralph/specs/:
# Feature Name
## Job to Be Done
What user need does this address?
## Acceptance Criteria
- [ ] Criterion 1
- [ ] Criterion 2
## Technical Notes
Implementation guidance (optional)See the examples/ directory for stack-specific configurations:
examples/node-typescript/- Node.js with TypeScriptexamples/python/- Python with pytest/mypyexamples/rust/- Rust with Cargo
- Philosophy - Design principles behind Ralph
- Docker Guide - Sandboxed execution setup
- Advanced Usage - Power user patterns
- Troubleshooting - Common issues
- Comparison - Ralph vs alternatives
Ralph runs with --dangerously-skip-permissions to enable autonomous execution. This means the agent can:
- Read and write any file
- Execute any command
- Make network requests
Recommendations:
- Always use Docker mode (
--docker) for autonomous runs - Review changes before pushing to main branches
- Set up branch protection rules
- Monitor agent output for unexpected behavior
- Use resource limits in Docker
- Bash 4.0+
- Git
- jq (for
ralph statusandralph clean) - Claude Code CLI (
npm i -g @anthropic-ai/claude-code) or - Codex CLI (
npm i -g @openai/codex) - Docker (optional, for sandboxed execution)
~/.ralph-wiggum/uninstall.sh
rm -rf ~/.ralph-wiggumMIT
Contributions welcome! Please read the contributing guidelines before submitting PRs.