clean-branches

Delete local git branches marked [gone] and their associated worktrees.

562|80|Updated Jan 9, 2026
One-click install
npx skills add https://github.com/kdlbs/kandev --skill clean-branches-kdlbs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clean-branches
Source: https://github.com/kdlbs/kandev/tree/main/.agents/skills/clean-branches
Command: npx skills add https://github.com/kdlbs/kandev --skill clean-branches-kdlbs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Remove local branches that no longer exist on the remote (marked [gone]), including any associated git worktrees to keep the local repository clean.

Core Features & Use Cases

  • Identify and prune local branches with remote deletions ([gone]).
  • Remove associated git worktrees safely to avoid orphaned worktrees.
  • Use after merging PRs to tidy up a repository and reduce clutter.

Quick Start

Run the cleanup steps in your local repository to remove any local branches that no longer exist on the remote, along with their worktrees.

Frequently Asked Questions about clean-branches

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

FAQPage Schema
How do I clean up gone branches in my local git repository?

To clean up gone branches, the tool identifies local branches marked [gone] after remote deletion and safely removes them along with any associated git worktrees to keep your repository tidy.

What is the best way to delete local branches after a pull request merge?

Deleting local branches after a merge is best handled by identifying branches with remote deletions and safely removing them, including any linked worktrees, to reduce repository clutter.

Why do I have orphaned git worktrees when a branch is deleted?

Orphaned git worktrees occur when local branches are deleted without removing their associated worktree directories. This tool prevents them by safely removing worktrees during branch cleanup.

Does this remove git worktrees safely when cleaning up gone branches?

Yes, removing git worktrees safely is a core feature. It identifies branches marked [gone] and removes both the branches and their corresponding worktrees to ensure repository maintenance.

When should I prune local branches that no longer exist on the remote?

You should prune local branches that no longer exist on the remote during ongoing repository maintenance or immediately after merging PRs to tidy up local clones and reduce clutter.