worktree-cleanup

Remove git worktree-pinned branches using the correct command sequence.

Updated Jul 1, 2026
One-click install
npx skills add https://github.com/NIMBUS-MX/nimbus-skills --skill worktree-cleanup-nimbus-mx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-cleanup
Source: https://github.com/NIMBUS-MX/nimbus-skills/tree/main/skills/worktree-cleanup
Command: npx skills add https://github.com/NIMBUS-MX/nimbus-skills --skill worktree-cleanup-nimbus-mx

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill ensures the correct order of operations when removing a branch that is pinned by a git worktree, preventing errors and maintaining workflow integrity.

Core Features & Use Cases

  • Branch Cleanup: Ensures the correct sequence of 'git worktree remove --force' followed by 'git branch -D' for clean-up.
  • Error Handling: Detects and reports errors related to worktree usage.
  • Batch Cleanup: Provides a method to clean up all merged branches with worktrees.
  • Cross-Repo Cleanup: Offers the ability to clean up old branches across all repositories.

Quick Start

Run the skill with the command "remove branch" or when you encounter "git branch -D" errors with "used by worktree".

Frequently Asked Questions about worktree-cleanup

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

FAQPage Schema
Why does git branch -D fail with a used by worktree error?

The git branch -D command fails because the branch is pinned by an active worktree, so you must remove the worktree first to enforce the correct deletion sequence and prevent errors.

How do I delete a git branch that is linked to a worktree?

To delete a git branch linked to a worktree, you must execute 'git worktree remove --force' followed by 'git branch -D' to ensure clean removal and prevent errors.

Can I batch cleanup all merged git branches that have worktrees?

Yes, you can batch cleanup all merged git branches with worktrees by running a dedicated method that automates the correct removal sequence across all matching branches.

What is the best way to clean up old git branches across multiple repositories?

The best way to clean up old git branches across multiple repositories is to use an automated cross-repo cleanup method that enforces the correct worktree removal sequence.

Does git worktree cleanup require any specific dependencies or environments?

Git worktree cleanup requires git installed for worktree management, and it is designed for developers and operations teams to maintain a clean git workflow.