cleanup-worktrees

Prune git worktrees and local branches after merged PRs.

1|Updated May 12, 2018
One-click install
npx skills add https://github.com/tbroadley/dotfiles --skill cleanup-worktrees
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup-worktrees
Source: https://github.com/tbroadley/dotfiles/tree/main/claude/skills/cleanup-worktrees
Command: npx skills add https://github.com/tbroadley/dotfiles --skill cleanup-worktrees

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps developers safely remove git worktrees and related local branches once associated PRs have been merged into the main line, reducing clutter and potential confusion.

Core Features & Use Cases

  • Remove worktrees whose PRs have been merged on GitHub.
  • Identify worktrees with open PRs to avoid accidental deletion.
  • Prune stale local branches corresponding to merged work, with user confirmation before deletion.

Quick Start

Use the cleanup-worktrees skill to scan local worktrees, confirm which ones are safe to remove, and delete them along with their branches.

Frequently Asked Questions about cleanup-worktrees

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

FAQPage Schema
How do I clean up git worktrees after a PR is merged?

To clean up git worktrees after a PR is merged, you can scan local worktrees, verify their merge status on GitHub, and safely remove the ones that have been merged along with their stale local branches.

Can I safely delete local branches associated with merged PRs?

Yes, you can safely delete local branches associated with merged PRs by verifying their merge status first and performing removal with user confirmation to prevent accidental deletion of open work.

How do I check if a git worktree has an open PR before deleting it?

To check if a git worktree has an open PR before deleting it, the skill identifies worktrees with open PRs on GitHub to ensure they are excluded from pruning and avoid accidental removal.

What is the best way to prune stale git worktrees across multiple repositories?

The best way to prune stale git worktrees across multiple repositories is to enumerate them using git worktree commands, verify merged status via gh pr, and execute confirmed removals safely.

Does this branch management skill work with GitHub PRs?

Yes, this branch management skill works with GitHub PRs by relying on the gh pr command to verify whether pull requests associated with local worktrees and branches have been merged.

Why should I avoid manually removing git worktrees instead of using a pruning tool?

You should avoid manually removing git worktrees because a dedicated pruning tool safely verifies merge status and identifies open PRs first, reducing clutter and preventing the accidental deletion of active branches.