← ClaudeAtlas

branch-hygienelisted

Use when a PR has just merged on `origin/develop` or `origin/main`, when multiple open PRs share an ancestor that has now landed, when the user says "rebase the open PRs" / "manage open PRs" / "PR X merged, clean up" / "fix conflicts" / "deal with conflicting PRs", **before merging a PR that another open PR is based on**, or after running `gh pr merge`. Goal — drop duplicate commits introduced by the merge, force-push the open PRs onto the new base, prune dead worktrees and branches, and close the issues the merged PR's keywords could not. Do NOT fire for deliberate history surgery on one PR (dropping, reordering or splitting commits is `rewrite-pr-history`) or for promoting an integration branch to the branch people install from (`close-the-release-cycle`).
damson/hard-won-skills · ★ 1 · Code & Development · score 67
Install: claude install-skill damson/hard-won-skills
# Post-merge branch hygiene After any merge to `develop` / `main`, the other open PRs that branched from the merged work appear `CONFLICTING` on GitHub because the merge commit assigned new SHAs to commits whose patches are now in the base. Resolution is mechanical: rebase + force-push. ## Before you merge a PR others are based on Merging is where a stack is lost, and both failure modes look like the tool helping. 1. **Find the children, and retarget them FIRST**: ```bash gh pr list --base <branch-about-to-merge> --json number,headRefName gh pr edit <n> --base <the parent's own base> # BEFORE the merge ``` Merging the parent does **not** retarget a child — it leaves it running its checks against a branch nobody will push to again. Deleting the parent's branch does not retarget it either: it **closes** it. And a closed PR can be neither retargeted (`Cannot change the base branch of a closed pull request`) nor reopened once its base branch is gone, so the only recovery is a new PR from the same branch — the review history stays behind on the closed one. 2. **Remove the worktree holding the branch**, or `--delete-branch` fails with `cannot delete branch '<x>' used by worktree at …` and the merge lands with the branch still there — which is the state that leaves a child stranded. ```bash git worktree remove <path> && gh pr merge <parent> --squash --delete-branch ``` 3. **Then rebase each child** onto the new base, per the