# Worktree New

> Git worktree conventions for isolated parallel feature work. Use when starting a new coding task, feature, bugfix, or PR-review in a git repository — anytime work should get its own branch and worktree instead of touching the main checkout, or when the user asks to work in / create / list / remove a worktree. Applies to whatever repository Claude is currently in.

- Skill: `enverge-labs/worktree-new` (Agent Skill)
- Install (CLI): `npx skillmds@latest add enverge-labs/worktree-new`
- Raw SKILL.md: https://api.skillmd.com/api/skills/enverge-labs/worktree-new/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: Enverge-Labs (https://skillmd.com/u/enverge-labs)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/enverge-labs/worktree-new

---


# Git worktrees

Isolate each task in its own worktree so the main checkout stays on the default branch and parallel work never collides.

## First: find the repo and defer to a local doc

Run these before anything else — they resolve the repo you're actually in (never hardcode a path):

```bash
ROOT="$(git rev-parse --show-toplevel)" || { echo "not a git repo"; exit 1; }
DEFAULT_BRANCH="$(git -C "$ROOT" symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | sed 's@^origin/@@' || echo main)"
```

**If `$ROOT/WORKTREES.md` exists, read it and follow it instead** — the repo's own doc is the source of truth and may override the conventions below. Only fall back to this skill's defaults when the repo has no `WORKTREES.md`.

## Naming (default convention)

| Item | Pattern | Example |
|------|---------|---------|
| Directory | `.claude/worktrees/<slug>/` | `.claude/worktrees/add-start-timestamp` |
| Branch | `worktree-<slug>` | `worktree-add-start-timestamp` |

`<slug>` = kebab-case task title (lowercase, hyphens).

## Create

From an up-to-date default branch:

```bash
git -C "$ROOT" fetch origin
SLUG="my-feature-name"
git -C "$ROOT" worktree add -b "worktree-${SLUG}" ".claude/worktrees/${SLUG}" "origin/${DEFAULT_BRANCH}"
cd "$ROOT/.claude/worktrees/${SLUG}"
```

If the branch already exists, drop `-b` and point at it:

```bash
git -C "$ROOT" worktree add ".claude/worktrees/${SLUG}" "worktree-${SLUG}"
```

## Ship

```bash
git add -A && git commit -m "…"
git push -u origin HEAD
gh pr create --title "…" --body "…"
```

Base branch is usually the repo default. Match existing PR titles/bodies in the repo.

## List / remove

```bash
git -C "$ROOT" worktree list
git -C "$ROOT" worktree remove ".claude/worktrees/${SLUG}"   # after the branch is merged
git -C "$ROOT" branch -d "worktree-${SLUG}"                  # if not auto-deleted
git -C "$ROOT" worktree prune
```

## Notes

- To tear a worktree down by PR state once the task ships, see the companion `worktree-cleanup` skill.
- Always run `git worktree` against `$ROOT`; paths are relative to it.
- Worktrees get their own `.git` file pointing at the shared object store; tracked files like `.claude/settings.json` and `.vscode/settings.json` are checked out normally.
- Sandboxed environments may block worktree creation under `.claude/` — retry with full filesystem/git access if checkout fails.

