git-cleanup

Classify local Git branches and worktrees for safe deletion with confirmation gates.

Updated May 2, 2026
One-click install
npx skills add https://github.com/ayehiaa/my-travel-assistant --skill git-cleanup-ayehiaa
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-cleanup
Source: https://github.com/ayehiaa/my-travel-assistant/tree/main/.agents/skills/git-cleanup
Command: npx skills add https://github.com/ayehiaa/my-travel-assistant --skill git-cleanup-ayehiaa

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Reduces clutter and risk in a local Git repo by helping you identify which local branches and worktrees can be safely removed versus ones that likely contain active or unpushed work.

Core Features & Use Cases

  • Safety-first branch categorization: Classifies branches and worktrees into merged (safe to delete), squash-merged (force delete), superseded (related but already integrated), remote-gone (needs review), and keep categories such as unpushed or active work.
  • Related-branch grouping by prefix: Groups similarly named branches (e.g., feature/api-*) and evaluates commit/PR evidence to avoid scattering related iterations across categories.
  • Interactive, gated deletion workflow: Requires user confirmation at two gates and blocks destructive actions if the repo/worktrees are dirty without explicit acknowledgment.

Quick Start

Ask the assistant to run git-cleanup to analyze your local branches and worktrees and then recommend exactly which ones you can delete after a safety-gated review.

Frequently Asked Questions about git-cleanup

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

FAQPage Schema
How do I safely clean up local Git branches after a squash merge?

To safely clean up local Git branches after a squash merge, the workflow analyzes PR evidence to classify them and uses a gated confirmation process before executing a force delete (git branch -D). This ensures squash-merged branches are removed without losing uncommitted work.

What is the best way to delete accumulated Git worktrees without losing active changes?

The best way to delete accumulated Git worktrees without losing active changes is to use a safety-first classification system that detects dirty states and filters protected branches, requiring explicit user acknowledgment at two gates before any destructive removal.

How does branch cleanup handle local branches when the remote is already gone?

Branch cleanup handles local branches with gone remotes by categorizing them for review rather than immediate deletion. It evaluates merge and PR evidence to determine if the branch is superseded or contains local work that needs to be kept.

Can I delete related feature branches grouped by prefix without checking each one individually?

Yes, you can delete related feature branches grouped by prefix safely. The workflow groups similarly named branches (e.g., feature/api-*) and evaluates their commit and PR history collectively to prevent scattering related iterations across deletion categories.

Why does the Git branch deletion workflow require two confirmation gates?

The Git branch deletion workflow requires two confirmation gates to prevent accidental data loss. It blocks destructive actions if the repository or worktrees are in a dirty state, ensuring you explicitly acknowledge and verify the categorized branches before removal.