claude-worktreelisted
Install: claude install-skill erclx/toolkit
# Claude worktree
See `wiki/claude-worktrees.md` for `EnterWorktree` and `ExitWorktree` semantics. This skill wraps the entry path with name derivation so the user does not pick a name by hand.
## Guards
- If `git rev-parse --git-dir` and `git rev-parse --git-common-dir` differ, the session is already inside a linked worktree. Stop: `❌ Already in a worktree. Run ExitWorktree first.`
- If neither command resolves, the session is not in a git repo and no `WorktreeCreate` hook is configured. Stop: `❌ Not a git repository. EnterWorktree needs git or a WorktreeCreate hook.`
## Step 1: resolve the main worktree root
Run in parallel:
- `git worktree list --porcelain | awk '/^worktree /{print $2; exit}' 2>/dev/null || pwd`
- `git branch --show-current 2>/dev/null || echo ""`
Plans always live at the main root, never inside a linked worktree. See Worktrees in `CLAUDE.md`.
## Step 2: derive the worktree name
Try each source in order. Stop at the first match.
1. **Plan matched to current branch.** Take the branch name and replace `/` with `-` to get `<slug>`. If `<main-root>/.claude/plans/feature-<slug>.md` exists, use `<slug>`.
2. **Single plan file.** List `<main-root>/.claude/plans/feature-*.md`. If exactly one match, derive `<slug>` from the filename.
3. **Multiple plan files, no branch match.** Ask the user which plan. Show the candidate slugs as a numbered list. Do not pick.
4. **Current branch.** When no plan exists, use the branch name (with `/` replaced by `-`) if it