[BUG] Edit tool silently clears file to 0 bytes on Windows
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?
The Edit tool reported "updated successfully" but actually wrote 0 bytes to the file, completely erasing its content. No error was thrown.
Evidence from file-history (path: ~/.claude/file-history/<session-id>/):
- v3: 1576 bytes (May 1 16:47) — last known good version
- v4: 0 bytes (May 1 23:43) — Edit tool produced an empty file
- v5: 1841 bytes (May 2 14:38) — manually restored via Write tool
The affected file was ~/.claude/CLAUDE.md (global user instructions). The Edit tool was adding 3 new lines to the existing content. It claimed success but the
file became completely empty.
What Should Happen?
The Edit tool should correctly apply the edit and preserve existing file content. If an error occurs, it should report the error instead of silently zeroing
out the file.
Error Messages/Logs
Steps to Reproduce
- Have a non-empty file (e.g., ~/.claude/CLAUDE.md with ~1576 bytes)
- Use Claude Code Edit tool to make a small modification (e.g., add a few lines to the end)
- Edit tool reports success: "updated successfully"
- Check file content — it is now empty (0 bytes)
Note: This is intermittent. It happened once during a long session on Windows. Possible triggers:
- Long session with /compact triggered
- Windows CRLF/LF encoding edge case
- Concurrent file access during context compaction
Environment: Windows 11 Pro, bash shell in Windows Terminal, Java project with ~50 Maven modules.
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.119
Platform
Other
Operating System
Windows
Terminal/Shell
Windows Terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗