Manage dependent PRs with gh stack. The caller supplies branches in order;
ask if the user names none. Run only requested steps (for example, step 2
alone to prepare a layer). Before switching, adding, syncing, rebasing, or
submitting layers, commit pending work with the commit skill so it cannot land
in the wrong layer.
Set up the stack
-
Check the extension. Run
gh stack --help. If missing, ask beforegh extension install github/gh-stack. -
Set up the requested stack:
- New stack:
gh stack init --base <trunk> <bottom-branch>, then rungh stack add <branch>for each higher layer as work reaches it. - Existing branches:
gh stack init --base <trunk> <bottom> … <top>. - Existing stack:
gh stack checkout <stack-number-or-branch>.
Setup is complete when
gh stack view --shortlists layers bottom to top. - New stack:
Prepare and submit PRs
- Write each layer's PR description using
PR-DESCRIPTION.md. Target the layer's base:
trunk for the bottom layer and the layer below for each higher layer. For
githubor an issue reference (#<n>or URL), read and follow GITHUB-ISSUES.md to use GitHub Issues and Issue Artifacts instead ofprojects/. Show every title and body, then wait for the user's approval. - Submit with
gh stack submit --auto --opento push and open PRs ready for review;--autoalone opens drafts. Then write each approved body to a temporary file and rungh pr edit <branch> --title "<title>" --body-file <file>. Complete when GitHub shows each approved title and body.
Maintain and merge
-
Keep the stack current. Run
gh stack syncafter trunk or a lower layer changes. Usegh stack rebaseto resolve conflicts andgh stack modifyto fold, reorder, insert, or rename layers. -
Merge bottom to top only. Merge only when every layer being merged has passing
gh pr checks <PR>and approved reviews. If a check fails, fix it on that layer and resubmit. Rungh stack merge --yes --<squash|rebase|merge>using the repository's merge style; pass a PR number to merge only through that layer. Then rungh stack sync --prune.If branch protection blocks the merge, merge each PR manually from the bottom up, then run
gh stack sync --prune. Merging is complete when the merged layers are in trunk.


