← ClaudeAtlas

worktree-hygienelisted

Use when creating, removing, or handing over git worktrees, or deleting their branches, or when several actors share one repository through worktrees.
Vivswan/skills · ★ 1 · AI & Automation · score 60
Install: claude install-skill Vivswan/skills
# Worktree Hygiene > A worktree is shared mutable state: removal is destructive, a handover is an ownership transfer, and every worktree shares the main repository's `.git`. Each rule below guards against a destructive failure seen in production. "An actor" below is anything that writes into a worktree: an agent, a subagent, a human session, a process one of them spawned. ## When to Apply - Removing a git worktree or deleting its branch - Handing a worktree or branch from one actor to another, or resuming an actor that owns one - Several actors (agents, sessions, scripts) share one repository or one worktree - Checking out branches or writing `git config` while other worktrees exist ## Removing a Worktree Verify all three before `git worktree remove`, freshly, in this order: 1. **Clean, by fresh status codes.** Run a fresh `git -C <tree> status --porcelain -uall` (`-uall` overrides a `status.showUntrackedFiles=no` config that would silently hide untracked files) and read the STATUS CODES; never trust a prior report's dirty count. Counts cannot distinguish new files from removal-in-progress deletions; codes can. Every entry blocks the removal unless its exact path is positively identified as disposable: a removal-in-progress shows its own deletions as `D`, and a coordinating actor's keepalive marker (below) is a lone `??`. A `??`, `M`, or `D` entry not identified that way is real work. - A clean tree loses nothing TRACKED on removal; its commits survive on their ref.