PlugWiki

gh-stack Skill from GitHub: Stacked Pull Requests With Claude

gh-stack (from GitHub) teaches Claude to split work into stacked branches and PRs with the gh stack extension, and to run it without interactive prompts.

Installs
20K
on skills.sh
Stars
1.7K
on GitHub
Files
3
besides SKILL.md
Updated
Nov 2026
last repo commit

A stack is a chain of branches off a trunk, where each branch has one pull request based on the branch below it. The skill loads when you mention a stack, dependent PRs or branch layers, ask to split work for review, or when a stack is checked out. It tells Claude to create the stack before writing code and put one concern in each layer.

Its key rule is to avoid commands that open a prompt or full-screen interface and hang an agent. It lists the commands to always run, such as gh stack view --json, gh stack submit --auto and gh stack merge <target> --yes, and the bare forms to never run. It also documents exit codes 0 to 10 with recovery steps.

It needs Git 2.36 or later and an authenticated GitHub CLI. SKILL.md says exit code 9 means stacked PRs are not enabled on the repository, so ask the user.

Good for

  • Developers who split big changes into small, ordered pull requests
  • Teams whose reviewers want to see one layer's diff at a time
  • Anyone who wants an agent to rebase, sync and merge a chain of PRs

Install gh-stack

Claude Code

  1. 1

    Copy this prompt.

    Install the gh-stack skill in Claude Code. Run this command:
    
    gh extension install github/gh-stack
    
    Then check that it loaded and tell me how to use it.
  2. 2

    Paste it into Claude Code. It shows the change and asks before running it.

Requires GitHub CLI (gh) v2.0 or later, Git 2.36 or later.

The skill drives the gh stack extension, so install the extension first (step 1). SKILL.md also recommends git config rerere.enabled true and, with more than one remote, git config remote.pushDefault origin.

From the project README. Source.

What's in the skill

When it loads

Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack. Use for stack creation, viewing, edits, push, submit, sync, rebase, merge, or checkout; when asked to split or isolate work for review; whenever a user mentions a stack, branch layers, dependent PRs, or gh stack; or when a stack is checked out.

Sections in SKILL.md

  1. Setup
  2. Non-interactive use
  3. Branch placement
  4. Core loop
  5. Staying in sync
  6. Merging
  7. Reading state
  8. Exit codes
  9. Constraints
  10. More detail

Key facts

Installs on skills.sh
19,976 as of 2026-11-02
GitHub stars (whole repo)
1,735 as of 2026-11-02
License
MIT
Last repo commit
2026-11-01
Files in the skill folder
4 files including SKILL.md

What it includes

  • Always run view --json, submit --auto, merge <n> --yes

    A table of commands to run and the bare forms that open a TUI or prompt under a PTY.

    Runs code · Setup and non-interactive rules

  • Create the stack first; edit the layer that owns the change

    Check out the owning layer, commit, run gh stack rebase --upstack, then return to the top and push.

    Runs code · Branch placement

  • init, add, submit --auto, view --json

    Creates branches, pushes them, and opens draft PRs (--open for ready for review).

    Runs code · Core loop

  • gh stack sync and sync --prune

    Fetches, reconciles with GitHub, rebases and pushes. --prune also deletes local branches for merged PRs.

    Delete · Staying in sync

  • gh stack merge <pr or stack> --yes with a method flag

    Merges a PR and every unmerged PR below it, all or nothing. A merge queue picks the method if one is on.

    Runs code · Merging

  • view --json fields

    Trunk, current branch and branches with PR number, URL, state, isMerged and needsRebase.

    Runs code · Reading state

  • 11 codes with recovery steps

    Includes 3 for rebase conflict, 4 for GitHub API failure and 9 for stacked PRs unavailable.

    Exit codes

  • stack-design, commands, troubleshooting

    Read stack-design before creating a stack and troubleshooting for conflicts, squash-merges and divergence.

    references/

From the official docs

Permissions

Medium risk

The skill makes Claude push branches, open and merge pull requests, and rewrite branch history with rebases. Use it on repositories where you accept those actions, and check what a merge covers before you approve it.

What it can do

  • Read your data
  • Create and change things
  • Delete things
  • Read-only mode

Watch out for

  • It can merge pull requests

    gh stack merge --yes merges a PR and every unmerged PR below it, all or nothing. Check the target number before you approve. github.com

  • It pushes branches and rewrites history

    push, submit, sync and rebase publish and rebase your branches. Work on a stack you can recover, and note that sync stops with "Sync aborted" if local and remote have diverged. github.com

  • sync --prune deletes local branches

    It removes local branches for merged PRs. SKILL.md says pruning never happens without the --prune flag when non-interactive. github.com

  • It suggests changing git config

    SKILL.md recommends git config rerere.enabled true and, with several remotes, remote.pushDefault origin. github.com

Technical details
Talks toGitHub (gh stack, gh API)
Scopes
  • your git repo

  • GitHub via an authenticated gh CLI

Questions

What does the gh-stack skill do?

It teaches Claude to manage stacked pull requests with the gh stack extension: create layered branches, open PRs, keep them in sync and rebased, and merge them, always using flags that avoid prompts.

How do I install it?

Use the install box above. Install the gh stack extension first, then the skill. The README documents gh skill install github/gh-stack for the skill.

Does it need anything besides the skill?

Yes. SKILL.md requires Git 2.36 or later and an authenticated GitHub CLI, and stacked PRs must be enabled on the repository, or commands exit with code 9.

Is it safe to install?

The skill bundles no scripts, but it directs Claude to push branches, open PRs, rebase and merge on GitHub. Merges are all-or-nothing and sync --prune deletes local branches for merged PRs, so use it on repositories where you accept those actions.

Can it merge my PRs?

Yes. gh stack merge <target> --yes merges a PR and every unmerged PR below it, or a whole stack, all or nothing. If the base branch uses a merge queue, the stack is queued instead and the queue picks the method.

Why not use plain git and gh pr?

SKILL.md says gh pr merge cannot merge a stack, and gh stack handles rebasing upstack branches and setting each PR's base branch. The skill covers its command quirks for agents.

Information

updated Nov 2, 2026

Repository
github/gh-stack
Folder
skills/gh-stack

github/gh-stackskills.sh

Sources

Docs, issue trackers and discussions this page is built from.

Show all 4
  1. gh-stack README · github.com
  2. skills.sh listing · skills.sh
  3. gh-stack SKILL.md · github.com
  4. gh-stack commands.md · github.com

Updated Nov 2, 2026.