Harness toolkit for autonomous AI coding loops
Project description
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 RALPH.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 + RALPH.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"]
ralph = "RALPH.md"
RALPH.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 RALPH.md needed
What it looks like
$ ralph run -n 3 --log-dir ralph_logs
── Iteration 1 ──
✓ Iteration 1 completed (52.3s) → ralph_logs/001_20250115-142301.log
Checks: 2 passed
✓ lint
✓ tests
── Iteration 2 ──
✗ Iteration 2 failed with exit code 1 (23.1s)
Checks: 1 passed, 1 failed
✓ lint
✗ tests (exit 1)
── Iteration 3 ──
✓ Iteration 3 completed (41.7s) → ralph_logs/003_20250115-143012.log
Checks: 2 passed
✓ lint
✓ tests
Done: 3 iteration(s) — 2 succeeded, 1 failed
Iteration 2 broke a test. Iteration 3 automatically received the failure output and fixed it — that's the self-healing loop in action.
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 --hardand 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 four primitives that live in the .ralphify/ 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 .ralphify/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 .ralphify/contexts/git-log/CONTEXT.md:
---
command: git log --oneline -10
---
## Recent commits
The command runs before each iteration. Use {{ contexts.git-log }} in your RALPH.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 RALPH.md to inject all enabled instructions.
Ralphs — named task switcher
Keep multiple ralphs for different jobs and switch between them at run time:
ralph new ralph docs
ralph new ralph refactor
Edit .ralphify/ralphs/docs/RALPH.md with your documentation-focused prompt, then:
ralph run docs # Use the "docs" ralph
ralph run refactor -n 5 # Use "refactor" for 5 iterations
Customizing your ralph
The generated RALPH.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 ralph 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
- Python 3.11+
- Claude Code CLI (or any agent CLI that accepts piped input)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ralphify-0.1.8.tar.gz.
File metadata
- Download URL: ralphify-0.1.8.tar.gz
- Upload date:
- Size: 211.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69e94c1956446ec570650904e0b0f55fee6f939931ee09c750597a592dc8ff4d
|
|
| MD5 |
af2b94ec5b1bec656a78bc302f690c62
|
|
| BLAKE2b-256 |
90c55b5586f492fa9d8350a6209c6303f05e5f7f5ee6d306d6d67feeacedf690
|
Provenance
The following attestation bundles were made for ralphify-0.1.8.tar.gz:
Publisher:
publish.yml on computerlovetech/ralphify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ralphify-0.1.8.tar.gz -
Subject digest:
69e94c1956446ec570650904e0b0f55fee6f939931ee09c750597a592dc8ff4d - Sigstore transparency entry: 1112136044
- Sigstore integration time:
-
Permalink:
computerlovetech/ralphify@ea90c5cb03a91bd711ad12aeaa771c57947145c5 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/computerlovetech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ea90c5cb03a91bd711ad12aeaa771c57947145c5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ralphify-0.1.8-py3-none-any.whl.
File metadata
- Download URL: ralphify-0.1.8-py3-none-any.whl
- Upload date:
- Size: 43.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfaa7f472893667cc1dd6130d395dd302969675c33ba0fc4aab3755024933567
|
|
| MD5 |
fe03771e7ce0be585d239cedfd3baa79
|
|
| BLAKE2b-256 |
ba1d4a284ef842f6344569fe05ff903485d34eeb87e11860f6de3e757deb59b7
|
Provenance
The following attestation bundles were made for ralphify-0.1.8-py3-none-any.whl:
Publisher:
publish.yml on computerlovetech/ralphify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ralphify-0.1.8-py3-none-any.whl -
Subject digest:
bfaa7f472893667cc1dd6130d395dd302969675c33ba0fc4aab3755024933567 - Sigstore transparency entry: 1112136050
- Sigstore integration time:
-
Permalink:
computerlovetech/ralphify@ea90c5cb03a91bd711ad12aeaa771c57947145c5 -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/computerlovetech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ea90c5cb03a91bd711ad12aeaa771c57947145c5 -
Trigger Event:
release
-
Statement type: