Backends
Ralph supports multiple AI CLI backends. This guide covers setup and selection.
Overview
Backends
Ralph supports multiple AI CLI backends. This guide covers setup and selection.
Supported Backends
| Backend | CLI Tool | Notes |
|---|---|---|
| Claude Code | claude | Recommended, primary support |
| Kiro | kiro-cli | Amazon/AWS |
| Gemini CLI | gemini | |
| Codex | codex | OpenAI |
| Amp | amp | Sourcegraph |
| Copilot CLI | copilot | GitHub |
| OpenCode | opencode | Community |
| Pi | pi | Multi-provider |
Auto-Detection
Ralph automatically detects installed backends:
ralph init
# Auto-detects available backend
Detection order (first available wins):
- Claude
- Kiro
- Gemini
- Codex
- Amp
- Copilot
- OpenCode
- Pi
Explicit Selection
Override auto-detection:
# Via CLI
ralph init --backend kiro
ralph run --backend gemini
# Via config
# ralph.yml
cli:
backend: "claude"
Backend Setup
Each backend below includes:
- Install instructions
- Auth & env vars (API keys or login)
- Hat YAML configuration
ralph doctorvalidation notes
Backend names (used in YAML and CLI flags): claude, kiro, gemini, codex, amp, copilot, opencode, pi.
Claude Code (claude)
The recommended backend with full feature support.
# Install
npm install -g @anthropic-ai/claude-code
# Authenticate
claude login
# Verify
claude --version
Auth & env vars:
claude login(preferred)ANTHROPIC_API_KEY(used byralph doctorauth hints)
Hat YAML:
hats:
planner:
backend: "claude"
Doctor checks:
claude --versionmust succeed- Warns if
ANTHROPIC_API_KEYis missing
Features:
- Full streaming support
- All hat features
- Memory integration
Kiro (kiro)
Amazon/AWS AI assistant.
# Install
# Visit https://kiro.dev/
# Verify
kiro-cli --version
Auth & env vars:
- Complete Kiro CLI authentication (AWS/SSO) per Kiro docs
KIRO_API_KEY(optional; used byralph doctorauth hints)
Hat YAML:
hats:
coder:
backend: "kiro"
Kiro agent selection (optional):
hats:
reviewer:
backend:
type: "kiro"
agent: "codex"
Doctor checks:
kiro-cli --versionmust succeed- Warns if
KIRO_API_KEYis missing (OK if you authenticated via CLI)
Gemini CLI (gemini)
Google's AI CLI.
# Install
npm install -g @google/gemini-cli
# Configure API key
# Verify
gemini --version
Auth & env vars:
GEMINI_API_KEY(used byralph doctorauth hints)
Hat YAML:
hats:
analyst:
backend: "gemini"
Doctor checks:
gemini --versionmust succeed- Warns if
GEMINI_API_KEYis missing
Codex (codex)
OpenAI's code-focused model.
# Install
# Visit https://github.com/openai/codex
# Configure
# Verify
codex --version
Auth & env vars:
OPENAI_API_KEYorCODEX_API_KEY(either satisfiesralph doctorauth hints)
Hat YAML:
hats:
coder:
backend: "codex"
Doctor checks:
codex --versionmust succeed- Warns if neither
OPENAI_API_KEYnorCODEX_API_KEYis set
Amp (amp)
Sourcegraph's AI assistant.
# Install
# Visit https://github.com/sourcegraph/amp
# Verify
amp --version
Auth & env vars:
- Authenticate via
ampCLI per Sourcegraph docs - No auth env vars are checked by
ralph doctorfor Amp
Hat YAML:
hats:
helper:
backend: "amp"
Doctor checks:
amp --versionmust succeed
Copilot CLI (copilot)
GitHub's AI assistant.
# Install
npm install -g @github/copilot
# Authenticate
copilot auth login
# Verify
copilot --version
Auth & env vars:
- Authenticate via Copilot CLI (
copilot auth loginorgh auth login) - No auth env vars are checked by
ralph doctorfor Copilot
Hat YAML:
hats:
reviewer:
backend: "copilot"
Doctor checks:
copilot --versionmust succeed
OpenCode (opencode)
Community AI CLI.
# Install
curl -fsSL https://opencode.ai/install | bash
# Verify
opencode --version
Auth & env vars:
- Set one of:
OPENCODE_API_KEY,ANTHROPIC_API_KEY,OPENAI_API_KEY - OpenCode can proxy multiple providers; use the env var matching your provider
Hat YAML:
hats:
strategist:
backend: "opencode"
Doctor checks:
opencode --versionmust succeed- Warns if none of
OPENCODE_API_KEY,ANTHROPIC_API_KEY,OPENAI_API_KEYare set
Pi (pi)
Multi-provider AI coding assistant.
# Install
npm install -g @mariozechner/pi-coding-agent
# Verify
pi --version
Auth & env vars:
- Set one of:
ANTHROPIC_API_KEY,OPENAI_API_KEY,GEMINI_API_KEY, or any supported provider key - Pi routes to the provider specified via
--provider(default: google) - Pass API key explicitly with
--api-keyor rely on provider-specific env vars
Hat YAML:
hats:
coder:
backend: "pi"
Pi provider selection (optional):
hats:
coder:
backend:
type: "pi"
args: ["--provider", "anthropic", "--model", "claude-sonnet-4"]
Doctor checks:
pi --versionmust succeed- Warns if no provider API key is set
Per-Hat Backend Override
Different hats can use different backends:
hats:
planner:
backend: "claude" # Use Claude for planning
triggers: ["task.start"]
instructions: "Create a plan..."
coder:
backend: "kiro" # Use Kiro for coding
triggers: ["plan.ready"]
instructions: "Implement..."
Custom Backends
For unsupported CLIs, use the custom backend:
cli:
backend: "custom"
custom_command: "my-ai-cli"
prompt_mode: "arg" # or "stdin"
Prompt modes:
| Mode | How Prompt is Passed |
|---|---|
arg | my-ai-cli -p "prompt" |
stdin | `echo "prompt" \ |
Backend Comparison
| Feature | Claude | Kiro | Gemini | Codex | Pi |
|---|---|---|---|---|---|
| Streaming | Yes | Yes | Yes | Yes | Yes |
| Tool use | Full | Full | Partial | Partial | Full |
| Context size | Large | Large | Large | Medium | Large |
| Speed | Fast | Fast | Fast | Medium | Fast |
| Cost | $$ | $ | $ | $$ | $ |
Troubleshooting
Backend Not Found
ERROR: No AI agents detected
Solution:
- Install a supported backend
- Ensure it's in your PATH
- Test directly:
claude -p "test"orpi -p "test"
Authentication Failed
ERROR: Authentication required
Solution:
# Claude
claude login
# Copilot
copilot auth login
# Gemini - set API key
# Pi - set provider API key
If the CLI is already authenticated but ralph doctor still warns, ensure the
expected env vars above are set (doctor checks are hints, not hard failures).
Wrong Backend Used
# Force specific backend
ralph run --backend claude
# Or set in config
cli:
backend: "claude"
Backend Hanging
Some backends need interactive authentication on first run:
# Run backend directly first
claude -p "test"
# Then use with Ralph
ralph run
Best Practices
- Pick one primary backend — Consistency helps
- Test backend directly — Before using with Ralph
- Use per-hat overrides sparingly — Can complicate debugging
- Keep backends updated — New features, bug fixes
Next Steps
- Configure Presets for your workflow
- Learn about Cost Management
- Explore Writing Prompts