skills/github-pr-stack-convention/SKILL.md
Stacked PR lifecycle: creating, retargeting, rebasing and merging PRs that depend on other PRs. Use when working with PRs based on other PRs or rebasing branches that have dependents. Pairs with github-pr-merge-convention for general merge strategy.
npx skillsauth add jitsusama/agentic-harness.pi github-pr-stack-conventionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A PR stack is a chain of pull requests where each one's branch is based on the previous one's branch. They let you break large changes into reviewable pieces while keeping a linear dependency order. This skill covers how to detect, create, retarget and merge stacked PRs safely.
For merge strategy, branch deletion defaults and
post-merge local cleanup, see github-pr-merge-convention.
This skill adds the stack-specific constraints on top
of those defaults.
Before merging or rebasing any PR, check whether it's part of a stack. A PR is in a stack if either condition is true:
main
or a release branch).Check both directions:
# What is this PR's base?
gh pr view NUMBER --json baseRefName --jq .baseRefName
# Does anything depend on this PR's branch?
gh pr list --state open --json baseRefName,headRefName,number \
--jq '.[] | select(.baseRefName == "BRANCH_NAME")'
If either check reveals a dependency, apply the rules below. If neither does, it's a standalone PR and none of this applies.
When creating a PR that depends on another PR's branch:
main.gh pr create always uses the current checkout as
the head branch, regardless of --head. Confirm
with a separate bash call:
git branch --show-current
gh pr create --base predecessor-branch ...
gh pr view NUMBER --json headRefName --jq .headRefName
👉
link per github-pr-format.Before merging any PR in a stack, verify the entire
chain is wired correctly. Every PR's base should point
to the previous PR's head branch, with the bottom of
the stack pointing to main:
gh pr list --state open \
--json number,baseRefName,headRefName \
--jq 'sort_by(.number)[] |
"#\(.number) base=\(.baseRefName) head=\(.headRefName)"'
If any PR in the stack has a wrong base (for example,
pointing to main when it should point to its
predecessor), fix the base before merging anything:
gh pr edit NUMBER --base correct-base-branch
Fix every miswired base in the chain first. Then start merging.
Always merge bottom-up: the PR closest to main first,
then the next one up, and so on. Never merge a PR in
the middle or top of a stack before its predecessors.
If the repository has the "Automatically delete head
branches" setting enabled (delete_branch_on_merge: true), merge each PR without --delete-branch:
gh pr merge NUMBER --merge
GitHub handles branch deletion as part of its internal
merge flow, which triggers auto-retarget: any open PR
that had the deleted branch as its base gets retargeted
to the merged PR's target (usually main). This is the
safest and simplest path through a stack.
After each merge, wait for GitHub to finish retargeting and recompute mergeability before merging the next PR:
gh pr view NEXT_NUMBER \
--json baseRefName,mergeable,mergeStateStatus \
--jq '"\(.baseRefName) | \(.mergeable) | \(.mergeStateStatus)"'
Don't merge until the base shows main (or whatever the
stack's root target is), mergeable shows MERGEABLE and
status shows CLEAN.
To check whether the setting is enabled:
gh api repos/OWNER/REPO --jq .delete_branch_on_merge
To enable it (requires admin access):
gh api repos/OWNER/REPO -X PATCH \
-f delete_branch_on_merge=true
If the repository does not have auto-delete enabled and you can't change the setting, use a three-step flow for each PR in the stack:
--delete-branch:
gh pr merge NUMBER --merge
gh pr edit NEXT_NUMBER --base main
git push origin --delete BRANCH_NAME
After step 3, verify the next PR is in good shape before continuing:
gh pr view NEXT_NUMBER \
--json baseRefName,mergeable,mergeStateStatus \
--jq '"\(.baseRefName) | \(.mergeable) | \(.mergeStateStatus)"'
Repeat for each PR in the stack, bottom to top.
--delete-branch Is Broken for StacksDo not use gh pr merge --delete-branch when merging
stacked PRs. The CLI's --delete-branch flag deletes
the branch via a separate API call after the merge
completes. GitHub treats this the same as git push origin --delete: a raw branch deletion that
auto-closes every open PR that uses the deleted
branch as its base. Those PRs can't be reopened; they
must be recreated from scratch.
The auto-retarget behaviour that makes stack merging
smooth only happens when GitHub's own internal flow
deletes the branch (the web UI merge button or the
delete_branch_on_merge repo setting). No external
API call can trigger it. This is
cli/cli#1168,
open since 2020.
For standalone PRs (no dependents), --delete-branch
is still fine. The danger is specific to PRs whose
branch is another PR's base.
After the full stack is merged, follow the cleanup steps
from github-pr-merge-convention, batching all stale
branches together.
When the bottom of a stack needs a rebase onto main,
rebase bottom-up: rebase the bottom branch first, then
rebase each subsequent branch onto the one below it.
Force-push each branch after rebasing.
Never rebase a branch in the middle of a stack without rebasing everything above it. The branches above will have stale merge bases and will conflict or silently carry wrong code.
--delete-branch with gh pr merge when
the PR has dependents. It auto-closes them
permanently. See "Why --delete-branch Is Broken
for Stacks" above.MERGEABLE | CLEAN.development
Structure of a quest README and the documents that live under it: frontmatter shape, the four core and four optional body sections, emoji glyphs, ID format, alias notation, Cast bullets and Journey entries. Use when writing or editing a quest README, a plan, research, brief or report document under a quest. Pairs with quest-convention for choices like kind, promotion and reordering. Follow the prose-standard for voice.
tools
Operational conventions for the quest system: when to use a quest versus a subquest versus a sidequest, when to scaffold a plan or research document, how to reorder priorities, when to add optional sections, when to conclude versus retire, the resuscitate pattern. Use when driving the quest tool, deciding kind, promoting or parking work, or organising a project as quests. Pairs with quest-format for the on-disk shape.
development
Markdown structure rules: Title Case headings with their exceptions, the line-width target and its legitimate exceptions, reference-style links, fenced code blocks with language tags, tables and lists. Use when writing or editing any markdown file (README, AGENTS, docs, plans, skill files), or when adding a heading, link, table or code block. Owns markdown structure; pairs with prose-standard, which owns voice, grammar, spelling and punctuation.
tools
How to measure whether convention corrections keep recurring in the pi session logs, by category and by week. Use to record a baseline before the convention gates take effect and to re-run afterwards to confirm the recurring categories bend down. Pairs with the convention gates (pr-guardian, issue-guardian, commit-guardian, slack-integration) and the convention-context extension.