Skip to content

Commit a0b8a79

Browse files
Kasper Jungeclaude
authored andcommitted
docs: add "When to use" guide so users can evaluate whether ralph loops fit their task
Users landing on the docs could see how ralphify works but had no guidance on whether it was the right tool for their specific use case. The new page covers what works well, what doesn't, loop vs. single conversation trade-offs, and how to adapt borderline tasks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3a53a11 commit a0b8a79

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

docs/when-to-use.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
description: When ralph loops are the right tool — what kinds of tasks work well, what doesn't, and how to tell if your task fits the pattern.
3+
---
4+
5+
# When to use ralph loops
6+
7+
Ralph loops are powerful but they're not the right tool for everything. This page helps you decide whether a loop fits your task before you invest time setting one up.
8+
9+
## The sweet spot
10+
11+
Ralph loops work best when a task has these properties:
12+
13+
**Decomposable into small, independent steps.** The loop does one thing per iteration. Tasks that naturally break into "do this, then this, then this" are ideal — implementing features from a TODO list, writing tests module by module, fixing lint errors one at a time.
14+
15+
**Has a clear definition of "done" for each step.** Checks need something to validate. If you can express "this iteration succeeded" as a command that exits 0 or non-zero (tests pass, build succeeds, lint is clean), the self-healing loop works. If success requires human judgment ("does this look good?"), a loop can't self-correct.
16+
17+
**Benefits from fresh context.** Long conversations degrade — the agent loses track of earlier instructions, fills up the context window, and starts making mistakes. If your task will take more than 15-20 minutes of agent work, a loop outperforms a single conversation because each iteration starts clean with the current state of the codebase.
18+
19+
**Progress is visible in the codebase.** The agent's work must be observable on disk — files changed, tests added, docs written, commits made. The next iteration reads the codebase to understand what's been done. Tasks that produce output elsewhere (a Slack message, a deployment, an email) need a wrapper that records progress locally.
20+
21+
## What works well
22+
23+
| Task | Why it fits |
24+
|---|---|
25+
| **Implementing features from a spec** | Each feature is one iteration; tests validate correctness |
26+
| **Writing tests** | Each module is one iteration; coverage reports guide prioritization |
27+
| **Fixing lint / type errors** | Each fix is small and independently verifiable |
28+
| **Documentation improvements** | Each page is one iteration; `mkdocs build --strict` validates |
29+
| **Codebase migrations** (JS→TS, Python 2→3) | Each file is one iteration; the compiler validates |
30+
| **Bug triage** | Each bug is one iteration; regression tests verify the fix |
31+
| **Refactoring** | Each extraction/rename is one iteration; tests catch regressions |
32+
33+
## What doesn't work well
34+
35+
| Task | Why it doesn't fit |
36+
|---|---|
37+
| **Design decisions** | Requires human judgment about trade-offs — no check can validate "is this the right architecture?" |
38+
| **Tasks requiring multi-step reasoning across iterations** | Each iteration starts fresh — the agent can't "continue where it left off" from memory, only from what's on disk |
39+
| **One-shot tasks** | If the task takes 5 minutes and you won't repeat it, just chat with the agent — the loop setup overhead isn't worth it |
40+
| **Tasks with no automated validation** | Without checks, there's no self-healing — the agent may compound errors across iterations |
41+
| **Creative writing** | Prose quality is subjective; no check can validate "is this well-written?" |
42+
| **Interacting with external services** | API calls, deployments, and messages are hard to undo if the agent makes a mistake |
43+
44+
## Loop vs. single conversation
45+
46+
Use a **single conversation** when:
47+
48+
- The task will take less than 10-15 minutes
49+
- You want to iterate interactively with the agent
50+
- The task requires back-and-forth discussion
51+
- You need to make subjective decisions along the way
52+
53+
Use a **ralph loop** when:
54+
55+
- The task involves many similar, independent steps
56+
- You want the agent to work autonomously without your attention
57+
- You have tests or checks that can validate correctness
58+
- The task would fill up a conversation's context window
59+
- You want to walk away and come back to completed work
60+
61+
## Making a borderline task work
62+
63+
Some tasks seem like they don't fit but can be adapted:
64+
65+
**"There's no automated check for this."** Write one. Even a simple script that checks for obvious problems (file exists, no syntax errors, word count above threshold) catches the worst failures. You can always add a more thorough check later.
66+
67+
**"The task requires multi-step reasoning."** Use a `PLAN.md` or `TODO.md` file as the coordination mechanism. The agent reads the plan each iteration, marks steps done, and the next iteration continues from there. The plan file IS the agent's memory.
68+
69+
**"Each iteration depends on the previous one."** That's fine — the agent reads the codebase, which includes all previous iterations' commits. As long as progress is visible on disk, the fresh context model works. The agent doesn't need conversation memory when the code tells the story.
70+
71+
**"I need to review the agent's work before it continues."** Use `-n 1` to run single iterations, review, then run again. Or use `--stop-on-error` with a check that requires your sign-off (a file you manually create or delete between iterations).
72+
73+
## How many iterations?
74+
75+
- **Start with `-n 3`** to verify your setup works and the agent produces useful output
76+
- **Use `-n 10-20`** for bounded tasks (a TODO list with known items)
77+
- **Run unlimited** (`ralph run` without `-n`) for open-ended improvement tasks with good checks — the checks prevent the agent from going off the rails
78+
- **Use `--stop-on-error`** when each iteration must succeed before the next one makes sense
79+
80+
## Next steps
81+
82+
- [Getting Started](getting-started.md) — set up your first loop
83+
- [Writing Prompts](writing-prompts.md) — patterns for effective autonomous loop prompts
84+
- [Cookbook](cookbook.md) — copy-pasteable setups for common workflows

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ extra:
8888
nav:
8989
- Home: index.md
9090
- Guide:
91+
- When to Use: when-to-use.md
9192
- Getting Started: getting-started.md
9293
- How it Works: how-it-works.md
9394
- Writing Prompts: writing-prompts.md

0 commit comments

Comments
 (0)