[BUG] Bash tool fails permanently after working directory is deleted
Resolved 💬 10 comments Opened Jan 14, 2026 by alexn-tinwell Closed Apr 28, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When the Bash tool's cwd is deleted (e.g., removing a git worktree the shell was in), all subsequent Bash commands fail with Exit code 1 until Claude Code is restarted, even if the claude process itself was started from a directory that still exists.
### Repro
- Create worktree:
git worktree add /tmp/wt main - Run commands (cwd implicitly moves to worktree)
- Remove:
git worktree remove /tmp/wt - All bash fails with:
getcwd: cannot access parent directories
### Expected
Auto-recover to valid cwd, or allow explicit cd to recover.
### Actual
Bash permanently broken until session restart.
What Should Happen?
Auto-recover to valid cwd, or allow explicit cd to recover.
Error Messages/Logs
`Exit code 1` plus a bunch of tokens spent on trying other things because the model doesn't understand why the tool is failing.
Steps to Reproduce
- Create worktree:
git worktree add /tmp/wt main - Run commands (cwd implicitly moves to worktree)
- Remove:
git worktree remove /tmp/wt - All bash fails with:
getcwd: cannot access parent directories
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.4
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗