stacked-pr-base-branch-deletion-auto-closes-dependentlisted
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