branch-cleanup
БесплатноБез исполняемых скриптовНе проверенComprehensive git branch cleanup and organization
от basher83★ 24 звезды на GitHubОб этом скилле
Perform a complete cleanup of local and remote branches after working on multiple PRs.
Current State
Default branch: !git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main"
Current branch: !git branch --show-current
Fetch latest: !git fetch --all --prune 2>&1
Branch Inventory
Local branches with tracking status:
!git branch --format='%(refname:short) %(upstream:track)' | sort
Recent branches by activity:
!git for-each-ref --count=15 --sort=-committerdate refs/heads/ --format='%(refname:short) - %(committerdate:relative)'
Remote branches:
!git branch -r --format='%(refname:short)' | grep -v HEAD | sort
Cleanup Candidates
Merged into default branch: !git branch --merged
Branches with gone remotes:
!git branch -vv | grep ': gone]' | awk '{print $1}' | sort
Protected Branches
Never delete branches matching these patterns:
main,master,develop,staging,productionrelease/*branches (unless explicitly confirmed)renovate/*branches (managed by Renovate bot)- Current working branch
- Branches with unpushed commits (confirm first)
Cleanup Workflow
Phase 1: Analyze
Review the branch inventory above. Categorize branches:
- Safe to delete: Merged branches and branches with gone remotes (excluding protected)
- Needs confirmation:
release/*branches, branches with unpushed commits - Protected: All protected branch patterns and current branch
Phase 2: Confirm Cleanup Plan
Present the cleanup plan and ask the user to select scope:
- All safe: Delete all merged and gone-remote branches
- Merged only: Delete only branches merged into default
- Gone only: Delete only branches with deleted remotes
- Review each: Confirm each branch individually
If "Review each" is selected, iterate through candidates asking per-branch confirmation.
Phase 3: Execute Cleanup
After confirmation, execute in order:
- Prune stale remote-tracking refs:
git remote prune origin - Delete merged local branches:
git branch -d <branch> - Delete gone-remote branches:
git branch -D <branch>
Record each branch name and SHA before deleting: git rev-parse <branch>
If deletion fails, ask user: Force delete, Skip, or Abort.
Phase 4: Remote Cleanup (Optional)
Ask whether to delete corresponding remote branches on origin.
Phase 5: Summary
Report:
- Count of deleted branches by category
- Repository branch count (before and after)
- Recovery commands with commit SHAs for each deleted branch:
git checkout -b <branch> <sha>
Установить branch-cleanup в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл branch-cleanup?
Comprehensive git branch cleanup and organization
Как установить скилл branch-cleanup?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл branch-cleanup запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
ci-review
The scan that the plugin's GitHub Action runs.
от Anthropicazure-static-web-apps
Helps create, configure, and deploy Azure Static Web Apps using the SWA CLI. Use when deploying static sites to Azure, setting up SWA local development…
от GitHubai-ready
Make any repo AI-ready — analyzes your codebase and generates AGENTS.md, copilot-instructions.md, CI workflows, issue templates, and more. Mines your PR…
от GitHubaws-cdk-python-setup
Setup and initialization guide for developing AWS CDK (Cloud Development Kit) applications in Python. This skill enables users to configure environment…
от GitHub