gh-stack

Manage stacked branches and dependent pull requests with the gh-stack GitHub CLI extension.

Updated Nov 10, 2013
One-click install
npx skills add https://github.com/bnferguson/dotfiles --skill gh-stack-bnferguson
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: gh-stack
Source: https://github.com/bnferguson/dotfiles/tree/main/.agents/skills/gh-stack
Command: npx skills add https://github.com/bnferguson/dotfiles --skill gh-stack-bnferguson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Breaking a large change into small, reviewable pull requests is hard when each PR depends on the previous one. This Skill manages stacks of dependent branches and PRs so each layer shows reviewers only its own diff, and keeps the whole chain rebased and in sync. ## Core Features & Use Cases - Stack creation and navigation: Initialize stacks with gh stack init, add layers with gh stack add, and move between layers with up, down, top, and bottom. - PR submission and syncing: Push branches and create linked PRs with gh stack submit --auto, and run gh stack sync to fetch, rebase, push, and reconcile PR state in one command. - Conflict and merge handling: Recover from squash-merges automatically, resolve rebase conflicts with rebase --continue/--abort, and restructure stacks with unstack. - Use Case: You are building a full-stack feature. Create a stack of data-models, api-routes, and frontend branches, submit them as three chained PRs, and when review feedback requires an API change, navigate down, commit the fix, and rebase the layers above. ## Quick Start Ask the agent to break the current feature into a stack of dependent PRs using gh stack, starting with a foundational branch and submitting draft PRs for each layer.

Frequently Asked Questions about gh-stack

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create stacked pull requests on GitHub?▼

Install the gh-stack extension with `gh extension install github/gh-stack`, then run `gh stack init branch-a branch-b` to create a chain of branches. Commit changes per layer and run `gh stack submit --auto` to push branches and create linked PRs.

How do I make changes to a lower branch in a stack?▼

Navigate to the target branch with `gh stack down` or `gh stack checkout <branch>`, commit your changes there, then run `gh stack rebase --upstack` to propagate them to higher layers. This keeps each PR's diff scoped to its own concern.

Does gh stack work with non-interactive agents or CI?▼

Yes, but every command must avoid prompts: always pass branch names to `init` and `add`, use `--auto` with `submit`, and use `--json` with `view`. Pre-configure `git config rerere.enabled true` and `remote.pushDefault` to skip first-run prompts.

What happens when a stacked PR is squash-merged?▼

Running `gh stack sync` detects the squash-merge and uses `git rebase --onto` to replay remaining branches onto the updated trunk. It then pushes the rebased branches and reports which PRs were merged.

How do I resolve rebase conflicts in a branch stack?▼

When `gh stack rebase` exits with code 3, edit the conflicted files, stage them with `git add`, and run `gh stack rebase --continue`. Repeat until done, or run `gh stack rebase --abort` to restore all branches to their pre-rebase state.

Can I use gh stack with jj or Sapling for branch management?▼

Yes. Use `gh stack link branch-a branch-b` to create or update a stack of PRs on GitHub without any local tracking state. It pushes branches, creates PRs with correct base chaining, and links them into a stack.