git-clean-gone-branches

Delete local git branches with deleted remote tracking branches and their worktrees.

1|Updated Apr 4, 2026
One-click install
npx skills add https://github.com/ybbms777/compound-engineering --skill git-clean-gone-branches-ybbms777
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-clean-gone-branches
Source: https://github.com/ybbms777/compound-engineering/tree/main/skills/git-clean-gone-branches
Command: npx skills add https://github.com/ybbms777/compound-engineering --skill git-clean-gone-branches-ybbms777

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Stale local git branches whose remote tracking branches have been deleted clutter your repository, create confusion when switching between tasks, and leave behind unused associated worktrees that take up unnecessary disk space.

Core Features & Use Cases

  • Automatic Gone Branch Detection: Fetches the latest remote state and identifies all local branches marked as gone from their remote tracking source.
  • Safe Worktree Cleanup: Automatically detects and removes associated git worktrees for stale branches before deleting the branches themselves to avoid orphaned directories.
  • Real-World Use Case: After merging multiple feature branches in a remote repository, use this skill to quickly clean up all corresponding local branches and their isolated worktrees to keep your development environment tidy.

Quick Start

Use the git-clean-gone-branches skill to delete all local branches that no longer exist on the remote and remove their associated worktrees.

Frequently Asked Questions about git-clean-gone-branches

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

FAQPage Schema
How do I delete local git branches that are gone on the remote?

To delete local git branches that are gone on the remote, this skill runs git fetch --prune and parses git branch -vv to identify stale branches. It safely removes associated worktrees and deletes the local branches after you explicitly confirm the action.

What is the best way to clean up stale git worktrees and local branches?

The best way to clean up stale git worktrees and local branches is to automate discovery of gone branches via git fetch --prune. This skill detects orphaned worktrees associated with stale branches and removes them before deleting the branches themselves to free disk space.

Can I automatically detect and remove orphaned git worktrees before deleting branches?

Yes, you can automatically detect and remove orphaned git worktrees before deleting branches. This skill identifies local branches marked as gone from their remote tracking source and safely removes their associated worktree directories prior to branch deletion.

Does pruning stale local branches require manual confirmation?

Yes, pruning stale local branches requires explicit user confirmation. The skill discovers gone branches by parsing git branch -vv output after fetching remote state, but it pauses to request your approval before executing any worktree or branch deletion commands.

Why do I have local git branches marked as gone after merging remote feature branches?

Local git branches are marked as gone after remote feature branches are merged and deleted. This skill addresses the resulting clutter by fetching the latest remote state, detecting these stale local branches, and cleaning up both the branches and their unused worktrees.