Bash cwd no longer persists between calls (regression, even without CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR)

Resolved 💬 6 comments Opened Apr 2, 2026 by cnavarro165 Closed May 29, 2026

Description

Running cd /some/path && pwd via the Bash tool no longer persists the working directory between calls. It immediately resets back to the project root with the message:

Shell cwd was reset to /Users/.../project-root

This used to work. I have 51+ instances across past conversation logs where cd successfully persisted the cwd between Bash tool calls in the same session.

Steps to Reproduce

  1. Open Claude Code in any project directory (e.g., ~/projects/myapp)
  2. Ask Claude to change directories: cd ~/ && pwd
  3. Observe the output shows the new directory (/Users/username) but also shows:

``
Shell cwd was reset to /Users/username/projects/myapp
``

  1. Subsequent Bash calls are back in the original project root

Expected Behavior

Per the official docs (Bash tool behavior):

"Working directory persists across commands. Set CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1 to reset to the project directory after each command."

The cwd should persist. The env var CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR is the opt-in to reset — implying the default is persistence. The env var is not set in my environment.

Environment

  • OS: macOS (Darwin 25.3.0)
  • Claude Code: Latest version
  • Shell: zsh
  • CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR: Not set
  • Custom statusLine: Yes (configured in settings.json)

Relationship to #31471

Issue #31471 documents that a custom statusLine command can reset shell cwd between Bash calls. However, in my case:

  1. This is a regression — the same statusLine config was present in prior sessions where cd persistence worked correctly
  2. Something changed in a recent Claude Code update that broke this behavior
  3. The statusLine command uses cd only inside a $(...) subshell (to get the git branch), which should not affect the parent shell's cwd

Impact

This prevents users from changing their working context mid-session, which is a core workflow — e.g., switching between project directories, navigating to home directory, etc. The only workaround is prefixing every single Bash command with cd /desired/path &&.

View original on GitHub ↗

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