sed on Windows silently converts CRLF to LF, breaking files

Resolved 💬 2 comments Opened May 29, 2026 by Kelley-Cadre Closed Jul 2, 2026

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

  1. On Windows with Claude Code (bash shell)
  2. Have a file with CRLF line endings (standard Windows)
  3. Ask Claude to edit the file using sed (e.g., remove a pattern)
  4. file command confirms the output is now LF-only

Expected behavior

Claude Code on Windows should either:

  1. Not use sed for file edits on Windows (prefer PowerShell or the Edit tool)
  2. Warn when sed will change line endings
  3. Automatically preserve line endings after sed operations

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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗