[BUG] Bash directory issues
Environment
- Platform (select one):
- [X] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.59
- Operating System: macOS 15.5
- Terminal: VS Code Terminal
Bug Description
Claudes bash tool sometimes changes directory to execute a command, the forgets where it is and spends 2-3 commands resolving its location when the next command doesn’t work. Even worse, depending on the command it executes, it may treat the failure (a grep with no matches because of wrong dir) as no matches and change behavior incorrectly.
The end results generally sorts itself out, costing time, system load and tokens.
I suggest that a fairly easy fix would be to wrap the bash commands in a subshell:
bash -c “bash whatever commands” so that every invocation takes you back to the parent shell and since you never changed directory in that shell, the commands claude tries to use will succeed or fail based on the actual command and not the wrong directory.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗