gh-stack
Skill1 starsChanged 20 days agoApache-2.0View on GitHub
Manage stacked branches and pull requests with GitHub's `gh stack` extension. Use when work involves stacked PRs, dependent branches, stack creation, navigation, submission, synchronisation, rebasing, restructuring, linking, or merging.
We split this skill into the rules it gives an agent
25 rules. 0 are common, 7 are distinctive, and 18 are very specific to this project.
0
Common
Most of the 40 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
18
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 10
Use GitHub's official gh stack extension for linear stacks of dependent branches and pull requests.
- Very specific: line 20
Do not commit through gh stack add -m, -A, or -u, and never run raw git commit.
- Very specific: line 23
Treat push, submit, sync, and branch arguments passed to link as push operations.
- Very specific: line 29
Treat rebase, modify, unstack, and rebuilding local tracking as history or stack-structure rewrites.
- Very specific: line 32
Run merge only after explicit merge authorisation for the named stack or PR range.
- Very specific: line 36
Never use plain force push.
- Distinctive: line 41
Avoid commands that open prompts or TUIs:
- Very specific: line 43
Use gh stack view --json, never bare view or view --short.
- Very specific: line 44
Treat view as best-effort PR-state refresh as well as inspection.
- Very specific: line 47
Do not run interactive modify.
- Very specific: line 49
If multiple remotes exist, pass --remote <name> where supported.
- Very specific: line 104
When authorised to commit, use dot git commit on the exact paths.
- Distinctive: line 105
Add the next branch from the current top:
- Distinctive: line 111
When the user separately authorises pushing and the generated PR metadata, submit non-interactively, then verify:
- Very specific: line 120
Do not use --open unless the user asks to mark them ready for review.
- Very specific: line 133
Commit only through the authorised dot git commit workflow.
- Distinctive: line 147
Use it only with explicit push and rewrite authorisation.
- Very specific: line 149
After a squash merge, sync can replay remaining branches onto the updated trunk.
- Very specific: line 161
Follow git-context for conflict resolution.
- Distinctive: line 164
If local and remote stack composition diverge, stop and present the actual local/remote chains.
- Very specific: line 180
If a modification conflicts, resolve and stage the files in the worktree named by the conflict.
- Distinctive: line 187
When a stack must be reordered, inserted into, renamed, folded, or have a layer removed:
- Very specific: line 192
Use gh stack unstack (or --local when preserving GitHub grouping).
- Very specific: line 201
Verify branch order, heads, bases, and PR associations with gh stack view --json.
- Distinctive: line 206
Before merging, verify every selected PR and every layer below it is open, non-draft, approved, current, and passing required checks.
“Common” is measured: kept by at least 6 in 10 of the 40 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
GitHub Stacks
Use GitHub's official gh stack extension for linear stacks of dependent
branches and pull requests. Each branch builds on the branch below it, and each
pull request targets that immediate parent so reviewers see one layer's diff.
Load git-context for branch and rebase operations. Load dot-git-commit only
after the user explicitly requests a commit or push.
Safety And Authorisation
- Inspect with
gh stack view --jsonbefore and after every mutation. - Do not commit through
gh stack add -m,-A, or-u, and never run rawgit commit. Commit only after explicit authorisation throughdot git commit, following thedot-git-commitskill. - Treat
push,submit,sync, and branch arguments passed tolinkas push operations. Run them only when the user explicitly authorises that push. submitandlinkcan create pull requests and generate or change titles, descriptions, and base branches. Obtain explicit consent for those specific PR changes before running them; permission to create a PR alone does not authorise its description.- Treat
rebase,modify,unstack, and rebuilding local tracking as history or stack-structure rewrites. Run them only when requested or when the user approves the explained recovery operation. - Run
mergeonly after explicit merge authorisation for the named stack or PR range. Never infer merge permission from approval to push or submit. - Preserve unrelated worktree changes. Structural operations require a clean tree; do not stash, discard, or absorb user changes without permission.
- Never use plain force push. Stack pushes use per-branch
--force-with-lease; stop if a lease is rejected.
Agent-Safe Operation
Avoid commands that open prompts or TUIs:
- Use
gh stack view --json, never barevieworview --short. - Treat
viewas best-effort PR-state refresh as well as inspection. - Give branch names to
initandadd. - Give a stack number, PR number, PR URL, or branch to
checkout. - Do not run interactive
modify. Explain the intended structure and use the explicit non-interactive recovery path only after approval. - If multiple remotes exist, pass
--remote <name>where supported. Do not changeremote.pushDefaultmerely to avoid a prompt.
The extension must be installed and authenticated:
gh extension install github/gh-stack
gh stack --helpInstallation is a separate system change and requires the user's request or
approval. Verify command flags against live help because gh stack is in
public preview.
Choose The Right Operation
| Intent | Command | Important effect |
| Inspect local stack | gh stack view --json | Read-only |
| Start/adopt local tracking | gh stack init --base <trunk> <branches...> | Creates/adopts branches |
| Add a top layer | gh stack add <branch> | Creates and checks out a branch |
| Navigate | gh stack up, down, top, bottom, trunk | Changes checkout |
| Check out known stack | gh stack checkout <target> | Fetches remote stack when target is a stack/PR |
| Push tracked branches | gh stack push --remote <remote> | Pushes active branches with leases |
| Create/update PR stack | gh stack submit --auto --remote <remote> | Pushes, creates/updates PRs and remote stack |
| Routine reconciliation | gh stack sync --remote <remote> | Fetches, may rebase, pushes, and updates remote stack |
| Cascade history | gh stack rebase [--upstack|--downstack] | Rewrites stack branch history |
| Link externally managed branches/PRs | gh stack link ... | Remote-only tracking; may push/create/retarget PRs |
| Restructure | gh stack modify | Interactive; do not drive as an agent |
| Remove tracking/grouping | gh stack unstack [--local] | Removes local and optionally remote stack state |
| Merge | gh stack merge <stack-or-pr> --yes <method> | Merges an authorised prefix or stack |
link does not establish local stack tracking. Use it for branches managed by
another tool or when the user explicitly wants remote-only linking. Use
init/submit for a locally managed stack.
For numeric checkout targets, resolution is stack number, then PR number, then branch name. Prefer an explicit PR URL or branch when a number could be ambiguous.
Build A Stack
- Plan one coherent story in dependency order before implementing it, and
create the stack first when the work is already known to need layers.
Foundational changes belong below their consumers; unrelated work belongs in
another stack. Prefer
<topic>/<concern>branch names unless repository conventions differ. Confirm the worktree and branch context, then initialise with explicit branch names:
gh stack init --base <trunk> <bottom-branch> [higher-branches...]- Implement and verify one independently reviewable layer at a time.
- When authorised to commit, use
dot git commiton the exact paths. Add the next branch from the current top:
gh stack add <next-branch>When the user separately authorises pushing and the generated PR metadata, submit non-interactively, then verify:
gh stack submit --auto --remote <remote> gh stack view --json
New PRs created with --auto default to draft unless --open is supplied.
Do not use --open unless the user asks to mark them ready for review.
init also enables Git rerere for the repository. Do not make additional Git
configuration changes without authorisation. If every PR in the submitted
stack has already merged, submission creates a new stack for remaining
branches.
Fix A Lower Layer
Make a correction on the branch that owns it, not as an upstack workaround:
- Navigate to the owning branch with
down,bottom, or explicitcheckout. - Make and verify the correction.
- Commit only through the authorised
dot git commitworkflow. With approval to rewrite the upstack branches, run:
gh stack rebase --upstack- With separate push authorisation, run
gh stack push, then verify withgh stack view --json.
Synchronise And Recover
gh stack sync performs fetch, reconciliation, possible cascading rebase,
push, PR-state sync, and remote-stack sync. It is not a read-only status check.
Use it only with explicit push and rewrite authorisation.
After a squash merge, sync can replay remaining branches onto the updated
trunk. If it reports a conflict, it restores the branches and exits with code
3. Then use the explicit rebase workflow:
gh stack rebase
# resolve files and stage only the resolutions
gh stack rebase --continue
# or restore the pre-rebase state
gh stack rebase --abortFollow git-context for conflict resolution. Do not use raw interactive rebase
continuation or editor workarounds when the extension owns the operation.
If local and remote stack composition diverge, stop and present the actual local/remote chains. Do not automatically choose the remote, delete the remote stack, or unstack. Those choices can discard tracking decisions.
Worktrees And Distributed Modify
rebase and sync update affected clean worktrees. They do not auto-stash or
create or remove worktrees. Paused operations use their recorded worktree owners
for recovery.
modify remains TUI-only and must not be launched by an agent. It now supports
stack branches checked out across worktrees. It checks affected worktree owners
before applying changes; unrelated and read-only worktrees are left alone, and
unoccupied branches use the initiating worktree. Dropped and folded source
branches and their worktrees are preserved.
If a modification conflicts, resolve and stage the files in the worktree named
by the conflict. gh stack modify --continue and --abort can be invoked from
any linked worktree, but operate in the recorded owners. No worktree is
automatically stashed, created, or removed.
Restructure Without The TUI
When a stack must be reordered, inserted into, renamed, folded, or have a layer removed:
- Show the current
view --jsonstate and the proposed final branch order. - Obtain explicit approval for local/remote unstacking and history rewrites.
- Use
gh stack unstack(or--localwhen preserving GitHub grouping). Recreate local tracking with explicit ordered branches:
gh stack init --base <trunk> <bottom> <middle> <top>- Rebase as needed, then obtain explicit push and PR-metadata consent before
submit --auto. - Verify branch order, heads, bases, and PR associations with
gh stack view --json.
Merge
Before merging, verify every selected PR and every layer below it is open, non-draft, approved, current, and passing required checks. Then require an explicit stack number or PR endpoint and merge method:
gh stack merge <stack-number-or-pr-number> --yes --squashWithout a merge queue, the selected range is all-or-nothing. With a merge queue, the PRs are enqueued together but may land in separate groups, and the queue chooses the merge method.
Exit Codes
| Code | Meaning | Response |
| 2 | Not in a stack | Inspect context; initialise only when requested |
| 3 | Rebase conflict | Resolve and rebase --continue, or abort |
| 4 | GitHub API failure | Report authentication/API failure; do not guess |
| 5 | Invalid arguments | Check live help |
| 6 | Branch belongs to multiple stacks | Check out a non-shared branch explicitly |
| 7 | Rebase already in progress | Continue or abort the existing operation |
| 8 | Stack locked | Stop; another process owns the stack |
| 9 | Stacked PRs unavailable | Report repository/platform availability |
| 10 | Interrupted modify | Run modify --abort only with recovery approval |
Limitations
- Stacks are linear and all branches must live in the same repository.
linkis additive and does not remove existing PRs from a remote stack.- Branch arguments to
linkmay be pushed automatically. submitgenerates PR titles and descriptions; edit them only with separate, specific user consent.pushandsubmitare not atomic across every branch. Inspect partial success before retrying.- GitHub's server-side rebase can create unsigned commits. Use the local extension workflow when signed commits are required.
Other versions41 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 41
- vercel/next.js★ 143ksame name
- remotion-dev/remotion★ 70ksame name
- CherryHQ/cherry-studio★ 53ksame name
- Arize-ai/phoenix★ 12ksame name
- trycompai/crm★ 11ksame name
- CherryHQ/cherry-studio-app★ 4ksame name
- dotnet/macios★ 2.9ksame name
- dotnet/android★ 2.1ksame name
- github/gh-stack★ 1.7ksame name
- NVIDIA-NeMo/Gym★ 1.3ksame name
31 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.
Used alongsideProjects with it also use gh-create-pr, gh-commit and 7 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
bmsuisseSkillprek
Set up code formatting and pre-commit hooks using prek (fast Rust-based alternative to pre-commit) with prek.toml config. Use whenever the user wants to configure prek, add formatters, set up pre-commit hooks, or enforce code style. Triggers on "set up prek", "add formatting", "configure formatters", "pre-commit setup", "add ruff", "set up biome", "configure sqlfmt". Works on new and existing projects. Always use when init-app-stack has just run.
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
In this repository50 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agentic-workflowsSkill
- asking-questionsSkill
- broSkill
- browser-accessSkill
- change-review-handoffSkill
- changeset-scopeSkill
- check-skill-updatesSkill
- chillSkill
- cleanup-unnecessary-variablesSkill
- code-reviewSkill
- decision-modelsSkill
- diagnoseSkill
- effect-principlesSkill
- evidence-firstSkill
- git-contextSkill
- github-development-rulesetsSkill
- github-repository-setupSkill
- grillingSkill
- handoffSkill
- herdr-workflowsSkill
- home-assistant-frontendSkill
- home-assistant-lit-renderingSkill
- human-step-guideSkill
- import-external-skillSkill
- lit-renderingSkill
- maintain-docsSkill
- npm-jsr-first-publishSkill
- opencode-effectSkill
- pitchfork-dev-serversSkill
- pkexec-rootSkill
- planSkill
- release-oxlint-rulesSkill
- remove-single-use-functionsSkill
- researchSkill
- retroSkill
- safe-process-signalsSkill
- session-coordinationSkill
- shared-workflowsSkill
- show-meSkill
- skill-prefixesSkill
- staged-implementationSkill
- task-focusSkill
- task-runnersSkill
- testingSkill
- to-questionnaireSkill
- types-enforce-tsSkill
- wranglerSkill
- writing-dot-skillsSkill
- writing-styleSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

