Git Cleanup — Development skill for Claude Code
Trail of Bits security skill for git cleanup.
How to install Git Cleanup
Installs to ~/.claude/skills/git-cleanup/
git clone --depth 1 https://github.com/trailofbits/skills /tmp/skills \
&& mkdir -p ~/.claude/skills \
&& cp -r /tmp/skills/plugins/git-cleanup ~/.claude/skills/git-cleanup Clones the whole repository, because a skill folder can carry scripts and resources beside its SKILL.md.
What Git Cleanup does
A Claude Code skill for safely cleaning up accumulated git worktrees and local branches.
Alternatives in Development
- Clean Worktree (Interactive) — Interactive cleanup of worktrees: lists merged/stale branches and asks confirmation before deleting 25.5k ★
- System Cache Cleanup — Clean temporary files and caches to free disk space: $ARGUMENTS 23.4k ★
- Cleanup Builds — Cleanup Dev Builds 20k ★
Repository README
This is the README for trailofbits/skills, shared by 13 entries
in this directory. It describes the repository, not this entry specifically.
git-cleanup
A Claude Code skill for safely cleaning up accumulated git worktrees and local branches.
What It Does
Analyzes your local git repository and categorizes branches/worktrees into:
- Safe to delete: Branches fully merged into the default branch
- Needs review: Branches with deleted remotes (
[gone]) that may have local-only work - Theme-related: Groups of branches working on similar functionality
- Keep: Active work with unpushed commits or untracked local branches
The skill uses a gated workflow requiring explicit user confirmation before any deletions.
When to Use
Invoke with `/git-cleanup` when you have accumulated many local branches and worktrees that need cleanup.
**Important**: This skill only runs when explicitly invoked. It will never suggest cleanup proactively or run automatically.
Safety Features
- Two confirmation gates (analysis review, then deletion confirmation)
- Uses safe delete (
git branch -d) for merged branches; force delete (git branch -D) only for squash-merged branches where git cannot detect the merge - Blocks removal of worktrees with uncommitted changes
- Never touches protected branches (main, master, develop, release/*)
- Flags
[gone]branches for review instead of auto-deleting
Installation
claude plugins:add trailofbits/skills/git-cleanup
Example
User: /git-cleanup
Claude: [Analyzes branches and worktrees]
[Presents categorized tables]
"I found 5 branches safe to delete, 2 needing review.
Which would you like to clean up?"
User: "Delete the merged branches"
Claude: "I will delete these branches:
- feature/auth
- bugfix/login
Confirm? (yes/no)"
User: "yes"
Claude: [Executes and reports results]
Related Skills
Debug Buttercup
Trail of Bits security skill for debug buttercup
Gh CLI
Trail of Bits security skill for gh cli
Paper Trail Registry Cleanup
Nettoyage historique du registre des fiches bibliographiques (les ~900 fiches existantes). Cible les vieilles
Raven Harden
Reviews security_log.md and promotes accumulated observations into
Reactbits.Dev Skill
Claude Code skill for React Bits (reactbits.dev) — fetches real component source from the live registry instea
Paper Trail Cascade
Acquire PDFs via the 8-source cascade (11 with opt-in extended sources) for a single ref by slug, or a batch f
Related Agents
Audit Logs
Query and manage Datadog Audit Trail events for compliance, security auditing, and tracking user actions acros
Flow Git
Use this agent for git operations — atomic commits, rebase, history cleanup, and style detection. Flow detects
Worktree Manager
Expert git worktree management and troubleshooting. Handles worktree creation, cleanup, lock file resolution,