clean-branches

Delete local Git branches whose pull requests are merged upstream.

4|Updated Feb 2, 2026
One-click install
npx skills add https://github.com/brave-experiments/brave-core-bot --skill clean-branches-brave-experiments
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-branches
Source: https://github.com/brave-experiments/brave-core-bot/tree/main/.claude/skills/clean-branches
Command: npx skills add https://github.com/brave-experiments/brave-core-bot --skill clean-branches-brave-experiments

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

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

Core Features & Use Cases

  • Automated Branch Detection: Fetches remote state and lists local branches.
  • Merge Status Verification: Uses multiple methods (ancestry, cherry, GitHub CLI) to confirm if a branch's work is merged.
  • Categorization: Sorts branches into 'Merged', 'Closed (not merged)', and 'No PR / Open PR' categories.
  • User Confirmation: Presents a clear summary and prompts for deletion confirmation, especially for branches closed without merging.
  • Use Case: After completing a feature and merging its PR, you can run this skill to automatically remove the now-obsolete local feature branch, preventing clutter.

Quick Start

Run the clean-branches skill to remove local branches that have been merged upstream.

Frequently Asked Questions about clean-branches

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

FAQPage Schema
How do I automatically delete local Git branches after a pull request is merged?

To delete local Git branches after a pull request is merged, you can run an automated cleanup script that fetches remote state and verifies merge status using ancestry, cherry, and GitHub CLI checks before prompting for deletion.

What is the best way to clean up local Git branches that have been merged upstream?

The best way to clean up local Git branches merged upstream is to use an automated tool that fetches remote state, categorizes branches by their merge status, and prompts for user confirmation before deleting them.

How does Git verify if a local branch has been merged upstream before deleting it?

To verify if a local branch is merged upstream, Git checks ancestry and cherry status against origin/master, while also using the GitHub CLI to confirm the corresponding pull request's merge state.

Can I use GitHub CLI to manage and remove obsolete local feature branches?

Yes, you can use GitHub CLI to manage obsolete local feature branches by verifying pull request merge status, categorizing branches into merged or closed groups, and prompting for user confirmation before deletion.

What happens to closed pull requests that were not merged during Git branch cleanup?

During Git branch cleanup, closed pull requests that were not merged are categorized separately from merged branches, and the tool will explicitly prompt for user confirmation before deleting them to prevent accidental data loss.

Do I need GitHub CLI installed to automate local Git branch deletion?

Yes, you need GitHub CLI installed to automate local Git branch deletion, as the tool depends on it to verify pull request merge status alongside Git ancestry and cherry checks against origin/master.