/cleanup:worktree-sweep [path]from cleanup
Finds and removes stale git worktrees across one or many repositories. Classifies each as clean/dirty/locked, measures reclaimable space, and removes safe ones after approval.
Ships in cleanup. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Find and remove stale git worktrees, then report reclaimed space.
Operates in report → confirm → execute order. Nothing is removed until the user approves the plan. After approval, perform the removals autonomously. Choices are gathered through interactive questions, not flags.
Resolve where to look, in this priority order:
$ARGUMENTS — use it verbatim as the scan root.<owner>/<repo> directories, and show the resolved root in the question so the user can confirm or correct it.~/git.For multi-repo scope, enumerate repositories by locating each .git directory (a directory, not a gitdir file) under the resolved root.
For each in-scope repository:
git -C "$REPO" worktree list --porcelain
The first entry is the main checkout — never a removal candidate. Every additional entry is a candidate. Also note the current worktree (the one this session runs in, if any) and exclude it.
For every candidate worktree path $WT:
Dirty — uncommitted or untracked changes:
git -C "$WT" status --porcelain
A non-empty result means dirty. Inspect what changed before judging (see Step 4).
Locked — git worktree list --porcelain prints a locked line. Read the lock reason. If it embeds a PID (e.g. pid 29180), check whether that process is still alive:
ps -p "$PID" >/dev/null 2>&1 && echo live || echo stale
A stale lock (dead PID) is safe to clear. A live lock means a process is actively using the worktree — never remove it.
Prunable — the entry carries a prunable line. The gitdir file points to non-existent location reason (the working directory is gone) is reported immediately by plain git worktree list --porcelain; purely age-based prunability is instead gated by gc.worktreePruneExpire (default 3 months) unless --expire is passed. Either way, git worktree prune (Step 5) is the authoritative cleanup.
Clean — none of the above. Safe to remove.
Measure reclaimable size per candidate with du -sk "$WT" and total it.
Present a table: repository, worktree path, branch (or detached HEAD), classification, size. Sum the reclaimable total for the clean + stale-locked set. Call out separately:
Then ask the user (interactive question) which set to remove — e.g. the safe set (clean + stale-locked), or a narrower selection. Nothing is removed without that approval.
Do not blanket-remove dirty worktrees. Show the diff/stat and decide per item:
package-lock.json, go.sum), generated code (zz_generated.*), editor cruft, stray binaries not in git. Safe to discard with approval.For each approved worktree:
Stale lock → clear it first: git -C "$REPO" worktree unlock "$WT".
Restore the write bit before removing. Build/module caches inside a worktree are often read-only directories. A plain remove can deregister the worktree from git's metadata and then fail mid-delete on the read-only directory, leaving an orphaned tree that git no longer tracks. Pre-empt it:
chmod -R u+w "$WT"
git -C "$REPO" worktree remove --force "$WT"
After processing a repo: git -C "$REPO" worktree prune to clear prunable and any stale admin refs.
If a worktree was already deregistered but its directory remains on disk (orphaned), remove the directory tree directly — git worktree remove no longer applies to it.
Re-measure and report total space freed, the count removed, and anything intentionally kept (dirty-real-work, live-locked) with the reason.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
6 skills in this plugin
/brew-cleanupReclaim Homebrew disk by removing old formula/cask versions, pruning the download cache, and uninstalling orphaned dependencies (brew autoremove). Shows a dry-run estimate first, then runs the user-chosen scope after approval. TRIGGER when the user wants to free Homebrew space ("brew cleanup", "почисти brew", "remove orphaned brew packages"). DO NOT trigger for uninstalling a specific named formula./cleanup-allRun the full local cleanup pipeline — stale git worktrees, dead personal forks, Docker prune, Go caches, and Homebrew — in one pass, each stage report → confirm → execute, then a combined reclaimed-space summary. TRIGGER when the user wants a broad disk cleanup ("free up disk space", "почисти всё", "run the cleanup pipeline"). DO NOT trigger when the user clearly wants only one specific cleaner — invoke that skill instead./npx claudepluginhub lexfrei/ccc --plugin cleanupOther plugins' skills for the same job