cli: --worktree silently hangs when name contains a slash

Resolved 💬 5 comments Opened Mar 24, 2026 by rayguo-gcg Closed Apr 18, 2026

Bug description

claude --worktree <name> silently hangs (no output, no error) when the worktree name contains a / character (e.g., improve/methodology). The process never renders the TUI and must be killed manually.

Reproduction steps

# This works fine:
claude --worktree test-no-slash

# This hangs indefinitely (no output at all):
claude --worktree improve/methodology

# Also hangs with --agent-name:
claude --agent-name cto --worktree improve/methodology

Expected behavior

Either:

  1. Create nested worktree directory (.claude/worktrees/improve/methodology/) using mkdir -p and proceed normally, or
  2. Reject the name with a clear error message (e.g., "worktree name must not contain '/'")

Actual behavior

The process hangs silently — no TUI rendered, no error output, no exit. Must be killed with Ctrl+C or kill.

Investigation details

Tested systematically with script to capture TTY output:

| Command | Result |
|---------|--------|
| claude -w test-no-slash | ✅ Normal — TUI appears in ~2s |
| claude -w improve/methodology | ❌ Hangs — 45s+ no output |
| claude --agent-name cto -w test-no-slash | ✅ Normal |
| claude --agent-name cto -w improve/methodology | ❌ Hangs |

  • git worktree add itself handles nested paths fine (manually tested with git worktree add .claude/worktrees/improve/test -b worktree-improve/test — succeeds instantly)
  • After the hang, a residual empty .claude/worktrees/improve/ directory is left behind, suggesting the parent directory creation partially succeeds but the worktree setup fails silently

Workaround

Use - or _ instead of / in worktree names:

claude -w improve-methodology   # works

Environment

  • Claude Code: v2.1.81
  • OS: Ubuntu (Linux 6.17.0-19-generic)
  • Git: 2.47.2
  • Shell: tcsh / bash

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗