branch-cleanup

Identify stale or merged Git branches and delete them after user approval.

4|1|Updated Jan 8, 2024
One-click install
npx skills add https://github.com/OpenSourcePharmaFoundation/ospf-ayurveda-kg --skill branch-cleanup-opensourcepharmafoundation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: branch-cleanup
Source: https://github.com/OpenSourcePharmaFoundation/ospf-ayurveda-kg/tree/main/.claude/skills/branch-cleanup
Command: npx skills add https://github.com/OpenSourcePharmaFoundation/ospf-ayurveda-kg --skill branch-cleanup-opensourcepharmafoundation

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you identify which local and remote Git branches are stale or fully merged so you can reduce repository clutter without accidentally deleting important work.

Core Features & Use Cases

  • Stale/merged branch discovery: Fetches and audits both local and remote branches against main to find fully merged targets.
  • Safety-first classification: Prevents destructive actions on main and the currently checked-out branch, avoids force deletion (-D), and flags “Potentially Stale” vs “Active” branches based on last commit recency.
  • Explicit approval workflow: Presents a categorized report and requires user approval before any deletion, including remote branch cleanup.

Quick Start

Ask the AI to run a branch hygiene report for your local branches and then propose deletions only for the branches that are fully merged into main.

Frequently Asked Questions about branch-cleanup

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

FAQPage Schema
How do I safely delete stale git branches locally and on remotes?

To safely delete stale git branches, you can fetch with prune, classify branches as merged or unmerged relative to main, and review a report before approving safe local deletion (-d) and remote deletion via git push --delete. This prevents accidental loss of active work.

What is the best way to find merged remote branches for repository cleanup?

Finding merged remote branches for repository cleanup involves fetching remote refs with prune and auditing them against your main branch. The Skill classifies branches by merged status and last commit recency, flagging potentially stale targets while preserving active development branches.

How do I clean up local git branches without losing unmerged work?

Cleaning up local git branches without losing unmerged work requires classifying branches relative to main to identify fully merged targets. The Skill avoids force deletion (-D) and protects the currently checked-out branch, requiring explicit approval before removing any redundant branch history.

Does git branch cleanup require explicit approval before deleting remote branches?

Yes, git branch cleanup requires explicit approval before deleting remote branches. The Skill presents a categorized report-first presentation showing last commit and ahead counts, and only executes remote deletion via git push --delete after you explicitly approve the proposed removals.

Can I prevent accidental deletion of main or active branches during repository hygiene maintenance?

You can prevent accidental deletion of main or active branches during repository hygiene maintenance by using a safety-first classification approach. The Skill blocks destructive actions on main and the checked-out branch, avoiding force deletion and categorizing targets as active or potentially stale based on commit recency.

When should I avoid force deleting git branches with git branch -D?

You should avoid force deleting git branches with git branch -D when performing repository hygiene, as it bypasses merged status checks. Instead, use safe local deletion (-d) after verifying branch classification relative to main, ensuring unmerged work is preserved and only redundant history is removed.