lazynet

Cleanup Worktree — Git skill for Claude Code

Git community

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

Terminal
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)

  1. Confirm .worktrees/$ARGUMENTS exists. If not, stop and tell the user nothing to clean.
  2. 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 Repository