| description |
|---|
Break up a large branch into smaller stacked PRs using git-spice |
Split a large branch into smaller, reviewable stacked PRs using git-spice (gs).
- Run
gs llto see current stack position - Run
git diff main --stat(or appropriate base) to see all changed files - Run
git log main..HEAD --onelineto understand commit history - Group changes into logical chunks for separate PRs:
- By package (client vs server)
- By feature/module
- By dependency order (types first, then implementation)
Present the proposed split to the user with:
- Branch names (prefix with
jordan/) - Which files/directories go in each
- Suggested order (what should be reviewed first)
Important: Always checkout files from the TOP branch (the original large branch being split), not the immediate parent.
For each chunk, starting from the bottom of the stack (first to be reviewed):
-
Run
gs llto identify the top branch (marked with ◀) - this is the source for all checkouts -
From current position, create child branch:
gs bc --below --no-commit jordan/<branch-name>
-
Checkout files from the TOP branch (not parent):
git checkout <top-branch> -- <paths>
-
Stage and commit:
git add -A git commit -m "<message>" -
Navigate back up to continue:
gs up
After creating all child branches:
-
Run
gs restackto ensure stack is properly ordered -
Run
gs llto show the final stack structure -
Ask user if they want to run
gs stack syncto push all branches and create PRs
gs ll- list stack (◀ marks current branch)gs up/gs down- navigate stackgs bc --below --no-commit <name>- create branch below currentgs restack- reorder/fix stack after changesgs stack sync- push all branches and create PRsgs bsq- squash branch commits
You can invoke this command two ways:
/split-branch
Claude analyzes the diff and proposes a split plan for approval.
/split-branch
jordan/types-and-schema: packages/schema/
jordan/server-changes: packages/server/
jordan/client-ui: packages/client/src/modules/foo/
Each line: <branch-name>: <paths...> (space or comma separated paths)
Branches listed top-to-bottom = bottom-to-top in stack (first line = first to review).
$ARGUMENTS - Optional split plan. If empty, analyzes current branch and proposes split.