# Creating Worktrees

> Create repo-local Git worktrees under .worktrees/.

- Skill: `darknesskiller/creating-worktrees` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add darknesskiller/creating-worktrees`
- Raw SKILL.md: https://api.skillmd.com/api/skills/darknesskiller/creating-worktrees/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: darknesskiller (https://skillmd.com/u/darknesskiller)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/darknesskiller/creating-worktrees

---


# Creating Worktrees

## Steps

1. Find repo root: `git rev-parse --show-toplevel`.
2. Get branch or task name; ask once if missing.
3. Sanitize slug: replace `/`, spaces, unusual chars with `-`.
4. Add `.worktrees/` to `$(git rev-parse --git-path info/exclude)` if missing.
5. Create: existing branch → `git worktree add <path> <branch>`; new branch → `git worktree add -b <branch> <path>`.
6. `codegraph init <path>` only when source has `.codegraph/` or user asks. Else `CodeGraph: not applicable`.
7. Report path, branch, exclude status, CodeGraph result.

## Output

End with a short report covering `Report` path/branch, `Sanitized slug`, `Worktree exists`, `Exclusion`, and `CodeGraph` status.

Completion: worktree exists, branch correct, exclusion recorded, CodeGraph reported.

