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.

MITAuto-check: notesAgent Workflows

Install Rebuild Branch

skills CLI
$ npx skills add platformplatform/PlatformPlatform --skill rebuild-branch -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install platformplatform/PlatformPlatform rebuild-branch --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/platformplatform/PlatformPlatform.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/rebuild-branch .claude/skills/rebuild-branch && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
rebuild-branch
GitHub stars
441
Token cost
~2.1k tokens
SKILL.md length
490 words
Files
1
Skills in repo
18
Repo updated
First seen
Licence
MIT

At a glance

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.

  • Works in 7 steps: Determine source branch → Detect resume vs. fresh start → Verify clean working tree → …
  • A branch has gone stale
  • SKILL.md covers STEP 1: Determine source branch, STEP 2: Detect resume vs.…, STEP 3: Verify clean working… and STEP 4: Discover commits, plus 4 more sections
  • Calls git

What it does

Rebuild Branch is an agent skill from platformplatform/PlatformPlatform. 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.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Agent Workflows, covering Autonomous loops, Git workflow and End-to-end testing. The repository describes itself as: A platform designed for building enterprise-grade, multi-tenant products using Azure, .NET, React, TypeScript, Infrastructure as Code, etc. The licence is MIT.

When your agent uses it

  • A branch has gone stale
  • Has merge conflicts with main
  • Needs to be split out of a long-lived feature branch

Example prompts

  • “/rebuild-branch”

Requirements

  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash, AskUserQuestion, EnterWorktree

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Determine source branch
  2. Detect resume vs. fresh start
  3. Verify clean working tree
  4. Discover commits
  5. Worktree decision
  6. Run mode and write planning files
  7. Emit the ralph-loop prompt

What it can do on your machine

Read from SKILL.md and the folder at commit 269de1c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash
    • AskUserQuestion
    • EnterWorktree

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Rebuild Branch loads about 2.1k tokens when it runs. Until then it costs about 81 tokens; SKILL.md has 490 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~81
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Edit, Bash, AskUserQuestion, EnterWorktree

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from platformplatform/PlatformPlatform at commit 269de1c, republished under its MIT licence (© platformplatform). 490 words, ~2,139 tokens.

Download SKILL.mdSave it as .claude/skills/rebuild-branch/SKILL.md (or your agent's skills folder).
name
rebuild-branch
description
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.
allowed-tools
Read, Write, Edit, Bash, AskUserQuestion, EnterWorktree

Rebuild Branch

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.

STEP 1: Determine source branch

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.

STEP 2: Detect resume vs. fresh start

Compute the root repo path (the main worktree, not the current one):

bash
ROOT_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:

  1. Read commits.md and count [x] vs [ ] lines. Identify the next pending commit.
  2. Read learnings.md and surface the last 3 entries.
  3. Show the user a status panel: branch name, N of M commits done, next commit hash + title, last learnings.
  4. Use AskUserQuestion to confirm continue and offer a run-mode change. Options: keep current mode, switch to autonomous, switch to interview-upfront, switch to interview-on-problem.
  5. Skip to STEP 7 (emit ralph-loop) with remaining iteration count.

If fresh: continue to STEP 3.

STEP 3: Verify clean working tree

bash
git status --porcelain

If there are uncommitted changes, stop and ask the user to stash or commit first. Do not proceed.

STEP 4: Discover commits

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:

bash
git 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.

Show full SKILL.md (222 more words)Show less

STEP 5: Worktree decision

Use AskUserQuestion to ask whether to create a worktree. (Some downstream projects don't support worktrees, so always ask — never assume.)

If yes:

bash
git 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:

bash
git checkout <source-branch>

If no: create the rebuild branch in the current repo:

bash
git switch --create <source-branch>-rebuild main

STEP 6: Run mode and write planning files

Use AskUserQuestion to ask which run mode the loop should use:

  • autonomous — loop plows through, fixes problems on its own, never asks
  • interview-upfront — N/A for rebuild-branch (only meaningful for the pull skill); fall through to interview-on-problem if selected
  • interview-on-problem — loop pauses and asks via AskUserQuestion when it can't make progress

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.md

commits.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

STEP 7: Emit the ralph-loop prompt

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.

Ralph-loop prompt template

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.

© platformplatform, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/rebuild-branch of platformplatform/PlatformPlatform.

Open the folder on GitHubat commit 269de1c

Compare with similar skills

Rebuild Branch next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Rebuild Branch compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Rebuild Branch this skillplatformplatform/PlatformPlatform441—~2.1kAutomated safety check: NotesMIT
Spec-Driven Development v2LichAmnesia/lich-skills234—~3.1kAutomated safety check: PassMIT
Autodev Paralleljh941213/my-cc-harness125—~1.3kAutomated safety check: NotesNone
Git Worktree IsolationjnMetaCode/superpowers-zh8.3k1 repos~982Automated safety check: PassMIT
Huashu Agent Swarmalchaincyf/huashu-skills1.7k—~576Automated safety check: PassMIT
Darwin SkillHHU3637kr/skills1451 repos~2.2kAutomated safety check: PassNone

Similar skills

  • Spec-Driven Development v2

    LichAmnesia/lich-skills

    Organizes long-running agent work into a Project, Sprint and Task hierarchy with per-task state files, isolated worktrees, review loops and script-checked rules.

    234 GitHub stars~3.1k tokensUpdated 4 mo ago
    Agent WorkflowsAuto-check passed
  • Autodev Parallel

    jh941213/my-cc-harness

    Parallel version of the Ralph Loop. An agent skill from jh941213/my-cc-harness.

    125 GitHub stars~1.3k tokensUpdated 2 mo ago
    Agent WorkflowsAuto-check: notes
  • Git Worktree Isolation

    jnMetaCode/superpowers-zh

    Sets up an isolated workspace before feature work or plan execution, preferring native worktree tools and falling back to git worktree, with instructions in Chinese.

    8.3k GitHub starsUsed in 1 repo~982 tokens
    DevelopmentAuto-check passed
  • Huashu Agent Swarm

    alchaincyf/huashu-skills

    多Agent蜂群并行协作,纯git自组织,适合大型项目开发。当用户提到"蜂群模式"、"多agent"、"并行开发"、"agent swarm"时使用。

    1.7k GitHub stars~576 tokensUpdated 18 days ago
    Agent WorkflowsAuto-check passed
  • Darwin Skill

    HHU3637kr/skills

    Darwin Skill (达尔文.skill): autonomous skill optimizer inspired by Karpathy's autoresearch.

    145 GitHub starsUsed in 1 repo~2.2k tokens
    Agent WorkflowsAuto-check passed
  • ULW Loop

    code-yeongyu/oh-my-openagent

    Runs a long task as a checkpointed goal loop: it creates goals, mirrors each step into a todo list, gathers evidence per criterion and lands every goal before the next.

    70k GitHub stars~3.2k tokensUpdated today
    Agent WorkflowsAuto-check passed

More from platformplatform/PlatformPlatform

All 18 skills in this repo
  • Create Prd

    platformplatform/PlatformPlatform

    Create a product requirement document (PRD) for a new feature.

    441 GitHub stars~3k tokensUpdated 16 days ago
    Auto-check passed
  • Swc Plugin Compatibility

    platformplatform/PlatformPlatform

    Diagnose and fix Lingui SWC plugin compatibility errors with Next.js, Rspack, or other SWC runtimes.

    441 GitHub stars~873 tokensUpdated 16 days ago
    Auto-check passed
  • Aspire Restart

    platformplatform/PlatformPlatform

    Start or restart the .NET Aspire AppHost via the developer CLI.

    441 GitHub stars~415 tokensUpdated 16 days ago
    Auto-check passed
  • Commit

    platformplatform/PlatformPlatform

    Commit session changes to git. An agent skill from platformplatform/PlatformPlatform.

    441 GitHub stars~567 tokensUpdated 16 days ago
    Auto-check passed
  • E2E

    platformplatform/PlatformPlatform

    Run end-to-end Playwright tests via the developer CLI. An agent skill from platformplatform/PlatformPlatform.

    441 GitHub stars~542 tokensUpdated 16 days ago
    Auto-check passed
  • Enhanced Message Context

    platformplatform/PlatformPlatform

    Provide additional context for messages based on the codebase and the context of the message to improve the quality of the translations.

    441 GitHub stars~1.6k tokensUpdated 16 days ago
    Auto-check passed

Questions about Rebuild Branch

What does Rebuild Branch do?

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. Rebuild Branch is an agent skill from platformplatform/PlatformPlatform. 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.

When should I use Rebuild Branch?

Rebuild Branch fits situations like: A branch has gone stale; has merge conflicts with main; needs to be split out of a long-lived feature branch.

How do I install Rebuild Branch in Claude Code?

Run `npx skills add platformplatform/PlatformPlatform --skill rebuild-branch -a claude-code`. Or copy the skill folder (.claude/skills/rebuild-branch in platformplatform/PlatformPlatform) into .claude/skills/rebuild-branch in your project. Claude Code loads it when a task matches its description.

How do I install Rebuild Branch in Codex?

Run `npx skills add platformplatform/PlatformPlatform --skill rebuild-branch -a codex`. Or copy the skill folder (.claude/skills/rebuild-branch in platformplatform/PlatformPlatform) into .agents/skills/rebuild-branch in your project. Codex loads it when a task matches its description.

Can I use Rebuild Branch in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add platformplatform/PlatformPlatform --skill rebuild-branch -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/rebuild-branch, .gemini/skills/rebuild-branch, .github/skills/rebuild-branch and .opencode/skills/rebuild-branch in your project.

What does Rebuild Branch need to run?

Going by SKILL.md and its folder, Rebuild Branch needs the command-line tools its instructions call (git). Its frontmatter pre-approves these tools: Read, Write, Edit, Bash, AskUserQuestion, EnterWorktree.

Does Rebuild Branch access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Rebuild Branch safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Rebuild Branch use?

Rebuild Branch is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Rebuild Branch use?

About 2.1k tokens (SKILL.md is roughly 8.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Rebuild Branch?

Skills that share tags, products or a category with Rebuild Branch: Spec-Driven Development v2 (LichAmnesia/lich-skills, 234 stars), Autodev Parallel (jh941213/my-cc-harness, 125 stars), Git Worktree Isolation (jnMetaCode/superpowers-zh, 8.3k stars) and Huashu Agent Swarm (alchaincyf/huashu-skills, 1.7k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Rebuild Branch?

platformplatform (a GitHub organization) maintains it in platformplatform/PlatformPlatform, which has 441 GitHub stars. The repository holds 18 skills in this directory. The repository was last updated on September 24, 2026.

Source: platformplatform/PlatformPlatform on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.