rick-plan-improve
Bounded improvement loop on a plan file written by /rick-plan (or any plan markdown). Reads the canonical plan, critiques against weakness categories, applies surgical edits, snapshots pre and post, up to 3 rounds.
Resolve the target plan
$ARGUMENTS resolution order, use the first that produces a value:
- Empty. Resolve to current branch:
git branch --show-current, sanitize / and spaces to -. Target canonical: docs/rick/<branch>/plan/current.md.
- Path ending in
.md. Treat as literal path. Target canonical = that path. <plan-dir> = its parent directory.
- Otherwise. Treat as a folder name. Target canonical:
docs/rick/<arg>/plan/current.md.
If the resolved canonical does not exist, stop with No plan at <path>. Run /rick-plan first. Do not silently fall through.
Before the loop
- Read the canonical plan file. The actual file, not your memory of it.
- Check for an intel dossier per
../rick-intel/LOOKUP.md. If one exists, read its Story Context + Findings — they're trust sources for verifying plan claims in step 6 and for spotting Unverified claim weakness. Plan and intel divergence (plan asserts X, intel cites Y) is a finding in the round.
- Read
CLAUDE.md (or equivalent project instructions). Half of plan problems are specs that violate conventions already written down six inches from Morty's face.
- Determine versioning state:
- Version directory:
<plan-dir>/ (same dir as the canonical — v1.md, v2.md, etc. sit alongside current.md).
- Next version
N: list <plan-dir>/v*.md, find the highest integer (ignore -pre suffix), next = highest + 1. A canonical written by /rick-plan always seeds v1.md, so the first improve run is v2.
- Snapshot pre: copy the canonical plan →
<plan-dir>/v<N>-pre.md BEFORE any edits. This is the rollback point. No exceptions.
- Read
<plan-dir>/VERSIONS.md if it exists. Records prior changes and rationale. Context, not a shield. To reverse a prior decision: state it, cite evidence its rationale is wrong, explain why the evidence invalidates it. All three or leave it alone.
- Verify claims in the plan against local files and the intel dossier (if present). Skip external URLs unless the claim cannot be verified locally.
- Count body lines (excluding frontmatter). Record as the baseline for the size stop condition.
Stop conditions (first that fires, stop immediately)
- 3 rounds completed. Hard cap. No exceptions.
- Round produces zero net-new changes. Say "no improvements found this round" and stop.
- Plan exceeds 500 lines. Round must cut before it can add. If you cannot get under 500, stop and tell Morty the plan needs to be split.
Loop protocol (up to 3 rounds)
Edit the canonical plan file directly. The pre-loop backup is already safe in <plan-dir>/v<N>-pre.md.
Each round:
- Read the canonical plan. The actual file. Not your memory from the last round.
- Critique against the weakness categories in WEAKNESS-CATEGORIES.md. Read that file once before round 1; carry the categories across rounds. Cite the section, line, or claim that is broken. No citation, no finding. If a section is solid, say so and move on.
- Rank worst first. Which gap costs the most wasted engineering time or produces the worst production bug? Name the failure mode in one sentence before fixing it. If you cannot name it, the finding does not qualify.
- Apply surgical fixes. Do not rewrite sections that work.
- Count body lines after edits. If over 500, stop the loop immediately.
- Report what changed. Format:
- [Section] Change description (why: failure it prevents). Hold these for the post-loop VERSIONS.md entry.
After the loop
Copy the final plan → <plan-dir>/v<N>.md with YAML frontmatter prepended:
---
version: <N>
date: <YYYY-MM-DD>
author: rick-plan-improve
parent: v<N>-pre.md
summary: <one-line stop-condition + total change count>
---
Append a full entry to <plan-dir>/VERSIONS.md (create with the header below if missing — but normally /rick-plan already created it):
# Plan Versions: <folder>
Append-only history. v1 is the initial plan; later versions are /rick-plan-improve runs.
- v<N> | <YYYY-MM-DD> | <stop-condition: 3-rounds | zero-changes | over-cap>
- Round 1: <one line, what changed>
- Round 2: <one line, or "stopped early">
- Round 3: <one line, or "stopped early">
Print exactly:
Improved <folder> (v<N>): <stop-condition>. <R> rounds, <C> total changes. Canonical: <plan-path>. History: <plan-dir>/VERSIONS.md
Where <folder> is the grandparent directory name (e.g. for docs/rick/48-rotate-share-token/plan/current.md, <folder> is 48-rotate-share-token).
Then stop. Don't recap. Don't offer to revert. The history file has the diff.
What NOT to do
- Don't add sections for hypothetical future requirements. Every section must prevent a specific, nameable failure.
- Don't expand the plan into a tutorial or add structure for its own sake. Engineers can read code.
- Don't soften language. "This will cause silent data loss" beats "this could potentially lead to inconsistencies."
- Don't touch
v*.md snapshot files mid-loop. Only write pre (before round 1) and post (after the final round).
- Don't run the loop on
rick-plan-improve itself. That's rick-improve's job.
Stop condition
After the post snapshot and VERSIONS.md update, print the one-line summary and stop. No recap, no "want me to revert," no offer to iterate further. The history file has the diff.
1---2name: rick-plan-improve3description: Bounded 3-round critique-and-fix loop on a plan written by /rick-plan. Snapshots pre/post versions alongside the canonical. 500-line cap.4---56# rick-plan-improve78Bounded improvement loop on a plan file written by `/rick-plan` (or any plan markdown). Reads the canonical plan, critiques against weakness categories, applies surgical edits, snapshots pre and post, up to 3 rounds.910## Resolve the target plan1112`$ARGUMENTS` resolution order, use the first that produces a value:13141. **Empty.** Resolve to current branch: `git branch --show-current`, sanitize `/` and spaces to `-`. Target canonical: `docs/rick/<branch>/plan/current.md`.152. **Path ending in `.md`.** Treat as literal path. Target canonical = that path. `<plan-dir>` = its parent directory.163. **Otherwise.** Treat as a folder name. Target canonical: `docs/rick/<arg>/plan/current.md`.1718If the resolved canonical does not exist, stop with `No plan at <path>. Run /rick-plan first.` Do not silently fall through.1920## Before the loop21221. Read the canonical plan file. The actual file, not your memory of it.232. Check for an intel dossier per [`../rick-intel/LOOKUP.md`](../rick-intel/LOOKUP.md). If one exists, read its Story Context + Findings — they're trust sources for verifying plan claims in step 6 and for spotting **Unverified claim** weakness. Plan and intel divergence (plan asserts X, intel cites Y) is a finding in the round.243. Read `CLAUDE.md` (or equivalent project instructions). Half of plan problems are specs that violate conventions already written down six inches from Morty's face.254. Determine versioning state:26 - **Version directory:** `<plan-dir>/` (same dir as the canonical — v1.md, v2.md, etc. sit alongside current.md).27 - **Next version `N`:** list `<plan-dir>/v*.md`, find the highest integer (ignore `-pre` suffix), next = highest + 1. A canonical written by `/rick-plan` always seeds `v1.md`, so the first improve run is `v2`.28 - **Snapshot pre:** copy the canonical plan → `<plan-dir>/v<N>-pre.md` BEFORE any edits. This is the rollback point. No exceptions.295. Read `<plan-dir>/VERSIONS.md` if it exists. Records prior changes and rationale. Context, not a shield. To reverse a prior decision: state it, cite evidence its rationale is wrong, explain why the evidence invalidates it. All three or leave it alone.306. Verify claims in the plan against local files and the intel dossier (if present). Skip external URLs unless the claim cannot be verified locally.317. Count body lines (excluding frontmatter). Record as the baseline for the size stop condition.3233## Stop conditions (first that fires, stop immediately)34351. **3 rounds completed.** Hard cap. No exceptions.362. **Round produces zero net-new changes.** Say "no improvements found this round" and stop.373. **Plan exceeds 500 lines.** Round must cut before it can add. If you cannot get under 500, stop and tell Morty the plan needs to be split.3839## Loop protocol (up to 3 rounds)4041Edit the canonical plan file directly. The pre-loop backup is already safe in `<plan-dir>/v<N>-pre.md`.4243Each round:44451. **Read the canonical plan.** The actual file. Not your memory from the last round.462. **Critique against the weakness categories in [WEAKNESS-CATEGORIES.md](WEAKNESS-CATEGORIES.md).** Read that file once before round 1; carry the categories across rounds. Cite the section, line, or claim that is broken. No citation, no finding. If a section is solid, say so and move on.473. **Rank worst first.** Which gap costs the most wasted engineering time or produces the worst production bug? Name the failure mode in one sentence before fixing it. If you cannot name it, the finding does not qualify.484. **Apply surgical fixes.** Do not rewrite sections that work.495. **Count body lines after edits.** If over 500, stop the loop immediately.506. **Report what changed.** Format: `- [Section] Change description (why: failure it prevents)`. Hold these for the post-loop VERSIONS.md entry.5152## After the loop53541. Copy the final plan → `<plan-dir>/v<N>.md` with YAML frontmatter prepended:5556 ```yaml57 ---58 version: <N>59 date: <YYYY-MM-DD>60 author: rick-plan-improve61 parent: v<N>-pre.md62 summary: <one-line stop-condition + total change count>63 ---64 ```65662. Append a full entry to `<plan-dir>/VERSIONS.md` (create with the header below if missing — but normally `/rick-plan` already created it):6768 ```markdown69 # Plan Versions: <folder>7071 Append-only history. v1 is the initial plan; later versions are /rick-plan-improve runs.72 ```7374 ```75 - v<N> | <YYYY-MM-DD> | <stop-condition: 3-rounds | zero-changes | over-cap>76 - Round 1: <one line, what changed>77 - Round 2: <one line, or "stopped early">78 - Round 3: <one line, or "stopped early">79 ```80813. Print exactly:8283 ```84 Improved <folder> (v<N>): <stop-condition>. <R> rounds, <C> total changes. Canonical: <plan-path>. History: <plan-dir>/VERSIONS.md85 ```8687 Where `<folder>` is the grandparent directory name (e.g. for `docs/rick/48-rotate-share-token/plan/current.md`, `<folder>` is `48-rotate-share-token`).8889Then stop. Don't recap. Don't offer to revert. The history file has the diff.9091## What NOT to do9293- Don't add sections for hypothetical future requirements. Every section must prevent a specific, nameable failure.94- Don't expand the plan into a tutorial or add structure for its own sake. Engineers can read code.95- Don't soften language. "This will cause silent data loss" beats "this could potentially lead to inconsistencies."96- Don't touch `v*.md` snapshot files mid-loop. Only write pre (before round 1) and post (after the final round).97- Don't run the loop on `rick-plan-improve` itself. That's `rick-improve`'s job.9899## Stop condition100101After the post snapshot and VERSIONS.md update, print the one-line summary and stop. No recap, no "want me to revert," no offer to iterate further. The history file has the diff.