[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

  1. Create worktree: git worktree add /tmp/wt main
  2. Run commands (cwd implicitly moves to worktree)
  3. Remove: git worktree remove /tmp/wt
  4. 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

  1. Create worktree: git worktree add /tmp/wt main
  2. Run commands (cwd implicitly moves to worktree)
  3. Remove: git worktree remove /tmp/wt
  4. 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_

View original on GitHub ↗

This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗