Ralph
A CLI agent harness for running AI coding agents in a loop.
Ralph wraps multiple AI CLI agents (Codex, Claude, Pi, Gemini) providing a unified interface with configuration file support, iteration control, and dangerous mode settings.
Installation
Quick Install (Recommended)
macOS / Linux:
|
Windows (PowerShell):
irm https://raw.githubusercontent.com/madhavajay/ralph/main/install.ps1 | iex
Via Cargo
From Source
Installing CLI Agents
Ralph can help install the CLI agents it supports:
# List available agents and their install status
# Show the install command Ralph would run
# Install a specific agent
# Install all detected-missing agents
Ralph automatically detects your package manager (brew, npm, cargo, pip/pipx, winget) and OS to use the appropriate install method.
Usage
# Run with a task file
# Run with an inline prompt
# Specify a harness
# Run multiple iterations
# Run infinitely
# Use a specific model
Harnesses
Ralph supports the following AI CLI agents:
| Harness | Command | Default Model | Default Provider |
|---|---|---|---|
| codex | codex |
gpt-5.2-codex | - |
| claude | claude |
claude-opus-4-5-20251101 | - |
| pi | pi |
claude-opus-4-5 | anthropic |
| gemini | gemini |
gemini-3 | - |
List available harnesses:
Configuration
Ralph supports configuration via .ralphrc or .ralphrc.toml files. Configuration is searched in:
- Current directory (
.ralphrcor.ralphrc.toml) - Home directory (
~/.ralphrcor~/.ralphrc.toml)
Generate an example config:
Example configuration:
# Agent harness: codex, claude, pi, gemini
= "codex"
# Model to use (optional, defaults vary by harness)
# model = "gpt-5.2-codex"
# Default task file
= "TASK.md"
# Number of iterations (number or "inf")
= "1"
# Enable dangerous mode (skip permissions)
= true
# Reasoning effort for codex
= "medium"
# Provider for pi harness (anthropic, openai, google, etc.)
# provider = "anthropic"
CLI Options
Usage: ralph [OPTIONS] [TASK] [COMMAND]
Commands:
providers List detected providers and their status
usage Show usage/quota information for providers
install Install CLI agents with available package managers
ps List and manage spawned agent processes
kill Kill spawned agent processes
cleanup Clean up stale process entries and discover orphans
logs View and manage logs
monitor Run monitor mode (outer agent watches inner agent)
help Print this message or the help of the given subcommand(s)
Arguments:
[TASK] Task file or prompt string
Options:
-H, --harness <HARNESS> Agent harness to use: codex, claude, pi, gemini
-m, --model <MODEL> Model to use (defaults vary by harness)
-n, --iterations <ITERATIONS> Number of iterations or 'inf' for infinite loop [default: 1]
--dangerous Enable dangerous mode (skip permissions) [default: true]
--safe Disable dangerous mode (require permissions)
--reasoning <REASONING> Model reasoning effort level (for codex) [default: medium]
--provider <PROVIDER> Provider for pi harness (anthropic, openai, google, etc.)
--list-harnesses List available harnesses and exit
--init Generate example .ralphrc config file
--tmux Run in tmux session (default when tmux is available)
--no-tmux Run in foreground without tmux
--tmux-attach Attach to tmux session after starting
--usage-limit-daily <N> Stop at daily usage percentage (0-100)
--usage-limit-weekly <N> Stop at weekly usage percentage (0-100)
--fallback-harness <NAME> Switch to this harness when usage limit reached
-v, --verbose Verbose logging (-v for debug, -vv for trace)
--log-stderr Also log to stderr (in addition to log file)
--log-file Show log file location
-h, --help Print help
-V, --version Print version
Tmux Sessions
When tmux is available, ralph runs in a tmux session by default. Session names include timestamp and PID, and ralph will auto-suffix if a name is already in use to avoid collisions.
Process Management
Ralph tracks spawned agent processes and provides commands to manage them:
# List all tracked processes
# List all processes including dead ones
# Kill all tracked processes
# Kill processes in a specific directory
# Kill processes for a specific harness
# Clean up stale process entries
# Discover orphaned agent processes
# Kill discovered orphans
Logging
Ralph logs to ~/.ralph/logs/ with daily rotation. Use -v for debug logging or -vv for trace logging.
# View recent logs
# View last 100 lines
# Follow log output (like tail -f)
# Show log file path
# Clear all log files
Environment Variables
All CLI options can be set via environment variables:
RALPH_HARNESS- Default harnessRALPH_MODEL- Default modelRALPH_ITERATIONS- Default iteration countRALPH_TASK- Default task fileRALPH_DANGEROUS- Enable dangerous modeRALPH_REASONING- Reasoning effort levelRALPH_PROVIDER- Provider for pi harness
Prerequisites
Ralph requires the corresponding CLI tool to be installed for each harness:
- codex: OpenAI Codex CLI -
npm install -g @openai/codex - claude: Claude Code -
npm install -g @anthropic-ai/claude-code - pi: Pi Coding Agent -
npm install -g @mariozechner/pi-coding-agent - gemini: Gemini CLI -
npm install -g @anthropic-ai/gemini-cli
Ralph checks for the presence of the CLI tool before running and will error if not found.
Optional: Usage Tracking
To see provider usage/quota information with ralph usage, install codexbar:
Platform Support
Ralph supports Linux, macOS, and Windows.
Development
Running Tests
# Run unit and integration tests
# Run clippy
Harness Integration Tests
Integration tests that run against real CLI harnesses are available but ignored by default (they require API keys and network access):
# Run all harness tests
# Run tests for a specific harness
Or run directly with cargo:
License
Apache-2.0