sed on Windows silently converts CRLF to LF, breaking files
Bug
When Claude Code runs on Windows (bash shell via Git Bash), using sed -i to edit files silently converts CRLF line endings to LF. This happens without any warning or error, and the resulting files appear identical in content but are broken for Windows tools that expect CRLF.
Impact
In my case, this caused ~4 hours of debugging a ScriptInstaller XML manifest that stopped working after Claude edited it with sed. The content looked correct in every inspection, but the .NET XML parser failed silently because the line endings were LF instead of CRLF. Multiple rounds of structural changes and re-packaging were attempted before the root cause was identified.
Reproduction
- On Windows with Claude Code (bash shell)
- Have a file with CRLF line endings (standard Windows)
- Ask Claude to edit the file using sed (e.g., remove a pattern)
filecommand confirms the output is now LF-only
Expected behavior
Claude Code on Windows should either:
- Not use
sedfor file edits on Windows (prefer PowerShell or the Edit tool) - Warn when
sedwill change line endings - Automatically preserve line endings after
sedoperations
Environment
- Platform: Windows 11 Pro
- Shell: bash (Git Bash)
- Claude Code CLI
Notes
The platform instructions (windows-environment.md) already warn about this, but the model does not consistently follow them. The Edit tool preserves line endings correctly -- sed via Bash does not.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗