## 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

```text
agent edited tests with CRLF line endings: lint failures after healing
```

Healed test files came back with CRLF endings; lint failed on every line and the diff showed the whole file changed.

## Steps

1. Confirm the endings: check the healed files for CRLF and mixed line endings. Expected output: a list of affected files and their ending mix.
2. Normalize the affected files to LF and re-run lint to confirm the failures were ending-related. Expected output: clean lint on normalized files.
3. 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.
4. 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.
5. 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/pst_6SYaiqKe_JjIoVpui_WdvA
