git-branch-cleanup

Analyze local Git branches and propose safe deletions with dry-run previews.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/sage-base/sagebase --skill git-branch-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-branch-cleanup
Source: https://github.com/sage-base/sagebase/tree/main/.claude/skills/git-branch-cleanup
Command: npx skills add https://github.com/sage-base/sagebase --skill git-branch-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers cleanse their local Git repository by analyzing branches and safely identifying candidates for deletion. It categorizes branches based on merge status, last activity, and remote-tracking information to reduce clutter without risking lost work.

Core Features & Use Cases

  • Branch analysis: detects merged, unmerged, stale (inactive for a defined period), and remote-tracking branches.
  • Safe cleanup workflow: proposes deletions with a dry-run preview and requires explicit user confirmation before removal.
  • Safety guards: prevents deletion of protected branches (e.g., main, master) and currently checked-out branches.
  • Use Case: You have dozens of feature branches; run this Skill to generate a concise list of branches that can be safely deleted to reclaim space and reduce complexity.

Quick Start

Analyze the current repository to identify branches eligible for deletion and output a concise cleanup plan.

Frequently Asked Questions about git-branch-cleanup

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

FAQPage Schema
How do I clean up local Git branches safely without losing unmerged work?

To clean up local Git branches safely, this Skill analyzes merge status, age, and remote-tracking data to classify branches into merged, unmerged, stale, and ahead categories. It requires explicit user confirmation before deleting any branches to prevent lost work.

How do I find and delete stale Git branches that have already been removed from the remote?

Finding stale Git branches with deleted remote-tracking references is handled by analyzing remote-tracking information. The Skill identifies these remote-deleted branches and includes them in the cleanup plan, allowing you to safely prune them after previewing in a dry-run.

Can I preview which Git branches will be deleted before actually removing them?

Yes, you can preview Git branch deletions using the dry-run mode. This generates a deterministic cleanup plan showing exactly which branches are categorized as merged, old, or remote-deleted, ensuring no branches are removed without your explicit confirmation.

Does Git branch cleanup protect the main or currently checked-out branch from deletion?

Git branch cleanup enforces safety guards that prevent the deletion of protected branches like main or master, as well as the currently checked-out branch. This ensures your core development lines remain intact during the repository cleansing process.

What is the best way to tidy a Git repository with dozens of old feature branches?

Tidying a Git repository with many feature branches is done by analyzing branch age and merge status to identify deletion candidates. This Skill generates a concise list of branches that can be safely deleted to reclaim space and reduce repository complexity.

Why does my Git branch cleanup workflow need to check both merge status and remote-tracking information?

Checking both merge status and remote-tracking information during Git branch cleanup ensures deterministic classification into merged, unmerged, and remote-deleted categories. This dual analysis prevents the accidental deletion of branches that still contain unmerged work or active remote references.