land-stack
Installation
SKILL.md
Land stack
Merges a stack PR by PR, never with GitHub's "Squash and merge stack" button, which folds every layer into one operation. Each layer lands as its own squash commit, and the next layer is checked before it merges.
Merging is outward-facing and cannot be undone, so this runs only on the user's explicit request, for the stack they named.
Before merging
- List the stack bottom to top:
gh stack view --jsonwhen the stack is checked out, else read each PR'sbaseRefNamefromgh pr view <n> --json number,title,baseRefName,mergeable,mergeStateStatus,reviewDecision,isDraftand follow the bases down to the trunk. - Find the ready layers: walk up from the bottom and stop at the first layer that is a draft, not
MERGEABLE, or has areviewDecisionother thanAPPROVED. Every layer below it lands; it and every layer above stay open, even ones that are ready, since a layer cannot land before the one under it.UNSTABLEalone is fine: it means a non-required check is pending or failing, and branch protection decides at merge time. When the bottom layer is not ready, stop and report. - Tell the user in one line the PRs that will land, in order, and the first one that stays and why, then start; do not ask again.
Merging
For each ready layer, bottom first:
gh stack merge <pr> --yes --squashmerges that PR alone, since it is the bottom of what remains. In a repository with no GitHub stack,gh pr merge <pr> --squashdoes the same. Use the merge method the user named, if any.- Confirm it:
gh pr view <pr> --json state,mergeCommitreadsMERGED, and note the merge commit. - Before the next layer, wait a few seconds for GitHub to retarget it, then confirm its base is the trunk and its
filesare only its own. A layer that still carries the merged layer's changes, or showsCONFLICTING, stops the run.