/gh-cli:stacksfrom gh-cli
Manages stacked pull requests (dependent PR chains) using the GitHub CLI `gh stack` extension. Splits large branches into reviewable layers and syncs/rebase/merges stacks.
Ships in gh-cli. 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.
Read when SKILL.md points to them.
gh stackA stack is a chain of small PRs where each targets the branch below it, and the whole
chain lands on a trunk (usually main). Instead of one giant diff, reviewers get
focused, independently reviewable layers. This is the antidote to the un-reviewable
"here's 4,000 lines of AI-generated code" PR.
Use this skill for any multi-PR dependent chain or any gh stack … command. For a single
standalone PR, use the pr skill instead.
github/gh-stack v0.1.0 (snapshot: 2026-08-02).
Behavior may change — if a command or flag here doesn't match reality, run
gh stack <command> --help and trust that.--base.Just run gh stack …. Don't run a detect/install check on every invocation — it adds
latency and noise for the common case. Base requirements: gh ≥ 2.90, git ≥ 2.20, and
gh auth status authenticated.
Only if a gh stack command actually fails, diagnose before installing anything:
| Failure | Response |
|---|---|
unknown command "stack" / extension not found | Offer gh extension install github/gh-stack — ask the user first (it downloads and runs third-party code). |
| A documented command/flag is missing | Preview drift — offer an approval-gated gh extension upgrade gh-stack (not a reinstall). |
gh < 2.90 or git < 2.20 | Report the version prerequisite; installing the extension won't fix it. |
| Auth / repo / divergence / network error | Do not suggest installing anything — fix the actual error. |
gh skill install github/gh-stack is not a prerequisite — that installs GitHub's own
agent skill; this skill is your guidance.
Order layers by dependency, foundation at the bottom, each layer a single coherent change small enough to review on its own. A reader should be able to go bottom-to-top and watch the feature come together. Example for "add user auth":
Lifecycle — don't skip the "commit each layer" step or you'll create empty/mislayered branches:
verify clean tree → choose trunk + bottom-to-top branch names → init (or adopt existing)
→ implement & commit layer → add next branch from the current top → gh stack view → submit
# Start a new stack (bottom branch based on the trunk)
gh stack init auth-model
# ...or create/adopt several layers bottom-to-top in one shot
gh stack init --base main auth-model auth-endpoints auth-middleware
# Add the next layer on top of the current top branch.
# -A stages ALL changes (incl. untracked) — prefer a deliberate `git add` of just this
# layer's files so unrelated work isn't swept in, then:
gh stack add -m "Add CRUD endpoints" auth-endpoints
# Inspect before submitting
gh stack view --short
# Create/update the PRs. In a terminal this opens an editor; pass --auto to skip it.
gh stack submit --auto # new PRs as drafts
gh stack submit --auto --open # new PRs marked ready for review
Use gh stack submit, not gh pr create, for stack branches — submit pushes
branches, creates/updates each PR, fixes PR base branches, and creates/updates the stack
object on GitHub. gh pr create does none of the stack wiring.
Fix the layer where the change belongs, not at the top — a fix on the wrong branch corrupts the diffs of every branch above it.
git status && gh stack view --short # know where you are first
gh stack checkout auth-model # or: gh stack down
# ...confirm you're on the intended branch, then edit + commit HERE...
git add <this-layer's-files> && git commit -m "Fix token expiry handling"
gh stack rebase --upstack # carry the fix up into the branches above
gh stack push
gh stack top # return to where you were working
Merging requires a linear history; restore it with a cascading rebase, then push.
gh stack rebase # cascade bottom→top (also: --downstack, --upstack, --no-trunk)
gh stack push
On conflict: resolve the markers → git add . → gh stack rebase --continue. To bail
out: gh stack rebase --abort (restores all branches).
Signed commits: the website "Rebase stack" button rebases server-side and produces
unsigned commits. If the repo requires signed commits, rebase locally with
gh stack rebase so commits follow your local signing config.
Every rebase/sync replays commits onto a new base, giving them new SHAs (same content, new identity). A branch that was cut from an old SHA is now parented to a commit that no longer exists on the remote, and GitHub reports this as a merge conflict even though the contents agree — a phantom conflict.
gh stack add, never a bare git checkout -b
off a stack branch. A branch the stack tracks is carried along by every sync; one it
doesn't track silently rots.gh stack view shows your local tips, which can be stale after someone else syncs.
Run git fetch first, or read view as "what my machine believes," not "what GitHub has."git fetch and look for a (forced update) line on the
parent; then compare commit subjects across the divide, not SHAs
(git log --oneline HEAD..origin/<parent> vs origin/<parent>..HEAD). Same subjects +
different SHAs = phantom conflict. Never hand-resolve a conflict whose two sides are the
same change — you'd be merging a change with itself. Instead let the cascade fix it:
gh stack checkout <pr#> (import if untracked) → gh stack view → gh stack sync
(rebase drops the duplicates by patch-id and replays only the genuinely new commits).gh stack push does per-branch --force-with-lease; one branch can update while another
is rejected (merged/queued branches are skipped). A push failure does not mean nothing
changed — inspect gh stack view to see which branches moved before retrying. Contrast:
gh stack sync pushes atomically (--force-with-lease --atomic).
gh stack sync fetches, reconciles the remote stack, fast-forwards the trunk,
cascade-rebases the remaining branches, pushes atomically, and syncs PR state. --prune
also deletes local branches for merged PRs.
It is not categorically safe — before running it confirm: clean worktree, correct
repo/remote, no unexpected local-only commits, and the stack isn't diverged. Prefer plain
gh stack sync; add --prune only with explicit user authorization (it deletes local
branches). A diverged stack aborts non-interactively rather than guessing.
gh stack sync # safe reconcile after a bottom PR merges
gh stack sync --prune # + delete merged local branches (needs authorization)
Merging is a real CLI command — not website-only. gh stack merge [<stack#>|<pr#>] merges
everything from the bottom up to and including the selected PR in one all-or-nothing
operation; GitHub auto-retargets the next layer.
gh stack view --short # ALWAYS preview the cutoff first
gh stack merge 2 --yes --squash # merge through the 2nd layer, squash, no prompt
Merge-safety rules — an agent gets these wrong easily:
gh stack view --short/--json.gh stack merge 42 actually targets before confirming.--squash / --merge / --rebase /
--merge-method) — otherwise the extension reuses its last-used method (hidden state).
Use the repo-approved method; don't assume squash.--yes is non-interactive — require explicit user authorization before using it.gh pr merge manually — that loses atomicity and merge-queue grouping.gh stack sync (--prune only with authorization).gh stack modify opens an interactive TUI (drop / fold / insert / reorder / rename).
It's not scriptable non-interactively — surface restructuring to the user rather than
attempting to drive it. After a modify session, run gh stack submit (not just push) so
PR bases and stack metadata update. gh stack unstack dissolves a stack.
Several subcommands prompt or open a TUI. Prefer the non-interactive form:
| Command | Default | Agent-safe form |
|---|---|---|
submit | opens editor | gh stack submit --auto / --auto --open |
merge | interactive wizard | gh stack merge [<n>] --yes --squash (with authorization) |
checkout (no arg) | interactive picker | pass an explicit <branch>/<pr>/<stack#> |
switch | interactive | use down/up/top/bottom/trunk, or checkout <x> |
modify | TUI only | not scriptable — surface to user; run submit after |
sync (diverged) | prompts; aborts non-interactively | never force; resolve divergence first |
view | interactive view | gh stack view --short / --json — your go-to inspector |
See references/commands.md for the full command/flag reference, per-command destructive
effects, recovery steps, and a troubleshooting table.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
6 skills in this plugin
/actionsGitHub Actions workflow management using GitHub CLI. Trigger when user wants to check CI status ("check CI", "is the build passing"), view workflow runs ("show recent runs", "view action logs"), watch running workflows ("watch CI"), or rerun failed workflows ("rerun the build")./issuesGitHub issue management using GitHub CLI. Trigger when user wants to list issues ("show open issues"), view issue details ("view issue 456"), create issues ("create an issue", "file a bug"), or edit/close issues ("close issue", "add label to issue")./prPull request operations using GitHub CLI. Trigger when user wants to list PRs ("show open PRs"), view PR details ("view PR 123"), create PRs ("create a pull request"), review/merge PRs ("merge PR", "approve PR"), or view PR diffs ("show PR diff", "what files changed in PR").npx claudepluginhub robbyt/claude-skills --plugin gh-cliOther plugins' skills for the same job