git-clean-gone-branches

Delete local Git branches whose remote tracking branch no longer exists, including associated worktrees.

6|2|Updated Jan 30, 2026
One-click install
npx skills add https://github.com/Jerrylalala/compound-engineering --skill git-clean-gone-branches-jerrylalala
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: git-clean-gone-branches
Source: https://github.com/Jerrylalala/compound-engineering/tree/main/plugins/compound-engineering/skills/git-clean-gone-branches
Command: npx skills add https://github.com/Jerrylalala/compound-engineering --skill git-clean-gone-branches-jerrylalala

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Over time, local repositories accumulate stale branches whose remote counterparts were deleted after merges, cluttering branch lists and making navigation harder. This Skill finds those orphaned branches and removes them safely, along with any linked worktrees. ## Core Features & Use Cases - Gone Branch Discovery: Runs git fetch --prune and parses git branch -vv output to identify branches marked : gone]. - Confirmation Before Deletion: Presents the full list of stale branches and waits for explicit user confirmation before deleting anything. - Worktree Cleanup: Detects and removes associated Git worktrees before deleting each branch, skipping the currently checked-out branch. - Use Case: After a sprint where many feature branches were merged and deleted on the remote, run this Skill to prune all local leftovers in one confirmed pass. ## Quick Start Ask the assistant to clean up local branches that no longer exist on the remote, then confirm the presented list to delete them.

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 were deleted on the remote?▼

Run git fetch --prune to sync remote state, then find branches marked ': gone]' in git branch -vv output and delete them with git branch -D. This Skill automates that discovery and deletion with a confirmation step.

How to clean up stale Git branches after merging pull requests?▼

After pull requests are merged and remote branches deleted, local copies remain until pruned. The Skill fetches with --prune, lists all gone branches, and deletes them in one confirmed batch.

Does deleting a branch also remove its Git worktree?▼

Not automatically; a worktree must be removed first with git worktree remove before its branch can be deleted. This Skill checks each branch for an associated worktree and removes it before deleting the branch.

Why can't git delete the currently checked-out branch?▼

Git refuses to delete the active branch because your working directory depends on it. The discovery script skips lines marked with '*' in git branch -vv output so the current branch is never targeted.

Is it safe to run git branch cleanup automatically?▼

Deletion is only safe after confirming the branches are truly obsolete. This Skill always presents the full list of gone branches and waits for an explicit yes-or-no confirmation before deleting anything.