gh-stack
Skill4 starsChanged 21 days agoMITView on GitHub
Creates, manages, splits, reorders, and submits stacked pull requests with the GitHub `gh stack` CLI extension. Use whenever the user mentions gh stack, stacked PRs, a PR stack, splitting or breaking up a large branch or PR, non-interactive/agent use, exit-code recovery, conflict resolution, reordering, trunk retargeting, or lockfiles, even if they do not explicitly ask for this skill.
- Deletes or force-pushes
- Commits and pushes
43 other projects use a version of this.
Adopted by
Most recently taken up by
- githubnext/chopintheir own version, first seen Nov 8, 2026
- ErikaAX08/erikas-skillstheir own version, first seen Nov 8, 2026
- devantler-tech/ksailtheir own version, first seen Nov 7, 2026
- theexperiencecompany/gaiatheir own version, first seen Nov 3, 2026
- cloudposse/atmostheir own version, first seen Nov 1, 2026
- Egoushka/agent-skillstheir own version, first seen Nov 1, 2026
Used with
Projects with it also use gh-create-pr, gh-commit and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
ant-designSkillgh-create-pr
使用 GitHub CLI (gh) 推送当前分支并创建或更新 PR。在用户说「提 PR」「新建 PR」「用 gh 建 PR」「submit PR」「create pull request」时使用。
Also in 4 projects that use this
kelvincushmanSkillgh-commit
Create well-formatted commits with conventional commit format.
Also in 3 projects that use this
kelvincushmanSkillprek
Use when setting up or running hooks with prek in any repository. prek is a Rust drop-in alternative to pre-commit for running Git hooks that check, format, lint, and validate code and repository files. Prefer it when speed, workspace mode, built-in hooks, shared toolchains, or native TOML configuration matter.
Also in 3 projects that use this
carapace-shSkillbun
Use when working with the bun CLI — Bun's all-in-one JavaScript runtime and toolkit. Covers the CLI command reference (install, add, remove, run, build, test, x, create, init, pm, upgrade, link, unlink), bunfig.toml configuration, environment variables, the package manager and lockfile, the test runner, the bundler, the Bun runtime API (Bun.serve, Bun.file, Bun.spawn, Bun.write, hashing, transpiler), the Bun shell ($ template literal), module resolution and loaders, and globals. Triggers on: "bun", "bunx", "bun install", "bun add", "bun remove", "bun run", "bun build", "bun test", "bun x", "bun create", "bun init", "bun pm", "bun upgrade", "bun link", "bun unlink", "bunfig.toml", "bun.lock", "Bun.serve", "Bun.file", "Bun.write", "Bun.spawn", "Bun.hash", "Bun.password", "bun:test", "Bun.build", "Bun.Transpiler", "bun shell", "$ template", "import.meta", "JavaScriptCore", "Bun.serve", "HTMLRewriter", "Bun.SQL", "Bun.RedisClient", "Bun.Glob", "Bun.plugin", "bun:ffi".
Also in 3 projects that use this
xfstudioSkilltypescript-expert
TypeScript and JavaScript expert with deep knowledge of type-level programming, performance optimization, monorepo management, migration strategies, and modern tooling. Use PROACTIVELY for any TypeScript/JavaScript issues including complex type gymnastics, build performance, debugging, and architectural decisions. If a specialized expert is a better fit, I will recommend switching and stop.
Also in 3 projects that use this
xfstudioSkilltypescript-advanced-types
Master TypeScript's advanced type system including generics, conditional types, mapped types, template literals, and utility types for building type-safe applications. Use when implementing complex type logic, creating reusable type utilities, or ensuring compile-time type safety in TypeScript projects.
Also in 4 projects that use this
Other versions43 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 43
- vercel/next.js★ 143ksame name
- remotion-dev/remotion★ 72ksame name
- CherryHQ/cherry-studio★ 53ksame name
- Arize-ai/phoenix★ 12ksame name
- trycompai/crm★ 12ksame name
- CherryHQ/cherry-studio-app★ 4.1ksame name
- dotnet/macios★ 2.9ksame name
- dotnet/android★ 2.1ksame name
- github/gh-stack★ 1.8ksame name
- cloudposse/atmos★ 1.4ksame name
33 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .copilot/copilot-instructions.mdCopilot instructions
- acting-as-diegoferigoSkill
- creating-skillsSkill
- guide-me-throughSkill
- opening-hunkSkill
- opening-zedSkill
- orchestrating-agentsSkill
- using-worktrunkSkill
- working-in-zedSkill
- working-on-dotfilesSkill
- code-reviewSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 2 are distinctive, and 6 are very specific to this project.
0
Common
Most of the 42 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 29
If splitting an existing large branch/PR, use the soft-reset method and the per-layer gate in reference/splitting.md.
- Very specific: line 36
When another workflow skill uses gh-stack, ownership is split once:
- Very specific: line 73
Do not run gh stack push, sync or submit for this incremental step.
- Very specific: line 81
Run gh stack merge only on the user's explicit instruction to merge.
- Very specific: line 85
When a repo has multiple remotes, set git config remote.pushDefault origin or pass --remote <name> to commands that support it.
- Very specific: line 87
After gh stack sync, verify with gh stack view --json.
- Very specific: line 89
If remote branches were rebased elsewhere, treat the remote as authoritative.
- Distinctive: line 91
If the order of an already-submitted stack changed or a layer was inserted below an existing PR, do not submit it.
“Common” is measured: kept by at least 6 in 10 of the 42 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
gh stack: Stacked Pull Requests
gh stack (extension github/gh-stack) creates and maintains a chain of small, dependent PRs. Bottom PRs merge first; every higher PR targets the branch below it. Use this skill whenever the work involves stacked PRs or splitting one large change into independently reviewable PRs. Native stacked pull requests are in public preview (changelog). Set GH_STACK_NO_UPDATE_NOTIFIER=1 in agent runs to silence update notices.
Docs: https://gh.io/stacks · Overview: https://github.github.com/gh-stack/introduction/overview/
First decisions
- Confirm setup and installed behavior:
gh stack --versionandgh stack <cmd> --help(gh stack help <cmd>is not per-command help). - If building a new stack, design the layers first: foundational/shared code lower, dependent code higher. Author every commit as one self-contained, single-concern unit so a layer stays splittable later, and shape every layer's diff to be as readable and reviewable as possible (pure moves apart from rewrites, mechanical changes apart from behavior), but default to small groups upfront: a lean PR clears the fixed, often-large per-review latency fast, so it merges sooner. See reference/stack-design.md.
- If splitting an existing large branch/PR, use the soft-reset method and the per-layer gate in reference/splitting.md.
- If a fix belongs to commits of one or several lower layers before review has started, fold it in with
git absorb(reference/absorb.md) instead of fixup commits. After review has started, never fold, amend or absorb: add anAddress review:commit on the owning layer and restack the layers above with a plain rebase. - If changing order, inserting a middle layer, retargeting trunk, resolving conflicts, or handling generated lockfiles, load the matching reference before running commands. For a whole-stack reshuffle of an open stack under review (new layers, a move split from its generalisation, a new order), use reference/reshuffle.md.
- Adding a layer on top needs no special procedure (
gh stack add, thensubmit --auto). Moving it to the middle afterwards is the same reorder as a middle insertion, so it saves nothing on a submitted stack. It only helps before the firstsubmit, becauseaddis scriptable andmodifyis TUI-only.
Cross-skill ownership
When another workflow skill uses gh-stack, ownership is split once:
- the domain skill decides whether consent covers an external mutation;
- the orchestrator decides when and by whom it runs, and journals it;
gh-stackdefines preconditions, exact commands, verification and recovery.
This skill never broadens consent granted by the active domain workflow. An active orchestrator may narrow delegation further than the standalone rules below.
Non-interactive agent rules
gh stack changes behavior when stdout is a TTY. In agent or CI contexts, avoid prompt/TUI commands and use these forms:
| Use | Avoid |
gh stack view --json | gh stack view |
gh stack submit --auto | gh stack submit (editor TUI) |
gh stack merge <target> --yes | gh stack merge <target> / gh pr merge |
gh stack init <branch>... | gh stack init |
gh stack add <branch> | gh stack add |
gh stack checkout <target> | gh stack checkout (picker) |
gh stack up / down / top / bottom | gh stack switch |
gh stack modify is TUI-only. submit without --auto opens a TUI editor in a terminal, and checkout without an argument opens a stack picker. When a human can drive a terminal, prefer asking them to run gh stack modify then gh stack submit --auto (see "Choose the route first" in reference/reordering-and-conflicts.md). Without a TTY, agents should use the documented fallbacks in reference/reordering-and-conflicts.md.
Safety gates
- Use one topology owner. A worker never invents a topology change or uses a different verb after an error. In standalone use, the owner may delegate one exact command only when the active workflow allows it and the brief includes verified preconditions, expected output and a stop-on-deviation rule. When an orchestrator agent coordinates workers, the orchestrator executes every mutating
gh stackcommand and push; workers edit, verify and optionally commit only. - Worktrees share one stack catalog (v0.2.0, Git 2.36+), but only the orchestrator changes the stack. State lives in
<common-dir>/gh-stack, sorebase,syncandmodifywork across worktrees and--continue/--abortrun from any worktree. Workers (subagents) still never rungh stackcommands that change the stack: the topology owner runs them from one worktree. See reference/troubleshooting.md. Streaming publication is branch-scoped Git, never
gh stack push. The latter pushes every active branch. When an active review workflow has proved one layer ancestry-stable and authorized its publication, the topology owner pushes only that ref with the journaled lease:git push --force-with-lease=<branch>:<recorded-remote-sha> \ <remote> <local-ref>:refs/heads/<branch>Do not run
gh stack push,syncorsubmitfor this incremental step. It changes no grouping or PR base. Re-gather remote heads afterwards, and reconcile local tracking before the next stateful stack operation.- Never
unstackto "fix" a stack, and never fuse separate stacks. If the local.git/gh-stacklooks stale or a PR seems to "belong to multiple stacks", do NOT reach forunstack/linkto force everything into one group. Fetch and compare every local/remote tip first. If tips diverged because the remote moved, do not sync, rebase or push; follow reference/syncing.md. Use sync only for non-divergent ordinary reconciliation. Fusing distinct stacks throws away each stack's number and its web-UI grouping. unstackon a stack that contains a merged PR is irreversible for the grouping. GitHub keeps the merged member but drops the open ones, and you cannot recreate the group:gh stack linkenforces base-ref chaining (each PR's base must equal the PR-below's head branch), and a merged bottom PR's head branch is deleted while its open successor correctly bases on trunk, so the link is rejected (HTTP 422). The web-UI view of "merged bottom + open successor" cannot be rebuilt. Do notunstacksuch a stack unless the user accepts losing that grouping. Observed with v0.2.1 (2026-10-23): the old stack keeps only the merged PRs, the open PRs are released without error, andgh stack link --base main <open PRs>then creates a new all-open stack. See reference/lessons.md.- Retargeting a stacked PR to trunk after its base merges is the canonical maintenance procedure, not blanket consent. Run it autonomously only when the active domain workflow or user instruction authorizes it. When authorized, and after journaling the server grouping, rebase the open successor of the merged base onto trunk (
git rebase --onto origin/<trunk> <old-base-tip>,--force-with-lease) and regroup on GitHub viagh stack unstack <open-server-stack#>+gh pr edit <bottom#> --base <trunk>+gh stack link --base <trunk> <b…>.unstackon an all-open stack is non-destructive (grouping recreates under a new number, tips and bases untouched), so there is no destructive-vs-safe choice within the authorized procedure: pick the stack-preserving regroup. This is the topology owner's routine, not worker improvisation, and it is distinct from the merged-member hazard above.gh pr edit --baseandlink/submitall 422 ("PullRequest.base is invalid") while the PR is still a member, sounstackfirst. See reference/trunk-retargeting.md. - Run
gh stack mergeonly on the user's explicit instruction to merge. - New PRs should be drafts unless the user explicitly asks otherwise: use
gh stack submit --autoand do not pass--open, because--openalso marks existing PRs ready for review. - When a repo has multiple remotes, set
git config remote.pushDefault originor pass--remote <name>to commands that support it.checkoutandtrunkhave no--remoteflag and rely on the config. - After
gh stack sync, verify withgh stack view --json; divergent local and remote stacks can printSync abortedwhile exiting 0. - If remote branches were rebased elsewhere, treat the remote as authoritative; do not
sync/rebase/pushstale local branches. Follow reference/syncing.md. - If the order of an already-submitted stack changed or a layer was inserted below an existing PR, do not submit it. Follow reference/reordering-and-conflicts.md to snapshot membership, push branches, guard ancestry, create missing draft PRs, unstack the all-open old grouping and link the complete chain.
- For generated lockfiles, regenerate and squash into the dedicated lockfile commit; do not hand-merge hunks. See reference/lockfiles.md.
Reviewing the whole stack
- Per-layer web review is blind to the stack as a whole; add one deep review over the full range. GitHub's automated PR review (Copilot web) and any per-PR reviewer only see each layer's own diff, whose base is the layer below, so nothing ever reads the feature end to end. That per-layer view structurally misses cross-layer defects: a fix landed in a lower layer that a higher layer silently re-breaks, an inconsistency between two layers, a term wired in one layer but consumed wrongly in another, or an invariant that only reads as wrong when the whole feature is seen at once. The blind spot is inherent to stacking, not a reviewer failing.
- Before submitting for review or merging, run one overall deep review across the full stack range in addition to the per-layer web reviews. Fetch the remote, verify the final PR heads, compute their merge-base with the gathered remote trunk and review
<merge-base-sha>...<top-headRefOid>. Reconcile findings back into the owning layer (edit the layer, re-cascade the rebase upward, force-push), never by squashing layers together to make one reviewable diff. - A long-running review workflow records this gate against the immutable merge-base/top-head pair. Any stack rewrite invalidates the record; rerun it before reporting convergence.
Quick command map
| Goal | Command |
| Start a stack | gh stack init [--base <trunk>] <branch> |
| Create/adopt layers | gh stack init <b1> <b2> <b3> |
| Add a layer from the top | gh stack add -m "msg" <branch> |
| View state | gh stack view --json |
| Navigate | gh stack up / down / top / bottom / trunk |
| Rebase | gh stack rebase [--no-trunk] (--no-trunk skips the trunk fetch/rebase) |
| Push branches only | gh stack push |
| Push + create/link PRs | gh stack submit --auto |
| Fetch/rebase/push/link | gh stack sync |
| Stateless API linking | gh stack link [--base <trunk>] <b…> |
| Pull a remote stack locally | gh stack checkout <n|PR|url> |
| Merge bottom-up | gh stack merge <stack#|PR#> --yes [--squash|--rebase|--merge] |
| Remove stack grouping | gh stack unstack [<stack#>] [--local] |
| Peel the top layer off (merge it separately) | unstack + init the kept layers + submit (see reordering-and-conflicts) |
For preconditions, side effects, atomicity, exit codes, and the view --json schema, read reference/commands.md.
Command shorthands
Invoked as /gh-stack <verb> [text]; the verb is the input's first token, and with no verb it runs ?. This skill exposes the shared core:
?: list these shorthands and the primary actions: design a stack, split a branch, submit, reorder, resolve conflicts, retarget trunk.status: report the current stack fromgh stack view --json: the layers, their order, each PR's target branch, and merge readiness.
Reference map
Load only the relevant file; each reference is linked directly from here.
- reference/commands.md: command semantics, setup, non-interactive forms, exit codes, JSON schema, source-of-truth/version policy.
- reference/stack-design.md: choosing layer order, branch naming, and one-stack/one-story guidance.
- reference/splitting.md: splitting a big branch/PR into layers with a per-layer verification gate.
- reference/reordering-and-conflicts.md:
modify, reordering, middle insertion, auto-merge trap, fallbacks, conflicts. - reference/reshuffle.md: reshuffling a submitted stack under review: readable diffs, local rebuild, per-layer verification, journal, publish order, realigning local state and PR text, rollback.
- reference/absorb.md: folding staged fixes into the right lower layers with
git absorb, then rebasing the layers above. - reference/syncing.md: reconciling local branches after the remote stack was rebased or force-pushed elsewhere.
- reference/trunk-retargeting.md: non-default or borrowed trunk, and moving back after the base PR merges.
- reference/lockfiles.md: generated/lockfile handling during stack rebases and reorders.
- reference/troubleshooting.md: upstream recovery recipes for conflicts, divergence, stack locks, interrupted modify, worktrees.
- reference/cleanup.md: pruning local stack branches and stale backups after a stack settles.
- reference/lessons.md: concise cross-repository planning, verification and rollback lessons.
- reference/legacy.md: pre-v0.1.0 workarounds kept only as history; use current commands first.
Upstream mirror policy
The upstream skill from github/gh-stack is pinned at d4ab7ab47e5b3e3708a27c8c42abcdf4bc321419 (skill v0.2.0, synced 2026-10-06). reference/commands.md, reference/stack-design.md, and reference/troubleshooting.md keep verbatim upstream blocks between <!-- upstream:begin --> / <!-- upstream:end -->; local notes live outside those markers. When behavior conflicts, prefer the installed command help and observed behavior, then the pinned upstream mirror, then local version-labelled exceptions, then legacy notes.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

