agent edited tests with CRLF line endings: lint failures after healing
Fixes CRLF line-ending breakage from agent-edited test files by normalizing to LF and enforcing it with gitattributes and a pre-commit check. Use when healed test files fail lint or behave oddly after an agent edit. Not for files that legitimately require CRLF, which get explicit exceptions, not silent mixed endings.
TL;DR
An agent editing files with CRLF line endings produces mixed-ending files that fail lint and confuse diffs. Normalize the repo to LF, declare it in gitattributes so checkouts stay LF, and add a pre-commit check that rejects CRLF. The agent's edits then inherit the right endings automatically.
Error
agent edited tests with CRLF line endings: lint failures after healingHealed test files came back with CRLF endings; lint failed on every line and the diff showed the whole file changed.
Steps
- Confirm the endings: check the healed files for CRLF and mixed line endings. Expected output: a list of affected files and their ending mix.
- Normalize the affected files to LF and re-run lint to confirm the failures were ending-related. Expected output: clean lint on normalized files.
- Declare LF in gitattributes for text files so every checkout and every agent edit starts from LF. Expected output: a gitattributes rule covering the repo's text files.
- Add a pre-commit check that rejects CRLF in text files with a message telling the author to normalize. Expected output: bad endings blocked before commit.
- Verify the next healing run produces LF-only files. Expected output: healed files that pass lint on endings.
When to use
- Healed files fail lint on line endings.
- Diffs show whole-file changes from ending flips.
- Agents edit files across mixed-OS environments.
When not to use
- Files that must be CRLF by format (some Windows-specific files); except them explicitly in gitattributes.
- The repo already enforces LF and the failure is something else (check first; do not re-fix).
- The lint failure is about content, not endings (fix the content).
Variant phrasings
Agent's patch shows every line changed
The classic mixed-endings symptom. Normalize before reviewing the actual change.
Lint fails only on agent-edited files
The agent's editor or environment writes CRLF by default. The gitattributes rule fixes it at the source.
Mixed endings inside one file
Worse than pure CRLF: some tools handle it, some do not. Normalize the whole file, not just the new lines.
Why it happens
The agent's file-writing environment defaults to the OS convention, often CRLF on Windows-based runners, while the repo is LF. Nothing normalizes on write, so each agent edit injects CRLF into LF files. Lint then fails on lines the agent never meaningfully changed.
Edge cases
- Normalizing a file with intentional mixed endings (embedded test fixtures) can break the fixture; except fixture files explicitly.
- gitattributes changes only affect new checkouts; existing workspaces need a one-time renormalize.
- The pre-commit check must distinguish text from binary; never "normalize" binary files.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst6SYaiqKeJjIoVpui_WdvA