worktree-cleanup

Automate removal of Git worktrees and their branches after workflows complete.

71|14|Updated Jun 26, 2025
One-click install
npx skills add https://github.com/ProfSynapse/PACT-Plugin --skill worktree-cleanup-profsynapse
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: worktree-cleanup
Source: https://github.com/ProfSynapse/PACT-Plugin/tree/main/pact-plugin/skills/worktree-cleanup
Command: npx skills add https://github.com/ProfSynapse/PACT-Plugin --skill worktree-cleanup-profsynapse

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill automates the removal of git worktrees and their associated branches after a PACT workflow completes, preventing orphaned worktrees and cluttered repositories.

Core Features & Use Cases

  • Identify the target worktree to remove, or prompt when none provided.
  • Remove the worktree in a safe, single-bash-call sequence that moves to the repo root and executes git worktree remove.
  • Delete the corresponding local branch after removal.
  • Surface git errors clearly and avoid automatic force-removal, guiding the user through rescue options.

Quick Start

Remove a stale worktree by invoking the command /PACT:worktree-cleanup after confirming the target.

Frequently Asked Questions about worktree-cleanup

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

FAQPage Schema
How do I remove a git worktree and delete its branch after merging a PR?

To remove a git worktree and delete its branch, the skill navigates to the repository root, executes git worktree remove in a single shell call, and then deletes the corresponding local branch, surfacing any git errors encountered during the process.

What is the best way to automate git worktree cleanup for consolidated sub-scope work?

Automating git worktree cleanup involves identifying the target worktree, safely removing it via a single bash command from the repo root, and subsequently deleting the associated branch to prevent repository clutter and orphaned worktrees.

Why does git worktree removal fail and how can I avoid force removal?

Git worktree removal can fail due to uncommitted changes or errors. This skill avoids automatic force removal, surfaces the specific git errors clearly, and prompts for user confirmation to guide you through safe rescue options.

Can I clean up multiple git worktrees and branches in a single shell call?

This skill targets a single worktree and its corresponding branch per execution, moving to the repo root and executing git worktree remove once, followed by deleting the branch, ensuring safe and verified cleanup rather than batch force removal.

Do I need to manually specify which worktree to clean up?

You do not always need to manually specify the worktree; the skill can identify the target worktree to remove and will prompt you to select a target when none is explicitly provided.

When should I use automated worktree cleanup instead of manual git commands?

You should use automated worktree cleanup after a merged PR workflow or consolidated sub-scope work completes to prevent orphaned worktrees, as it safely enforces user confirmation for edge cases and avoids accidental force removal.