Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Rebuild a stale branch by cherry-picking each commit onto a fresh branch off main, using a ralph-loop to validate each commit (build, test, format, lint, optional e2e) before moving on. Use when a branch has gone stale, has merge conflicts with main, or needs to be split out of a long-lived feature branch.
.claude/skills/platformplatform-rebuild-branch/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | 493% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 43% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 28% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 134% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 59% | 0% |
Drive the discovery + planning phase of a branch rebuild. Emit a /ralph-loop:ralph-loop prompt the user runs themselves to execute the cherry-picks one at a time.
The user may have named the source branch as the skill argument. If not, ask which branch to rebuild.
If the source branch isn't crystal-clear (multiple matches, ambiguous shorthand), confirm the resolved name with the user before proceeding.
Compute the root repo path (the main worktree, not the current one):
bashROOT_REPO=$(dirname "$(git rev-parse --path-format=absolute --git-common-dir)") CURRENT_BRANCH=$(git branch --show-current)
A run is in progress if $ROOT_REPO/.workspace/$CURRENT_BRANCH/commits.md exists AND the current branch ends with -rebuild.
If resuming:
commits.md and count [x] vs [ ] lines. Identify the next pending commit.learnings.md and surface the last 3 entries.If fresh: continue to STEP 3.
bashgit status --porcelain
If there are uncommitted changes, stop and ask the user to stash or commit first. Do not proceed.
Determine the base. If currently on main, the base is main. Otherwise use AskUserQuestion to ask whether to base on main or on the current branch.
List commits oldest-first:
bashgit log <base>..<source-branch> --reverse --format='%h %s'
Show the list newest-first to the user with hash + title and confirm the range. If empty, stop and report nothing to do.
Use AskUserQuestion to ask whether to create a worktree. (Some downstream projects don't support worktrees, so always ask — never assume.)
If yes:
bashgit worktree add .claude/worktrees/<source-branch>-rebuild main
Then call the EnterWorktree tool to switch context. If the user chose "current branch" as the base in STEP 4, checkout the source branch inside the worktree:
bashgit checkout <source-branch>
If no: create the rebuild branch in the current repo:
bashgit switch --create <source-branch>-rebuild main
Use AskUserQuestion to ask which run mode the loop should use:
Write the planning files in the root repo (not the worktree) so they survive worktree deletion:
$ROOT_REPO/.workspace/<source-branch>/commits.md
$ROOT_REPO/.workspace/<source-branch>/learnings.mdcommits.md format:
markdown<!-- mode: <run-mode> | source: rebuild-branch | started: <YYYY-MM-DD> --> N commits to apply. [ ] <hash> <subject> [ ] <hash> <subject> ...
Lines are oldest-first (the order they will be applied).
learnings.md starts as just a heading:
markdown# Learnings — <source-branch> rebuild
Compute iterations:
N = number of commits remaining
iterations = max(ceil(N * 1.25), N + 10)Send TWO separate messages (this is required so /copy only grabs the prompt, not the instructions).
Message 1 — instructions:
Use /copy to copy the following ralph-loop and run it from your Claude Code terminal.Message 2 — the literal command, nothing else:
/ralph-loop:ralph-loop "<PROMPT>" --max-iterations <N> --completion-promise "WE ARE DONE"Where <PROMPT> is the template below with placeholders filled in. Use real newlines, not escaped \n.
Substitute {{branch}}, {{worktree-path}}, {{root-repo}}, {{commits-file}}, {{learnings-file}}, {{run-mode}}. If no worktree was created, {{worktree-path}} equals {{root-repo}}.
We are rebuilding the {{branch}} branch onto {{worktree-path}} by cherry-picking commits one at a time from {{commits-file}}. Run mode: {{run-mode}}.
For each iteration:
1. Pick the next commit — the first line in the commits file without [x]. If every line is marked, output WE ARE DONE.
2. Land the commit cleanly — cherry-pick it and resolve any conflicts so the working tree reflects the intended state of that commit. Note whether conflicts were manually resolved — this drives the validation order in step 4.
3. Sanitize the commit message — the message must be a single line (PlatformPlatform's pull-request-conventions CI forbids multi-line messages except for `Co-authored-by:` trailers). Strip any `# Conflicts:` block that git inserts after a conflicted cherry-pick, and any other `#`-prefixed comment lines. Verify with `git log -1 --format=%B` that the message is one line.
4. Validate the change — order depends on whether conflicts were resolved in step 2:
**Conflicts resolved (we touched code by hand):**
1. build (must succeed)
2. format (must run before lint, since manual edits often need formatting that would otherwise show up as lint findings)
3. in parallel: backend tests, restart Aspire, e2e tests (smoke for small changes; full suite for large changes; full suite at least every 5 commits)
4. lint
5. if lint or any earlier step changed anything, restart this validation from step 4.1
**No conflicts (clean cherry-pick):**
1. build (must succeed)
2. in parallel: backend tests, format, lint, restart Aspire, e2e tests (same scope rules as above)
3. if lint or any other parallel step changed anything, restart this validation from step 4.1
E2E run with --stop-on-first-failure --quiet to fail fast. If tests fail, do not move on until the full suite is green. If something is missing because a later commit introduces it, pull only the minimum needed lines forward and note it under that future commit in the commits file as an indented line: '(partially pulled into earlier commit)'.
5. Fold all fixes into the cherry-picked commit — amend so the commit is self-contained: it builds, tests, lints, and passes e2e on its own. Re-run the sanitize step from #3 if the amend re-introduces any `# Conflicts:` block or `#`-prefixed lines.
6. Verify the working tree is clean — git status must show zero changes after the amend. If anything remains, you missed folding it in. Fix and amend again.
7. Mark the commit done — change [ ] to [x] on its line in the commits file.
8. Log learnings — append a one-line entry to {{learnings-file}} for any non-trivial adaptation, conflict resolution choice, or skipped piece. Format: '- <hash> — <one-line note>'. Skip routine cherry-picks that landed cleanly.
Mode-specific behavior:
- autonomous: do not ask the user anything. Make every judgement call yourself. Note unusual choices in {{learnings-file}}.
- interview-on-problem: when you cannot make progress (irreconcilable conflict, ambiguous intent, change that no longer makes sense in the new codebase), use AskUserQuestion to ask. Bake the answer into your next attempt and log it in {{learnings-file}}.
Operating principles:
- Never stop. If a commit cannot be made to work as-is, reshape the plan: collapse it with a neighbor, split it, reorder it, or drop changes that are no longer needed. The goal is a working rebuild, not literal preservation of every original commit.
- Smallest possible change when borrowing forward — pull only the lines required to compile or pass tests, never whole files or unrelated changes.
- Trust the loop. Every iteration ends with a clean tree, a passing build, passing tests, passing lint, passing e2e, and one more [x] in the commits file.| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 12,512 | 2,736 | -78% | 1 | 1 | 0% | 2,121 | 2,282 | +8% | 0 | 0 | — |
case-02 | fail→fail | 3,344 | 4,073 | +22% | 1 | 1 | 0% | 389 | 2,296 | +490% | 0 | 0 | — |
case-03 | fail→fail | 9,600 | 4,560 | -53% | 1 | 1 | 0% | 1,491 | 2,251 | +51% | 0 | 0 | — |
case-04 | fail→fail | 8,987 | 3,806 | -58% | 1 | 1 | 0% | 1,327 | 2,328 | +75% | 0 | 0 | — |
case-05 | fail→fail | 5,278 | 3,205 | -39% | 1 | 1 | 0% | 906 | 2,241 | +147% | 0 | 0 | — |
case-06 | fail→fail | 8,085 | 3,249 | -60% | 1 | 1 | 0% | 1,562 | 2,251 | +44% | 0 | 0 | — |
case-07 | fail→pass | 5,783 | 16,834 | +191% | 1 | 1 | 0% | 877 | 5,199 | +493% | 0 | 0 | — |
case-08 | fail→fail | 13,162 | 6,129 | -53% | 1 | 1 | 0% | 1,920 | 2,354 | +23% | 0 | 0 | — |
case-09 | fail→fail | 12,925 | 4,046 | -69% | 1 | 1 | 0% | 2,164 | 2,272 | +5% | 0 | 0 | — |
case-10 | fail→fail | 12,617 | 5,322 | -58% | 1 | 1 | 0% | 2,052 | 2,392 | +17% | 0 | 0 | — |
case-11 | fail→fail | 11,323 | 5,213 | -54% | 1 | 1 | 0% | 1,912 | 2,244 | +17% | 0 | 0 | — |
case-12 | fail→pass | 11,350 | 4,188 | -63% | 1 | 1 | 0% | 1,931 | 2,763 | +43% | 0 | 0 | — |
case-13 | fail→pass | 12,102 | 3,428 | -72% | 1 | 1 | 0% | 2,067 | 2,641 | +28% | 0 | 0 | — |
case-14 | fail→pass | 7,084 | 1,991 | -72% | 1 | 1 | 0% | 1,053 | 2,459 | +134% | 0 | 0 | — |
case-15 | fail→pass | 10,087 | 2,195 | -78% | 1 | 1 | 0% | 1,510 | 2,404 | +59% | 0 | 0 | — |
case-21 | pass→fail | 7,862 | 7,402 | -6% | 1 | 1 | 0% | 1,219 | 2,598 | +113% | 0 | 0 | — |
case-16 | fail→pass | 14,332 | 3,665 | -74% | 1 | 1 | 0% | 2,232 | 2,682 | +20% | 0 | 0 | — |
case-17 | fail→pass | 12,165 | 2,329 | -81% | 1 | 1 | 0% | 2,008 | 2,414 | +20% | 0 | 0 | — |
case-18 | fail→fail | 10,644 | 6,084 | -43% | 1 | 1 | 0% | 1,610 | 3,426 | +113% | 0 | 0 | — |
case-19 | pass→pass | 11,244 | 1,938 | -83% | 1 | 1 | 0% | 1,725 | 2,348 | +36% | 0 | 0 | — |
case-20 | fail→pass | 12,901 | 3,907 | -70% | 1 | 1 | 0% | 1,984 | 2,402 | +21% | 0 | 0 | — |
case-22 | pass→fail | 7,403 | 7,157 | -3% | 1 | 1 | 0% | 1,369 | 2,610 | +91% | 0 | 0 | — |
case-23 | fail→fail | 8,987 | 5,416 | -40% | 1 | 1 | 0% | 1,660 | 2,367 | +43% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted, and 10 counted toward the lift figure. The other 13 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +26 percentage points is the difference between those two pass rates over the 10 comparable cases. 3 cases got worse with the skill loaded, and they are included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.