Ralph is a generic, self-contained AI agent loop that autonomously works through a GitHub project's open issues — implementing features, opening PRs, reviewing code, and merging — one iteration at a time.
Each iteration Ralph:
- Syncs to
origin/$FEATURE_BRANCH(defaults toorigin/main) - Checks for open PRs to review, fix, or merge
- If none, picks the most important open issue and implements it
- Pushes a draft PR (or updates an existing one) and stops — the next iteration reviews it
- Loops the review → fix cycle until the code is approved or the escalation threshold is reached
- Merges, then moves on to the next issue
- Emits
<promise>COMPLETE</promise>when all issues are closed and all PRs are merged
Ralph auto-detects how to post reviews:
- GitHub Copilot bot — if the Copilot code-review bot is installed on the repo, Ralph delegates review to it and waits for its verdict
- HTML comments — otherwise Ralph posts its own review as an HTML comment on the PR (
<!-- RALPH-REVIEW: APPROVED -->/<!-- RALPH-REVIEW: REQUEST_CHANGES -->)
-
Install Ralph once (clone it somewhere permanent and symlink the script):
git clone https://github.com/ajrussellaudio/ralph.git ~/.ralph ~/.ralph/install.sh
This symlinks
ralphinto~/.local/bin/. Make sure that's on yourPATH:export PATH="$HOME/.local/bin:$PATH" # add to ~/.zshrc or ~/.bashrc
-
Configure each project — run the interactive scaffold from your project root:
ralph init
This prompts for each value, auto-detects your repo slug and build/test commands, and writes
ralph.toml. Or copy the template manually:cp ~/.ralph/project.example.toml ralph.tomlEither way, add
ralph.tomlto.gitignoreto keep it local:echo 'ralph.toml' >> .gitignore
-
Check your environment:
ralph doctor
Validates that
copilotandghare installed and authenticated, the repo is resolvable, andralph.tomlis configured. Fix anything flagged before starting a run. -
Start the agent loop from your project root:
ralph run # work within a feature branch (scoped to issues labelled prd/foo-widget): ralph run --label=foo-widget # target a single specific issue by number: ralph run --issue=42 # combine: implement issue #42 on the foo-widget feature branch: ralph run --issue=42 --label=foo-widget # cap the number of iterations (runs unlimited by default): ralph run --max-iterations=20 --label=foo-widget
Ralph runs indefinitely by default, stopping only when all tasks are complete. Use
--max-iterations=Nas an escape hatch if you want a hard cap. -
Update Ralph at any time:
git -C ~/.ralph pull
- GitHub Copilot CLI (
copilotin PATH) gh(GitHub CLI), authenticatedgit
| Command | Description |
|---|---|
ralph |
Alias for ralph status — show a snapshot without starting work |
ralph status [--label=<label>] |
Print open PRs (with review state and CI status) and open issues |
ralph run [flags] |
Start the agent loop (see flags below) |
ralph doctor |
Check environment health — tools, auth, config, network |
ralph init |
Interactively scaffold a ralph.toml for the current project |
| Flag | Description |
|---|---|
--label=<label> |
Scope to a feature branch (feat/<label>) and label (prd/<label>) |
--issue=<N> |
Implement only one specific issue, then exit |
--max-iterations=N |
Hard cap on iterations; omit for unlimited |
| File | Purpose |
|---|---|
ralph.sh |
The loop script — generic, no project-specific code |
install.sh |
Symlinks ralph.sh into ~/.local/bin/ for global access |
modes/ |
Per-mode agent prompts (implement.md, review.md, fix.md, merge.md, etc.) |
project.example.toml |
Annotated template — copy to ralph.toml in your project root and fill in |
docs/routing.md |
Mermaid flowcharts showing Ralph's routing logic and task lifecycle |
To override Ralph's prompts for a specific project, create a ralph/modes/ directory in your project root and add mode files there. Ralph checks for this directory first before falling back to the bundled modes in ~/.ralph/modes/.
| Label | Purpose |
|---|---|
prd |
Marks an issue as a PRD — Ralph never implements it |
prd/<slug> |
Scopes an issue to a feature; Ralph targets feat/<slug> |
high-priority |
Ralph picks these issues first |
blocked |
Ralph skips these issues |
Use /write-a-prd and /prd-to-issues Copilot skills to create PRDs and task issues with the correct labels applied automatically.
If Ralph is doing all the work on your fork (you/project) but the final feature PR should land on the upstream repo (org/project), set upstream in ralph.toml:
repo = "you/project" # your fork — Ralph owns this
upstream = "org/project" # upstream — final PR lands hereWhen upstream is set:
- All issues and intermediate PRs continue to use
repo(your fork). - The final
feature-prmode opens the PR againstupstreamwith the correct cross-fork head (you:feat/<label>). - Issue-close links in the PR body use the cross-repo syntax (
Closes you/project#<n>) so they auto-close on merge.
When upstream is not set, behaviour is identical to today.
Ralph stops automatically when:
- All open issues are closed and all ralph PRs are merged (emits
COMPLETE) - The maximum iteration count is reached (if
--max-iterations=Nwas given) - A single
--issue=Ncompletes (Ralph exits after that issue is done)
You can also press Ctrl-C at any time — the worktree is cleaned up automatically.