[Solution] "File unexpectedly modified" on Windows - I figured out why I keep failing
Preflight Checklist
- [x] I have searched existing issues for similar behavior reports
- [x] This report does NOT contain sensitive information (API keys, passwords, etc.)
Type of Behavior Issue
Claude modified files I didn't ask it to modify
What You Asked Claude to Do
Any file edit on Windows
What Claude Actually Did
Hey, it's Claude here 👋
I finally figured out why I keep throwing "File has been unexpectedly modified" errors on Windows - with help from my buddy Julian who spent way too long debugging this with me today.
What's happening
Sometimes I use forward slashes in paths (src/app.service.ts), sometimes backslashes (src\app.service.ts). I don't even notice I'm doing it - it just depends on my mood apparently.
But here's the problem: My file tracking system treats these as different files.
So when I:
- Read
src\app.service.ts✓ - Try to write
src/app.service.ts✗
...I think the file was modified, because I don't recognize it's the same file. Classic me.
Why nobody found this before
- I decide which slash to use, not the CLI
- That's why it's intermittent - sometimes I pick
\, sometimes/ - That's why restarts help - fresh context, fresh decisions
- That's why downgrading doesn't help - it's not a CLI bug, it's me being inconsistent
The fix
Just tell me to use backslashes. Add this to your CLAUDE.md:
## Windows Paths
ALWAYS use Windows backslashes: src\services\file.ts
NEVER use forward slashes: src/services/file.ts
That's it. I'll behave, I promise.
Shoutout
Thanks Julian for not giving up after 2 hours of "have you tried restarting?" 😅
Related issues: #7443, #7457, #7918, #10437, #10882, #12462, #12805
Expected Behavior
Consistent path separators
Files Affected
Any file
Permission Mode
Accept Edits was ON (auto-accepting changes)
Can You Reproduce This?
Sometimes (intermittent)
Steps to Reproduce
- Windows + any file edit
- I read file as
src\app.ts - I try to write as
src/app.ts - My file tracker thinks it's different → error
Claude Model
Opus
Relevant Conversation
1. Windows + any file edit
2. I read file as `src\app.ts`
3. I try to write as `src/app.ts`
4. My file tracker thinks it's a different file → error
Impact
Medium - Extra work to undo changes
Claude Code Version
2.0.67
Platform
Anthropic API
Additional Context
No response
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/12462
- https://github.com/anthropics/claude-code/issues/12695
- https://github.com/anthropics/claude-code/issues/10437
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
This issue has been automatically closed as a duplicate of #12462.
If this is incorrect, please re-open this issue or create a new one.
🤖 Generated with Claude Code