Environment
- Platform (select one):
- Claude CLI version: 1.0.21 (Claude Code)
- Operating System: Ubuntu 22.04
- Terminal: VSCode
Bug Description
Claude Code loses track of the current working directory after executing cd commands, causing subsequent shell commands to fail because they are executed in the wrong directory. The session does not maintain awareness of directory changes between commands.
Steps to Reproduce
- Start Claude Code in a repository root directory
- Execute a command that changes directory, e.g.,
cd docs && ls -l
- Ask Claude Code to perform another file operation (e.g.,
grep for something in the repository)
- The subsequent command fails because Claude Code still assumes it's in the repository root, but the shell session is actually in the
docs subdirectory
Expected Behavior
Claude Code should maintain awareness of the current working directory throughout the session, tracking any cd commands and adjusting subsequent command paths accordingly. Alternatively, each command should be executed from a consistent starting directory (repository root).
Actual Behavior
After executing a cd command, Claude Code's internal state doesn't update to reflect the new working directory. Subsequent commands fail with "file not found" or similar errors because they're being executed from the wrong directory. The issue persists until explicitly asking Claude Code to run pwd or cd back to the root directory.
Additional Context
This issue significantly impacts workflow when Claude Code needs to navigate between directories for different tasks. It requires manual intervention to reset the working directory, breaking the natural flow of automated command execution. A potential workaround is to always use absolute paths or chain commands with && to ensure they run in the intended directory, but this shouldn't be necessary.
Environment
Bug Description
Claude Code loses track of the current working directory after executing
cdcommands, causing subsequent shell commands to fail because they are executed in the wrong directory. The session does not maintain awareness of directory changes between commands.Steps to Reproduce
cd docs && ls -lgrepfor something in the repository)docssubdirectoryExpected Behavior
Claude Code should maintain awareness of the current working directory throughout the session, tracking any
cdcommands and adjusting subsequent command paths accordingly. Alternatively, each command should be executed from a consistent starting directory (repository root).Actual Behavior
After executing a
cdcommand, Claude Code's internal state doesn't update to reflect the new working directory. Subsequent commands fail with "file not found" or similar errors because they're being executed from the wrong directory. The issue persists until explicitly asking Claude Code to runpwdorcdback to the root directory.Additional Context
This issue significantly impacts workflow when Claude Code needs to navigate between directories for different tasks. It requires manual intervention to reset the working directory, breaking the natural flow of automated command execution. A potential workaround is to always use absolute paths or chain commands with
&&to ensure they run in the intended directory, but this shouldn't be necessary.