cleanup-pr-diff-worktree

Remove git worktrees created for pull request diff reviews, including dirty or non-empty contents.

Updated Mar 3, 2026
One-click install
npx skills add https://github.com/D3Hunter/ai-engineer --skill cleanup-pr-diff-worktree
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cleanup-pr-diff-worktree
Source: https://github.com/D3Hunter/ai-engineer/tree/main/skills/cleanup-pr-diff-worktree
Command: npx skills add https://github.com/D3Hunter/ai-engineer --skill cleanup-pr-diff-worktree

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires git, and includes scripts (resource) components.

What problem does it solve?

When using a dedicated git worktree for pull request diff reviews, leftover uncommitted changes or extra files often block standard worktree removal, leaving unnecessary clutter in your project repository. This Skill automates the cleanup of these PR review worktrees, even when they are dirty or non-empty, eliminating manual deletion hassle and git errors.

Core Features & Use Cases

  • Force Cleanup Support: Removes worktrees with uncommitted changes or extra files that would normally block deletion, with an optional no-force mode for strict cleanup requirements.
  • Flexible Target Identification: Accepts either the worktree folder name under the project's worktrees/ directory or an absolute filesystem path to the worktree location.
  • Safety Guardrails: Restricts cleanup operations only to paths under the project's designated worktrees/ root, preventing accidental deletion of unrelated directories.
  • Use Case: After finishing a PR code review in an isolated worktree, use this Skill to instantly clean up the worktree without manually resolving git worktree removal errors or deleting leftover files.

Quick Start

Use the cleanup-pr-diff-worktree skill to remove the PR-123 worktree from your current git project, including any leftover uncommitted files.

Frequently Asked Questions about cleanup-pr-diff-worktree

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

FAQPage Schema
How do I force delete a git worktree with uncommitted changes?

To force delete a git worktree with uncommitted changes, you need a cleanup tool that overrides standard git removal blocks. This Skill forcibly removes dirty PR review worktrees, clearing leftover files and non-empty directories that prevent normal deletion.

Why does git worktree remove fail on dirty directories?

Git worktree remove fails on dirty directories when uncommitted changes or extra files block standard deletion. This Skill bypasses those git errors by applying forced cleanup to stale PR review worktrees, eliminating the need for manual file resolution.

What is the best way to clean up PR review worktrees after code review?

The best way to clean up PR review worktrees after code review is automating the forced removal of isolated worktree directories. This Skill targets worktrees by folder name or absolute path and safely deletes them under the project's designated worktrees root.

Can I restrict git worktree cleanup to a specific project directory?

Yes, you can restrict git worktree cleanup to a specific project directory using built-in safety guardrails. This Skill limits removal operations strictly to paths under the project's designated worktrees root, preventing accidental deletion of unrelated directories.

How do I remove a stale git worktree using an absolute filesystem path?

To remove a stale git worktree using an absolute filesystem path, provide the path to a cleanup utility that supports flexible target identification. This Skill accepts absolute paths or worktree folder names to force-remove leftover PR review directories.