/building:stacked-diffsfrom building
Use when a branch has grown too large to review in one pass, or when starting work that is known to be large — splits the change into a stack of dependent draft PRs (`main ← PR-1 ← PR-2 ← PR-3`), each small enough to review on its own. Also handles rebasing and merging the stack as reviews progress.
Ships in building. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
git branch --show-currentgit config --get-regexp '^branch\..*\.stackBase$' 2>/dev/null || echo "(none configured)"git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null || echo origin/maingit log --oneline origin/HEAD..HEAD 2>/dev/null || echo "(cannot compute — origin/HEAD unset)"gh pr view --json number,url,baseRefName,state 2>/dev/null || echo "(no PR for this branch)"If a stackBase is listed for the branch named above, that is this branch's base, not
the default branch — recompute the commit range against it before splitting the stack.
If the branch is a normal size and reviewable in one sitting, use rebase + draft-pr instead. Stacking is overhead; only pay it when the alternative is an unreviewable diff.
A stack is an ordered chain of branches where each is based on the previous:
main ← feat/thing-01-schema ← feat/thing-02-api ← feat/thing-03-ui
Each branch has exactly one parent (the branch it was created from) and exactly one PR targeting that parent. The bottom of the stack targets main (or whatever the repo's default branch is).
The parent of each stacked branch is stored locally in git config:
git config branch.<name>.stackBase <parent-branch>
This is the source of truth for:
rebase skill reads stackBase before falling back to origin/HEAD.gh pr create --base <stackBase>.stackBase points at a given branch to find its children.stackBase is a plain local git config key. It is not pushed with the branch. If you work on the stack from another machine, set it again there.
Use a shared prefix plus a zero-padded index so branches sort naturally:
feat/<topic>-01-<slice>
feat/<topic>-02-<slice>
The prefix and slice names are up to the user — the important part is that they sort in stack order and share a prefix so the stack is easy to identify.
Each PR in the stack is opened with --draft, same as the draft-pr skill. The draft state is the human checkpoint. The user transitions each PR to ready-for-review themselves.
The bottom of the stack merges first. Never merge PR-2 before PR-1 — its diff is defined relative to PR-1's changes, and merging it first would apply PR-1's changes into main by accident.
When rebasing the stack propagates new commits to already-pushed branches, use git push --force-with-lease. Never --force. If the lease is rejected, stop and investigate — somebody else may have pushed.
The skill never pushes to the default branch directly. All merges go through the PR UI.
--no-verify, no silent force-pushesHooks exist for a reason. If a hook fails, surface the error and stop.
Use when the current branch has grown too large and needs to be split.
git log --oneline --reverse origin/HEAD..HEAD
origin/HEAD resolves to the remote default branch without substitution. If a stack
base is listed in Current state for this branch, use that ref in place of
origin/HEAD — the slice starts from the parent, not from the default branch.Slice 1 (feat/thing-01-schema): <commit-a>, <commit-b>
Slice 2 (feat/thing-02-api): <commit-c>, <commit-d>, <commit-e>
Slice 3 (feat/thing-03-ui): <commit-f>
Wait for user approval. If the commits are not already grouped logically in history, offer to reorder via interactive rebase first (git rebase -i <base>), then re-propose.git branch feat/thing-01-schema <last-commit-of-slice-1>
git config branch.feat/thing-01-schema.stackBase main
git branch feat/thing-02-api <last-commit-of-slice-2>
git config branch.feat/thing-02-api.stackBase feat/thing-01-schema
git branch feat/thing-03-ui <last-commit-of-slice-3>
git config branch.feat/thing-03-ui.stackBase feat/thing-02-api
git push -u origin feat/thing-01-schema
git push -u origin feat/thing-02-api
git push -u origin feat/thing-03-ui
stackBase:
gh pr create --draft --base main --head feat/thing-01-schema --title "..." --body "..."
gh pr create --draft --base feat/thing-01-schema --head feat/thing-02-api --title "..." --body "..."
gh pr create --draft --base feat/thing-02-api --head feat/thing-03-ui --title "..." --body "..."
Use the draft-pr body format (Intent / What / Why / How), with the Intent placeholder left blank on every layer for the author. In the Why, note this PR's position in the stack and link the PRs above and below it.Use when the current branch already has its PR open and you are starting the next slice of work.
git switch -c feat/thing-02-api
git config branch.feat/thing-02-api.stackBase feat/thing-01-schema
--base feat/thing-01-schema. Use commit then draft-pr as normal; draft-pr should pick up the stackBase as the base automatically.Use when a lower PR picked up review feedback and its branch head moved. Everything above it must be rebased onto the new tip.
stackBase. One command lists every child-to-parent edge:
git config --get-regexp '^branch\..*\.stackBase$'
Each line is branch.<child>.stackBase <parent>. Build the ordering from those pairs
yourself rather than looping in shell — a loop needs substitution, which is refused
inside a worktree.git switch feat/thing-02-api
git rebase feat/thing-01-schema
git push --force-with-lease origin feat/thing-02-api
git switch feat/thing-03-ui
git rebase feat/thing-02-api
git push --force-with-lease origin feat/thing-03-ui
Resolve any conflicts as they occur. If --force-with-lease is rejected, stop and investigate.Use after a PR in the stack merges to main (or its parent branch). The child PR's base must be retargeted.
gh pr view <parent-pr> --json state,mergeCommit.main):
gh pr edit <next-pr> --base main
stackBase config to match:
git config branch.feat/thing-02-api.stackBase main
git switch feat/thing-02-api
git fetch origin
git rebase origin/main
git push --force-with-lease origin feat/thing-02-api
stackBase was the just-merged branch — walk up and rebase each in order.<parent> and <branch> are placeholders — substitute the literal ref you resolved
from Current state. Do not compute them inline with command substitution: a
worktree-isolated session refuses commands whose arguments are produced that way, and
this skill runs in a worktree.
| Goal | Command |
|---|---|
| Inspect stack parent | git config branch.<name>.stackBase |
| Set stack parent | git config branch.<name>.stackBase <parent> |
| See commits on this slice | git log --oneline <parent>..HEAD |
| List every child-to-parent edge | git config --get-regexp '^branch\..*\.stackBase$' |
| Rebase onto parent's new tip | git rebase <parent> |
| Push after rebase | git push --force-with-lease origin <branch> |
| Open stacked PR | gh pr create --draft --base <parent> --title ... --body ... |
| Retarget PR base after parent merged | gh pr edit <pr> --base main && git config branch.<name>.stackBase main |
| Condition | Behavior |
|---|---|
| User asks to split a branch with unrelated commits jumbled together | Offer to reorder via git rebase -i <base> first so slices map to contiguous commit ranges. |
| Current branch has uncommitted changes | Refuse. Point at the commit skill. |
stackBase is unset when rebasing | Fall back to origin/HEAD, then main. Warn the user that stack ordering is not known. |
--force-with-lease rejected | Stop. Someone else (or another machine) pushed. Investigate before overriding. |
| User asks to merge PR-2 before PR-1 | Refuse. Explain bottom-up merge order. |
| Parent PR was squash-merged | The new base is the squash commit on main; rebase the child onto origin/main (not the old parent ref, which no longer has the same commits). |
| No default branch detectable | Refuse. Ask the user for the default branch. |
git push --force without --with-lease.--draft.git branch -D an old stacked branch before its PR has merged or been closed.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub joelstoddard/guardrails --plugin buildingOther plugins' skills for the same job
10 skills in this plugin
/biasesCounter reasoning biases when investigating, debugging, or searching a codebase or history. Follow this skill when looking for every instance of a pattern, diagnosing an incident, judging a past decision, or answering "has this happened before" — anywhere a partial sample could pass for the whole population./ci-watchWatch a pull request's CI checks and repair failures until they pass. Follow this skill after opening a PR, or when asked to watch, babysit, or fix CI on a PR. Bounded at three fix rounds; never weakens a test to reach green./commitCreate atomic conventional commits. Follow this skill whenever committing code — commit without asking, never push, and sub-agents commit as they go and surface a summary in their return value.