.agents/skills/speckit-worktree-clean/SKILL.md
Remove stale or merged worktrees and reclaim disk space
npx skillsauth add pradeepmouli/lspeasy speckit-worktree-cleanInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Remove worktrees for branches that have been merged or are no longer needed. Safely cleans up .worktrees/ directory entries and reclaims disk space.
$ARGUMENTS
You MUST consider the user input before proceeding (if not empty). The user may specify a branch name to clean (e.g., "005-api-gateway"), "merged" to clean all merged worktrees, or "all" to clean everything.
.specify/ directory.worktrees/ directory exists and contains worktreesScan worktrees: List all worktrees and classify them:
Build cleanup plan: Based on user input, determine what to remove:
| User Input | Action |
|-----------|--------|
| Specific branch name | Remove that worktree only (with confirmation) |
| merged | Remove all merged worktrees |
| stale | Remove all stale worktrees (30+ days inactive) |
| all | Remove all worktrees except main (with strong warning) |
| No input | Remove merged and orphaned only (safest default) |
Present cleanup plan: Show a preview before making any changes:
# Worktree Cleanup Plan
| # | Branch | Status | Action | Disk Size |
|---|--------|--------|--------|-----------|
| 1 | 005-api-gateway | ✅ Merged | Remove | ~45 MB |
| 2 | 002-old-feature | ❌ Orphaned | Remove | ~32 MB |
| 3 | 004-chat-system | 🟡 Idle | Keep (not merged) | ~41 MB |
**Will remove**: 2 worktrees (~77 MB)
**Will keep**: 1 worktree
Confirm with user: Ask for explicit confirmation before proceeding. Removing worktrees with uncommitted changes is destructive.
Check for uncommitted changes: Before removing each worktree:
git -C .worktrees/{branch}/ status --porcelain to check for uncommitted workExecute cleanup: For each worktree to remove:
git worktree remove .worktrees/{branch-name} to safely removegit worktree unlock .worktrees/{branch-name} first.worktrees/ directorygit worktree prune after all removals to clean up stale referencesReport: Output a summary:
.worktrees/git worktree prune to clean up stale administrative filestools
Use for ANY rename, file-move, or move-symbol refactor — especially rename-heavy work across multiple files. Claude Code's built-in LSP tool is READ-ONLY (find references, but no rename / file-move / move-symbol). Hand-editing those refactors silently misses re-exports, aliased imports, type-only imports, and {@link} doc references. This skill drives a real language server via the `lspeasy` CLI to apply a correct WorkspaceEdit that catches every reference. Trigger when the user asks to rename a function/class/variable/type project-wide, move a file and fix its importers, or pull a symbol out into another module.
tools
Documentation site for lspeasy Use when: You are building a browser-based LSP client, a WebSocket-backed language....
tools
Documentation site for lspeasy Use when: You are implementing a custom client layer and need the same validation....
tools
Use when working with lspeasy (client, core, server). Covers: lsp, language-server-protocol, lsp-client, language-client, jsonrpc, transport, lsp-server, language-server.