clean-branches

Remove local Git branches already integrated into the default branch.

3|1|Updated Mar 2, 2026
One-click install
npx skills add https://github.com/denniscalazans/denniscalazans-plugins --skill clean-branches-denniscalazans
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-branches
Source: https://github.com/denniscalazans/denniscalazans-plugins/tree/main/plugins/dc/skills/clean-branches
Command: npx skills add https://github.com/denniscalazans/denniscalazans-plugins --skill clean-branches-denniscalazans

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill helps you maintain a clean Git history by identifying and removing local branches that have already been merged into your default branch, preventing clutter and confusion.

Core Features & Use Cases

  • Content-based Integration Check: Uses git merge-tree to reliably determine if a branch's content is already present in the default branch, regardless of merge strategy (merge commit, squash, rebase).
  • Contextual Information: Provides details on branch tracking status, last commit date, and worktree association to aid decision-making.
  • Safe Deletion Workflow: Offers options to delete all integrated branches, select specific branches, or skip deletion, with fallback to safe deletion flags.
  • Worktree Management: Automatically removes associated worktrees before deleting a branch.

Quick Start

Use the clean-branches skill to scan and remove local branches whose content is already in the default branch.

Frequently Asked Questions about clean-branches

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

FAQPage Schema
How do I clean up local Git branches that have already been merged?

To clean up merged Git branches, this Skill identifies branches whose content is already integrated into the default branch and safely removes them along with their associated worktrees.

How does Git detect squash-merged branches for safe deletion?

Detecting squash-merged branches uses `git merge-tree` to perform a content-based integration check, reliably verifying if a branch's content is present in the default branch regardless of the merge strategy used.

What is the best way to delete local Git branches with active worktrees?

Deleting local Git branches with active worktrees requires automatically removing the associated worktrees before deleting the branch itself, preventing conflicts and keeping your codebase maintenance workflow clean.

Can I exclude protected Git branches when cleaning up merged local branches?

Yes, when cleaning up merged local branches, the process automatically excludes protected branches and the current branch, ensuring only safely integrated branches are targeted for deletion.

Does Git branch cleanup work with rebased branches?

Yes, Git branch cleanup works with rebased branches by using `git merge-tree` to check if the branch's content is already present in the default branch, handling merged, squash-merged, or rebased branches effectively.