clean-branches

Identify and delete local Git branches with merged pull requests.

3.5k|1.4k|Updated Nov 10, 2017
One-click install
npx skills add https://github.com/brave/brave-core --skill clean-branches-brave
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: clean-branches
Source: https://github.com/brave/brave-core/tree/main/.claude/skills/clean-branches
Command: npx skills add https://github.com/brave/brave-core --skill clean-branches-brave

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gh, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps maintain a clean local Git repository by automatically identifying and offering to delete branches whose associated pull requests have already been merged upstream.

Core Features & Use Cases

  • Automated Branch Cleanup: Fetches remote status and checks local branches against origin/master.
  • Multi-Method Merge Detection: Uses git branch --merged, git cherry, and gh pr to accurately identify merged or squash-merged branches.
  • User-Guided Deletion: Presents a clear summary of branch statuses (Merged, Closed, Open) and prompts for confirmation before deleting.
  • Use Case: After completing several feature branches and merging their PRs, run this skill to quickly remove the now-obsolete local branches, keeping your repository tidy.

Quick Start

Run the clean-branches skill to remove local branches that have been merged into origin/master.

Frequently Asked Questions about clean-branches

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

FAQPage Schema
How do I delete local Git branches that have already been merged upstream?▼

To delete merged local Git branches, this skill fetches remote status, checks branches against origin/master using git branch --merged, git cherry, and gh pr status, then prompts for confirmation before deleting them.

Can I detect squash merged Git branches for local cleanup?▼

Yes, you can detect squash merged Git branches because this skill uses git cherry alongside GitHub PR status checks via the gh CLI to identify branches whose commits were squash merged into the upstream repository.

Does this branch cleanup tool require the GitHub CLI to work?▼

This branch cleanup tool requires the gh CLI dependency to fetch GitHub PR statuses, though it also uses native git ancestry and git cherry methods for detecting merged branches without relying solely on GitHub.

What is the best way to prune stale remote tracking references after branch deletion?▼

The best way to prune stale remote tracking references is built into this skill, which prunes them automatically after identifying merged branches and completing the user-guided local deletion process.

Why does git branch --merged sometimes miss branches that were squash merged?▼

Git branch --merged misses squash merged branches because squash merges create a new commit hash without ancestry linkage, so this skill supplements it with git cherry and gh pr checks to detect them.