Ralph loop setup
Resolve configuration and seed the loop files. Never start the loop. Setup
ends with a summary and an instruction to run /ralph-loop start.
Writing is done by scripts/seed-ralph-loop.sh, not by hand. Your job is to
resolve values and call it. Hand-authoring the loop file reintroduces the
unsubstituted-placeholder failure the script exists to prevent: a stray
{{MAX_ITERATIONS}} in the frontmatter fails the hook's numeric validation and
silently deletes the loop.
Interview
Ask only what you cannot resolve yourself. Use structured questions, not prose.
Preset. If not given:
engineering-delivery — drive a work item (typically an epic, but a
large story works the same way) through implement, review, validate,
and merge request, one task per iteration.
ad-hoc — repeat a single prompt until it is done.
custom — define your own steps.
Target. The work item ID for engineering delivery; the task prompt
for ad-hoc; the step list for custom.
Budgets. Max iterations. Default 50, but for engineering delivery
propose tasks × 6 + 10, since a 12-task work item will not fit in 50.
Completion promise. Propose a default and confirm it. For a work item,
its canonical ID (or slug, in the filesystem-only fallback) upper-snake-cased
with _COMPLETE.
Environment. Only for presets that need it, per
references/environment-resolution.md.
Workflow
1. Resolve the agent
CLAUDE_PLUGIN_ROOT set means claude; CURSOR_PROJECT_DIR set means
cursor. This determines the base directory (.claude/loop or
.cursor/loop). There is no pointer file and no --ralph-dir flag.
2. Resolve the preset inputs
engineering-delivery
- Resolve
{work-id} per
work-item-resolution.md:
detect the source system (Linear, Jira, GitHub/GitLab, or filesystem) and
the canonical ID first — ask the user on any ambiguity, per that file's
ask-first checklist. Never guess.
- Locate
tasks.md and tdd.md under docs/work/{work-id}/, accepting a
legacy design.md in place of tdd.md. Fail loudly, naming the missing
file, if either is absent.
- Derive a dependency-safe task order: topological by declared dependencies,
stable by document order on ties. Render as
N. {TASK_ID} — <title> (depends on: <ids or ->).
- Resolve the branch. Report the expected branch; never create or switch one.
- Resolve validation commands, tracker actions, and UI signals per
references/environment-resolution.md.
ad-hoc
Write the task prompt to a file and pass --prompt-file. Apply
../ralph-loop/references/prompt-authoring.md:
explicit completion criteria, a verification step each iteration, and an
escape hatch for being stuck.
custom
Write the step definitions to a file and pass --steps-file. Each step needs a
name, what to do, and which step comes next. See
../ralph-loop/references/preset-authoring.md.
3. Seed
Call the script. Every template value goes through --set:
scripts/seed-ralph-loop.sh \
--agent claude \
--preset engineering-delivery \
--run-id "{work-id}-$(date -u +%Y%m%d-%H%M%S)" \
--max-iterations 70 \
--completion-promise CHECKOUT_FOUNDATION_COMPLETE \
--session-id "$SESSION_ID" \
--set WORK_ID=checkout-foundation \
--set BRANCH=feat/checkout-foundation \
--set TASKS_PATH=docs/work/checkout-foundation/tasks.md \
--set TDD_PATH=docs/work/checkout-foundation/tdd.md \
--set FIRST_ITEM=CHK01-01 \
--set "WORK_SEQUENCE=$(cat sequence.txt)" \
--set "GOAL=..." --set "DONE_CRITERIA=..." --set "PRESET_CONTEXT=..."
(WORK_ID is the canonical ID — a tracker key like JIRA-123 when one
resolved, otherwise the slug shown above.)
Run with --dry-run first when anything is uncertain. The script refuses to
overwrite a loop past iteration 1 without --force, and exits non-zero on any
unresolved placeholder.
4. Report
Files written, resolved configuration, expected branch, and "Run
/ralph-loop start to begin." Nothing else.
Policies
- MUST NOT execute loop steps or launch sub-agents. Setup only writes files.
- MUST NOT create or switch git branches.
- MUST NOT hand-author
active.md, loop-state.md, or context.md.
- MUST fail loudly, naming the file, when a required source is missing.
- MUST NOT invent a task order that ignores declared dependencies.
Anti-patterns
- Writing the loop file directly instead of calling the seed script.
- Starting the loop after seeding it.
- Guessing at validation commands rather than resolving them from the repo.
- Setting a completion promise the loop has no way to verify.
1---2name: ralph-loop-setup3description: Use to seed or configure a Ralph loop before running it: choose a preset (engineering delivery for a work item, ad-hoc for a single repeating prompt, or custom steps), resolve the environment, set the completion promise and iteration budget, and write the loop files. Triggers on "set up a ralph loop", "configure a ralph loop", "ralph-loop-setup", or naming a work item to loop over. Do NOT use to start, inspect, or stop a loop (ralph-loop) — setup never executes loop steps.4license: MIT5---67# Ralph loop setup89Resolve configuration and seed the loop files. **Never start the loop.** Setup10ends with a summary and an instruction to run `/ralph-loop start`.1112Writing is done by `scripts/seed-ralph-loop.sh`, not by hand. Your job is to13resolve values and call it. Hand-authoring the loop file reintroduces the14unsubstituted-placeholder failure the script exists to prevent: a stray15`{{MAX_ITERATIONS}}` in the frontmatter fails the hook's numeric validation and16silently deletes the loop.1718## Interview1920Ask only what you cannot resolve yourself. Use structured questions, not prose.21221. **Preset.** If not given:23 - `engineering-delivery` — drive a work item (typically an epic, but a24 large story works the same way) through implement, review, validate,25 and merge request, one task per iteration.26 - `ad-hoc` — repeat a single prompt until it is done.27 - `custom` — define your own steps.28292. **Target.** The work item ID for engineering delivery; the task prompt30 for ad-hoc; the step list for custom.31323. **Budgets.** Max iterations. Default 50, but for engineering delivery33 propose `tasks × 6 + 10`, since a 12-task work item will not fit in 50.34354. **Completion promise.** Propose a default and confirm it. For a work item,36 its canonical ID (or slug, in the filesystem-only fallback) upper-snake-cased37 with `_COMPLETE`.38395. **Environment.** Only for presets that need it, per40 [references/environment-resolution.md](references/environment-resolution.md).4142## Workflow4344### 1. Resolve the agent4546`CLAUDE_PLUGIN_ROOT` set means `claude`; `CURSOR_PROJECT_DIR` set means47`cursor`. This determines the base directory (`.claude/loop` or48`.cursor/loop`). There is no pointer file and no `--ralph-dir` flag.4950### 2. Resolve the preset inputs5152**engineering-delivery**5354- Resolve `{work-id}` per55 [work-item-resolution.md](../tasks/references/work-item-resolution.md):56 detect the source system (Linear, Jira, GitHub/GitLab, or filesystem) and57 the canonical ID first — ask the user on any ambiguity, per that file's58 ask-first checklist. Never guess.59- Locate `tasks.md` and `tdd.md` under `docs/work/{work-id}/`, accepting a60 legacy `design.md` in place of `tdd.md`. Fail loudly, naming the missing61 file, if either is absent.62- Derive a dependency-safe task order: topological by declared dependencies,63 stable by document order on ties. Render as64 `N. {TASK_ID} — <title> (depends on: <ids or ->)`.65- Resolve the branch. Report the expected branch; never create or switch one.66- Resolve validation commands, tracker actions, and UI signals per67 [references/environment-resolution.md](references/environment-resolution.md).6869**ad-hoc**7071Write the task prompt to a file and pass `--prompt-file`. Apply72[../ralph-loop/references/prompt-authoring.md](../ralph-loop/references/prompt-authoring.md):73explicit completion criteria, a verification step each iteration, and an74escape hatch for being stuck.7576**custom**7778Write the step definitions to a file and pass `--steps-file`. Each step needs a79name, what to do, and which step comes next. See80[../ralph-loop/references/preset-authoring.md](../ralph-loop/references/preset-authoring.md).8182### 3. Seed8384Call the script. Every template value goes through `--set`:8586```bash87scripts/seed-ralph-loop.sh \88 --agent claude \89 --preset engineering-delivery \90 --run-id "{work-id}-$(date -u +%Y%m%d-%H%M%S)" \91 --max-iterations 70 \92 --completion-promise CHECKOUT_FOUNDATION_COMPLETE \93 --session-id "$SESSION_ID" \94 --set WORK_ID=checkout-foundation \95 --set BRANCH=feat/checkout-foundation \96 --set TASKS_PATH=docs/work/checkout-foundation/tasks.md \97 --set TDD_PATH=docs/work/checkout-foundation/tdd.md \98 --set FIRST_ITEM=CHK01-01 \99 --set "WORK_SEQUENCE=$(cat sequence.txt)" \100 --set "GOAL=..." --set "DONE_CRITERIA=..." --set "PRESET_CONTEXT=..."101```102103(`WORK_ID` is the canonical ID — a tracker key like `JIRA-123` when one104resolved, otherwise the slug shown above.)105106Run with `--dry-run` first when anything is uncertain. The script refuses to107overwrite a loop past iteration 1 without `--force`, and exits non-zero on any108unresolved placeholder.109110### 4. Report111112Files written, resolved configuration, expected branch, and "Run113`/ralph-loop start` to begin." Nothing else.114115## Policies116117- MUST NOT execute loop steps or launch sub-agents. Setup only writes files.118- MUST NOT create or switch git branches.119- MUST NOT hand-author `active.md`, `loop-state.md`, or `context.md`.120- MUST fail loudly, naming the file, when a required source is missing.121- MUST NOT invent a task order that ignores declared dependencies.122123## Anti-patterns124125- Writing the loop file directly instead of calling the seed script.126- Starting the loop after seeding it.127- Guessing at validation commands rather than resolving them from the repo.128- Setting a completion promise the loop has no way to verify.