Automate the Ralph Wiggum Loop for Spec-Driven Development workflows.
- π€ What is speckit-ralph?
- β‘ Quick Start
- π½οΈ How It Works
- π€ Supported AI Agents
- π§ CLI Reference
- π‘οΈ Guardrails (Signs)
- π Activity Logging
- βοΈ Environment Variables
- π Troubleshooting
- π Learn More
- π License
SPEC-KIT is GitHub's official toolkit for Spec-Driven Development β a structured approach where specifications become executable, directly generating working implementations.
While SPEC-KIT's /speckit.implement runs tasks once, speckit-ralph automates the iterative loop:
- Reads tasks from
specs/<branch>/tasks.md - Feeds them to your AI agent (Claude Code or Codex)
- Runs multiple iterations until completion
- Tracks progress, learns from failures, applies guardrails
Think of it as: SPEC-KIT defines the "what" and "how", Ralph executes the "do" repeatedly until done.
- SPEC-KIT installed and initialized in your project
- Spec workflow complete:
spec.md,plan.md,tasks.mdexist inspecs/<branch>/ - Feature branch matching your spec directory (e.g.,
feature/authβspecs/feature/auth/)
uv tool install speckit-ralph --from git+https://github.com/merllinsbeard/speckit-ralph.git# 1. Checkout your feature branch
git checkout feature/my-feature
# 2. Initialize Ralph (creates .speckit-ralph/ directory)
speckit-ralph init
# 3. Run the loop
speckit-ralph once --agent claude # Single iteration (review each step)
speckit-ralph loop 10 --agent claude # Multiple iterations (AFK mode)# See what Ralph will send to the AI agent
speckit-ralph build-prompt
# Save to file for review
speckit-ralph build-prompt --output prompt.mdIf you haven't set up SPEC-KIT yet:
# Install SPEC-KIT
uv tool install specify-cli --from git+https://github.com/github/spec-kit.git
# Initialize in your project
specify init . --here --ai claude
# Create spec workflow (in Claude Code)
/speckit.specify # Create specifications
/speckit.plan # Create implementation plan
/speckit.tasks # Generate task breakdown
# Then install and run Ralph
uv tool install speckit-ralph --from git+https://github.com/merllinsbeard/speckit-ralph.git
speckit-ralph init
speckit-ralph loop 10 --agent claudeβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SPEC-KIT Phase β
β (Human-Guided) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β /speckit.specify β specs/<branch>/spec.md β
β /speckit.plan β specs/<branch>/plan.md β
β /speckit.tasks β specs/<branch>/tasks.md β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Ralph Phase β
β (Automated Loop) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β speckit-ralph loop 10 --agent claude β
β ββ AI reads tasks.md, spec.md, plan.md β
β ββ AI implements one task per iteration β
β ββ AI sees previous work via git history (self-ref) β
β ββ Loop continues until: β
β ββ All tasks complete β
β ββ <promise>COMPLETE</promise> detected β
β ββ Max iterations reached β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| Agent | CLI | Status |
|---|---|---|
| Claude Code | claude |
β |
| Codex CLI | codex |
β |
| Droid | droid |
β |
| OpenCode | opencode |
β |
| Command | Description |
|---|---|
speckit-ralph once |
Run a single iteration |
speckit-ralph loop <N> |
Run N iterations |
speckit-ralph init |
Initialize .speckit-ralph directory |
speckit-ralph show-guardrails |
Display guardrails |
speckit-ralph show-activity |
Display activity log |
speckit-ralph show-errors |
Display errors log |
speckit-ralph build-prompt |
Generate prompt for inspection |
speckit-ralph scripts-path |
Print bundled scripts path |
| Option | Commands | Description |
|---|---|---|
--agent, -a |
once, loop |
Required. Agent: claude, codex, droid, or opencode |
--keep-artifacts, -k |
once, loop |
Keep temp files for debugging |
--promise, -p |
once, loop |
Completion promise string |
--detach, -d |
loop |
Run in background |
--sleep, -s |
loop |
Seconds between iterations |
--spec, -S |
once, loop, build-prompt |
Spec directory path (overrides branch detection) |
--root, -r |
init, show-activity, show-errors, show-guardrails |
Project root directory |
--lines, -n |
show-activity, show-errors |
Number of lines to show (default: 50) |
--output, -o |
build-prompt |
Output file path |
# Single iteration with Claude
speckit-ralph once --agent claude
# Single iteration with Codex
speckit-ralph once --agent codex
# 10 iterations with Claude, keep artifacts
speckit-ralph loop 10 --agent claude --keep-artifacts
# Run Codex in background
speckit-ralph loop 20 --agent codex --detach
# Custom sleep between iterations
speckit-ralph loop 10 --agent claude --sleep 5
# Multi-spec: explicitly specify which spec to use
speckit-ralph loop 5 --agent claude --spec specs/feature/auth
speckit-ralph once --agent codex --spec specs/feature/paymentsBy default, Ralph detects which spec to use based on your current git branch name (e.g., feature/auth maps to specs/feature/auth/).
For projects with multiple specs, you can explicitly specify which spec to use:
# Override branch detection with --spec
speckit-ralph loop 10 --agent claude --spec specs/feature/auth
# Use relative path from repo root
speckit-ralph once --agent codex --spec specs/feature/payments
# Or absolute path
speckit-ralph loop 5 --agent claude --spec /path/to/my-project/specs/feature/checkoutWhen to use --spec:
- Working on a different spec than your current branch
- Running multiple loops in parallel for different specs
- Testing a spec from a non-feature branch (e.g.,
main)
Guardrails are signs β lessons learned from failures that prevent recurring mistakes. They are stored in .speckit-ralph/guardrails.md and injected into each iteration's prompt.
Edit .speckit-ralph/guardrails.md directly to add new signs.
### Sign: [Name]
- **Trigger**: When this applies
- **Instruction**: What to do instead
- **Added after**: Why it was added| Type | Purpose |
|---|---|
| Preventive | Stop problems before they happen |
| Corrective | Fix recurring mistakes |
| Process | Enforce good practices |
| Architecture | Guide design decisions |
Ralph automatically logs all activity to .speckit-ralph/activity.log:
- Loop start/end events
- Iteration start/end with duration
- Errors and failures
- Git HEAD changes per iteration
Run summaries are stored in .speckit-ralph/runs/ with:
- CLI used (claude or codex)
- Duration
- Status (success or error)
- Git commits made
| Variable | Default | Description |
|---|---|---|
RALPH_AGENT |
claude |
Agent: claude or codex |
RALPH_PROMISE |
COMPLETE |
Completion promise string |
RALPH_SLEEP_SECONDS |
2 (claude), 1 (codex) |
Seconds between iterations |
RALPH_ARTIFACT_DIR |
(temp) | Directory for artifacts |
RALPH_SKIP_BRANCH_CHECK |
0 |
Skip feature branch validation |
RALPH_SPEC_DIR |
(auto) | Override spec directory (multi-spec) |
CODEX_SANDBOX |
workspace-write |
Codex sandbox mode |
CODEX_APPROVAL_POLICY |
never |
Codex approval policy |
ERROR: SPEC-KIT not initialized in this project.
Solution: Ralph requires SPEC-KIT to be set up first. Run these commands:
# 1. Install SPEC-KIT
uv tool install specify-cli --from git+https://github.com/github/spec-kit.git
# 2. Initialize SPEC-KIT in your project
specify init . --here --ai claude
# 3. Create your spec in Claude Code
/speckit.specify
/speckit.plan
/speckit.tasks
# 4. Now Ralph can run
speckit-ralph init
speckit-ralph loop 10ERROR: plan.md not found at specs/<branch>/plan.md
Solution: Complete the SPEC-KIT workflow:
/speckit.specify # Create spec.md
/speckit.plan # Create plan.md
/speckit.tasks # Create tasks.md
speckit-ralph loop 10 # Now Ralph can runSolution: Ensure tasks.md follows SPEC-KIT format:
## User Story 1: [Title]
- [ ] Task 1 description
- [ ] Task 2 description
## User Story 2: [Title]
- [ ] Task 3 description- SPEC-KIT β GitHub's official Spec-Driven Development toolkit
- Spec-Driven Methodology β Complete methodology guide
- Ralph Wiggum Technique β Original methodology
- 11 Tips for Better Ralph Wiggums β Best practices
This project is licensed under the terms of the MIT open source license. See LICENSE for details.