Perform git repository cleanup operations based on the analysis from `/git-tools:analyze-git`.
Performs destructive cleanup of stale git branches, worktrees, and dependabot references based on prior analysis.
/plugin marketplace add bengous/claude-code-plugins/plugin install git-tools@bengous-pluginsPerform git repository cleanup operations based on the analysis from /git-tools:analyze-git.
IMPORTANT: This command performs DESTRUCTIVE operations. Run /git-tools:analyze-git first to review what will be deleted.
You MUST run /git-tools:analyze-git before using this command to understand what will be deleted.
Run the following command to remove worktrees and delete branches marked as [gone]:
git branch -v | grep '\[gone\]' | sed 's/^[+* ]//' | awk '{print $1}' | while read branch; do
echo "Processing branch: $branch"
worktree=$(git worktree list | grep "\\[$branch\\]" | awk '{print $1}')
if [ ! -z "$worktree" ] && [ "$worktree" != "$(git rev-parse --show-toplevel)" ]; then
echo " Removing worktree: $worktree"
git worktree remove --force "$worktree"
fi
echo " Deleting branch: $branch"
git branch -D "$branch"
done
After completion, report:
Run the following command to prune worktrees marked as prunable:
git worktree prune -v
Report the output showing which worktrees were pruned.
IMPORTANT: Before deleting, verify these are truly closed/merged by checking the PR list.
For each dependabot branch with a CLOSED or MERGED PR:
git fetch --prune
Report:
After all cleanup operations:
git branch
git branch -r
git worktree list
Create a summary report with:
/git-tools:analyze-git first