[BUG] Desktop: "+ New" worktree session fails with "WorktreeCreate hook failed: path contains control characters" (repo not under a TCC-protected folder)
Summary
Starting a new session from the Desktop app's "+ New" screen with the "Worktree" checkbox enabled fails every time with:
WorktreeCreate hook failed: path contains control characters
This appears before the project's own WorktreeCreate hook script ever runs — the configured hook is bash scripts/setup-worktree.sh 2>&1 || true, which always exits 0, so it cannot itself produce this message. No directory is created under .claude/worktrees/, so the failure happens at path/name validation time, before mkdir/hook invocation.
Environment
- Claude.app (Desktop) 1.30096.5
- Embedded Claude Code runtime: 2.1.229 (
~/Library/Application Support/Claude/claude-code/2.1.229) - macOS, Darwin 25.5.0 (arm64)
- Repo path:
~/source/github.com/org/repo-name— NOT under~/Desktop,~/Documents, or any other TCC-protected folder .claude/settings.jsonhas aWorktreeCreatehook configured:
``json``
"hooks": {
"WorktreeCreate": [{"hooks": [{"type": "command", "command": "bash scripts/setup-worktree.sh 2>&1 || true", ...}]}]
}
Steps to reproduce
- Open Claude Code Desktop, "+ New" session screen
- Select repo
repo-name, branchmain - Check the "Worktree" checkbox
- Leave the task/question input empty
- Start the session
Result
An error card appears immediately:
WorktreeCreate hook failed: path contains control characters
Reproduced twice, byte-identical result both times.
Why this doesn't look like a hook/script problem
- The configured hook command always exits 0 (
|| true), so it cannot itself throw this validation error. - No new directory appears under
.claude/worktrees/after the failure, so the failure happens before the app attempts to create/populate the worktree directory. - The task/question field was empty, so no user-typed text should have fed into whatever name/path is being generated (the app appears to auto-generate a worktree name similar to existing ones in this repo, e.g.
elegant-jepsen-2ccd85).
Possibly related
#82691 describes a different-but-adjacent regression in the same "+ New" → WorktreeCreate flow since Desktop 2.1.217, though with a distinct error signature (git/getcwd() EPERM under TCC-protected folders like ~/Desktop/~/Documents). This repo is not in a TCC-protected location, and the error text here is different ("path contains control characters" vs. the git EPERM message), so this may be a separate bug in the same code path rather than the same root cause — flagging the connection in case it's useful for triage.
Ask
- What string is being validated here (worktree name? full path? branch name?), and why would it contain a control character when auto-generated with no user input?
- Is there a way to surface/log the exact rejected string client-side, to help pin down the source?
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗