ralph-claude-code

Autonomous Claude Code loop with exit detection and rate limiting

Overview

ralph-claude-code is an autonomous development loop tool for Claude Code, based on a technique credited to Geoffrey Huntley. It repeatedly runs Claude Code against a project so the project is improved iteratively until completion, with safeguards against endless loops and excess API usage. It is documented as install once and usable as a global command from any directory.

The product is aimed at developers who want an agent to work through a task list or specification without step-by-step prompting. It imports tasks from PRD documents, beads, and GitHub issues, supports prompt files, and includes an enablement wizard that detects project type and framework before generating configuration. A dual-condition exit gate requires both completion indicators and an explicit exit signal before the loop stops.

What distinguishes it is the surrounding control machinery: hourly call limits, a circuit breaker, response analysis with semantic understanding, session continuity with configurable expiration, dry-run simulation, live streaming, desktop notifications, git backup branches with rollback, and per-loop metrics. Development is active, and the project ships a CI pipeline and a dedicated uninstall script.

Best for

  • Software developers
  • Engineering teams using Claude Code
  • Automation and DevOps engineers
  • Maintainers working from task lists or PRDs
  • Software development
  • Developer tooling

How to use

  1. Install Ralph so the global command is available in any directory.
  2. Run the enablement wizard in an existing project or set up the project configuration and prompt file.
  3. Import tasks from a PRD, beads, or GitHub issues as needed.
  4. Validate the configuration and prompt with a dry run before spending API calls.
  5. Start the loop, optionally with the tmux monitor or live streaming output.
  6. Review status, metrics, and notifications, and inspect or restore backups if required.

What it can do

Autonomous loop with dual-condition exit

Ralph runs repeated Claude Code iterations and stops only when completion indicators and an explicit exit signal are both present. This is intended to prevent premature stops while still allowing a clear finish. A documented fix ensures a complete status with a false exit signal keeps the loop working.

Rate limiting and circuit breaker

Hourly API calls are capped, with a configurable default of 100 calls per hour and an hourly reset. A circuit breaker with error detection halts runaway loops, and its state can be inspected or reset, including an automatic reset on startup for unattended runs.

Session continuity and control

Session state is saved so context can be preserved across loops using a resume flag, with a configurable expiration defaulting to 24 hours. Sessions can be reset to start fresh, and the documented design deliberately avoids a continue-style flag to prevent session hijacking.

Task and issue import

Tasks can be brought in from PRD documents, beads, or GitHub issues. GitHub issue import supports metadata filters such as labels, title, assignee, milestone, and state, plus first, interactive, or priority selection and a dry-run preview.

Dry-run, live output, and monitoring

A dry-run mode simulates the loop scaffolding without making API calls or incrementing the call counter. Live streaming shows Claude Code output in real time, and an integrated tmux monitor places the loop and a live dashboard side by side. Verbose mode adds detailed progress updates.

Git backup and rollback

When enabled, a backup branch is created before each loop iteration, committed even with no staged changes so a restore point always exists. Rollback lists available backup branches newest first or checks out a named one. The feature does nothing outside a git repository.

Metrics, notifications, and logging

Per-loop metrics are recorded in JSON Lines and can be reviewed with an analytics command. Desktop notifications cover loop completion, errors, circuit breaker trips, API limits, and project completion, with cross-platform delivery and a terminal bell fallback. Logs rotate at a fixed size while keeping archived files.

Configuration and project enablement

Project settings live in a configuration file, and an interactive wizard enables Ralph in existing projects through detection, task source selection, configuration, file generation, and verification phases. The configuration file is parsed as data rather than executed, so shell syntax in values is rejected.

How it works

Ralph is installed once and runs as a global command. In a project, either the setup process or the enablement wizard creates the configuration and prompt files; the wizard detects project type and framework and can pull tasks from beads, GitHub issues, or a PRD. The loop then invokes Claude Code headless, applying rate limits, a timeout, error detection, and the dual-condition exit gate around each iteration. Output is parsed from JSON when available with a text fallback, and session state is persisted between iterations.

Humans still set the prompt, task source, and tool permissions, and choose whether to enable backups, notifications, live output, or monitoring. When the circuit breaker trips or an API limit is reached, a person decides whether to inspect the cause and reset, and unattended setups can opt into automatic reset on startup. The documentation notes that the tool is moving toward a provider-agnostic design, but that direction is documented as a decision and design, not as shipped behavior.

Supervised

Ralph runs multi-step loops on its own, but a human configures the prompt, task source, and permissions and approves recovery from circuit breaker trips, API limits, and rollbacks.

Where it fits

  • Let Claude Code work through a PRD or task list until the project is complete.
  • Import GitHub issues with label and milestone filters and process them in priority order.
  • Simulate a loop configuration without API calls before committing to a long run.
  • Create a git backup before each iteration and roll back to an earlier state if needed.

Good fit

  • Teams running long autonomous Claude Code development loops on an existing project
  • Projects that need rate limiting, a circuit breaker, and dry-run simulation before spending API calls
  • Workflows that import tasks from GitHub Issues, PRDs, or beads and track per-loop metrics
  • Unattended or CI-style runs that benefit from backups, rollbacks, and notifications

Not a fit

  • Users who need a provider other than Claude driving the loop today: provider-agnostic support is a ratified design direction, with Claude as the unchanged default until another provider is selected
  • Projects that rely on shell syntax in .ralphrc, since only KEY=VALUE lines are applied and shell syntax is rejected with a warning
  • Environments without tmux if they want the integrated monitor view, which requires tmux

How to evaluate

  1. Check that the API call cap matches your budget: the default is 100 calls per hour and is configurable
  2. Confirm your .ralphrc files contain only KEY=VALUE entries, because shell syntax such as variables or command substitution is rejected
  3. Decide whether you want session continuity: sessions resume via --resume, and saved sessions expire after a configurable timeout whose default is 24 hours
  4. Run with --dry-run first to validate the prompt and configuration without making API calls
  5. Verify prerequisites for the features you plan to use: git for backup branches, tmux for the monitor, and platform notification tools

Our take

Ralph wraps Claude Code in a repeating development loop with several safeguards against runaway behavior: hourly rate limiting, a circuit breaker, semantic response analysis, and a dual-condition exit gate that requires both completion indicators and an explicit exit signal. Setup is heavyweight but structured, with a setup command, an enable wizard that detects project type and imports tasks, and a dry-run mode for testing configuration before real runs. The project reports 784 tests with a full pass rate, in active development, and a pending design direction toward provider-agnostic operation that has not changed default behavior yet. It is most sensible for Claude Code users who already have a tuned prompt and want careful, observable automation rather than a quick one-off script.

Alternatives

AgentPricingAutonomyBest for
oh-my-claudecode—SupervisedSoftware developers using Claude Code, Engineering team leads, Code reviewers and security reviewers, UI and UX designers working in code, Data scientists, Technical writers and documentation specialists
happy—SupervisedSoftware developers, Engineering teams, Pair-programming collaborators, Developers who work across desk and mobile
plandex—SupervisedSoftware developers, Engineering teams on large codebases, Developers reviewing AI-generated changes, Teams exploring multiple models, Self-hosting developers
MiMo-Code—SupervisedSoftware developers, Engineers working in terminals, Developers managing Git repositories, Teams using multiple LLM providers
superplane—SupervisedSoftware engineers, Engineering managers, Platform and infrastructure engineers, DevOps and release engineers, Open source maintainers
KiroCrew—SupervisedSoftware developers, DevOps and platform engineers, Engineering teams running scheduled automation, Developers who prefer self-hosted tooling, Operators managing always-on server workloads

FAQ

How does Ralph decide when to stop looping?
It uses a dual-condition exit gate: completion indicators must appear together with an explicit EXIT_SIGNAL. A completion status with an exit signal set to false keeps the loop working.
What prevents Ralph from running away or exhausting my API quota?
A rate limit caps API calls per hour, with a default you can change, and a circuit breaker detects errors including multi-line patterns to stop stuck loops. You can inspect or reset the breaker state and configure its thresholds through environment variables.
Can I try the configuration without making API calls?
Yes. Dry-run mode runs the loop scaffolding, such as rate-limit checks and exit detection, but skips Claude invocation and does not increment the call counter.
Does Ralph keep context between iterations?
It does. Session continuity uses the --resume flag to preserve context without hijacking sessions, and saved sessions expire after a configurable timeout whose default is 24 hours. A reset command clears the saved session.
How does Ralph handle tasks from existing tools?
It can import tasks from PRD documents, beads, and GitHub Issues, including metadata filters such as labels, milestone, assignee, and state, with a dry-run preview option. The enable wizard helps import tasks when setting up an existing project.
How is pricing handled?
The sources do not describe a pricing plan for Ralph itself. Because each loop iteration invokes the Claude Code CLI, usage may incur Claude-related billing depending on your setup; check your own Claude billing terms. The available plan information is limited to the pricing fields.
What do I need installed before using it?
The monitor requires tmux, backup branches require the project to be a git repository, and notifications rely on platform tools such as osascript on macOS or notify-send on Linux with a terminal bell fallback.
Can I use a coding agent other than Claude?
Not as the default today. A recorded architecture decision adopts a provider-agnostic direction with a configuration flag, but Claude remains the reference adapter and default behavior stays unchanged until another provider is selected.

Comments

No comments yet.

Embed a listing badge

Featured on AI Agents Marketplace
<a href="https://aiagentsmarketplace.dev/agents/ralph-claude-code"><img src="https://aiagentsmarketplace.dev/badges/featured.svg" alt="Featured on AI Agents Marketplace" width="262" height="36"></a>
See badge options