Claude Desktop creates session worktrees inside the repo root, ignoring CLAUDE.md rules and WorktreeCreate hook block decisions
Environment
- Claude Desktop (macOS)
- Repo uses git worktrees extensively; project
CLAUDE.mdmandates worktrees live as sibling directories of the main repo, not as subdirectories of it.
Expected
When starting a new Claude Desktop session on a linked repo, the session worktree should be creatable outside the main repo — either via a user-level "worktree parent directory" preference, or by respecting a project-level hook that rejects a path.
Actual
The app hardcodes worktreePath = originCwd + "/" + <random-slug> with no user-facing override. Each new session creates a new subdirectory inside the main repo root, e.g.:
<repo-root>/
thirsty-leavitt-21670b/ ← session worktree
kind-khayyam-174f8e/ ← another session worktree
...
This pollutes git status (each slug dir shows as untracked in the main repo), violates project conventions that require sibling layout, and makes manual cleanup tedious.
What I tried
PreToolUseBash hook that blocksgit worktree add <path>when<path>is inside the repo. Doesn't fire — the app creates the worktree through native machinery, not a Bash tool call.WorktreeCreatehook returning{"decision":"block","reason":"..."}. Also doesn't fire in time — the worktree is already created on disk when a subsequent session starts inside it.
Session JSON under ~/Library/Application Support/Claude/claude-code-sessions/.../local_*.json confirms the path layout:
{
"originCwd": "/Users/<me>/<repo-root>",
"worktreePath": "/Users/<me>/<repo-root>/<slug>",
"worktreeName": "<slug>",
"sourceBranch": "main",
"branch": "claude/<slug>"
}
Requested fixes (any one would resolve this)
- Honor
decision: "block"onWorktreeCreatehooks and abort session startup when blocked. - Add a user-level setting (e.g.
coworkWorktreeParentDirin~/.claude/settings.jsonor~/Library/Application Support/Claude/config.json) to override where session worktrees are placed. - Default to sibling-directory placement (
<repo-parent>/<repo-name>-<slug>) since co-located subdirectories are almost always wrong — they inflate the main repo'sgit status, conflict with build/test caches, and aren't a shape most projects want.
Why it matters
- Breaks projects whose
CLAUDE.mdexplicitly forbids in-repo worktrees. - Forces manual cleanup after every session.
- Untracked slug directories risk being accidentally
git add'd.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗