worktree-cleanup

Remove finished Git worktrees and associated tmux sessions by pattern.

Updated Jan 26, 2013
One-click install
npx skills add https://github.com/boxp/dotfiles --skill worktree-cleanup-boxp
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-cleanup
Source: https://github.com/boxp/dotfiles/tree/main/.claude/skills/worktree-cleanup
Command: npx skills add https://github.com/boxp/dotfiles --skill worktree-cleanup-boxp

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill cleans up finished worktrees and their tmux sessions, preventing clutter and confusion after feature work, while preserving important branches.

Core Features & Use Cases

  • Cleanup completed worktrees and their associated tmux sessions based on a worktree pattern.
  • Remove the worktree directory while leaving the Git branch intact, enabling continued work on the same branch later if needed.
  • Remove both the worktree and its branch with the -b option for a complete cleanup.
  • Prune stale worktree references to keep the repository state clean.

Quick Start

To perform a complete cleanup for a given worktree pattern, run: gwq tmux kill <pattern>; cd $(gwq get master); gwq remove -b <pattern>; gwq prune.

Frequently Asked Questions about worktree-cleanup

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

FAQPage Schema
How do I clean up git worktrees and associated tmux sessions after finishing a task?

To clean up git worktrees and tmux sessions after a task, you can automate the removal of finished worktree directories and their linked tmux sessions based on a specific worktree pattern. This prevents clutter while keeping your repository state clean.

Can I remove a git worktree without deleting the branch?

Yes, you can remove a git worktree directory while leaving the Git branch intact. This preserves the branch for later use, allowing you to continue work on it without needing to recreate the branch.

What is the best way to prune stale git worktree references?

The best way to prune stale git worktree references is to use a cleanup operation that targets and removes outdated worktree links. This keeps your repository state clean and prevents confusion during development and maintenance workflows.

Do I need external libraries to automate worktree and tmux session cleanup?

No, you do not need external libraries to automate worktree and tmux session cleanup. The process requires only the gwq tool to be available in your environment to manage worktree removal and tmux session killing.

How do I completely remove both a worktree and its git branch?

To completely remove both a worktree and its git branch, you can use a cleanup command with the -b option. This deletes the worktree directory along with the associated branch for a thorough cleanup of finished feature work.