cleanup-dangling-worktrees

Remove Git worktrees whose linked pull requests have merged while preserving active development branches.

4|1|Updated Oct 29, 2025
One-click install
npx skills add https://github.com/bacchus-labs/wrangler --skill cleanup-dangling-worktrees
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup-dangling-worktrees
Source: https://github.com/bacchus-labs/wrangler/tree/main/skills/cleanup-dangling-worktrees
Command: npx skills add https://github.com/bacchus-labs/wrangler --skill cleanup-dangling-worktrees

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires gh, and includes scripts (resource) components.

What problem does it solve?

This Skill helps maintain a clean Git repository by automatically identifying and removing stale worktrees associated with merged feature branches, preventing clutter and potential confusion.

Core Features & Use Cases

  • Automated Cleanup: Safely removes Git worktrees for branches whose associated Pull Requests have been merged.
  • Safety First: Implements strict checks to ensure no active development worktrees are deleted (e.g., uncommitted changes, unpushed commits, open PRs).
  • Use Case: After a busy development cycle with many feature branches, run this skill to clear out worktrees for completed features, keeping your project tidy and focused.

Quick Start

Run the cleanup-dangling-worktrees skill to remove any unneeded Git worktrees.

Frequently Asked Questions about cleanup-dangling-worktrees

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

FAQPage Schema
How do I automatically remove Git worktrees for merged branches?

To automatically remove Git worktrees for merged branches, run a cleanup process that verifies Pull Request merge status via GitHub CLI and safely prunes associated worktrees while preserving active development branches and uncommitted changes.

What is a dangling worktree in Git and when should I prune it?

A dangling Git worktree is a stale working directory left behind after a feature branch is merged. You should prune worktrees after completing development cycles to clear clutter and prevent confusion in your repository.

Do I need the GitHub CLI to clean up stale Git worktrees?

Yes, you need the GitHub CLI (gh) to clean up stale Git worktrees safely. The process requires gh to verify whether associated Pull Requests have been merged before removing the worktree directories.

Is it safe to automatically delete Git worktrees with uncommitted changes?

Automatically deleting Git worktrees with uncommitted changes is prevented by strict safety checks. The cleanup process scans for uncommitted changes, unpushed commits, and open PRs to ensure active development worktrees are preserved.

What is the best way to clean up Git worktrees after merging a Pull Request?

The best way to clean up Git worktrees after merging a PR is to use an automated cleanup skill that identifies stale worktrees, verifies PR merge status using gh, and removes them while applying strict checks against deleting active branches.