Official agent skill

Gh Stack

by vercel in vercel/next.js

Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack.

OfficialMITAuto-check passed

Install Gh Stack

skills CLI
$ npx skills add vercel/next.js --skill gh-stack -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install vercel/next.js gh-stack --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/vercel/next.js.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/gh-stack .claude/skills/gh-stack && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
gh-stack
GitHub stars
143k
Used in
7 other repos
Token cost
~2.3k tokens
SKILL.md length
977 words
Files
4 (incl. references)
Skills in repo
27
Repo updated
First seen
Licence
MIT

At a glance

Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack.

  • Isolate work for review
  • SKILL.md covers Setup, Non-interactive use, Branch placement and Core loop, plus 6 more sections
  • Calls gh and git
  • Whenever a user mentions a stack

What it does

Gh Stack is an agent skill from vercel/next.js, published by the product's own GitHub organization. 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.

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/commands.md`, `references/stack-design.md` and `references/troubleshooting.md`).

The licence is MIT.

When your agent uses it

  • Isolate work for review
  • Whenever a user mentions a stack
  • A stack is checked out

Example prompts

  • “Use the gh-stack skill to manage stacked PRs and splits multi-part work into reviewable branches with gh-stack”
  • “/gh-stack”

What it can do on your machine

Read from SKILL.md and the folder at commit a32ddfd. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • gh
    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • cli.github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Gh Stack loads about 2.3k tokens when it runs, and up to ~7.4k if it reads all its reference files. Until then it costs about 85 tokens; SKILL.md has 977 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~85
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from vercel/next.js at commit a32ddfd, republished under its MIT licence (© vercel). 977 words, ~2,324 tokens.

Download SKILL.mdSave it as .claude/skills/gh-stack/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
gh-stack
description
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.
metadata.author
github
metadata.version
0.1.0

gh-stack

gh stack is a GitHub CLI extension for stacked branches and pull requests. A stack is an ordered chain of branches rooted on a trunk, where each branch has one PR based on the branch below it, so a reviewer sees only that layer's diff.

gh stack prints a stack trunk-first, left to right:

(main) <- auth <- api <- frontend

Left is the bottom, right is the top. auth is based on main and merges first; frontend merges last. up moves toward the top, away from trunk; down moves toward it. Foundational work belongs at the bottom, code that depends on it above. For how to choose the layers, read references/stack-design.md.

Setup

bash
gh extension install github/gh-stack
git config rerere.enabled true         # remember conflict resolutions
git config remote.pushDefault origin   # required if the repo has more than one remote

Non-interactive use

gh stack branches on whether stdout is a TTY. Piped, most commands error cleanly or print static text; under a PTY the same commands open a prompt or a full-screen TUI and block forever. Agent harnesses differ, so always pass the flags below instead of relying on that detection.

Multiple remotes: never run push, submit, sync, rebase, or link without --remote <name> unless remote.pushDefault is configured. checkout and trunk have no --remote flag and require the config.

Always runNever run bareWhy
gh stack view --jsongh stack viewopens a TUI under a PTY
gh stack submit --autogh stack submitprompts for a title per new PR
gh stack merge <target> --yesgh pr mergegh pr merge cannot merge a stack
gh stack init <branch>...gh stack initprompts for branch names
gh stack add <branch>gh stack addprompts for a name, and fails even when piped
gh stack checkout <target>gh stack checkoutopens a selection menu
gh stack up / down / top / bottomgh stack switchswitch is menu-only
—gh stack modifyTUI-only, no non-interactive path
  • view --short is safe in both modes, but it is formatted for humans. Use --json to parse.
  • checkout <pr> when a different local stack already covers those branches cannot be forced. Run gh stack unstack --local first (this keeps the stack on GitHub), then retry.

Branch placement

  • Starting multi-part work: create the stack before writing files. Do not implement every concern on trunk and split it later. Put one dependent concern in each layer, bottom to top.
  • Editing an existing stack: check out the layer that owns the change before editing. Never commit a lower layer's concern on the current top branch. Run gh stack view --json; if ownership is unclear, inspect git log --all -- <path>. Then check out the owner, edit, commit, rebase upstack, and return to top.
bash
gh stack down                   # or: gh stack checkout api
git add ... && git commit -m "Add get-user endpoint"
gh stack rebase --upstack       # replay every branch above onto the change
gh stack top                    # return to where you were
gh stack push

Core loop

bash
gh stack init auth              # create the stack and check out its branch
git add ... && git commit -m "Add auth middleware"
gh stack add api                # next layer, branched from the current one
git add ... && git commit -m "Add API routes"
gh stack submit --auto          # push every branch and open draft PRs
gh stack view --json            # confirm

Add --open to submit to create PRs ready for review instead of drafts. Branch names are verbatim — gh stack add refactor/foo creates refactor/foo.

Staying in sync

bash
gh stack sync                   # fetch, reconcile with GitHub, rebase, push, refresh PR state
gh stack sync --prune           # also delete local branches for merged PRs

Pruning never happens without --prune when non-interactive. If the local and remote stacks have diverged, sync prints both chains, makes no changes, and exits 0 with Sync aborted — see references/troubleshooting.md.

Merging

Scope the merge with an argument:

bash
gh stack merge 42 --yes          # PR #42 plus every unmerged PR below it
gh stack merge 7 --yes           # every unmerged PR in stack #7
gh stack merge 42 --yes --squash # or --merge, --rebase, --merge-method <method>

Pass a PR number to merge that PR and every unmerged PR below it, or a stack number to merge every unmerged PR in that stack. The operation is all-or-nothing: if any PR in that set cannot merge, none do.

Without a method flag the last-used method is reused. If the base branch uses a merge queue, the stack is queued instead and the queue picks the method, ignoring any flag you passed with a warning; queued PRs may land in separate groups.

Show full SKILL.md (409 more words)Show less

Reading state

gh stack view --json writes JSON to stdout. Status messages go to stderr — do not parse them, branch on exit codes instead.

trunk           string
currentBranch   string
branches[]      name, head, base, isCurrent, isMerged, isQueued, needsRebase
branches[].pr   number, url, state ("OPEN" | "MERGED" | "QUEUED"); absent when no PR exists

base is the saved SHA of the parent branch that this branch was last known to contain. It may be older than the parent's current tip. needsRebase is true when the current parent tip is no longer an ancestor of the branch.

Exit codes

CodeMeaningRecovery
0Success—
1Generic errorRead stderr
2Not in a stackgh stack init, or gh stack checkout <target>
3Rebase conflictFollow the Exit 3 recovery below
4GitHub API failureCheck gh auth status, retry
5Invalid argumentsFix the invocation; see <command> --help
6Disambiguation requiredBranch is in several stacks; check out a non-shared branch
7Rebase already in progressgh stack rebase --continue or --abort
8Stack file lockedAnother gh stack process is writing; retry after ~5s
9Stacked PRs unavailableNot enabled on the repository; tell the user
10Modify recovery requiredgh stack modify --abort

Exit 3 recovery:

  • After gh stack rebase: resolve the files, run git add, then gh stack rebase --continue; use gh stack rebase --abort to restore the stack.
  • After gh stack sync: the stack has already been restored. Run gh stack rebase to recreate the conflict, then resolve and continue as above.

Constraints

  • Stacks are strictly linear: one parent, at most one child. Use separate stacks for parallel work.
  • There is no non-interactive reorder or removal. Errors may suggest gh stack modify, but it is TUI-only — restructure with unstack then init instead.
  • PR titles and bodies are auto-generated. Use gh pr edit afterwards to change them.
  • checkout <branch-name> resolves against local stacks only. Use a stack or PR number to pull a stack down from GitHub.

More detail

gh stack <command> --help is authoritative for flags and arguments. Note that gh stack help <command> does not work — it prints the top-level help.

Open the reference whose trigger matches the task; no need to preload all three.

  • references/stack-design.md — read before creating a stack, when deciding how many layers to use, what belongs in each one, or whether work belongs in a new stack.
  • references/commands.md — read when a command fails unexpectedly or you need its preconditions, side effects, atomicity, or ordering guarantees.
  • references/troubleshooting.md — read on a rebase conflict, after a squash-merge, on local and remote divergence, when restructuring a stack, or when driving stacks from another tool.

© vercel, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in .agents/skills/gh-stack of vercel/next.js.

  • SKILL.md
  • references/commands.md
  • references/stack-design.md
  • references/troubleshooting.md

Open the folder on GitHubat commit a32ddfd

Used in 7 other repositories

We found 8 copies of this SKILL.md (exact, near-identical or edited) in other folders, from 7 other GitHub owners. This page covers the copy in vercel/next.js, which our catalogue first saw on October 8, 2026.

Compare with similar skills

Gh Stack next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Gh Stack compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Gh Stack this skillvercel/next.js143k7 repos~2.3kAutomated safety check: PassMIT
Stacking PRsPostHog/posthog40k—~2.5kAutomated safety check: PassCustom licence
Stack Split Commitmozilla-firefox/firefox13k—~1.3kAutomated safety check: PassCustom licence
Stacked PRsFoundationDB/fdb-record-layer675—~1.9kAutomated safety check: PassApache-2.0
Secrets Managementdavila7/claude-code-templates32k12 repos~2kAutomated safety check: PassMIT
Shepherd PRsflutter/flutter179k—~1.7kAutomated safety check: PassBSD-3-Clause

Similar skills

  • Stacking PRs

    PostHog/posthog

    Official

    Create and manage GitHub native Stacked PRs in this repo with the gh stack CLI.

    40k GitHub stars~2.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Stack Split Commit

    mozilla-firefox/firefox

    Split one large or hard-to-review commit into several commits that each stand on their own for review, in a git or a Jujutsu (jj) checkout.

    13k GitHub stars~1.3k tokensUpdated today
    DevelopmentAuto-check passed
  • Stacked PRs

    FoundationDB/fdb-record-layer

    Create and manage stacked pull requests on FoundationDB/fdb-record-layer using the gh stack CLI extension.

    675 GitHub stars~1.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Secrets Management

    davila7/claude-code-templates

    Secure secrets management practices for CI/CD pipelines using Vault, AWS Secrets Manager, and other tools.

    32k GitHub starsUsed in 12 repos~2k tokens
    DevOps & CloudAuto-check passed
  • Shepherd PRs

    flutter/flutter

    Automate shepherding, checking status, updating branches, and landing open PRs or approved third-party contributor PRs in the flutter/flutter repository using the gh CLI.

    179k GitHub stars~1.7k tokensUpdated today
    MobileAuto-check passed
  • Project Manager

    RightNow-AI/openfang

    Project management expert for Agile, estimation, risk management, and stakeholder communication

    18k GitHub stars~960 tokensUpdated 3 mo ago
    Product & Project ManagementAuto-check passed

More from vercel/next.js

All 27 skills in this repo
  • Sandbox Bench

    vercel/next.js

    Official

    Benchmark React or Next.js changes on Vercel Sandbox VMs with paired A/B statistics: react PR/commit vs base, or Next.js PR/commit vs base, measured end-to-end through the bench/render-pipeline app…

    143k GitHub stars~4.1k tokensUpdated today
    Auto-check passed
  • Next Dev Loop

    vercel/next.js

    Official

    Verify Next.js runtime behavior after editing app code. An agent skill from vercel/next.js.

    143k GitHub starsUsed in 9 repos~2.3k tokens
    Auto-check passed
  • Docs Diagrams

    vercel/next.js

    Official

    Draw diagrams for the Next.js docs in the style of the ones already published there: the light/dark PNGs an mdx references with <Image srcLight="/docs/light/<name.png" srcDark="/docs/dark/<name.png".

    143k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Official

    Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces.

    143k GitHub starsUsed in 6 repos~8.3k tokens
    Auto-check passed
  • React Sync

    vercel/next.js

    Official

    Build local React changes in the bundle variants consumed by Next.js, sync them into a local Next.js checkout, and test the resulting integration.

    143k GitHub stars~486 tokensUpdated today
    Auto-check passed
  • Next Bundle Optimizer

    vercel/next.js

    Official

    Audit and reduce Next.js browser initial-load work. An agent skill from vercel/next.js.

    143k GitHub stars~2.4k tokensUpdated today
    Auto-check passed

Questions about Gh Stack

What does Gh Stack do?

Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack. js, published by the product's own GitHub organization. Manages stacked PRs and splits multi-part work into reviewable branches with gh-stack.

When should I use Gh Stack?

Gh Stack fits situations like: isolate work for review; whenever a user mentions a stack; A stack is checked out.

How do I install Gh Stack in Claude Code?

Run `npx skills add vercel/next.js --skill gh-stack -a claude-code`. Or copy the skill folder (.agents/skills/gh-stack in vercel/next.js) into .claude/skills/gh-stack in your project. Claude Code loads it when a task matches its description.

How do I install Gh Stack in Codex?

Run `npx skills add vercel/next.js --skill gh-stack -a codex`. Or copy the skill folder (.agents/skills/gh-stack in vercel/next.js) into .agents/skills/gh-stack in your project. Codex loads it when a task matches its description.

Can I use Gh Stack in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add vercel/next.js --skill gh-stack -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/gh-stack, .gemini/skills/gh-stack, .github/skills/gh-stack and .opencode/skills/gh-stack in your project.

What does Gh Stack need to run?

Going by SKILL.md and its folder, Gh Stack needs the command-line tools its instructions call (gh and git).

Does Gh Stack access the network?

SKILL.md names 1 domain. As links in the text: cli.github.com. This is read from the text; nothing was executed.

Is Gh Stack safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Gh Stack use?

Gh Stack is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Gh Stack use?

About 2.3k tokens (SKILL.md is roughly 9.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 5k tokens, read only when the agent opens those files.

What are the alternatives to Gh Stack?

Skills that share tags, products or a category with Gh Stack: Stacking PRs (PostHog/posthog, 40k stars), Stack Split Commit (mozilla-firefox/firefox, 13k stars), Stacked PRs (FoundationDB/fdb-record-layer, 675 stars) and Secrets Management (davila7/claude-code-templates, 32k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Gh Stack?

vercel (a GitHub organization, an official publisher) maintains it in vercel/next.js, which has 143,241 GitHub stars. The repository holds 27 skills in this directory. The repository was last updated on October 8, 2026.

Source: vercel/next.js on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.