git-cleanup

Analyzes and deletes local git branches and worktrees by categorizing them as merged, squash-merged, superseded, or active.

Updated Mar 22, 2026
One-click install
npx skills add https://github.com/TECH-HY/SKILLS --skill git-cleanup-tech-hy
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-cleanup
Source: https://github.com/TECH-HY/SKILLS/tree/main/skills/git-cleanup
Command: npx skills add https://github.com/TECH-HY/SKILLS --skill git-cleanup-tech-hy

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Local repositories accumulate stale branches and worktrees over time, and deleting them blindly risks losing unpushed or unmerged work. This Skill performs a thorough, evidence-based analysis of every branch and worktree, then requires explicit user confirmation before any deletion. ## Core Features & Use Cases - Branch Categorization: Classifies branches as merged, squash-merged, superseded, remote-gone, unpushed, or synced, using commit history and PR merge evidence rather than name matching. - Related Branch Grouping: Groups branches sharing a prefix (e.g., feature/api-*) and traces which PRs incorporated each iteration before recommending deletion. - Two-Gate Safety Workflow: Presents a full analysis first, then shows the exact git commands (with correct -d or -D flags) for final confirmation before executing. - Use Case: After months of feature work, a developer has 30 local branches and several worktrees. The Skill identifies which were merged via PRs, which contain unpushed commits, and safely deletes only the confirmed stale ones. ## Quick Start Run /git-cleanup to analyze my local branches and worktrees and help me safely delete the ones whose work is already merged.

Frequently Asked Questions about git-cleanup

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

FAQPage Schema
How do I safely delete local git branches that are already merged?

Use git branch --merged to list branches merged into your default branch, then delete them with git branch -d. This Skill automates the analysis and confirms each deletion with you before running any command.

How to clean up squash-merged branches that git branch -d refuses to delete?

Squash-merged branches always fail git branch -d because git cannot detect the incorporated work, so they require git branch -D. The Skill detects squash merges by searching default-branch history for the corresponding PR before force-deleting.

Can I delete branches whose remote tracking branch is gone?

A [gone] status only means the remote branch was deleted; the local branch may still hold unpushed commits. Check git log origin/<branch>..<branch> and search main for a merged PR before deleting.

Does this skill work for remote branch cleanup or non-interactive automation?

No. It handles local branches and worktrees only, not remote branch management or repository maintenance like gc or prune. It requires interactive user confirmations at two gates, so it is unsuitable for headless automation.

What happens if a worktree has uncommitted changes during cleanup?

The Skill runs git status --porcelain on every worktree and displays a prominent warning listing modified and untracked files. It refuses to remove a dirty worktree without explicit acknowledgment of the data loss.