← ClaudeAtlas

git-worktreeslisted

Set up an isolated git worktree so the current checkout stays untouched and several tickets can run at once on one repo. Detects existing isolation and reuses a ticket's worktree, creates or attaches .worktrees/<branch>, verifies setup. Use when the user asks for a worktree; execute-plan calls it when the checkout is not already on the ticket branch (consent implied there).
ayberkcansever/ai-skills · ★ 2 · AI & Automation · score 73
Install: claude install-skill ayberkcansever/ai-skills
# Git Worktrees Ensure work happens in an isolated workspace without disturbing the current checkout. Detect first. Consent only when the user invoked this skill directly; execute-plan skips the consent question, not this skill. **Announce at start:** "I'm using the git-worktrees skill to set up an isolated workspace." ## Step 1: Detect existing isolation ```bash GIT_DIR=$(cd "$(git rev-parse --git-dir)" && pwd -P) GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" && pwd -P) git worktree list ``` - `GIT_DIR != GIT_COMMON` → already in a linked worktree. Report path + branch, skip to Step 3. Exception: if `git rev-parse --show-superproject-working-tree` prints a path, you are in a submodule, not a worktree — treat as normal repo. - `git worktree list` already shows a worktree for this ticket → `cd` into it and skip to Step 3. Never create a second one for the same ticket. - Current branch already matches this ticket (`git branch --show-current` contains the ticket key) → this checkout is the venue. Skip Step 2. Go to Step 3. - `GIT_DIR == GIT_COMMON` and no ticket worktree → normal checkout, continue. ## Step 2: Create the worktree **Consent:** ask once, unless the user already told you their preference — > "Set up an isolated worktree? It protects your current branch and > uncommitted work." If declined, stop. Do not execute in the current checkout. **Invoked from execute-plan, consent is implied and this question is skipped**: execute-plan only reaches t