worktree-cleanup

Remove merged or stale git worktrees after verifying a clean state.

18|5|Updated Nov 3, 2025
One-click install
npx skills add https://github.com/mvillmow/ml-odyssey --skill worktree-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-cleanup
Source: https://github.com/mvillmow/ml-odyssey/tree/main/.claude/skills/worktree-cleanup
Command: npx skills add https://github.com/mvillmow/ml-odyssey --skill worktree-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? This Skill automates the removal of merged or stale Git worktrees, helping developers maintain an organized workspace, free up disk space, and avoid clutter from old development branches. It simplifies repository maintenance, saving time and reducing complexity.

Core Features & Use Cases:

  • Remove Single Worktree: Safely delete a specific worktree by issue number or path, with safety checks for uncommitted changes.
  • Clean Merged Worktrees: Automatically identify and remove worktrees associated with merged branches, keeping your local repo tidy.
  • Use Case: After merging several pull requests, use this skill to automatically identify and remove all worktrees associated with those merged branches. This keeps your local repository clean and efficient, freeing up valuable disk space.

Quick Start: Use the worktree-cleanup skill to remove all git worktrees associated with merged branches.

Frequently Asked Questions about worktree-cleanup

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

FAQPage Schema
How do I remove merged Git worktrees automatically?

Remove merged Git worktrees by identifying branches merged to main, locating their corresponding worktrees, and executing git worktree remove commands. This automation cleans your repository and frees disk space without manual branch tracking.

What safety checks happen when cleaning up worktrees?

Worktree cleanup verifies no uncommitted changes exist, avoids removing the active worktree, and includes optional user confirmation before deletion. Error handling ensures failed removals don't corrupt your repository state.

Can I delete a specific worktree by issue number or path?

Yes, remove single worktrees by specifying an issue number or path. The Skill performs safety checks for uncommitted changes before deletion, letting you target stale worktrees individually.

When should I clean up Git worktrees?

Clean up worktrees after merging pull requests to maintain an organized workspace and recover disk space. Regular cleanup prevents clutter from old development branches and keeps your local repository efficient.

Does worktree cleanup work with repositories using multiple worktrees?

Yes, worktree cleanup is designed for repositories using Git worktrees. It safely handles multiple worktrees, identifies merged branches across them, and removes obsolete ones while protecting your active worktree.