gh-stack Stacked PR Playbook
A playbook for using the GitHub CLI gh-stack extension to split multi-part work into reviewable stacked branches and PRs, safely and non-interactively.
Dev & CodingAdvanced★ 183⑂ 13AI score 9/10Last updated: Oct 9, 2026
What it does
- Creates and manages stacked branch/PR chains rooted on trunk with
gh stack, so each reviewer only sees that layer's diff. - Gives non-interactive rules so an agent never hangs on a TUI: a table of required flags (
view --json,submit --auto,merge <target> --yes,init <branch>) and commands you must never call bare (modify,switch). - Explains branch placement: pick the layer that owns a change, edit it,
rebase --upstack, return to top and push; plussync/sync --prunefor staying aligned with GitHub. - Documents stack merging scope (PR number vs stack number, all-or-nothing, merge-queue behavior), the
view --jsonschema (trunk, branches[].pr, needsRebase), and recovery for exit codes 0–10 including rebase conflicts and lock contention. - Points to
references/stack-design.md,commands.md, andtroubleshooting.mdwith clear read triggers.
Who it's for
- Developers on teams that break large features into small, dependent PRs.
- Anyone letting an AI agent run git/gh commands who has been burned by interactive prompts or full-screen TUIs.
- Monorepo / multi-remote / worktree users who need
--remoteandremote.pushDefaultdiscipline.
Examples
- "Stack auth → api → frontend and open PRs":
gh stack init auth, commit,gh stack add api, commit, thengh stack submit --autofor draft PRs (--openfor review-ready). - Fixing a middle layer:
gh stack down, commit the endpoint change,gh stack rebase --upstackto replay every branch above, thengh stack topandgh stack push. - Landing approved lower PRs:
gh stack merge 42 --yes --squashmerges PR #42 and all unmerged PRs below it atomically, followed bygh stack sync --pruneto clean up local branches.
· · · Install guide · · ·
Try it now, no install
Paste this into Claude to use the skill without installing anything.
Read the instructions in this file and follow them to help me: https://raw.githubusercontent.com/molefrog/moi/HEAD/.agents/skills/gh-stack/SKILL.md What I want: (describe your task here)
If Claude can't open the link, open it yourself and paste the contents instead.
↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the .agents/skills/gh-stack folder from the GitHub repo molefrog/moi into my ~/.claude/skills/gh-stack/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/molefrog/moi.git /tmp/moi && mkdir -p ~/.claude/skills && cp -r /tmp/moi/.agents/skills/gh-stack ~/.claude/skills/gh-stack⚠ This is a third-party skill. Check the source repository before installing.
- Prerequisites: install Git 2.36+ and the GitHub CLI, then verify auth with
gh auth status. - Install the extension:
gh extension install github/gh-stack - Recommended config:
git config rerere.enabled true, and if the repo has multiple remotes alsogit config remote.pushDefault origin. - Clone the skill repo:
git clone https://github.com/molefrog/moi.git /tmp/moi - Copy the skill:
mkdir -p ~/.claude/skills && cp -r /tmp/moi/.agents/skills/gh-stack ~/.claude/skills/gh-stack(include the references folder). - Activate: restart Claude Code and ask something like "split this work into stacked PRs".
- Smoke test: run
gh stack view --json; exit code 9 means Stacked PRs aren't enabled on that repository.
View source on GitHub ↗License: NOASSERTION