
Gh Stack
Split a big feature into ordered, small PRs and manage rebase, push, and navigation with the gh stack CLI extension.
Overview
gh-stack is an agent skill most often used in Ship (also Build integrations) that guides the GitHub CLI `gh stack` extension for creating, rebasing, pushing, and navigating dependent PR chains.
Install
npx skills add https://github.com/github/gh-stack --skill gh-stackWhat is this skill?
- Models stacks as branch chains rooted on trunk, each branch → one PR against the branch below
- Navigation semantics: up/top away from trunk, down/bottom toward trunk
- Supports create, rebase, push, sync, and view for dependent pull requests
- Targets incremental code review instead of one giant diff
- Official GitHub CLI extension workflow (metadata version 0.0.5)
- Each stack layer maps to one PR with base set to the branch below
Adoption & trust: 2.2k installs on skills.sh; 457 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need to land a large change as small reviewable PRs without losing branch order or rebasing the whole stack by hand.
Who is it for?
Solo builders using GitHub CLI who want native stacked branches without Graphite.
Skip if: Teams that do not use GitHub or want stacking only inside a non-GitHub forge.
When should I use this skill?
User wants to create, push, rebase, sync, navigate, or view stacks of dependent PRs with gh-stack.
What do I get? / Deliverables
Your agent runs the right `gh stack` commands so each dependent branch has a matching PR and the stack stays in sync with trunk.
- Ordered stack of branches and matching PRs
- Rebased/synced stack aligned to trunk
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Stacked PRs land in Ship because they exist to get incremental diffs reviewed and merged safely—not to ideate or ship marketing. Review is the canonical shelf: each layer is one reviewable PR with a dependent base branch.
Where it fits
Land auth middleware in the bottom stack PR before API endpoints in the next layer.
Rebase the whole stack after trunk moves so reviewers see only per-layer diffs.
Add a hotfix as a new stack segment without collapsing prior merged layers.
How it compares
GitHub-native stacking via `gh stack`, not the separate Graphite `gt` workflow skill.
Common Questions / FAQ
Who is gh-stack for?
Solo and indie developers who already use GitHub CLI and want agent help managing stacked, dependent pull requests on GitHub.
When should I use gh-stack?
Use it in Ship when breaking a feature into reviewable PR chains, during Build when splitting backend/frontend layers, or whenever tasks mention stacked diffs, branch chains, or syncing dependent PRs.
Is gh-stack safe to install?
Treat it as tooling guidance around git and GitHub; review the Security Audits panel on this Prism page before installing from any marketplace source.
SKILL.md
READMESKILL.md - Gh Stack
# gh-stack `gh stack` is a [GitHub CLI](https://cli.github.com/) extension for managing **stacked branches and pull requests**. A stack is an ordered list of branches where each branch builds on the one below it, rooted on a trunk branch (typically the repo's default branch). Each branch maps to one PR whose base is the branch below it, so reviewers see only the diff for that layer. ``` main (trunk) └── feat/auth-layer → PR #1 (base: main) - bottom (closest to trunk) └── feat/api-endpoints → PR #2 (base: feat/auth-layer) └── feat/frontend → PR #3 (base: feat/api-endpoints) - top (furthest from trunk) ``` The **bottom** of the stack is the branch closest to the trunk, and the **top** is the branch furthest from the trunk. Each branch inherits from the one below it. Navigation commands (`up`, `down`, `top`, `bottom`) follow this model: `up` moves away from trunk, `down` moves toward it. ## When to use this skill Use this skill when the user wants to: - Break a large change into a chain of small, reviewable PRs - Create, rebase, push, or sync a stack of dependent branches - Navigate between layers of a branch stack - View the status of stacked PRs - Tear down and rebuild a stack to remove, reorder, or rename branches ## Prerequisites The GitHub CLI (`gh`) v2.0+ must be installed and authenticated. Install the extension with: ```bash gh extension install github/gh-stack ``` Before using `gh stack`, configure git to prevent interactive prompts: ```bash git config rerere.enabled true # remember conflict resolutions (skips prompt on init) git config remote.pushDefault origin # if multiple remotes exist (skips remote picker) ``` ## Agent rules **All `gh stack` commands must be run non-interactively.** Every command invocation must include the flags and positional arguments needed to avoid prompts, TUIs, and interactive menus. If a command would prompt for input, it will hang indefinitely. 1. **Always supply branch names as positional arguments** to `init`, `add`, and `checkout`. Running these commands without arguments triggers interactive prompts. 2. **When a prefix is set, pass only the suffix to `add`.** `gh stack add auth` with prefix `feat` → `feat/auth`. Passing `feat/auth` creates `feat/feat/auth`. 3. **Always use `--auto` with `gh stack submit`** to auto-generate PR titles. Without `--auto`, `submit` prompts for a title for each new PR. 4. **Always use `--json` with `gh stack view`.** Without `--json`, the command launches an interactive TUI that cannot be operated by agents. There is no other appropriate flag — always pass `--json`. 5. **Use `--remote <name>` when multiple remotes are configured**, or pre-configure `git config remote.pushDefault origin`. Without this, `push`, `submit`, `sync`, `link`, and `checkout` trigger an interactive remote picker. 6. **Avoid branches shared across multiple stacks.** If a branch belongs to multiple stacks, commands exit with code 6. Check out a non-shared branch first. 7. **Plan your stack layers by dependency order before writing code.** Foundational changes (models, APIs, shared utilities) go in lower branches; dependent changes (UI, consumers) go in higher branches. Think through the dependency chain before running `gh stack init`. 8. **Use standard `git add` and `git commit` for staging and committing.** This gives you full control over which changes go into each branch. The `-Am` shortcut is available but should not be the default approach—stacked PRs are most effective when each branch contains a deliberate, logical set of changes. 9. **Nav