- name
- git-repo-cleaner
- description
- Audit and clean up Git repositories. Find stale/merged branches, large files in history, orphaned tags, repo bloat, and generate cleanup scripts. Use when asked to clean up a git repo, find stale branches, detect large files in git history, audit repo health, find merged branches to delete, reduce repo size, or perform git maintenance. Triggers on "clean up repo", "stale branches", "large files in git", "repo bloat", "merged branches", "git cleanup", "repo maintenance", "git audit".
Git Repo Cleaner
Audit Git repositories for bloat, stale branches, and maintenance issues. Generate safe cleanup scripts.
Quick Audit
python3 scripts/audit_repo.py /path/to/repoSpecific Checks
# Stale branches only
python3 scripts/audit_repo.py /path/to/repo --check branches
# Large files in history
python3 scripts/audit_repo.py /path/to/repo --check large-files
# Full audit
python3 scripts/audit_repo.py /path/to/repo --check allOutput Formats
python3 scripts/audit_repo.py /path/to/repo --format text|json|markdownChecks Performed
1. Stale Branches
- Branches not updated in >30 days (configurable with
--stale-days) - Branches already merged into main/master
- Branches with no unique commits
- Remote tracking branches with deleted remotes
2. Large Files
- Files >1MB in current tree (configurable with
--min-size) - Large blobs in git history (top 20)
- Binary files that shouldn't be tracked
3. Repo Stats
- Total repo size (.git directory)
- Pack file stats
- Object count and size
- Unreachable objects
4. Maintenance
- Missing .gitignore patterns (node_modules, __pycache__, .env, etc.)
- Unoptimized packfiles
- Stale reflog entries
Cleanup Script Generation
Use --fix to generate (not execute) cleanup scripts:
python3 scripts/audit_repo.py /path/to/repo --fix
# Outputs cleanup.sh with safe delete commandsThe generated script uses git branch -d (safe delete, refuses if not merged) by default. Use --force-delete to generate git branch -D commands instead.
Workflow
- Run audit on repo
- Review findings
- Generate cleanup script if needed
- Review script before executing
- Execute cleanup