Skip to content
BENIBIX Learn

CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR

AI⌨️ Claude CodeConfiguration

Also known as CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1

It goes back to the start folder after each Bash command.

Think of it like

It is like you go back to your desk after each errand.

Example

Claude ran cd into a subfolder, and Emma's next test run failed there. She sets this, and each command starts at the top.

Why it matters

A command in the wrong folder can build, test or delete the wrong files.

Definition

CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR sends Claude Code back to the folder it started in. It does this after each Bash command. Without it, a cd in one command carries over to the next. That is how a later command can run in the wrong folder.

Example code

bash
export CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1
claude
Every command starts in the project folder.

Common mistake

Thinking it blocks cd. The cd still works inside its own command.

Key takeaways

  1. 1
    Back after each command. To the start.
  2. 2
    cd does not carry. To the next.
  3. 3
    Main session. Bash and PowerShell.