ctx:worktree

Diagnose and resolve locked, stale, and orphaned git worktrees.

5|Updated Oct 14, 2025
One-click install
npx skills add https://github.com/Shakes-tzd/contextune --skill ctx-worktree
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ctx:worktree
Source: https://github.com/Shakes-tzd/contextune/tree/main/skills/git-worktree-master
Command: npx skills add https://github.com/Shakes-tzd/contextune --skill ctx-worktree

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill resolves frustrating Git worktree issues like locked files, removal errors, orphaned branches, and performance degradation, ensuring your development environment remains clean and efficient.

Core Features & Use Cases

  • Automated Diagnosis & Fixes: Quickly identify and safely resolve common worktree problems such as "locked" errors or "already exists" conflicts.
  • Intelligent Cleanup: Implement tailored cleanup strategies, from pruning stale references to removing merged worktrees, reclaiming disk space and improving performance.
  • Best Practices & Prevention: Learn proper worktree lifecycle management and receive guidance to prevent future issues, including automated maintenance scripts.

Quick Start

I can't remove my 'feature-x' worktree, it says it's locked.

Frequently Asked Questions about ctx:worktree

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

FAQPage Schema
How do I fix a git worktree that says it's locked?

A locked worktree error occurs when git-worktree lock files persist after abnormal termination. Remove the `.git/worktrees/[worktree-name]/locked` file or use `git worktree prune` to clear stale locks and restore access to your worktree.

Why can't I remove a worktree and how do I fix it?

Worktree removal fails due to unmerged branches, active processes, or file locks. Diagnose the issue with `git worktree list --prune`, merge or delete the branch, terminate blocking processes, and remove locks before running `git worktree remove`.

What are orphaned git worktrees and how do I clean them up?

Orphaned worktrees are registered in git but their directories are missing or inaccessible, causing performance degradation. Run `git worktree prune` to remove stale entries and reclaim disk space while maintaining repository integrity.

How do I prevent git worktree performance issues with multiple worktrees?

Performance degrades with numerous worktrees due to stale registrations and orphaned entries. Implement regular maintenance using `git worktree prune`, monitor with `git worktree list`, and remove merged worktrees to keep your repository optimized.

Can I automate git worktree maintenance and cleanup?

Yes, automate worktree lifecycle management with maintenance scripts that run `git worktree prune` periodically, remove merged branches, and check for locks. This prevents accumulation of stale registrations and keeps your development environment clean.