git-prune-worktrees

Prunes stale Git worktrees and merged branches with dry-run previews and protected branch patterns.

1|Updated Apr 13, 2026
One-click install
npx skills add https://github.com/t-uda/skills --skill git-prune-worktrees
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-prune-worktrees
Source: https://github.com/t-uda/skills/tree/main/skills/git-prune-worktrees
Command: npx skills add https://github.com/t-uda/skills --skill git-prune-worktrees

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Prune stale Git worktrees and merged branches across a repository to reduce clutter and maintenance cost.

Core Features & Use Cases

  • Dry-run previews to review planned removals before applying changes.
  • Safely delete merged local branches and prune stale linked worktrees.
  • Respect protected branches and user-specified include/exclude patterns.

Quick Start

Run the script with a dry-run to preview actions, then rerun with --yes to apply the cleanup.

Frequently Asked Questions about git-prune-worktrees

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

FAQPage Schema
How do I safely clean up stale Git worktrees and merged branches?

To safely clean up stale Git worktrees and merged branches, run a dry-run preview to review planned removals, then execute the script with the --yes flag to apply the deletion plan while respecting protected refs.

Can I preview Git worktree and branch deletions before applying them?

Yes, you can preview Git worktree and branch deletions by running a dry-run, which generates a JSON-like report of planned actions, skips, and errors without modifying your repository.

How do I exclude specific branches from a Git worktree cleanup?

You can exclude specific branches from a Git worktree cleanup by using user-specified include/exclude patterns, which selectively target branches for removal while enforcing protection for critical refs.

What is the best way to automate the removal of multiple stale Git worktrees?

The best way to automate removing multiple stale Git worktrees is using a plan-driven workflow that optionally fetches remote updates, applies include/exclude patterns, and requires a --yes approval to execute the pruning.

Does Git worktree pruning work with protected branches?

Yes, Git worktree pruning respects protected branches by evaluating removal plans against protected refs, ensuring critical branches are skipped during the automated cleanup of merged local branches and stale worktrees.

Why should I use a plan-driven workflow for Git branch management?

A plan-driven workflow for Git branch management reduces maintenance clutter by safely validating removal actions, providing JSON-like reporting of errors and skips, and preventing accidental deletion of unmerged or protected branches.