[BUG] False "File has been unexpectedly modified" errors caused by stale background shell tracking
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?
Description:
The Edit and Write tools fail with "File has been unexpectedly modified" even when the file is provably unchanged. This appears to be caused by stale background shell state that incorrectly persists after shells have completed.
Steps to Reproduce:
- Start Firebase emulators in background: firebase emulators:start with run_in_background: true
- Kill the emulator processes (taskkill or Ctrl+C)
- Attempt to edit any file with the Edit tool
Observed Behavior:
- KillShell returns status: completed or status: killed for all background shells
- System reminders continue to appear claiming shells are status: running with "new output available"
- Edit tool fails with "File has been unexpectedly modified"
- Write tool fails with "File has not been read yet" even immediately after Read
- File hash (md5sum) confirms file is unchanged
- File timestamp confirms file is unchanged
Expected Behavior:
- Shell status should be consistent between KillShell responses and system reminders
- File modification detection should use actual file state, not be affected by unrelated shell tracking
- Edit/Write should succeed when file is unchanged
Environment:
- Platform: Windows (win32)
- Working directory on V: drive (possibly mapped/virtual drive)
- Multiple background shells were spawned during session
Evidence:
KillShell says completed:
Shell ee9b0a is not running, so cannot be killed (status: completed)
But system reminder says running:
Background Bash ee9b0a (command: ...) (status: running) Has new output available
File hash unchanged:
a29eb961536944249c6ec4d795eab161 (before) a29eb961536944249c6ec4d795eab161 (after 2 second delay)
Workaround:
Start a new conversation to clear the corrupted shell tracking state.
What Should Happen?
File should be editable
Error Messages/Logs
Steps to Reproduce
Just try editing a file.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
not sure
Claude Code Version
2.0.60 (Claude Code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
No response
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/12813
- https://github.com/anthropics/claude-code/issues/13249
- https://github.com/anthropics/claude-code/issues/10840
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
Broke in 2.0.61. When does it get fixed. This is pure ass
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.