← ClaudeAtlas

worktree-lifecyclelisted

Create and fully tear down git worktrees safely — anchored on the true main repo root (never nested), with a real teardown that frees the disk space a worktree's dependency install costs.
YoniChechik/claude-code-config · ★ 0 · AI & Automation · score 60
Install: claude install-skill YoniChechik/claude-code-config
## Why this exists Two real incidents drove this skill: 1. **Nested worktrees.** The older `create-worktree` skill's script resolves the repo root with `git rev-parse --show-toplevel`. Run from inside a worktree instead of the main repo checkout, that returns the WORKTREE's own top level, not the main repo's — so the new worktree gets created nested inside the old one (e.g. `core/.claude/worktrees/A/.claude/worktrees/B`). This repo's automated worktree/branch sweep hook (`session-maintenance.sh`, see the root `AGENTS.md` / `vibe-code-onboarding/AGENTS.md`) treats a nested worktree as orphaned and **destroys it without warning** — including any uncommitted work inside it. 2. **No teardown.** A worktree's setup runs a full dependency install (`pnpm install` across every workspace project, or `uv venv`), which costs several GB of disk per worktree. There was a creation script but nothing to fully remove one afterward, so finished worktrees piled up until the disk filled ("No space left on device"), blocking new worktree creation entirely. ## Hard rules - **Never run `git worktree add` / `git worktree remove` directly**, and **never use Claude Code's built-in `EnterWorktree`/`ExitWorktree` tools** for a repo worktree. Always go through `setup_worktree.sh` / `destroy_worktree.sh` (or the existing `/create-worktree` skill for creation, which this skill's setup script is interoperable with — both produce a worktree at the same