git-cleanup
/git-cleanup
Repository hygiene — prune merged/stale branches, detect orphans, repo health checks. Use when cleaning up branches, checking repo health, or scanning projects.
- Author
- specterops ↗
- Repository
- skills ↗
- Licence
- Apache-2.0
- Last repository change
- 14.10.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 14.10.2026, without references to retired models or APIs.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
What it does and when to use it
Repository hygiene — prune merged/stale branches, detect orphans, repo health checks. Use when cleaning up branches, checking repo health, or scanning projects.
Original author description
Repository hygiene — prune merged/stale branches, detect orphans, repo health checks. Use when cleaning up branches, checking repo health, or scanning projects.
How it works
- Prerequisites
- Protected Branches
- Action: branches (default)
- Action: stale [days]
- Action: health
- Action: all
- Safety Rules
SKILL.md preview
---
name: git-cleanup
description: Repository hygiene — prune merged/stale branches, detect orphans, repo health checks. Use when cleaning up branches, checking repo health, or scanning projects.
metadata:
author: "GhostWorks"
---
# Git Repository Cleanup
Repository hygiene: prune branches, detect stale work, and check repo health.
Parse the user's input to determine the action:
- `$git-cleanup` or `$git-cleanup branches` — find and prune merged/stale branches
- `$git-cleanup stale [days]` — branches with no commits in N days (default 30)
- `$git-cleanup health` — large files, dangling refs, worktrees, repo size
- `$git-cleanup all` — scan all git repos under ~/Projects/
## Prerequisites
1. Verify we're in a git repository (`git rev-parse --is-inside-work-tree`) — except for `all` action which scans directories
2. If not in a git repo (and not using `all`), tell the user and stop
## Protected Branches
The following branches are NEVER suggested for deletion: `main`, `master`, `develop`
## Action: branches (default)
1. Fetch latest remote state: `git fetch --prune`
2. Identify the default branch (`git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null` or fall back to `main`/`master`)
3. Find merged branches:
- `git branch --merged <default>` — local branches already merged into default
- Exclude protected branches and current branch
4. Find branches with deleted remotes:
- `git branch -vv` — look for `[origin/...: gone]` entries
5. Present findings as a **dry-run preview**:
- List branches that can be safely deleted (merged)
- List branches whose remote is gone
- Show last commit date and message for each
6. Ask the user which branches to delete (or "all listed")
7. On confirmation, delete with `git branch -d <branch>` (safe delete)
8. If a branch fails `-d` (unmerged), warn the user and offer `-D` with explicit explanation that commits may be lost — only proceed with user confirmation
## Action: stale [days]
1. Default to 30 days if no argument provided
2. For each local branch (excluding protected branches):
- Get last commit date: `git log -1 --format='%ci' <branch>`
- Calculate age in days
3. List branches older than the threshold, sorted by age (oldest first)
4. Show for each: branch name, last commit date, last commit message, age in days
5. Present as dry-run preview — ask before deleting
6. On confirmation, use `git branch -d` first; offer `-D` only with warning if unmerged
## Action: health
Run a comprehensive repository health check:
1. **Repository size**:
- `.git` directory size: `du -sh .git`
- Working tree size: `du -sh . --exclude=.git` (or equivalent)
- Object count: `git count-objects -vH`
2. **Large files** (top 10 by size in history):
- `git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '/^blob/ {print $3, $4}' | sort -rn | head -10`
- Flag files over 10MB
3. **Dangling objects**:
- `git fsck --no-reflogs 2>&1` — look for dangling commits, blobs, trees
- Report count and suggest `git gc` if significant
4. **Worktrees**:
- `git worktree list` — show active worktrees
5. **Remote status**:
- `git remote -v` — list remotes
- Check if local is ahead/behind remote
6. **Stale tracking branches**:
- `git remote prune origin --dry-run` — branches that would be pruned
7. Present findings with recommendations
8. If cleanup is recommended (gc, prune), show the commands but **always ask before running them**
## Action: all
1. Find all git repositories under `~/Projects/`:
- `find ~/Projects -maxdepth 3 -name .git -type d`
2. For each repository found:
a. Show repo name and path
b. Run the **branches** check (merged + gone remotes)
c. Show summary: N merged branches, M gone-remote branches
3. **Per-repo confirmation** — ask before deleting branches in each repo
4. Show overall summary at the end
## Safety Rules
1. **Never delete without confirmation** — always preview first
2. **Never delete protected branches** (main, master, develop)
3. **Never `git push origin --delete` on protected branches**
4. **Never run `git gc` without asking**
5. **Always preview first** — every action starts as a dry run
6. **Per-repo confirmation for `all`** — don't batch-delete across repos
7. Use `git branch -d` (safe delete) first; only offer `-D` with explicit warning
Files in this package (4)
- SKILL.md 4 KB
- agents/openai.yaml 1 KB
- assets/icon.png 1 KB
- assets/icon.svg 1 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · specterops/skills | 90 | Apache-2.0 |
| Richicinschi/studio-os | 100 | MIT |
| motlin/claude-code-plugins | 100 | Apache-2.0 |
| gosuda/dalcom-skills | 100 | Apache-2.0 |
| mostafa-drz/claude-skills | 100 | MIT |
| OutlineDriven/outline-driven-development | 100 | Apache-2.0 |
| alibaba/page-agent | 100 | MIT |
| redhatproductsecurity/prodsec-skills | 100 | Apache-2.0 |
| viknesh20-20/claude-code-tool-kit | 100 | MIT |
Database snapshot: 13.11.2026 · package version a3d47f0c374b (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100cleaning-up-branches
Deletes merged git branches (local and remote) and flags stale unmerged branches for manual review. Use when user mentions "cleanup branches", "delete merged branches", "prune old branches", "remove stale branches", "branch cleanup", or runs /cleanup-branches command. - 100cleanup-git
Remove merged local branches and stale git worktrees. Use when the user says "cleanup branches", "prune worktrees", "tidy git", "remove merged branches", "delete merged branches", "gone branches", or wants to clean local git state. NOT for creating commits, creating worktrees,… - 100branch-cleanup
Prune stale git branches after a merge wave: delete closed/merged remote branches, remove local tracking branches that no longer exist on the remote, and optionally clean up local branches already merged to main. Use after running dependabot-triage, after a sprint wind-down, or… - 100branch-cleanup
Prune stale git branches after a merge wave: delete closed/merged remote branches, remove local tracking branches that no longer exist on the remote, and optionally clean up local branches already merged to main. Use after running dependabot-triage, after a sprint wind-down, or… - 100branch-hygiene
Classify and clean up merged, stale, and orphaned git branches and worktrees. Detects squash-merges that git branch --merged cannot see, stale worktrees, and remote-gone branches. Use when user asks to clean up branches, prune worktrees, tidy the repo, or perform git housekeeping. - 90cleanup-branches
Delete merged and stale feature branches. Use when cleaning up after closed issues/MRs, or when you have many old local branches. Fetches, lists branches, identifies candidates, deletes with confirmation.