Skip to main content

Harness toolkit for autonomous AI coding loops

Project description

ralphify

PyPI version Python versions License Documentation

Put your AI coding agent in a while True loop and let it ship.

Ralphify is a minimal harness for running autonomous AI coding loops, inspired by the Ralph Wiggum technique. The idea is simple: pipe a prompt to an AI coding agent, let it do one thing, commit, and repeat. Forever. Until you hit Ctrl+C.

while :; do cat PROMPT.md | claude -p ; done

Ralphify wraps this pattern into a proper tool with config, iteration tracking, and clean shutdown.

Install

uv tool install ralphify    # recommended

Or if you don't have uv:

pipx install ralphify       # isolated install via pipx
pip install ralphify         # plain pip (use a virtualenv or --user)

Any of these gives you the ralph command.

Quickstart

# In your project directory
ralph init      # Creates ralph.toml + PROMPT.md
ralph run       # Starts the loop (Ctrl+C to stop)

That's it. Two commands.

Or skip setup entirely with an ad-hoc prompt:

ralph run -n 1 -p "Add type hints to all public functions in src/"

What ralph init creates

ralph.toml — tells ralphify what command to run:

[agent]
command = "claude"
args = ["-p", "--dangerously-skip-permissions"]
prompt = "PROMPT.md"

PROMPT.md — a starter prompt template. This file IS the prompt. It gets piped directly to your agent each iteration. Edit it to fit your project.

What ralph run does

Reads the prompt, pipes it to the agent, waits for it to finish, then does it again. Each iteration gets a fresh context window. Progress lives in the code and in git.

ralph run          # Run forever
ralph run -n 10    # Run 10 iterations then stop
ralph run -p "Fix the login bug"   # Ad-hoc prompt, no PROMPT.md needed

The technique

The Ralph Wiggum technique works because:

  • One thing per loop. The agent picks the most important task, implements it, tests it, and commits. Then the next iteration starts fresh.
  • Fresh context every time. No context window bloat. Each loop starts clean and reads the current state of the codebase.
  • Progress lives in git. Code, commits, and a plan file are the only state that persists between iterations. If something goes wrong, git reset --hard and run more loops.
  • The prompt is a tuning knob. When the agent does something dumb, you add a sign. Like telling Ralph not to jump off the slide — you add "SLIDE DOWN, DON'T JUMP" to the prompt.

Read the full writeup: Ralph Wiggum as a "software engineer"

Beyond the basic loop

The simple loop works, but ralphify's real power comes from three primitives that live in the .ralph/ directory.

Checks — the self-healing loop

Checks validate the agent's work after each iteration. When one fails, its output automatically feeds into the next iteration so the agent can fix its own mistakes.

ralph new check tests

Edit .ralph/checks/tests/CHECK.md:

---
command: uv run pytest -x
timeout: 120
---
Fix all failing tests. Do not skip or delete tests.

Now the loop self-corrects:

Iteration 1 → Agent adds feature → tests pass ✓ → moves on
Iteration 2 → Agent adds feature → tests fail ✗
Iteration 3 → Agent sees failure output → fixes tests → pass ✓

You define what "valid" means. Ralphify feeds failures back automatically.

Contexts — dynamic data injection

Contexts inject fresh data into the prompt each iteration — git history, test status, anything a shell command can produce.

ralph new context git-log

Edit .ralph/contexts/git-log/CONTEXT.md:

---
command: git log --oneline -10
---
## Recent commits

The command runs before each iteration. Use {{ contexts.git-log }} in your PROMPT.md to control where the output appears.

Instructions — reusable rules

Instructions are static text blocks (coding standards, commit conventions) you can toggle on and off without editing the prompt.

ralph new instruction code-style

Drop {{ instructions }} into PROMPT.md to inject all enabled instructions.

Customizing your prompt

The generated PROMPT.md is a starting point. A good prompt for autonomous loops typically includes:

  • What to work on (specs, plan file, TODO list)
  • Constraints — what NOT to do (no placeholders, no skipping tests)
  • Process — how to validate and commit

The agent reads this prompt fresh every iteration, so you can edit it while the loop is running. When the agent does something dumb, add a sign to the prompt — the next iteration follows the new rules.

Documentation

Full documentation at computerlovetech.github.io/ralphify — tutorials, cookbook, prompt writing guide, and troubleshooting.

Requirements

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ralphify-0.1.5.tar.gz (267.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ralphify-0.1.5-py3-none-any.whl (49.0 kB view details)

Uploaded Python 3

File details

Details for the file ralphify-0.1.5.tar.gz.

File metadata

  • Download URL: ralphify-0.1.5.tar.gz
  • Upload date:
  • Size: 267.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ralphify-0.1.5.tar.gz
Algorithm Hash digest
SHA256 d79ecb23a862b319b1a5a1134edecc514f01d8dd82abe7a2a245320b4bc3c93c
MD5 4e68fd826ff2bf47de8eae6bec965475
BLAKE2b-256 c110754a0a69a957b54561613fddd7b1d830a7d1b36f6134edcfa6bca87c2065

See more details on using hashes here.

File details

Details for the file ralphify-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: ralphify-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 49.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for ralphify-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 80433d1d765eecfa4e879b44b70a75642bc941c76ec1b3c39e6200f22286db7e
MD5 4b7036985cc41bc05e615fa38ab29066
BLAKE2b-256 48f4e3c7d61488b8a5a5df5f9e83c4a08cc15b387c0172db98ac9683654b968b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page