git-cleanup

Categorizes and deletes local git branches and worktrees based on merge status.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/marumo333/atrox --skill git-cleanup-marumo333
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: git-cleanup
Source: https://github.com/marumo333/atrox/tree/main/.claude/skills/trailofbits/plugins/git-cleanup/skills/git-cleanup
Command: npx skills add https://github.com/marumo333/atrox --skill git-cleanup-marumo333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Local repositories accumulate stale branches and worktrees after PRs merge, making it hard to tell which branches are safe to delete and which contain unpushed work. This Skill analyzes every branch and worktree, categorizes them by merge status, and deletes only what the user explicitly confirms. ## Core Features & Use Cases - Merge Status Categorization: Classifies branches as merged, squash-merged, superseded, remote-gone, unpushed, or synced, choosing git branch -d or -D accordingly. - Related Branch Grouping: Groups branches by name 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 exact deletion commands for final confirmation, and blocks dirty worktree removal. - Use Case: After months of feature work, run the cleanup to discover that four feature/api- branches were all merged via PRs #29, #45, and #67, then delete them in one confirmed batch. ## Quick Start Ask the assistant to run /git-cleanup to analyze and safely clean up your local git branches and worktrees.

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 merged local git branches?▼

List merged branches with git branch --merged against your default branch, then delete them with git branch -d. This Skill automates that analysis, groups related branches, and asks for confirmation before deleting anything.

Why does git branch -d fail on squash-merged branches?▼

Git cannot detect that squash-merged work was incorporated because the original commits never entered the default branch history. Use git branch -D to force delete after verifying the work landed via a PR in the main branch log.

How to clean up git worktrees and branches together?▼

Run git worktree list and git branch -vv to inventory both, check each worktree for uncommitted changes with git status --porcelain, then remove stale worktrees with git worktree remove and delete their merged branches.

Can I delete all branches with [gone] remotes safely?▼

No. A [gone] marker only means the remote branch was deleted; the local branch may still hold unpushed commits. Check git log origin/<branch>..<branch> and search the default branch for a squash-merge PR before deleting.

When should I not use automated git branch cleanup?▼

Avoid it for remote branch management, repository maintenance like gc or prune, and non-interactive automation. This workflow requires user confirmations at two gates and only handles local branches and worktrees.