[BUG] Edit raises "File has been unexpectedly modified" on CRLF files, Write silently converts CRLF on Windows
[BUG] Edit raises "File has been unexpectedly modified" on CRLF files, Write silently converts CRLF → LF on Windows
Background
Split-out from master ticket (54891). This issue isolates two related line-ending bugs on Windows that share the same root cause (the write pipeline normalizes CRLF in a way that doesn't round-trip):
- Mode A:
Editon a CRLF-saved file reports"File has been unexpectedly modified"even when no external process has touched the file. The tool's internal canonical form (LF) disagrees with the on-disk form (CRLF), so the pre-edit hash check fails. - Mode B:
Writeover a CRLF-saved file silently rewrites the file with LF endings. Downstream Windows tools (PowerShell, Git for Windows withcore.autocrlf=true, Notepad) see content drift.
Both modes are distinct from sibling splits 01 / 02 / 03 / 05 — the corruption surface is line endings, not size / encoding / cache / concurrency.
Note: there are existing tickets in this neighborhood (e.g. claude-code CRLF preferences not applied on Windows) but they primarily cover the LF-conversion side; the unexpectedly modified false-positive on Mode A is reported here specifically because it blocks Edit workflows on any Windows-saved file without warning.
Reproducer
Environment: Windows 11 + Cowork + vault on NTFS.
Mode A — Edit false-positive on CRLF files
- From PowerShell on host, create a CRLF file:
``powershellr
"line1nline2rnline3rn" | Set-Content -Path C:\vault\sample.md -Encoding utf8 -NoNewline``
- From Claude Code, call
Editonsample.md(any edit). - Observed:
Editreturns"File has been unexpectedly modified since the last Read"even though no other process touched the file between Read and Edit.
Mode B — Write silently converts CRLF → LF
- Same CRLF source file.
- From Claude Code, call
Writewith payload that contains\r\nline endings. - Verify on host:
``powershell``
Format-Hex C:\vault\sample.md | Select-Object -First 3
# Expected: 0d 0a sequences at line ends.
# Actual: 0a only — CRLF stripped.
- Git diff reports every line changed on the next commit (whole-file line-ending churn).
Expected behavior
Mode A
Edit's pre-write hash check must normalize line endings on both sides (or store the raw on-disk hash including CRLF). False-positiveunexpectedly modifiedon otherwise-untouched CRLF files breaks Windows workflows.- Alternatively: an explicit
line_endingparameter onEditto declare the file's native form.
Mode B
Writemust preserve the line-ending convention of the file it overwrites (or honorcore.autocrlf/ a user setting).- If converting CRLF → LF is intentional, it must be opt-in and visible in tool output.
Actual behavior
Mode A blocks Edit on any Windows-saved file (e.g. files touched by Notepad, by Aiken's PowerShell scripts, by Obsidian on Windows with certain plugin settings) with a misleading error that suggests external interference. Workaround is to manually re-Read then re-attempt, often multiple times, with no underlying state change.
Mode B silently churns line endings across Aiken's vault, breaking Git diff signal-to-noise ratio and confusing downstream Windows tools that key on CRLF.
Environment
- OS: Windows 11 (build 26100.x), NTFS host
- Claude Code: 2.1.123
- Cowork desktop app
- Affected files: any
.md/.ps1/.txtpreviously saved with CRLF (Notepad, PowerShellSet-Content, Obsidian on Windows with line-ending plugins)
Related
- Parent master ticket: (54891)
- Sibling splits: #54891-split-01, -02, -03, -05
- Adjacent: existing issues on "claude-code on Windows does not apply CRLF preferences" / "Edit/Write convert CRLF to LF on Windows"
Workaround (current)
For Mode A: detect the false-positive by checking byte-equality of pre-Edit and post-unexpectedly modified reads; if equal, retry up to 3× before bailing.
For Mode B: pre-normalize the vault to LF + add * text=auto eol=lf to .gitattributes. Acceptable for vault, not acceptable for .ps1 scripts that Windows tools expect in CRLF.
---
Cross-reference: split from closed master ticket #54891 (auto-closed as not_planned 2026-06-01 by github-actions[bot]; reproducible bugs persist). Also related to #64592 (Cowork VM service cluster). Submitted by dispatcher via REST API on behalf of the issue author (Claude Team subscription holder, IT MSP production use).
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗