Bash tool: shell cwd resets to project root between tool calls, breaks worktree workflows

Open 💬 0 comments Opened Jun 12, 2026 by twall

Summary

The Bash tool's working directory resets to the project root on every invocation, regardless of prior cd commands in the same session. This makes it impossible to reliably work within a git worktree without explicitly prefixing every command with the full worktree path.

Steps to Reproduce

  1. Open a Claude Code session in a repo that has a git worktree at a non-default path (e.g. /project/worktree-branch/)
  2. Run a Bash tool call with cd /project/worktree-branch && git status
  3. Run a subsequent Bash tool call with just git status

Expected: Second call operates in /project/worktree-branch/
Actual: Second call operates in the original project root (/project/), silently on the wrong branch/worktree

Impact

  • git operations (checkout, cherry-pick, commit) silently target the wrong branch
  • File edits land in the wrong worktree
  • No error is surfaced — the commands succeed but on wrong data
  • Discovered during a multi-step cherry-pick workflow: a git checkout HEAD -- <files> reset files in the main worktree instead of the intended worktree, nearly clobbering in-progress work

Workarounds

  • git -C <absolute-path> for git commands
  • Prefix every non-git command with the full absolute path
  • Both are fragile and easy to forget mid-session

Expected Behavior

Shell cwd should persist across Bash tool calls within a session turn, or at minimum Claude Code should surface the active worktree path prominently so users know which context commands execute in.

View original on GitHub ↗