Write tool overwrites uncommitted working tree changes without warning
Resolved 💬 4 comments Opened Mar 15, 2026 by noamsneteera Closed May 1, 2026
Bug Description
Claude Code's Write tool overwrote a file that had uncommitted working tree changes (shown as M in git status at conversation start), destroying the user's in-progress work without preserving it.
Steps to Reproduce
- Have a file with uncommitted modifications (unstaged changes visible in
git status) - Ask Claude Code to modify that file
- Claude Code uses the Write tool to completely replace the file contents with new code
- The user's pre-existing uncommitted changes are permanently lost (no stash, no backup)
Expected Behavior
Before overwriting a file with uncommitted changes, Claude Code should either:
- Read and preserve the existing contents, building on top of the user's changes
- Warn the user that uncommitted changes exist and will be lost
- Use the Edit tool (which applies diffs) instead of the Write tool (which replaces entirely)
Actual Behavior
Claude Code used the Write tool to completely replace tracker/src/tracker/base.py, which had unstaged modifications ( M in git status). The pre-existing uncommitted work was destroyed with no way to recover it.
Context
- The git status at conversation start clearly showed the file was modified:
M tracker/src/tracker/base.py - Claude Code did read the file before writing, but did not compare against the committed version to identify and preserve the user's changes
- The file was not stashed, so recovery was impossible
Environment
- Claude Code CLI
- Model: claude-opus-4-6
- OS: Linux
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗