clean-gone-branches

Delete local git branches marked [gone] while skipping worktree branches.

Updated Nov 16, 2025
One-click install
npx skills add https://github.com/mixomat/claude-plugins --skill clean-gone-branches
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-gone-branches
Source: https://github.com/mixomat/claude-plugins/tree/main/plugins/git-workflow/skills/clean-gone-branches
Command: npx skills add https://github.com/mixomat/claude-plugins --skill clean-gone-branches

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automates cleaning local git branches that are no longer present on the remote (marked [gone]), while safely skipping branches with worktrees.

Core Features & Use Cases

  • Identify Gone Branches: Detect local branches with the [gone] status.
  • Safe Cleanup: Delete non-worktree branches using git branch -D.
  • Progress Reporting: Provide per-branch feedback and a final summary.

Quick Start

  • List branches: git branch -v
  • Clean gone branches (without worktrees): git branch -v | grep '\[gone\]' | while read line; do if [[ $line =~ ^[+] ]]; then branch=$(echo "$line" | awk '{print $1}' | sed 's/^+//') echo "Skipping $branch (has worktree - remove worktree first)" else branch=$(echo "$line" | sed 's/^[* ]//' | awk '{print $1}') echo "Deleting branch: $branch" git branch -D "$branch" fi done
  • Report results and note about manual worktree cleanup

Frequently Asked Questions about clean-gone-branches

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I clean up local git branches marked as [gone]?

Clean up [gone] branches by identifying them with git branch -v, then deleting non-worktree branches using git branch -D. This removes local branches no longer present on the remote while safely preserving branches with active worktrees.

What are [gone] branches and why do they appear?

[gone] branches are local git branches whose remote counterparts have been deleted. They persist locally until manually removed, appearing in git branch -v output as [gone] to signal the remote tracking reference is stale.

Can I safely delete [gone] branches if I have git worktrees?

Yes, but with caution. Branches with worktrees (marked with +) must be skipped during cleanup—remove the worktree first, then delete the branch. This automation identifies and skips worktree branches automatically.

How do I automate removal of stale local branches after remote deletion?

Automate branch cleanup by filtering git branch -v output for [gone] status, skipping worktree-linked branches, and executing git branch -D on safe candidates. This provides per-branch feedback and a final summary of deletions.

What's the best way to batch clean gone branches without manual git commands?

Use an automated cleanup script that identifies [gone] branches, validates worktree associations, deletes safe branches with git branch -D, and reports results. This eliminates repetitive manual commands and reduces deletion errors.