← ClaudeAtlas

stacked-pr-base-branch-deletion-auto-closes-dependentlisted

Recover from the trap where deleting a base PR's branch auto-closes any open dependent stacked PR, and the closed PR cannot be reopened or retargeted. Use when: (1) you set up a stacked PR pair (PR2's `base` field = PR1's branch instead of `main`), (2) you merged PR1 via squash, (3) PR1's remote branch got deleted — via ANY route: `gh pr merge <N> --squash --delete-branch`, `gh api -X DELETE refs/heads/<branch>`, or `gh pr merge` followed by separate branch cleanup — (4) the dependent PR2 is now reported as `state: CLOSED` even though you never closed it, (5) `gh pr reopen N` fails with `Could not open the pull request`, (6) `gh pr edit N --base main` fails with `Cannot change the base branch of a closed pull request`. The only recovery for the stacked-PR case is to open a fresh PR from the same head branch with base=main. **v1.2.0 (2026-05-19) adds the recoverable single-PR variant**: if the deleted branch was the HEAD of a single, in-flight, NEVER-MERGED PR (e.g. user deleted the branch after a failed merge
wan-huiyan/agent-traffic-control · ★ 2 · AI & Automation · score 79
Install: claude install-skill wan-huiyan/agent-traffic-control
# Stacked PR: Base-Branch Deletion Auto-Closes the Dependent PR ## Problem You have a stacked PR pair: - **PR1** — `base: main`, `head: feature-pr1` - **PR2** — `base: feature-pr1`, `head: feature-pr2` (stacked on PR1) You squash-merge PR1. The merge succeeds. You then run: ```bash gh api -X DELETE repos/<owner>/<repo>/git/refs/heads/feature-pr1 ``` …to clean up the orphaned remote branch (because `gh pr merge --delete-branch` failed locally with the worktree-checkout-trap and you used the API as a workaround). Within seconds, PR2 silently transitions to `state: CLOSED`: ```bash $ gh pr view <PR2> --json state,closed,mergedAt,baseRefName {"baseRefName":"feature-pr1","closed":true,"mergedAt":null,"state":"CLOSED"} ``` You never closed PR2. The PR's `head` branch still exists with all the work. But: ```bash $ gh pr reopen <PR2> API call failed: GraphQL: Could not open the pull request. (reopenPullRequest) $ gh pr edit <PR2> --base main GraphQL: Cannot change the base branch of a closed pull request. (updatePullRequest) ``` GitHub refuses to reopen the PR (its base branch no longer exists), and refuses to retarget a closed PR. The PR is effectively a dead reference — all comments, reviews, and history land on a record that nothing can resurrect. ## Why this happens When a PR's base branch is deleted, GitHub's behavior is asymmetric: - **If the base branch is deleted via the GitHub UI's "delete branch" button on a merged PR**, GitHub usually auto-retargets depende