gh-stack
Skill1 starsChanged 56 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.
16 other projects use a version of this.
Adopted by
Most recently taken up by
- devantler-tech/ksailtheir own version, first seen Oct 3, 2026
- github/gh-stacktheir own version, first seen Oct 1, 2026
- T0mSIlver/skillstheir own version, first seen Sep 29, 2026
- sd0xdev/sd0x-harnesstheir own version, first seen Sep 26, 2026
- LinnJS/skillstheir own version, first seen Sep 25, 2026
- flightctl/ai-workflowstheir own version, first seen Sep 21, 2026
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 16
- vercel/next.js★ 144ksame name
- github/gh-stack★ 1.6ksame name
- theexperiencecompany/gaia★ 306same name
- sd0xdev/sd0x-harness★ 191same name
- devantler-tech/ksail★ 166same name
- iuhoay/skills★ 53same name
- flightctl/ai-workflows★ 9same name
- sherifabdlnaby/skills★ 8same name
- kelvincushman/orphus★ 4same name
- zazzcode/zazz-skills★ 4same name
6 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 repository51 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agentic-workflowsSkill
- asking-questionsSkill
- branch-context-consumerSkill
- broSkill
- browser-accessSkill
- browser-controlSkill
- 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-lazy-contextSkill
- home-assistant-list-componentsSkill
- home-assistant-lit-renderingSkill
- human-step-guideSkill
- import-external-skillSkill
- lit-renderingSkill
- maintain-docsSkill
- 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
- testingSkill
- to-questionnaireSkill
- types-enforce-tsSkill
- wranglerSkill
- writing-dot-skillsSkill
- writing-styleSkill
The file
Show its rules and text
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 16 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 15
Use GitHub's official gh stack extension for linear stacks of dependent branches and pull requests.
- Very specific: line 25
Do not commit through gh stack add -m, -A, or -u, and never run raw git commit.
- Very specific: line 28
Treat push, submit, sync, and branch arguments passed to link as push operations.
- Very specific: line 34
Treat rebase, modify, unstack, and rebuilding local tracking as history or stack-structure rewrites.
- Very specific: line 37
Run merge only after explicit merge authorisation for the named stack or PR range.
- Very specific: line 41
Never use plain force push.
- Distinctive: line 46
Avoid commands that open prompts or TUIs:
- Very specific: line 48
Use gh stack view --json, never bare view or view --short.
- Very specific: line 49
Treat view as best-effort PR-state refresh as well as inspection.
- Very specific: line 52
Do not run interactive modify.
- Very specific: line 54
If multiple remotes exist, pass --remote <name> where supported.
- Very specific: line 109
When authorised to commit, use dot git-commit on the exact paths.
- Distinctive: line 110
Add the next branch from the current top:
- Distinctive: line 116
When the user separately authorises pushing and the generated PR metadata, submit non-interactively, then verify:
- Very specific: line 125
Do not use --open unless the user asks to mark them ready for review.
- Very specific: line 138
Commit only through the authorised dot git-commit workflow.
- Distinctive: line 152
Use it only with explicit push and rewrite authorisation.
- Very specific: line 154
After a squash merge, sync can replay remaining branches onto the updated trunk.
- Very specific: line 166
Follow git-context for conflict resolution.
- Distinctive: line 169
If local and remote stack composition diverge, stop and present the actual local/remote chains.
- Very specific: line 185
If a modification conflicts, resolve and stage the files in the worktree named by the conflict.
- Distinctive: line 192
When a stack must be reordered, inserted into, renamed, folded, or have a layer removed:
- Very specific: line 197
Use gh stack unstack (or --local when preserving GitHub grouping).
- Very specific: line 206
Verify branch order, heads, bases, and PR associations with gh stack view --json.
- Distinctive: line 211
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 16 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.
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.

