stacked-prs-gh-cli

Manages dependent GitHub pull request stacks using plain gh CLI and git rebase.

Updated Jun 30, 2026
One-click install
npx skills add https://github.com/Codeseys-Labs/agentic-sdlc --skill stacked-prs-gh-cli-codeseys-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: stacked-prs-gh-cli
Source: https://github.com/Codeseys-Labs/agentic-sdlc/tree/main/plugin/skills/stacked-prs-gh-cli
Command: npx skills add https://github.com/Codeseys-Labs/agentic-sdlc --skill stacked-prs-gh-cli-codeseys-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Maintaining a stack of dependent GitHub pull requests is error-prone: when a parent PR merges, is rewritten, or is abandoned, every child PR must be retargeted and rebased without losing commits, racing other writers, or deleting branches still in use. This Skill provides a disciplined procedure for doing that safely with only the gh CLI and git. ## Core Features & Use Cases - Stack creation with recorded boundaries: Create layered PRs with explicit --base fields and save PR number, branch, base/head names, and exact remote OIDs before every mutation. - Parent merge and retargeting: After a parent merges or is renamed, re-query open PRs, retarget each immediate child with gh pr edit --base, and cascade bottom-up rebases with git rebase --onto so only the child's own commits are replayed. - Lease-protected rewrites and deletion: Push rewritten branches and delete branches only with --force-with-lease pinned to the saved remote OID, after a final race check of PR state, required checks, and governance evidence. - Use Case: You have PRs feat-a → feat-b → feat-c stacked on main. When feat-a merges, this Skill walks you through retargeting feat-b to main, rebasing feat-c onto the new feat-b, re-running gates, and force-pushing each layer with an exact-OID lease. ## Quick Start Ask the agent to restack my dependent GitHub pull requests after the parent PR merged, retargeting each child and force-pushing with a saved-OID lease.

Frequently Asked Questions about stacked-prs-gh-cli

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I restack dependent GitHub pull requests after a parent merges?

Re-query the parent result, identify each immediate child from open PR data, then retarget each child with gh pr edit <child-pr> --base <new-base>. Afterward, cascade bottom-up rebases with git rebase --onto <new-parent> <old-parent> <child> so only the child's commits are replayed.

How to force push a rewritten branch safely in a PR stack?

Use git push --force-with-lease=refs/heads/<branch>:<saved-remote-oid> origin <branch> with the exact remote OID saved before the rewrite. Re-run a full race check of PR base/head/state, checks, and governance immediately before pushing; a lease failure means stop and re-query, not retry.

Does the gh CLI have a built-in command for stacked PRs?

No, gh has no stack command, so stacking relies on explicit base-branch fields set with gh pr create --base and gh pr edit --base. All topology tracking, restack leases, and readbacks must be managed manually with gh and git commands.

When is it safe to delete a branch in a pull request stack?

Only after re-querying all open PRs and confirming none still use the branch as a base, since a child using it keeps it alive. Perform a final race check of open-child usage, PR state, saved remote OID, and required checks, then delete with a force-with-lease pinned to the saved OID.

What happens if gh returns HTTP 403 or missing check data during a restack?

Missing governance data, unsupported fields, or HTTP 403 is treated as UNKNOWN, never as approval. Deletion, merging, or mutation stops until fresh evidence is obtained, because absent or stale evidence cannot confirm required checks or review status.