wt-cleanup

Detect merged pull request worktrees and remove them after user confirmation.

1|Updated Jan 22, 2022
One-click install
npx skills add https://github.com/gotomts/dotfiles --skill wt-cleanup-gotomts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wt-cleanup
Source: https://github.com/gotomts/dotfiles/tree/main/claude/skills/wt-cleanup
Command: npx skills add https://github.com/gotomts/dotfiles --skill wt-cleanup-gotomts

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Detects worktrees corresponding to branches whose pull requests have already been merged and helps remove stale local worktrees to keep repositories clean and reclaim disk space.

Core Features & Use Cases

  • Detects non-main worktrees in the current repository and maps each worktree branch to its corresponding GitHub pull request.
  • Classifies branches into merged (deletion candidates), unmerged, or having no PR, and presents a clear interactive summary for user review.
  • Use Case: After feature branches are merged, run this to safely remove their local worktrees in bulk while preserving open or manually managed branches.

Quick Start

Run the wt-cleanup skill to detect merged-PR worktrees in the current repository and interactively remove the confirmed ones.

Frequently Asked Questions about wt-cleanup

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

FAQPage Schema
How do I bulk remove merged PR worktrees from my local Git repository?

To bulk remove merged PR worktrees, run the wt-cleanup workflow from your repository root. It detects non-main worktrees, checks their GitHub PR status via the gh CLI, and interactively removes confirmed merged branches using the wt remove command.

How does worktree cleanup map local branches to merged GitHub pull requests?

Worktree cleanup maps local branches to merged GitHub pull requests by using the authenticated GitHub CLI to query each branch's PR status. It then classifies branches as merged, unmerged, or having no PR, presenting merged branches as interactive deletion candidates.

Do I need wt and gh CLI installed to clean up stale git worktrees?

Yes, you need the wt tool installed and the gh CLI authenticated to clean up stale git worktrees. The workflow operates from the local repository root and relies on wt remove for deletion after explicit user confirmation of merged PR branches.

Can I safely delete local worktrees without affecting open pull requests?

You can safely delete local worktrees without affecting open pull requests because the workflow classifies branches into merged, unmerged, or no PR categories. It only removes worktrees corresponding to branches whose GitHub PRs are already merged after explicit user confirmation.

What is the best way to reclaim disk space from stale feature branch worktrees?

The best way to reclaim disk space from stale feature branch worktrees is to run this workflow after features merge. It identifies merged-PR worktrees and performs interactive bulk deletion via wt remove, keeping your repository clean and freeing up local storage.

Why should I use an interactive worktree cleanup workflow instead of manual git branch deletion?

An interactive worktree cleanup workflow prevents accidental data loss by explicitly mapping local worktrees to their GitHub PR status before deletion. It ensures only merged branches are removed via wt remove, preserving unmerged or manually managed local worktrees during disk reclamation.