/branch fails with 'No conversation to branch' after EnterWorktree
Bug
/branch always fails with Failed to branch conversation: No conversation to branch when the session's working directory has been changed by EnterWorktree. It works fine when the cwd is in the main repo.
Repro
- Start a Claude Code session in a git repo (have some conversation first)
- Enter a worktree via
EnterWorktree(or/wtwhich calls it) - Try
/branch - →
Failed to branch conversation: No conversation to branch - Exit the worktree back to the main repo
- Try
/branchagain - → Works fine
Root cause (likely)
The session JSONL lives under the original project directory (e.g. ~/.claude/projects/-Users-dorian-dev-caelum/). After EnterWorktree changes the cwd to a worktree path like /Users/dorian/dev/caelum/.claude/worktrees/foo, the /branch command resolves the project directory from the current cwd, landing in a different project path (-Users-dorian-dev-caelum--claude-worktrees-foo) that doesn't contain the running session's JSONL file. So it concludes there's no conversation to branch.
Evidence
Analyzed ~45 /branch invocations across session logs:
- Every failure (9 instances, excluding 2 empty-session cases) occurred while the session was inside a worktree (
has_wt_context=True) - Every success (~35 instances) occurred while the session was in the main repo directory
- 3 sessions that entered and exited a worktree before trying
/branchsucceeded — confirming the issue is cwd-dependent, not permanent corruption
Environment
- Claude Code CLI (latest channel)
- macOS
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗