npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kiblazer/ralph-run

v1.0.2

Published

Unattended iterative Claude Code execution loop

Readme

@kiblazer/ralph-run

npm version License: MIT

Unattended iterative AI agent execution loop. Run Claude Code, Codex, or OpenCode in a headless retry loop until the job succeeds.

Why

AI agents sometimes fail mid-task — network hiccups, API rate limits, transient tool errors, or the agent simply getting stuck. ralph-run automates the boring part: run the agent, detect failure, back off, and retry. It keeps logs for every attempt so you can audit what happened.

Features

  • Multi-agent support — Claude Code (default), OpenAI Codex CLI, OpenCode
  • Automatic retry with exponential backoff — configurable base / cap
  • Timeout protection — total process timeout and no-output idle timeout
  • Per-attempt log files — stdout and stderr saved for debugging
  • Session resumption — optional shared context across attempts (Claude Code)
  • Countdown timer — visual pause between rounds
  • Zero runtime dependencies except commander

Installation

Global (recommended)

npm install -g @kiblazer/ralph-run

npx (no install)

npx @kiblazer/ralph-run --prompt "write a test suite" --runs 3

Local

npm install --save-dev @kiblazer/ralph-run

Prerequisites

You must have the target agent CLI installed and available in your $PATH:

| Agent | Required CLI | |---------|--------------------------------------| | claude | claude-code | | codex | @openai/codex | | opencode| opencode |

Usage

Usage: ralph-run [options]

Options:
  -V, --version                          output the version number
  --prompt <text>                        Prompt text to send to agent
  --prompt-file <path>                   Read prompt from file (overrides --prompt)
  --agent <name>                         Agent to use: claude, codex, opencode (default: "claude")
  --runs <n>                             Number of successful runs to achieve (default: "1")
  --project-dir <path>                   Working directory (default: ".")
  --logs-dir <path>                      Logs directory (default: ./logs-ralph-<timestamp>)
  --permission-mode <mode>               Permission mode: bypassPermissions, acceptEdits, yolo (default: "bypassPermissions")
  --shared-context                       Enable session resumption across attempts
  --retry-base <seconds>                 Base seconds for exponential backoff (default: "120")
  --retry-cap <seconds>                  Max seconds for exponential backoff (default: "3600")
  --process-timeout <seconds>            Total process timeout (0=disabled) (default: "21600")
  --no-output-timeout <seconds>          No-output idle timeout (0=disabled) (default: "10800")
  --heartbeat <seconds>                  Heartbeat interval (0=disabled) (default: "30")
  --countdown <seconds>                  Countdown between rounds (default: "10")
  --max-attempts <n>                     Max attempts per round (0=unlimited) (default: "0")
  -h, --help                             display help for command

Examples

Run a single task with Claude Code

ralph-run --prompt "Refactor src/utils.ts to use async/await" --runs 1

Run 3 independent rounds with a prompt file

ralph-run --prompt-file ./prompts/refactor.md --runs 3 --agent claude

Use Codex with yolo mode

ralph-run --prompt "Add JSDoc to all exported functions" --agent codex --permission-mode yolo

Custom timeouts and retry policy

ralph-run \
  --prompt-file ./prompts/migrate.md \
  --runs 2 \
  --process-timeout 3600 \
  --no-output-timeout 1800 \
  --retry-base 60 \
  --retry-cap 600

Enable session resumption

ralph-run --prompt "Continue implementing the API" --shared-context --runs 1

Important: Shell escaping

If your prompt contains backticks (`), bash will attempt command substitution. Always use single quotes for inline prompts:

# WRONG — bash tries to execute "date" inside backticks
ralph-run --prompt "Fix the \`createdAt\` field"

# CORRECT
ralph-run --prompt 'Fix the `createdAt` field'

For long or complex prompts, prefer --prompt-file:

ralph-run --prompt-file ./my-prompt.md

How it works

  1. Countdown — waits the configured seconds before starting a round.
  2. Execute — spawns the selected agent with the prompt.
  3. Detect — classifies success (exit_code === 0) or failure.
  4. Log — writes stdout and stderr to timestamped files in the logs directory.
  5. Retry on failure — sleeps with exponential backoff, then re-runs the same round.
  6. Repeat — continues until the required number of successful runs is reached.

Logs

Each attempt produces two files:

logs-ralph-20260515T143022/
├── round-1_attempt-1_20260515T143022_stdout.log
├── round-1_attempt-1_20260515T143022_stderr.log
├── round-1_attempt-2_20260515T143100_stdout.log
└── ...

Development

git clone https://github.com/kiblazer/ralph-run.git
cd ralph-run
npm install
npm run build
node dist/index.js --help

License

MIT