git-worktree-cleanup

Remove Git worktrees for merged branches and closed Pull Requests.

3|1|Updated Jan 31, 2026
One-click install
npx skills add https://github.com/andres-vv/Flowkify-mission-10x --skill git-worktree-cleanup
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-worktree-cleanup
Source: https://github.com/andres-vv/Flowkify-mission-10x/tree/main/skills/git-worktree-cleanup
Command: npx skills add https://github.com/andres-vv/Flowkify-mission-10x --skill git-worktree-cleanup

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

This Skill automates the cleanup of Git worktrees that are no longer needed, specifically those whose branches have been merged or whose associated Pull Requests have been closed, preventing clutter and improving repository management.

Core Features & Use Cases

  • Automated Merged Branch Cleanup: Removes Git worktrees tied to branches that are already merged into the base branch.
  • Pull Request Status Check: Identifies and cleans up worktrees for branches associated with closed or merged Pull Requests, even for squash merges.
  • Work Item Resolution: Updates Azure DevOps (ADO) work items to a 'Resolved' state for branches that have been cleaned up.
  • Use Case: After completing a feature and merging its Pull Request, this Skill can automatically remove the corresponding worktree and update the related ADO ticket.

Quick Start

Run the git-worktree-cleanup skill to prune stale Git worktrees.

Frequently Asked Questions about git-worktree-cleanup

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

FAQPage Schema
How do I automatically clean up git worktrees after a pull request is merged?

You can automatically clean up git worktrees by running a script that identifies worktrees tied to merged branches or closed pull requests, deletes the worktrees and local branches, and prunes stale references. This prevents clutter and improves repository management.

Can I remove git worktrees for squash merged branches?

Yes, you can remove git worktrees for squash merged branches. The cleanup process identifies and cleans up worktrees for branches associated with closed or merged pull requests, detecting squash merges to ensure the corresponding worktrees are deleted.

Does git worktree cleanup work with Azure DevOps work items?

Yes, git worktree cleanup works with Azure DevOps. It updates Azure DevOps work items to a 'Resolved' state for branches that have been cleaned up, integrating repository management with project tracking via API interaction.

What do I need to automate git worktree deletion and branch pruning?

To automate git worktree deletion and branch pruning, you need bash scripting, Git commands, and interaction with GitHub and Azure DevOps APIs via MCP. These components identify merged branches, remove worktrees, delete local branches, and prune stale references.

Why do stale git worktrees accumulate in my repository?

Stale git worktrees accumulate when branches are merged or pull requests are closed without removing the associated worktrees. This happens frequently with squash merges where local branch references remain, requiring automated cleanup to prevent repository clutter.

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

The best way to prune stale git worktrees is to automate the cleanup process by checking pull request status and branch merge state. This approach removes unnecessary worktrees, deletes local branches, prunes stale references, and updates related work items simultaneously.