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
Optional (not yet supported as harnesses):
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]
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, full sandbox access) [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
-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.
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
- claude: Claude Code
- pi: Pi CLI
- gemini: Gemini CLI
Ralph checks for the presence of the CLI tool before running and will error if not found.
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