stacked-prs
Skill1 starsChanged 38 days agoMITView on GitHub
Stack mechanics for GitHub native Stacked PRs via the gh stack extension and the stacks REST API. Use when asked to stack, split a change into layers or dependent PRs, open stacked PRs, use gh stack, read stack state, sync or restack after trunk moves, or land the stack. Also the place babysit, shipping, and orchestrate playbooks delegate stack mechanics to.
- Commits and pushes
14 other projects use a version of this.
Adopted by
Most recently taken up by
- Integralist/agent-skillstheir own version, first seen Nov 6, 2026
- dbosk/claude-skillstheir own version, first seen Nov 1, 2026
- Mathews-Tom/armorytheir own version, first seen Nov 1, 2026
- Beakpoint-Insights/roosttheir own version, first seen Nov 1, 2026
- gsimone/skillstheir own version, first seen Oct 25, 2026
- azents/azentstheir own version, first seen Oct 23, 2026
Used with
Projects with it also use show-me, improve-codebase-architecture and 2 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.
AnasX7Skillshow-me
Help the user understand the current topic visually with concise diagrams, code-shape sketches, and focused HTML artifacts.
Also in 3 projects that use this
GoogleSkillimprove-codebase-architecture
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
Also in 3 projects that use this
GoogleSkillgrilling
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
Also in 3 projects that use this
SentrySkillskill-creator
Create new agent skills following the Agent Skills specification. Use when asked to "create a skill", "add a new skill", "write a skill", "make a skill", "build a skill", or scaffold a new skill with SKILL.md. Guides through requirements, writing, registration, and verification.
Also in 3 projects that use this
Other versions14 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 14
- Mathews-Tom/armory★ 340same name
- dgalarza/agent-skills★ 72same name
- Beakpoint-Insights/roost★ 32same name
- Integralist/agent-skills★ 23same name
- azents/azents★ 16same name
- d-oit/rust-2026-template★ 15same name
- malinskibeniamin/skills★ 4same name
- anis-dr/skills★ 3same name
- magnusrodseth/dotfiles★ 3same name
- zehuichan/vibe-harness★ 2same name
4 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 repository58 other files it gives its agents.
- architectSkill
- arenaSkill
- automate-meSkill
- benchmark-checklistSkill
- blast-radiusSkill
- browser-useSkill
- control-cliSkill
- control-uiSkill
- correctSkill
- create-verification-skillSkill
- cua-driverSkill
- deslopSkill
- figure-it-outSkill
- howSkill
- interrogateSkill
- maintain-verification-skillSkill
- no-commentsSkill
- poteto-modeSkill
- principle-attack-the-premiseSkill
- principle-boundary-disciplineSkill
- principle-build-the-leverSkill
- principle-encode-lessons-in-structureSkill
- principle-exhaust-the-design-spaceSkill
- principle-experience-firstSkill
- principle-explain-the-numberSkill
- principle-fix-root-causesSkill
- principle-foundational-thinkingSkill
- principle-guard-the-context-windowSkill
- principle-laziness-protocolSkill
- principle-make-operations-idempotentSkill
- principle-migrate-callers-then-delete-legacy-apisSkill
- principle-minimize-reader-loadSkill
- principle-model-the-domainSkill
- principle-never-block-on-the-humanSkill
- principle-outcome-oriented-executionSkill
- principle-prove-it-worksSkill
- principle-redesign-from-first-principlesSkill
- principle-separate-before-serializing-shared-stateSkill
- principle-sequence-verifiable-unitsSkill
- principle-small-door-big-roomSkill
- principle-subtract-before-you-addSkill
- principle-test-behavior-not-implementationSkill
- principle-tests-pay-rentSkill
- principle-type-system-disciplineSkill
- recallSkill
- reflectSkill
- setup-pstackSkill
- show-me-your-workSkill
- swarmSkill
- tddSkill
- teachSkill
- technical-writingSkill
- thermo-nuclear-code-quality-reviewSkill
- thermo-nuclear-reviewSkill
- thermosSkill
- typescript-best-practicesSkill
- unslopSkill
- whySkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 13 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 57
One topology writer per stack: Only one agent runs init, add, rebase, sync, push, submit, link, unstack, merge, and branch navigation.
- Very specific: line 141
No in-place reorder or removal.
“Common” is measured: kept by at least 6 in 10 of the 13 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
stacked-prs
A stack is an ordered chain of PRs in one repo. The bottom PR targets trunk, every other PR targets the branch below it, so a reviewer sees one layer's diff. gh stack prints it trunk-first:
(main) <- auth <- api <- frontendLeft is the bottom, right is the top. auth merges first. up moves toward the top, down toward trunk. Foundations go at the bottom.
Adapted from GitHub's official gh-stack agent skill (MIT, GitHub, Inc.; see LICENSE-gh-stack), with pstack conventions on top. GitHub stacked PRs are a public preview.
When to stack
Stack when the change is large or spans concerns, each layer fits in one sentence, and the bottom layer is a foundation the upper ones need. Prefer five narrow PRs to one large one. Unrelated work gets its own stack. Layer design lives in references/stack-design.md.
Do not stack for a single-concern change (one PR), for a fork (stacks are same-repo only), or when the repo has not enabled the preview (gh stack submit exits 9). Then fall back to independent PRs off trunk, or a base-branch chain opened with gh pr create --base <parent> and landed one at a time. Say so once.
Setup
gh extension install github/gh-stack
git config rerere.enabled true # replay conflict resolutions
git config remote.pushDefault origin # required with more than one remote
gh auth statusNeeds Git 2.36+. gh stack --help working means the extension is installed. Probe the repo with gh api -H 'X-GitHub-Api-Version: 2026-03-10' repos/{owner}/{repo}/stacks --silent. A 404 means the preview is off (or no access). Exit 9 from a gh stack command says the same.
Non-interactive use
gh stack branches on whether stdout is a TTY. Under a PTY the bare commands open prompts or a TUI and block forever. Always pass these.
| Always run | Never run bare | Why |
gh stack view --json | gh stack view | TUI under a PTY |
gh stack submit --auto --open | gh stack submit | prompts for a title per PR |
gh stack merge <target> --yes | gh pr merge | gh pr merge cannot merge a stack |
gh stack init <branch>... | gh stack init | prompts for names |
gh stack add <branch> | gh stack add | prompts, fails even piped |
gh stack checkout <target> | gh stack checkout | selection menu |
gh stack up / down / top / bottom | gh stack switch | menu only |
| none | gh stack modify | TUI only. Restructure with unstack then init |
gh stack sync --prune or gh stack sync --remote <name> | gh stack sync | prompts under a TTY: the prune prompt, the divergence prompt, the remote picker |
With several remotes pass --remote <name> to push, submit, sync, rebase, link unless remote.pushDefault is set. checkout and trunk have no --remote and need the config. checkout <pr> blocked by a different local stack covering those branches needs gh stack unstack --local first. --print-path on navigation locates a branch held by another worktree without stealing it. Check the exit status before using the path.
pstack conventions
- PRs open ready.
gh stack submit --auto --open.--openalso readies existing PRs. - Titles and bodies come after submit.
--autogenerates titles from commits or branch names and there is no flag to override. Rungh pr edit <n> --title "<type>(<scope>): <summary>" --body-file <file>per PR. Conventional-commits title, briefing body, per theopening-a-prplaybook inpoteto-mode. Squash bodies become the commit body, so keep them short. - One topology writer per stack. Only one agent runs
init,add,rebase,sync,push,submit,link,unstack,merge, and branch navigation.gh stackserializes on a clone-wide lock (exit 8) but that does not make concurrent writers safe. - Workers commit on their own layer only, in their own worktree, and never run the mutating commands above. The topology owner then runs
gh stack rebase --upstackandgh stack push. - Review is thermos per layer. Scope spec for one layer is
git diff <parent-branch>...<branch>(the parent of the bottom layer is trunk), the PR number, and the names of layers below for context. One scope per layer, never the whole stack diff. - Nothing lands without an independent per-PR verdict. Merging PR N lands everything below it, so the merge target is the highest PR of the contiguous verified bottom-up run.
- Frontier. The ordered unmerged PRs with head SHAs, recomputed after every merge or mutation. GitHub base refs are authoritative and retarget on their own. Never hand-retarget inside a stack with
gh pr edit --base. - Babysit, shipping, and orchestrate link here for mechanics. They keep their own loop logic.
Core loop
gh stack init auth # create stack, check out first branch
git add ... && git commit -m "feat(auth): add middleware"
gh stack add api # next layer, branched from current
git add ... && git commit -m "feat(api): add routes"
gh stack submit --auto --open # push all, open ready PRs, link the stack
gh pr edit 101 --title "..." --body-file ... # per PR, then gh stack view --jsonBranch names are verbatim (gh stack add refactor/foo creates refactor/foo). Create the stack before writing code. Never implement everything on trunk and split later.
Editing a lower layer. Check out its owner, never commit a lower concern on the top branch.
gh stack down # or: gh stack checkout api
git add ... && git commit -m "fix(api): handle empty body"
gh stack rebase --upstack # replay layers above
gh stack top && gh stack pushTrunk moved or a lower PR merged. Run gh stack sync --prune when pruning merged local branches is wanted, otherwise gh stack sync --remote <name> (fetch, reconcile with GitHub, rebase, push, refresh PR state). Treat sync as potentially interactive in agent runs. When you need certainty that nothing will prompt, use gh stack rebase then gh stack push instead. Divergence non-interactively prints both chains, changes nothing, exits 0 with Sync aborted. See references/troubleshooting.md.
Reading state
gh stack view --json writes JSON to stdout, status text to stderr. Branch on exit codes, not text.
trunk, currentBranch
branches[] name, head?, base?, isCurrent, isMerged, isQueued, needsRebase
branches[].pr number, url, state (OPEN | MERGED | QUEUED), absent without a PR. Never CLOSED: a closed PR still reports OPENBottom to top. head and base are saved SHAs and may be stale or absent; use git rev-parse <name> for live SHAs.
Frontier without a checkout ($PR is any layer):
gh api -H 'X-GitHub-Api-Version: 2026-03-10' "repos/{owner}/{repo}/stacks?pull_request=$PR" \
--jq '.[0].pull_requests // [] | map(select(.merged_at == null) | {number, state, draft, ref: .head.ref, sha: .head.sha})'view --json cannot show a closed PR, so cross-check with the REST frontier above or gh pr view <n> --json state. A closed entry blocks everything above it. REST, GraphQL, webhook, and Actions details are in references/api.md.
Landing
gh stack merge 42 --yes --squash # PR 42 and every unmerged PR below it, atomic
gh stack merge 7 --yes --squash # every unmerged PR in stack #7PRs must be open and non-draft, history linear, protections evaluated against the stack base. gh stack merge cannot pin a head SHA, so re-read the target PR's head SHA just before merging and confirm it is the SHA that got the verdict, or use the merge-async REST call with sha (see references/landing.md). Auto-merge is not supported for stacked PRs. A merge queue on the base branch takes the whole stack and ignores method flags. After the bottom merges GitHub retargets the next PR to trunk and rebases the rest, then gh stack sync --prune. Merge exit codes, merge queue behavior, the merge-async REST flow, partial failures, and the unsigned "Rebase stack" button caveat live in references/landing.md.
CI cost
Workflows run for every PR in the stack. Gate expensive jobs on stack.position == stack.size (top) or stack.base.ref == base.ref (lowest unmerged), after a github.event.pull_request.stack != null check. See references/api.md.
Exit codes
| Code | Meaning | Recovery |
| 0 | ok | none. Note sync exits 0 on Sync aborted |
| 1 | generic | read stderr |
| 2 | not in a stack | init, or checkout <target> |
| 3 | rebase conflict | resolve, git add, gh stack rebase --continue. After sync everything was restored, rerun gh stack rebase first |
| 4 | GitHub API failure | gh auth status, retry |
| 5 | bad arguments | see <cmd> --help |
| 6 | ambiguous stack | checkout a branch unique to the stack |
| 7 | rebase in progress | --continue or --abort |
| 8 | stack file locked | retry after ~5s. Never delete lock files |
| 9 | stacked PRs not enabled | tell the user, use the fallback |
| 10 | modify recovery | gh stack modify --abort |
Constraints
- Strictly linear. One parent, at most one child, max 100 PRs. Use separate stacks for parallel work.
- No in-place reorder or removal.
gh stack unstackthengh stack init --base <trunk> <branches...>thensubmit. Existing PRs survive. unstacknever deletes PRs or branches. Merged and queued PRs stay in the stack.gh stack <cmd> --helpis authoritative for flags.gh stack help <cmd>only prints top-level help.
References
references/stack-design.mdbefore creating a stack or choosing layers.references/commands.mdwhen a command fails or you need preconditions, atomicity, side effects.references/landing.mdfor merge, merge queue, merge-async REST, partial failures.references/api.mdfor REST, GraphQL, webhooks, Actions expressions.references/troubleshooting.mdfor conflicts, divergence, restructuring, closed mid-stack PRs, locks.
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.

