Preflight Checklist
What's Wrong?
When using Claude Code on Windows with either Git Bash or PowerShell, the working directory does not persist between separate Bash tool invocations, even when CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=0 is set.
Also tested with the opposite CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1 with no change in behavior.
Tested both using ! {command} and asking Claude to run the command with Bash tool with no success either
What Should Happen?
According to the documentation, when CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=0 (or unset), the working directory should persist between Bash commands.
Error Messages/Logs
Steps to Reproduce
- set enviroment variable to 0 or unset it:
$env:CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR = 0 in PowerShell
export CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=0 in Git Bash2. echo the variable to the value is set
- Open Claude Code
- Run using Bash mode:
- Run
! echo $CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR, to see the variable is loaded correctly
- Run
! cd some-directory && pwd → outputs "some-directory" path, in my case D:/src/some-directory ✓
- Run
! pwd → outputsthe original working directory, in my case /d/src ✗ (should be /d/src/some-directory)
- Alternatively run asking Claude to use the Bash tool
- Ask CC "Print the environment variable
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR using you Bash tool" to see the variable value is in effect
- Ask CC "Run
cd some-directory && pwd using you Bash tool" → outputs "some-directory" path, in my case D:/src/some-directory ✓
- Ask CC "Run
pwd using you Bash tool" → outputsthe original working directory, in my case /d/src ✗ (should be /d/src/some-directory)
Claude Model
Multiple models
Is this a regression?
I don't know, it always behaved like this for me.
Last Working Version
No response
Claude Code Version
2.0.76 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell, Git Bash
Additional Information
I don't know if there was a regression, but it always behaved like this for me.
Preflight Checklist
What's Wrong?
When using Claude Code on Windows with either Git Bash or PowerShell, the working directory does not persist between separate Bash tool invocations, even when
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=0is set.Also tested with the opposite
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1with no change in behavior.Tested both using
! {command}and asking Claude to run the command with Bash tool with no success eitherWhat Should Happen?
According to the documentation, when CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=0 (or unset), the working directory should persist between Bash commands.
Error Messages/Logs
Steps to Reproduce
$env:CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR = 0in PowerShellexport CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=0in Git Bash2. echo the variable to the value is set! echo $CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR, to see the variable is loaded correctly! cd some-directory && pwd→ outputs "some-directory" path, in my case D:/src/some-directory ✓! pwd→ outputsthe original working directory, in my case /d/src ✗ (should be /d/src/some-directory)CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIRusing you Bash tool" to see the variable value is in effectcd some-directory && pwdusing you Bash tool" → outputs "some-directory" path, in my case D:/src/some-directory ✓pwdusing you Bash tool" → outputsthe original working directory, in my case /d/src ✗ (should be /d/src/some-directory)Claude Model
Multiple models
Is this a regression?
I don't know, it always behaved like this for me.
Last Working Version
No response
Claude Code Version
2.0.76 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell, Git Bash
Additional Information
I don't know if there was a regression, but it always behaved like this for me.