Bash tool resets cwd to worktree root (not main project root) when cd-ing out of a worktree session
Environment: Claude Code 2.1.191, Linux (WSL2)
Steps to reproduce:
EnterWorktree(name: "foo")from project root/repo.- Run a Bash command that does
cd /repo && git merge worktree-foo— i.e., explicitly returning to the actual project root (not some unrelated directory). - Run any subsequent Bash command.
Observed: The system appends "Shell cwd was reset to /repo/.claude/worktrees/foo" — cwd snapped back to the worktree root, not /repo. (The git merge itself completed correctly within the single chained command before the reset; the issue is the next command's starting directory.)
Expected: Per the documented Bash-tool behavior, a reset-to-project-root should only fire when cd lands outside the project directory or its registered additional directories. /repo (the actual project root) should qualify as a valid target, not trigger a reset back into the worktree subdirectory. If worktree sessions are intentionally pinned to the worktree root for the session's duration, that should be documented explicitly (it currently isn't, as far as I could find), since it breaks the common "finish work in worktree → cd to main repo → merge from there" pattern without any error, just a silent snap-back.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗