prune-merged-branches

Prune local git branches verified as merged via GitHub PR head SHAs.

Updated May 20, 2026
One-click install
npx skills add https://github.com/paywhereb/paywhere-claude-plugins --skill prune-merged-branches
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prune-merged-branches
Source: https://github.com/paywhereb/paywhere-claude-plugins/tree/main/paywhere-eng-workflow/skills/prune-merged-branches
Command: npx skills add https://github.com/paywhereb/paywhere-claude-plugins --skill prune-merged-branches

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents accidental loss of un-pushed work by deleting only local git branches that are confirmed as fully merged on GitHub, including protection against squash-merge pitfalls.

Core Features & Use Cases

  • Squash-merge aware safety: Refuses to rely on git’s ancestry-only “merged” heuristics and instead verifies the merged PR’s recorded head SHA is present in the local branch.
  • Report-first cleanup: Classifies branches into DELETE, KEEP, and SKIP and shows exactly what would be removed before deleting anything.
  • Guardrails against uncertainty: Never deletes the default branch or the currently checked-out branch, and never deletes branches in KEEP/SKIP states even with affirmative confirmation.

Quick Start

Run the prune-merged-branches skill from your repository root to generate a safety report and then delete only the branches it marks as safe.

Frequently Asked Questions about prune-merged-branches

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

FAQPage Schema
How do I safely delete local git branches after a squash merge on GitHub?

To safely delete local git branches after a squash merge, verify the merged pull request's head SHA exists locally instead of relying on git ancestry heuristics. This prevents losing un-pushed commits when squash merges make naive git branch deletion unsafe.

Why does git branch --merged not work for deleting squash-merged branches?

Git branch --merged fails for squash-merged branches because squash merges create a new commit without preserving ancestry. Safe deletion requires fetching the GitHub PR head ref and confirming the exact head SHA is present in the local branch history.

What is the best way to clean up local git branches without losing un-pushed commits?

The best way to clean up local git branches without losing un-pushed commits is using a report-first tool that classifies branches into DELETE, KEEP, and SKIP categories, verifying GitHub PR head objects locally before removing anything.

Do I need the gh CLI to prune merged local branches tied to GitHub pull requests?

Yes, you need the gh CLI to prune merged local branches tied to GitHub pull requests. The tool requires gh to list merged PR head refs, fetch and verify PR-head objects locally, and confirm ancestry via merge-base before deletion.

How to avoid deleting unrelated historical branches when cleaning up merged git branches?

To avoid deleting unrelated historical branches during git cleanup, verify branch names against active GitHub PR head refs and confirm ancestry via merge-base. This prevents collisions when local branch names match unrelated historical branches.

Will a report-first git branch cleanup tool delete my current or default branch?

No, a report-first git branch cleanup tool will not delete your current or default branch. It includes guardrails that never remove the checked-out branch or default branch, and never deletes branches classified as KEEP or SKIP even with explicit confirmation.