|
| 1 | +# Ralphify |
| 2 | + |
| 3 | +> A minimal CLI harness for autonomous AI coding loops. Run commands, assemble a prompt, pipe it to an agent, and repeat with fresh context each iteration. |
| 4 | + |
| 5 | +Ralphify puts your AI coding agent in a `while True` loop. Each iteration: run commands (tests, lint, git log), inject their output into a prompt via placeholders, pipe the prompt to an agent, and repeat. The agent starts fresh every cycle — no context decay, no conversation bloat. |
| 6 | + |
| 7 | +## Quick install |
| 8 | + |
| 9 | +```bash |
| 10 | +uv tool install ralphify |
| 11 | +``` |
| 12 | + |
| 13 | +Requires Python 3.11+ and an AI agent CLI (Claude Code recommended). |
| 14 | + |
| 15 | +## Core concept |
| 16 | + |
| 17 | +A **ralph** is a directory containing a `RALPH.md` file. That file has YAML frontmatter (agent command, commands, args) and a prompt body with `{{ placeholders }}`. |
| 18 | + |
| 19 | +```markdown |
| 20 | +--- |
| 21 | +agent: claude -p --dangerously-skip-permissions |
| 22 | +commands: |
| 23 | + - name: tests |
| 24 | + run: uv run pytest -x |
| 25 | +--- |
| 26 | + |
| 27 | +{{ commands.tests }} |
| 28 | + |
| 29 | +You are an autonomous coding agent running in a loop. |
| 30 | +Fix failing tests before starting new work. |
| 31 | +Read TODO.md and implement the next task. |
| 32 | +``` |
| 33 | + |
| 34 | +Run it: |
| 35 | + |
| 36 | +```bash |
| 37 | +ralph run my-ralph # Loop forever (Ctrl+C to stop) |
| 38 | +ralph run my-ralph -n 5 # Run 5 iterations |
| 39 | +``` |
| 40 | + |
| 41 | +## Key features |
| 42 | + |
| 43 | +- **Self-healing feedback loop**: Command output (test failures, lint errors) feeds into each iteration — the agent sees and fixes its own mistakes. |
| 44 | +- **Live steering**: Edit `RALPH.md` while the loop runs. Changes take effect on the next iteration. |
| 45 | +- **Fresh context every cycle**: No conversation bloat or hallucinated memories. The agent reads current codebase state each time. |
| 46 | +- **Progress in git**: Every iteration commits to git. Roll back with `git reset` if needed. |
| 47 | +- **Any agent**: Works with Claude Code, Aider, Codex CLI, or any CLI that reads stdin. |
| 48 | +- **Shareable ralphs**: Install pre-built ralphs from GitHub with `ralph add owner/repo`. |
| 49 | + |
| 50 | +## Placeholder types |
| 51 | + |
| 52 | +- `{{ commands.<name> }}` — replaced with command output (stdout + stderr) |
| 53 | +- `{{ args.<name> }}` — replaced with user argument values from CLI flags |
| 54 | +- `{{ ralph.name }}` — ralph directory name |
| 55 | +- `{{ ralph.iteration }}` — current iteration number (1-based) |
| 56 | +- `{{ ralph.max_iterations }}` — total iterations if `-n` was set |
| 57 | + |
| 58 | +## CLI commands |
| 59 | + |
| 60 | +- `ralph run <path> [-n N] [--log-dir DIR] [--stop-on-error] [--timeout SEC] [--delay SEC]` — run the loop |
| 61 | +- `ralph init <name>` — scaffold a ralph from template |
| 62 | +- `ralph new [name]` — AI-guided ralph creation |
| 63 | +- `ralph add <source>` — install ralph(s) from GitHub |
| 64 | + |
| 65 | +## Python API |
| 66 | + |
| 67 | +```python |
| 68 | +from ralphify import run_loop, RunConfig, RunState |
| 69 | +``` |
| 70 | + |
| 71 | +Embed the loop in automation pipelines. See the API docs for details. |
| 72 | + |
| 73 | +## Documentation |
| 74 | + |
| 75 | +- [Getting Started](https://ralphify.co/docs/getting-started/): Install to running loop in 10 minutes |
| 76 | +- [When to Use](https://ralphify.co/docs/when-to-use/): Task suitability guide |
| 77 | +- [How it Works](https://ralphify.co/docs/how-it-works/): Iteration lifecycle details |
| 78 | +- [Writing Prompts](https://ralphify.co/docs/writing-prompts/): Patterns for effective loop prompts |
| 79 | +- [Using with Different Agents](https://ralphify.co/docs/agents/): Claude Code, Aider, Codex CLI setup |
| 80 | +- [Cookbook](https://ralphify.co/docs/cookbook/): Copy-pasteable recipes for coding, docs, research |
| 81 | +- [CLI Reference](https://ralphify.co/docs/cli/): All commands and options |
| 82 | +- [Python API](https://ralphify.co/docs/api/): Programmatic usage |
| 83 | +- [Quick Reference](https://ralphify.co/docs/quick-reference/): Cheat sheet |
| 84 | +- [Troubleshooting](https://ralphify.co/docs/troubleshooting/): Common issues and fixes |
| 85 | + |
| 86 | +## Source |
| 87 | + |
| 88 | +- PyPI: https://pypi.org/project/ralphify/ |
| 89 | +- GitHub: https://github.com/computerlovetech/ralphify |
0 commit comments