CLI Reference
Ralph provides extensive command-line options organized into the following categories.
Quick Reference
Flag |
Description |
|---|---|
|
Skip all prompts and run automatically |
|
Increase verbosity level |
|
Suppress non-essential output |
|
CI mode (non-interactive, no color, JSON output) |
|
Provide project intent inline |
|
Override test command for verification |
|
Set max retries per task (default: 3) |
|
Execute only specified task(s) |
|
Resume from a specific task |
|
Output in JSON format |
|
Enhance intent before architect phase |
|
Revise PRD for quality improvements |
|
Enable all enhancement features |
Output/Verbosity
Control how Ralph displays information during execution.
Flag |
Description |
|---|---|
|
Increase verbosity (use -v, -vv, or -vvv for more detail) |
|
Suppress non-essential output |
|
Disable colored output |
|
Replace emojis with text equivalents |
Example: Run with maximum verbosity and no colors for log parsing:
ralph -vvv --no-color execute
Intent/Input
Specify what you want Ralph to build without interactive prompts.
Flag |
Description |
|---|---|
|
Provide intent inline (what to build) |
|
Load intent from a file |
|
Override prompt.md path for user context |
Example: Start a new project with intent from command line:
ralph --intent "Build a REST API with user authentication" architect
Architect Control
Configure the architect phase behavior.
Flag |
Description |
|---|---|
|
File tree depth for architect (default: 2) |
|
Patterns to ignore in file tree |
Example: Generate deeper file tree analysis while ignoring test directories:
ralph --tree-depth 4 --tree-ignore "test*" "spec*" architect
Execution Control
Fine-tune how Ralph executes tasks.
Flag |
Description |
|---|---|
|
Override test command for verification |
|
Skip verification step after task execution |
|
Override max retries per task (default: 3) |
|
Override agent timeout in seconds (default: 600) |
|
Execute only specified task IDs |
|
Skip specified task IDs |
|
Resume execution from a specific task ID |
Example: Execute specific tasks with custom test command and extended timeout:
ralph --only TASK-001 TASK-003 --test-cmd "npm test" --timeout 900 execute
Context
Control which files Ralph considers and how context is managed.
Flag |
Description |
|---|---|
|
Include only files matching these glob patterns in context |
|
Exclude files matching these glob patterns from context |
|
Limit maximum number of context files considered |
Example: Focus Ralph on source files only, excluding generated code:
ralph --include "src/**/*.py" --exclude "**/generated/**" execute
Model/LLM
Configure the underlying language model behavior.
Flag |
Description |
|---|---|
|
Model identifier for LLM requests (e.g., claude-3-opus) |
|
Sampling temperature (0.0-1.0) for response generation |
|
Maximum number of tokens in the LLM response |
|
Random seed for reproducible outputs |
|
Select agent backend (e.g., claude, copilot) |
Example: Use a specific model with deterministic output:
ralph --model claude-3-opus --temperature 0 --seed 42 execute
Logging/IO
Configure logging behavior and output formats.
Flag |
Description |
|---|---|
|
Redirect log output to specified file |
|
Set log level (debug, info, warn, error) |
|
Output in JSON format |
|
Output in newline-delimited JSON format |
|
Print PRD contents and exit without executing |
|
Export PRD to specified file |
|
Skip PRD archival after execution |
Example: Generate detailed logs for debugging:
ralph --log-file debug.log --log-level debug --prd-out plan.json execute
Headless/CI
Options for running Ralph in continuous integration pipelines.
Flag |
Description |
|---|---|
|
Disable all interactive prompts (fails if input required) |
|
CI mode: enables –non-interactive –no-color –no-emoji –json |
|
Check PRD status and exit with code (0=complete, 1=incomplete, 2=no PRD) |
Example: Run Ralph in a CI pipeline with JSON output:
ralph --ci --intent-file requirements.txt all
# Or check completion status in a script
ralph --status-check && echo "All tasks complete"
CI Mode
The --ci flag enables a bundle of CI-friendly options:
ralph --ci --intent-file requirements.txt all
This is equivalent to:
ralph --non-interactive --no-color --no-emoji --json
Status Check Exit Codes
Code |
Meaning |
|---|---|
0 |
All tasks complete |
1 |
Tasks incomplete |
2 |
No PRD found |
JSON Output Format
When using --json or --ndjson, Ralph outputs structured data:
{
"event": "TASK_SUCCESS",
"task_id": "TASK-001",
"timestamp": "2024-01-15T10:30:00Z",
"phase": "execute",
"verification_exit_code": 0
}
Use --ndjson for streaming output where each event is a separate JSON line:
ralph --ci --ndjson all | jq 'select(.event == "TASK_FAILURE")'
Extensibility
Extend Ralph with hooks and plugins.
Flag |
Description |
|---|---|
|
Disable hook execution |
|
Enable only specified hooks by name |
|
Shell command(s) to run before each phase |
|
Shell command(s) to run after each phase |
|
Load plugin(s) from Python file or directory path |
Example: Run linting before each phase and notify on completion:
ralph --pre "npm run lint" --post "curl -X POST https://hooks.example.com/notify" execute
For more details on hooks and plugins, see Hook/Event System.
Privacy
Protect sensitive information in logs and outputs.
Flag |
Description |
|---|---|
|
Regex patterns to redact from logs (e.g., API keys) |
|
Load redaction patterns from file (one pattern per line) |
|
Do not log prompts to log file |
|
Do not log responses to log file |
Example: Redact sensitive data from logs:
ralph --redact "sk-[a-zA-Z0-9]+" "password=\S+" --no-log-prompts execute
PRD Validation
Validate and customize the generated Product Requirements Document.
Flag |
Description |
|---|---|
|
Validate generated PRD against a JSON schema file |
|
Require at least N acceptance criteria per user story |
|
Add custom labels to PRD (format: key=value or just key) |
Example: Enforce PRD quality standards:
ralph --schema prd-schema.json --min-criteria 3 --label team=backend priority=high planner
Enhancement Features
Ralph provides AI-powered enhancement agents that improve the quality of your inputs and outputs throughout the development workflow.
Enhancement Flags Reference
Flag |
Description |
|---|---|
|
Process intent through enhancement agent before architect phase |
|
Exit on enhancement failure instead of falling back to original intent |
|
Disable intent enhancement (overrides |
|
Pass PRD through revision agent for quality improvements |
|
Disable PRD revision (overrides |
|
Enable all enhancement features at once |
Intent Enhancement
The --enhance-intent flag refines your initial project description to create a more precise, actionable, and well-structured description.
What it does:
Clarifies ambiguities in your intent
Adds specificity where the intent is too general
Structures requirements into clear, logical components
Surfaces implicit requirements that are essential but not explicitly stated
Translates user-facing language into technical requirements
Example: Enhance intent before starting a project:
ralph --enhance-intent --intent "Build a todo app" architect
With strict mode: Exit if enhancement fails:
ralph --enhance-intent --enhance-intent-strict --intent "Build a todo app" architect
PRD Revision
The --revise-prd flag reviews and improves the generated Product Requirements Document for clarity, completeness, and quality.
What it does:
Ensures each user story has clear, unambiguous descriptions
Verifies acceptance criteria are specific, measurable, and testable
Identifies missing edge cases or error handling scenarios
Ensures consistent terminology and formatting across all stories
Verifies technical requirements are correctly specified
Fixes any JSON formatting issues
Example: Revise PRD after generation:
ralph --revise-prd planner
Combined with schema validation:
ralph --revise-prd --schema prd-schema.json --min-criteria 3 planner
Using --enhance-all
The --enhance-all flag enables both enhancement features at once:
ralph --enhance-all all
Selectively disable specific features using --no-* flags:
# Enable all enhancements except intent enhancement
ralph --enhance-all --no-enhance-intent planner
Combining Enhancement Flags with Other Options
Enhancement flags work seamlessly with other Ralph options including headless operation modes.
With CI mode:
ralph --ci --enhance-all --intent-file requirements.txt all
With non-interactive mode:
ralph --non-interactive --enhance-intent --intent "Build an API" architect
With quiet mode:
ralph --quiet --enhance-all execute
Complete CI pipeline example:
ralph --ci --enhance-all --intent-file requirements.txt --test-cmd "npm test" all
Fallback Behavior
Enhancement agents gracefully handle failures:
Feature |
Default Behavior |
Strict Mode |
|---|---|---|
Intent Enhancement |
Falls back to original intent |
Exits with error ( |
PRD Revision |
Falls back to original PRD |
N/A |
When fallback occurs:
A warning is logged explaining the failure
The original (unenhanced) content is used
Execution continues normally
Error Messages and Resolutions
Error Message |
Cause |
Resolution |
|---|---|---|
|
Empty intent provided with |
Provide a non-empty intent via |
|
Agent failed to process the intent |
Check agent connectivity; intent will use fallback unless |
|
Agent failed with |
Fix the underlying issue or remove |
|
Agent returned empty content |
Check agent connectivity; will use fallback unless strict mode |
|
Agent response missing |
Will use fallback; check agent prompt compatibility |
|
Agent response missing |
Will use original PRD; check agent prompt compatibility |
|
Revised PRD doesn’t match |
Will use original PRD; review schema requirements |
|
Agent returned malformed JSON |
Will use original PRD; check agent output |
Events Emitted by Enhancement Features
Enhancement features emit events that can be subscribed to via hooks:
Event Type |
Trigger |
|---|---|
|
Intent enhancement begins |
|
Intent successfully enhanced |
|
Intent enhancement failed |
|
PRD revision begins |
|
PRD successfully revised |
|
PRD revision failed |
Example hook for enhancement events:
# .ralph/hooks/enhancement_monitor.py
from pyralph import Event # Optional: for type hints
EVENTS = [
"INTENT_ENHANCE_SUCCESS",
"INTENT_ENHANCE_FAILURE",
"PRD_REVISE_SUCCESS"
]
def on_event(event: Event) -> None:
if "FAILURE" in event.event_type.name:
print(f"Enhancement failed: {event.event_type.name}")
else:
print(f"Enhancement completed: {event.event_type.name}")
Hook/Event System
Ralph provides an extensible event-driven hook system that lets you subscribe to lifecycle events and execute custom code at key points during execution.
Available Event Types
Events are organized by lifecycle phase:
Category |
Events |
|---|---|
Phase |
|
Architect |
|
Planner |
|
Execute |
|
Task |
|
Verification |
|
PRD |
|
Error |
|
Event Payload
All events carry the following data:
event_type: EventType # The type of event
timestamp: str # ISO format timestamp
phase: Optional[str] # Current phase: architect/planner/execute
task_id: Optional[str] # Task identifier
task_description: Optional[str] # Task description
retry_count: Optional[int] # Current retry attempt
max_retries: Optional[int] # Maximum retries allowed
error: Optional[Any] # Error object if applicable
verification_command: Optional[str] # Test command
verification_exit_code: Optional[int] # Exit code from verification
prd_path: Optional[str] # Path to PRD file
metadata: Dict[str, Any] # Custom metadata
Creating Python Module Hooks
Create a Python file in .ralph/hooks/:
# .ralph/hooks/my_hook.py
from pyralph import Event, EventType # Optional: for type hints
EVENTS = ["TASK_SUCCESS", "TASK_FAILURE"] # Required: events to subscribe to
PRIORITY = 50 # Optional: lower = earlier (default: 100)
TIMEOUT = 10.0 # Optional: max seconds (default: 5.0)
MODIFIES_DATA = False # Optional: can modify events (default: False)
def on_event(event: Event) -> None:
"""Handle task completion events."""
print(f"Task {event.task_id}: {event.event_type.name}")
if event.error:
print(f" Error: {event.error}")
Hooks are auto-discovered from .ralph/hooks/ on startup.
Creating Executable Hooks
Create a script with a companion YAML config:
# .ralph/hooks/notify.sh
#!/bin/bash
EVENT_JSON=$(cat) # Receive JSON event via stdin
EVENT_TYPE=$(echo "$EVENT_JSON" | jq -r '.event_type')
TASK_ID=$(echo "$EVENT_JSON" | jq -r '.task_id')
echo "Task $TASK_ID: $EVENT_TYPE" >&2
# .ralph/hooks/notify.yaml
events:
- TASK_SUCCESS
- TASK_FAILURE
priority: 100
timeout: 5.0
Hook Execution Behavior
Hooks execute in priority order (lower values first)
Each hook runs in an isolated thread with timeout protection
Exceptions are caught and logged without halting execution
Hooks with
MODIFIES_DATA = Truecan transform event data
Plugin System
Plugins extend Ralph’s functionality by registering hooks programmatically.
Loading Plugins
# Load a single plugin file
ralph --plugin /path/to/plugin.py
# Load all plugins from a directory
ralph --plugin /path/to/plugins/
Creating a Plugin
# ~/my_plugins/monitoring.py
from pyralph import Event, EventType # Optional: for type hints
EVENTS = ["PHASE_START", "PHASE_END", "TASK_SUCCESS", "TASK_FAILURE"]
PRIORITY = 50
TIMEOUT = 10.0
def on_event(event: Event) -> None:
"""Monitor Ralph lifecycle events."""
if event.event_type.name == "TASK_SUCCESS":
print(f"Task {event.task_id} completed")
elif event.event_type.name == "TASK_FAILURE":
print(f"Task {event.task_id} failed: {event.error}")
elif event.event_type.name == "PHASE_START":
print(f"Starting {event.phase} phase")
Combining with Hooks for CI Notifications
# .ralph/hooks/ci_notify.py
import os
import requests
from pyralph import Event # Optional: for type hints
EVENTS = ["TASK_FAILURE", "PLANNER_SUCCESS", "EXECUTE_END"]
def on_event(event: Event) -> None:
"""Send notifications in CI environment."""
webhook_url = os.environ.get("SLACK_WEBHOOK_URL")
if not webhook_url:
return
if event.event_type.name == "TASK_FAILURE":
requests.post(webhook_url, json={
"text": f"Task {event.task_id} failed: {event.error}"
})
elif event.event_type.name == "EXECUTE_END":
requests.post(webhook_url, json={
"text": "Ralph execution completed"
})