Execute a plan file's checklist(s) to completion. This skill is deliberately pipeline-agnostic —
it works identically no matter which skill produced the plan (feature-analyst or anything else
that writes the same checklist shape), and it never publishes anything or notifies anyone itself.
It reports done or blocked back to whoever invoked it; the caller decides what happens next.
It can also be invoked standalone — /ralph-implement <path-to-plan-file> — to resume any
in_progress or blocked plan from a cold session. All progress lives in the plan file itself,
not in conversation memory, so a fresh invocation with zero prior context can pick up exactly
where a previous one left off.
Step 0 — Resolve the target plan file
- If
$ARGUMENTS is a path, use it.
- If empty: list
plans/*.md (excluding plans/implemented/). If exactly one file exists, use
it. If more than one, AskUserQuestion which one. If none, report there's nothing to implement
and stop.
Step 1 — Parse frontmatter, guard on status
Read the file. Extract the YAML frontmatter (kind, status, iteration, max_iterations,
suggested_model, suggested_effort, confirmed_model, confirmed_effort).
- No frontmatter at all (a legacy/hand-authored plan): this is still supported. Synthesize it
now and write it in: count existing checklist items to compute
max_iterations = clamp(total_items * 2, 8, 30), set iteration: 0,
suggested_model/suggested_effort unset (null — skip the reconciliation question in Step 2
entirely when there's nothing to suggest), and treat status as approved (a plan file that
exists under plans/ without frontmatter was clearly already approved by whatever process
created it).
status: draft — stop. Tell the user this plan hasn't been approved yet; send them back to
whichever skill authored it.
status: done — report it's already done, stop. Idempotent no-op.
approved, in_progress, or blocked — proceed to Step 2.
Step 2 — Model/effort reconciliation (once per plan, only)
Only runs the first time a plan transitions approved → in_progress (i.e. skip this entirely on
every resume — confirmed_model/confirmed_effort being already set is exactly the signal that
this already happened, don't re-ask).
- If
suggested_model/suggested_effort are null (legacy plan, nothing suggested): set
confirmed_model to whatever model this session is currently running as, confirmed_effort to
medium, persist, move on — no question needed, there's nothing to reconcile against.
- Otherwise compare:
suggested_model vs. the model this current session is actually running as.
suggested_effort vs. any effort level the user explicitly specified when invoking this
skill or the plan's originating command (if none was specified, there's nothing to compare —
treat effort as matching).
- If both match: set
confirmed_model/confirmed_effort to the suggested values, persist,
proceed silently. Do not ask anything.
- If either differs: ask once, via
AskUserQuestion:
- Question:
"This plan suggests {suggested_model}/{suggested_effort} for implementation ({one-line reason from the plan's Context section}). Use suggested, keep current session settings, or choose different ones?"
- Options:
"Use suggested", "Use current session settings", "Choose other" (if chosen,
follow up with which model and which effort).
- Persist the resolved values into
confirmed_model/confirmed_effort immediately. This is
permanent for the life of this plan — every later retry and resume reads these fields and
never asks again.
Step 3 — Enter/resume
status: approved → flip to in_progress, bump iteration from 0 to 1, persist. This marks
"an attempt is underway," it is not itself a retry.
status: in_progress or blocked already → this is a resume. Do not bump iteration here;
bumps only happen per validation-retry attempt (Step 5).
Step 4 — Implementation / Fix-plan fast pass
Only runs if the plan's ## Implementation (feature) or ## Fix plan (bugfix) section has any
remaining - [ ] boxes.
Spawn one ralph-implementer subagent (Agent(subagent_type: "ralph-implementer", model: confirmed_model)) covering the entire remaining section in a single pass — not one subagent
per checklist item. Tell it: the plan file path, that this is an "implementation pass," and the
confirmed_effort level. It writes through checkbox updates to the plan file directly as it
completes each item; you don't need to re-apply anything from its report.
When it returns, re-read the plan file's checkbox state (don't trust the subagent's prose summary
as ground truth — the file is ground truth). If items remain unchecked and the subagent reported
a genuine blocker (not just "ran out of budget"), treat this the same as a validation failure
would be treated in Step 5: surface it to the user directly rather than silently retrying
indefinitely.
Once every Implementation/Fix-plan box is checked, fall straight into Step 5 in the same turn —
no need to wait for a new invocation.
Step 5 — Validation / Tests pass with bounded self-correction
For each unchecked item under ## Validation (feature) or ## Tests (bugfix), in order:
- If it names a literal command: spawn a
ralph-implementer subagent for a "validation
retry" pass, telling it the plan file path, the exact command, and confirmed_effort.
- It reports pass → the box is already checked (the subagent writes through) → continue to the
next item.
- It reports fail → before it retries again, you bump
iteration in the plan frontmatter
and persist it immediately (this write must land before the retry, so a crash mid-retry
resumes with the correct count) → check iteration >= max_iterations:
- If not yet at the cap: spawn another
ralph-implementer "validation retry" pass for the
same command (it already has the failure context from its own last attempt if this is
the same subagent conversation; if this is a fresh subagent call, give it the previous
failure output so it isn't starting blind). Repeat until pass or cap reached.
- If at the cap: go to Step 7 (Blocked). Do not mark the box done. Do not continue to later
items. Do not fabricate success.
- If it's a manual/human-only item (no literal runnable command — e.g. "manual smoke test by
user"): leave it unchecked. Do not silently check it, and do not block completion on it either
— note it in the final report as "left for user to verify."
Step 6 — Completion gate
Once every mechanical box across both sections is checked (manual items aside):
- Re-run every command listed in
## Definition of Done together, right now, even if some
were already exercised individually earlier — this is the final no-drift check, catching
anything that regressed between when an individual box was checked and now.
- All must exit 0 / pass. If one fails here, treat it exactly like a Step 5 validation failure:
diagnose, fix, retry, bounded by the same
max_iterations, escalate to Step 7 if exhausted.
- If the plan has no
## Definition of Done section at all (legacy plan): skip this extra gate,
note in your report that it was missing, and treat "all mechanical boxes checked" as sufficient
for completion.
- On success: set
status: done, persist. Stop here. Report completion back to whoever
invoked this skill (or directly to the user, if invoked standalone), including: what was
implemented, what validation passed, and any manual/human-only items still left for the user.
Do not move the file, do not publish or notify anyone, do not attempt any epilogue
— those are pipeline-specific and owned entirely by the caller.
Step 7 — Blocked
iteration >= max_iterations reached with mechanical items still unchecked:
Set status: blocked, persist.
Replace any existing ## Blocked section (don't let it grow across repeated block/resume
cycles — keep only the most recent) with:
## Blocked (iteration <N>/<max_iterations>, <ISO timestamp>)
**Done:**
- [x] <currently-checked items, copied>
**Remaining:**
- [ ] <currently-unchecked items, copied>
**Blocking command:** `<exact failing command>`
Last failure output:
<captured tail of stderr/stdout>
**What was tried:** <1-3 sentence summary of the diagnose-fix-retry attempts and why none
resolved it>
**Suggested next step:** <short actionable note for a human>
Report this to the user, stop. Do not proceed to Step 6. Do not run any epilogue. Never claim
success when blocked.
Using /loop + ScheduleWakeup
Default is inline — proceed through Steps 3-7 in the current turn without touching /loop at
all. Reach for it only in two specific cases:
- Resuming across a session boundary: at Step 1, the plan's
status was already
in_progress or blocked before this invocation started (the practical signal that an
earlier attempt didn't finish in one sitting), and meaningful validation-retry work likely
remains.
- A large fresh plan: at Step 3, the total checklist item count exceeds roughly 12, or your
own judgment says this plan is unlikely to finish in one turn.
When used: invoke the loop skill with no interval (dynamic self-pacing). Each ScheduleWakeup
call passes the identical /ralph-implement <path> prompt forward, sets noop: false with a
reason describing the concrete work just done (each firing here does real work, never idle
polling), and picks delaySeconds near the 60-second floor rather than the 20-30 minute idle
default. Call stop: true the instant Step 6 or Step 7 is reached.
Notes
- Never commit or push to git — this skill (and the subagents it spawns) never does, regardless
of what a plan implies. Progress is tracked entirely via the plan file's own checkboxes and
frontmatter, not git history.
ralph-implementer subagents never have Agent tool access — they cannot recursively spawn
further loops. All iteration/retry control lives here, in this orchestrator.
- This skill has zero knowledge of caller-specific epilogues (publishing, notifications, moving
files). If you find yourself about to do one of those, stop — that belongs in the calling
skill, not here.
- Consider adding a code-review gate between Step 4 and Step 5 — a read-only reviewer subagent
over the diff before validation runs — once a project has enough history to justify the extra
round trip. See
.claude/agents/ralph-reviewer.md in this bootstrap repo for a ready-made one;
it isn't wired into this skill by default to keep the loop's cost predictable for small changes.
1---2name: ralph-implement3description: Execute a checklist plan file (feature or bugfix) to completion via a bounded, resumable, self-correcting loop — delegates each pass to a ralph-implementer subagent, flips checkboxes live, retries failed validation commands up to max_iterations (persisted in the plan's own frontmatter so retries survive a session restart), marks the plan blocked rather than falsely done if the budget runs out. Pipeline-agnostic — knows nothing about any caller-specific epilogue (publishing, notifying, moving files); callers own that.4---56Execute a plan file's checklist(s) to completion. This skill is deliberately pipeline-agnostic —7it works identically no matter which skill produced the plan (`feature-analyst` or anything else8that writes the same checklist shape), and it never publishes anything or notifies anyone itself.9It reports `done` or `blocked` back to whoever invoked it; the caller decides what happens next.1011It can also be invoked standalone — `/ralph-implement <path-to-plan-file>` — to resume any12`in_progress` or `blocked` plan from a cold session. All progress lives in the plan file itself,13not in conversation memory, so a fresh invocation with zero prior context can pick up exactly14where a previous one left off.1516## Step 0 — Resolve the target plan file1718- If `$ARGUMENTS` is a path, use it.19- If empty: list `plans/*.md` (excluding `plans/implemented/`). If exactly one file exists, use20 it. If more than one, `AskUserQuestion` which one. If none, report there's nothing to implement21 and stop.2223## Step 1 — Parse frontmatter, guard on status2425Read the file. Extract the YAML frontmatter (`kind`, `status`, `iteration`, `max_iterations`,26`suggested_model`, `suggested_effort`, `confirmed_model`, `confirmed_effort`).2728- **No frontmatter at all** (a legacy/hand-authored plan): this is still supported. Synthesize it29 now and write it in: count existing checklist items to compute30 `max_iterations = clamp(total_items * 2, 8, 30)`, set `iteration: 0`,31 `suggested_model`/`suggested_effort` unset (`null` — skip the reconciliation question in Step 232 entirely when there's nothing to suggest), and treat `status` as `approved` (a plan file that33 exists under `plans/` without frontmatter was clearly already approved by whatever process34 created it).35- **`status: draft`** — stop. Tell the user this plan hasn't been approved yet; send them back to36 whichever skill authored it.37- **`status: done`** — report it's already done, stop. Idempotent no-op.38- **`approved`, `in_progress`, or `blocked`** — proceed to Step 2.3940## Step 2 — Model/effort reconciliation (once per plan, only)4142Only runs the first time a plan transitions `approved → in_progress` (i.e. skip this entirely on43every resume — `confirmed_model`/`confirmed_effort` being already set is exactly the signal that44this already happened, don't re-ask).4546- If `suggested_model`/`suggested_effort` are `null` (legacy plan, nothing suggested): set47 `confirmed_model` to whatever model this session is currently running as, `confirmed_effort` to48 `medium`, persist, move on — no question needed, there's nothing to reconcile against.49- Otherwise compare:50 - `suggested_model` vs. the model this current session is actually running as.51 - `suggested_effort` vs. any effort level the user explicitly specified when invoking this52 skill or the plan's originating command (if none was specified, there's nothing to compare —53 treat effort as matching).54 - **If both match**: set `confirmed_model`/`confirmed_effort` to the suggested values, persist,55 proceed silently. Do not ask anything.56 - **If either differs**: ask once, via `AskUserQuestion`:57 - Question: `"This plan suggests {suggested_model}/{suggested_effort} for implementation58 ({one-line reason from the plan's Context section}). Use suggested, keep current session59 settings, or choose different ones?"`60 - Options: `"Use suggested"`, `"Use current session settings"`, `"Choose other"` (if chosen,61 follow up with which model and which effort).62 - Persist the resolved values into `confirmed_model`/`confirmed_effort` immediately. This is63 permanent for the life of this plan — every later retry and resume reads these fields and64 never asks again.6566## Step 3 — Enter/resume6768- `status: approved` → flip to `in_progress`, bump `iteration` from 0 to 1, persist. This marks69 "an attempt is underway," it is not itself a retry.70- `status: in_progress` or `blocked` already → this is a resume. Do not bump `iteration` here;71 bumps only happen per validation-retry attempt (Step 5).7273## Step 4 — Implementation / Fix-plan fast pass7475Only runs if the plan's `## Implementation` (feature) or `## Fix plan` (bugfix) section has any76remaining `- [ ]` boxes.7778Spawn **one** `ralph-implementer` subagent (`Agent(subagent_type: "ralph-implementer", model:79confirmed_model)`) covering the *entire* remaining section in a single pass — not one subagent80per checklist item. Tell it: the plan file path, that this is an "implementation pass," and the81`confirmed_effort` level. It writes through checkbox updates to the plan file directly as it82completes each item; you don't need to re-apply anything from its report.8384When it returns, re-read the plan file's checkbox state (don't trust the subagent's prose summary85as ground truth — the file is ground truth). If items remain unchecked and the subagent reported86a genuine blocker (not just "ran out of budget"), treat this the same as a validation failure87would be treated in Step 5: surface it to the user directly rather than silently retrying88indefinitely.8990Once every Implementation/Fix-plan box is checked, fall straight into Step 5 in the same turn —91no need to wait for a new invocation.9293## Step 5 — Validation / Tests pass with bounded self-correction9495For each unchecked item under `## Validation` (feature) or `## Tests` (bugfix), in order:9697- **If it names a literal command**: spawn a `ralph-implementer` subagent for a "validation98 retry" pass, telling it the plan file path, the exact command, and `confirmed_effort`.99 - It reports pass → the box is already checked (the subagent writes through) → continue to the100 next item.101 - It reports fail → before it retries again, **you** bump `iteration` in the plan frontmatter102 and persist it immediately (this write must land before the retry, so a crash mid-retry103 resumes with the correct count) → check `iteration >= max_iterations`:104 - If not yet at the cap: spawn another `ralph-implementer` "validation retry" pass for the105 *same* command (it already has the failure context from its own last attempt if this is106 the same subagent conversation; if this is a fresh subagent call, give it the previous107 failure output so it isn't starting blind). Repeat until pass or cap reached.108 - If at the cap: go to Step 7 (Blocked). Do not mark the box done. Do not continue to later109 items. Do not fabricate success.110- **If it's a manual/human-only item** (no literal runnable command — e.g. "manual smoke test by111 user"): leave it unchecked. Do not silently check it, and do not block completion on it either112 — note it in the final report as "left for user to verify."113114## Step 6 — Completion gate115116Once every mechanical box across both sections is checked (manual items aside):117118- Re-run **every command listed in `## Definition of Done`** together, right now, even if some119 were already exercised individually earlier — this is the final no-drift check, catching120 anything that regressed between when an individual box was checked and now.121- All must exit 0 / pass. If one fails here, treat it exactly like a Step 5 validation failure:122 diagnose, fix, retry, bounded by the same `max_iterations`, escalate to Step 7 if exhausted.123- If the plan has no `## Definition of Done` section at all (legacy plan): skip this extra gate,124 note in your report that it was missing, and treat "all mechanical boxes checked" as sufficient125 for completion.126- On success: set `status: done`, persist. **Stop here.** Report completion back to whoever127 invoked this skill (or directly to the user, if invoked standalone), including: what was128 implemented, what validation passed, and any manual/human-only items still left for the user.129 Do **not** move the file, do **not** publish or notify anyone, do **not** attempt any epilogue130 — those are pipeline-specific and owned entirely by the caller.131132## Step 7 — Blocked133134`iteration >= max_iterations` reached with mechanical items still unchecked:135136- Set `status: blocked`, persist.137- Replace any existing `## Blocked` section (don't let it grow across repeated block/resume138 cycles — keep only the most recent) with:139140 ```markdown141 ## Blocked (iteration <N>/<max_iterations>, <ISO timestamp>)142143 **Done:**144 - [x] <currently-checked items, copied>145146 **Remaining:**147 - [ ] <currently-unchecked items, copied>148149 **Blocking command:** `<exact failing command>`150151 Last failure output:152 ```153 <captured tail of stderr/stdout>154 ```155156 **What was tried:** <1-3 sentence summary of the diagnose-fix-retry attempts and why none157 resolved it>158159 **Suggested next step:** <short actionable note for a human>160 ```161- Report this to the user, stop. Do not proceed to Step 6. Do not run any epilogue. Never claim162 success when blocked.163164## Using `/loop` + `ScheduleWakeup`165166Default is inline — proceed through Steps 3-7 in the current turn without touching `/loop` at167all. Reach for it only in two specific cases:168169- **Resuming across a session boundary**: at Step 1, the plan's `status` was already170 `in_progress` or `blocked` *before this invocation started* (the practical signal that an171 earlier attempt didn't finish in one sitting), and meaningful validation-retry work likely172 remains.173- **A large fresh plan**: at Step 3, the total checklist item count exceeds roughly 12, or your174 own judgment says this plan is unlikely to finish in one turn.175176When used: invoke the `loop` skill with no interval (dynamic self-pacing). Each `ScheduleWakeup`177call passes the *identical* `/ralph-implement <path>` prompt forward, sets `noop: false` with a178`reason` describing the concrete work just done (each firing here does real work, never idle179polling), and picks `delaySeconds` near the 60-second floor rather than the 20-30 minute idle180default. Call `stop: true` the instant Step 6 or Step 7 is reached.181182## Notes183184- Never commit or push to git — this skill (and the subagents it spawns) never does, regardless185 of what a plan implies. Progress is tracked entirely via the plan file's own checkboxes and186 frontmatter, not git history.187- `ralph-implementer` subagents never have `Agent` tool access — they cannot recursively spawn188 further loops. All iteration/retry control lives here, in this orchestrator.189- This skill has zero knowledge of caller-specific epilogues (publishing, notifications, moving190 files). If you find yourself about to do one of those, stop — that belongs in the calling191 skill, not here.192- Consider adding a code-review gate between Step 4 and Step 5 — a read-only reviewer subagent193 over the diff before validation runs — once a project has enough history to justify the extra194 round trip. See `.claude/agents/ralph-reviewer.md` in this bootstrap repo for a ready-made one;195 it isn't wired into this skill by default to keep the loop's cost predictable for small changes.