worktree-cleanup

Remove Git worktrees and optionally delete associated branches.

17|8|Updated Oct 30, 2025
One-click install
npx skills add https://github.com/michael-harris/devteam --skill worktree-cleanup-michael-harris
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-cleanup
Source: https://github.com/michael-harris/devteam/tree/main/skills/worktree-cleanup
Command: npx skills add https://github.com/michael-harris/devteam --skill worktree-cleanup-michael-harris

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill provides a manual way to clean up Git worktrees, which is rarely needed as they are usually removed automatically.

Core Features & Use Cases

  • Manual Worktree Removal: Safely remove Git worktrees, with checks for uncommitted or unpushed changes.
  • Branch Management: Optionally delete associated Git branches after worktree removal.
  • Use Case: If an automatic worktree cleanup fails after a development track is merged, you can use this command to manually remove the leftover worktree and its branch.

Quick Start

Use the worktree cleanup skill to remove all worktrees.

Frequently Asked Questions about worktree-cleanup

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

FAQPage Schema
How do I manually clean up leftover Git worktrees after a branch merge?

To clean up Git worktrees, you can manually remove leftover development tracks and optionally delete their associated branches. This is useful when automatic worktree cleanup fails after a merge.

Is it safe to remove a Git worktree with uncommitted changes?

Removing a Git worktree is safe because the process validates for uncommitted changes and warns about unpushed commits before removal. This prevents accidental data loss during the branch management cleanup.

How do I delete a Git branch when removing its worktree?

You can optionally delete associated Git branches during worktree removal. The cleanup process safely manages branch deletion alongside the worktree cleanup to ensure your repository stays organized.

Why does automatic Git worktree cleanup fail and leave leftover directories?

Automatic Git worktree cleanup can fail after a development track is merged, leaving leftover directories. Manual worktree removal resolves this by safely targeting and deleting the remaining worktree files.

Does Git worktree cleanup keep an audit trail of removed branches?

Git worktree cleanup updates SQLite state to maintain an audit trail of removed worktrees and branches. This ensures you have a historical record of the branch management and cleanup actions performed.