git-worktreeslisted
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