Bash cwd no longer persists between calls (regression, even without CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR)
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
- Open Claude Code in any project directory (e.g.,
~/projects/myapp) - Ask Claude to change directories:
cd ~/ && pwd - Observe the output shows the new directory (
/Users/username) but also shows:
````
Shell cwd was reset to /Users/username/projects/myapp
- 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 insettings.json)
Relationship to #31471
Issue #31471 documents that a custom statusLine command can reset shell cwd between Bash calls. However, in my case:
- This is a regression — the same
statusLineconfig was present in prior sessions wherecdpersistence worked correctly - Something changed in a recent Claude Code update that broke this behavior
- The
statusLinecommand usescdonly 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 &&.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗