Ralph is a minimal loop runner for Claude Code or Codex CLI. It executes an agentic loop that works through a spec (spec.md) one task at a time, committing progress as it goes. Each iteration is a fresh context window.
ralph.sh # Core implementation (single bash script)
CHANGELOG.md # Version history (must match VERSION in ralph.sh)
hooks/pre-commit # Enforces version sync
skills/ralph-planner/ # Claude Code skill for planning sessions
examples/ # Supervisor pattern examples
Manual versioning with pre-commit enforcement.
- Version lives in
ralph.shline 4:VERSION="X.Y.Z" - CHANGELOG.md header:
## Version X.Y.Z (YYYY-MM-DD) - Pre-commit hook blocks commits if versions don't match
- Update
VERSIONinralph.shline 4 - Add entry to
CHANGELOG.mdwith matching version and today's date - Commit — hook validates match
# Hook installation (already done, but for reference)
ln -sf ../../hooks/pre-commit .git/hooks/pre-commit- Patch (0.0.X): Bug fixes, minor tweaks
- Minor (0.X.0): New features, backward-compatible
- Major (X.0.0): Breaking changes (env var renames, file format changes)
# Run script directly
./ralph.sh --help
./ralph.sh --version
# Test pre-commit hook
./hooks/pre-commit
# Test with a session
./ralph.sh init test-session
./ralph.sh --session test-session --once claude- Edit
ralph.sh - If adding features/fixes, bump version in both files
- Run
./hooks/pre-committo verify - Commit
## Version X.Y.Z (YYYY-MM-DD)
### Breaking Changes
- Description of breaking change
### New Features
- Description of new feature
### Bug Fixes
- Description of fixKey variables to know when developing:
| Variable | Purpose |
|---|---|
RALPH_CLAUDE_PRETTY |
Pretty-print Claude JSON output (default: 1) |
RALPH_CODEX_PRETTY |
Pretty-print Codex JSON output (default: 1) |
RALPH_COMPRESS_LOGS |
Gzip logs immediately (default: 0) |
- Bash with
set -euo pipefail - Functions use
localfor variables - Heredocs for multi-line strings
- Use
${VAR:-default}for optional env vars - Keep it simple — this is intentionally a single bash script
When working on session-related code, understand this structure:
.agent/sessions/<name>/
├── spec.md # Tasks in markdown (⬜/✅ status, checkboxes)
├── progress.txt # Append-only log
├── prompt.md # Session-specific instructions
└── logs/ # Run transcripts
### ⬜ Task: task-id
**Priority:** high|medium|low
**Status:** incomplete
Description here.
**Acceptance:**
- [ ] Criterion 1
- [ ] Criterion 2
---When complete: change ⬜ to ✅, incomplete to complete, check boxes [x].
Logs combine prompt + transcript + summary into single .md files:
- Prompt only included if changed from previous run (deduplication)
- Old logs (>1 day) auto-compressed to
.gz - Use
ralph cleanto manually clean up