Cleanup Worktree — Git skill for Claude Code
Remove a merged worktree and its branch after verifying it was merged into main.
How to install Cleanup Worktree
Installs to ~/.claude/commands/lazynet-lazy-harness-cleanup-worktree.md
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/lazynet/lazy-harness/HEAD/.claude/commands/cleanup-worktree.md -o ~/.claude/commands/lazynet-lazy-harness-cleanup-worktree.md Restart Claude Code, or start a new session, for it to be picked up.
What Cleanup Worktree does
description: Remove a merged worktree and its branch after verifying it was merged into main argument-hint: (the directory name under .worktrees/, without the type prefix)
You are cleaning up the worktree `.worktrees/$ARGUMENTS` and its associated branch. This command must never remove unmerged work — verify first, remove second.
Validation (do this first, in order)
- Confirm
.worktrees/$ARGUMENTSexists. If not, stop and tell the user nothing to clean. - Identify
Alternatives in Git
- Ws Reset — Reset the current branch to main, fetch upstream, and update submodules 38.1k ★
- Clean Worktrees (Automatic) — Automatically remove all worktrees for branches merged into master 25.5k ★
- OSS PR — Commit + PR workflow for open source contributions: auto-creates a user-prefixed branch when on main/master, t 19.7k ★
Full documentation available on GitHub
View Source RepositoryRelated Skills
Branch Cleanup
Clean up merged, stale, and orphaned git branches. Protects main/develop/release/ automatically. Supports --dr
PR Merged
Post-merge cleanup — checkout main, pull latest, delete the feature branch, and close the linked work item.
Cleanup Merged
Clean up worktree and local + remote branch for a merged PR
Clean After Merged
Switch to the repo's main branch, pull, and delete the just-merged local branch.
Stack Sync
Cascade-rebase the current branch and all its descendants onto the new main, after a parent PR has merged. Use
CloseBranch
Close out a branch after its PR is merged/closed - switches to the PR's base branch (main, or the todo's arc b
Related Agents
Branch Janitor
Post-merge cleanup agent — after the human confirms a PR/branch merge, removes stale agent worktrees, deletes
Merge Cleanup
Commits worktree changes, cherry-picks them to main, removes the worktree, and prunes the branch. Use at the e
Code Cleanup Optimizer
Remove technical debt, improve quality, eliminate redundancy after implementation is verified. Never use befor