AX notes · Incident

Claude Code on Windows: CRLF broke four checks

On a Windows PC running Claude Code, core.autocrlf=true checks text files out with CRLF and breaks checks that count bytes. Which bytes ship decides what to fix.

By Stephen Working with agents 9 min read Last updated

Same repository, same file: one work tree built fine, the other failed after 35 seconds. The document viewer app's engine file was 11,548 bytes larger on disk, exactly one byte per line.

Our harness runs Claude Code on a Windows PC and checks out a fresh work tree for each repository. Git on Windows wrote the text files in those trees with CRLF line endings. The original work trees had been copied file by file from WSL and were still mostly LF, so the difference stayed hidden. In the month after the move, the same cause broke a check four times, in three different kinds of check, and the right fix was in a different place each time.

Contents (7)
  1. The engine file grew by 11,548 bytes and the build failed
  2. Copied trees kept LF; fresh checkouts got CRLF
  3. The CSS budget failure was a 4-byte margin running out
  4. Regex tests expected \n and nothing else
  5. Which bytes ship decides what you fix
  6. Changing attributes did not rewrite files already checked out
  7. What to look at in a fresh work tree before trusting a byte check

The engine file grew by 11,548 bytes and the build failed

At 09:18 on November 4 (KST), the harness's daily run built a debug APK of SugarDoc, our Korean HWP document viewer for Android. The build failed at its asset check, verifyRhwpAssets. That task pins two rhwp engine files (rhwp.js and rhwp_bg.wasm) to the exact bytes of the npm release, pins the fonts, font CSS and license texts to the bytes recorded in an asset list, and compares size and SHA-512 on every build.

The first failure line read rhwp.js: size 444510 != pinned 432962. Within a minute the agent found core.autocrlf=true, Git's setting that rewrites line endings on checkout. fonts.css in the harness tree had CRLF; the same file in the original work tree had LF, and that tree had built the app on October 25.

On November 21 we rebuilt the situation in a throwaway clone. Of the 28 pinned files, 16 text files no longer matched. The 12 that still matched were 11 binaries (10 fonts, 1 wasm) and one license file, the Rust crates notice, whose original already mixes in CRLF, so Git left it alone. The output shows 31 files turned to CRLF, more than 16, because the same folder also holds files outside the pinned list: our own viewer code.

Terminal output: in a temporary clone with core.autocrlf=true, the commit before the fix has 16 of 28 pinned files mismatched and rhwp.js at 444,510 bytes, a fresh clone of the fix commit has 0, and the site CSS is 41,055 bytes on disk vs 40,595 committed, failing the budget until the checker fix
Real output, re-run in temporary clones on Nov 21, 2026. a and b are the viewer repository, s is the site repository. The pin comparison is the Gradle task's rule (size and SHA-512) ported to a Python script.

Copied trees kept LF; fresh checkouts got CRLF

The true came from the system config file that Git for Windows installs. git config --show-origin core.autocrlf printed that file; neither the global nor the repository config set the value. With this setting, Git adds one CR per line when it checks out a text file that is stored with LF.

When we moved from WSL to Windows on October 18, we copied the repositories with rsync, which carried the LF bytes over unchanged. The copied tree has 40 files today that are LF in the commit but CRLF on disk, but in a tree that Git on Windows checked out from scratch, most text files are CRLF. The harness keeps a separate work tree per repository: the utility apps' tree appeared on October 25, the site's on the evening of November 1.

Horizontal bars: in the same utility-app repository, the tree copied from WSL has 831 files that are LF in the commit and on disk and 40 that are LF in the commit but CRLF on disk; the harness tree checked out on Windows has 81 and 818
Line endings in two work trees of one repository, counted with git ls-files --eol on Nov 21, 2026. The trees point at different commits, so the totals differ slightly.

The dates differ by tree. The CSS budget broke on the evening of November 1, when the site's harness tree appeared; the asset check broke on November 4, the first SugarDoc build in the utility apps' harness tree that the harness logs show. The October 23 failure happened before any harness tree existed, and the records do not say which tree it ran in, but the three viewer files that test reads (viewer.js, edit.js, protocol.js) are among the copied tree's 40 files that are LF in the commit but CRLF on disk. We did not check file by file when those 40 became CRLF.

The CSS budget failure was a 4-byte margin running out

On the site, the failure shows up first in the 8 p.m. handover log of November 1. The build check raised BUDGET-CSS (site.css at 41,055 bytes against a 40,960-byte budget), and the log put it down to another session's layout commit, to be fixed before publishing.

The 23:13 run measured the committed file first. The blob, Git's stored copy, was 40,595 bytes, inside the budget, and the 460-byte gap to the disk size was the file's line count.

CommitCommitted sizeSize checked out with CRLF40,960-byte budget
6ab2edb, before the layout40,49840,956passes, 4 bytes left
33af6de, layout40,59541,055fails

The checker measured the CSS with os.path.getsize, the bytes on disk. Its HTML budget read pages in Python text mode, which turns CRLF into LF on read, so the same flaw was blocked on that path by accident. GitHub Pages serves the committed files, so the agent made the CSS check strip CRs before counting (eed841d).

About two minutes passed between the error and the commit, and the agent got two things wrong in that time. Its first test file stayed under the budget even with CRLF, so it could not exercise the fix; the agent made it larger before running it. Then, following an owner rule that a test which still passes with the guard removed is fake, it reverted the fix to watch the test fail. Its sed pattern was mis-escaped, nothing changed, and the test said OK. The agent printed the values, redid the revert by line number, and only then saw the failure.

The site's tools now turn CRLF into LF in six places, added separately on four different days between October 18 and November 15.

Regex tests expected \n and nothing else

The third kind is a test that reads source files with a regular expression. On October 23 the utility apps' unit tests ran on Windows for the first time since the move and failed in five ways; one was the web viewer's security-policy test, whose LF pattern did not match a CRLF file. One line fixed it: replace \r\n with \n on read (62488f2).

On November 16 the agent writing these notes hit the same thing while re-running the E2E isolation test of AXFamily, our family-schedule app, on an old commit unpacked with git archive (which writes a commit out as a folder). That test removes one safety guard at a time and expects the checker to catch it. One removal regex expected lines to end in \n only, so on a CRLF copy it removed nothing.

Re-run on November 21: 20 of 21 passed on the CRLF copy, 21 of 21 on the LF copy.

The failure message was "the case did not change the file". Because the test asserts that its substitution actually happened, it failed loudly. The revert check on November 1 had no such assertion, so it printed OK even though nothing had been substituted (the cause there was the sed escaping, not CRLF).

Which bytes ship decides what you fix

An APK packs whatever is on disk at build time. Built from the CRLF tree, the app would have carried an rhwp.js that differs from the npm release, so the asset check failed correctly and the files had to change. The site is the opposite: deployment uses the committed files, so the disk-size check was the thing that was wrong.

Comparison: on the left, viewer assets that go into the APK from disk (16 of 28 engine, font and license files mismatched, fixed in the files with -text); on the right, the site CSS served from the committed files (41,055 bytes on disk, 40,595 committed, fixed in the checker)
The viewer assets ship from disk, so we fixed the files; the site CSS ships from the commit, so we fixed the checker.

Don't switch every byte check to "measure the committed blob". On the APK asset check, that would have passed an APK whose 16 text assets carried CRLF.

In the table, .gitattributes is the repository file that tells Git how to treat each path, and -text marks a path as not text, so Git never rewrites its line endings.

ApproachWhereResultLimit
-text per path in .gitattributesviewer assets (bcb1f2f)fresh clone: all 28 matchonly for vendored files pinned byte for byte; on source you edit, CRLF written by Windows editors gets committed as is
checker strips CRssite CSS budget (eed841d)0 errorswrong where the disk file ships
turn \r\n into \n on readsecurity-policy test (62488f2)125 web tests, 0 failedonly for tests about content
git -c core.autocrlf=false archiveE2E re-run (Nov 16)21 passedcovers that one command
clone with core.autocrlf=falsetried Nov 21 (commit before the fix)all 28 matchset per clone or per PC; nothing stays in the repository
text=auto eol=lftried Nov 21checked-out bytes matchrenormalising changes the Rust crates notice
text eol=lftried Nov 21checked-out bytes matchrenormalising changes 12 files, fonts and wasm included

eol=lf asks Git to write LF line endings on checkout. -text leaves the Rust crates notice alone, but with eol=lf a git add --renormalize (which reapplies the current attributes to files already committed) stages the notice's original CRLF lines without their CRs. The November 4 records show neither eol=lf nor core.autocrlf=false being considered; the last three rows of the table were tried separately on November 21.

Changing attributes did not rewrite files already checked out

On November 4 the agent wrote .gitattributes (one comment, two -text lines) and ran git checkout-index -f to check the files out again. They stayed CRLF and the build failed again. Tried on its own, fonts.css stayed at 6,465 bytes instead of its pinned 6,410, and a temporary clone on November 21 behaved the same.

The agent then stripped every CR from the text files in that folder with sed. git diff --stat showed a file that should not have changed: the Rust crates notice, where sed had removed the 81 CRs that belong to the original. The agent wrote that one file back from its committed bytes, and the build passed at 09:22.

The day's ops log noted that a fresh checkout was not re-tested. On November 21, a tree already checked out with CRLF only matched after the folder was moved away and checked out again.

What to look at in a fresh work tree before trusting a byte check

  1. See which file sets the value.

    git config --show-origin core.autocrlf
  2. Count the files changed on checkout. i/lf w/crlf means LF in the commit, CRLF on disk.

    git ls-files --eol | cut -f1 | sort | uniq -c
  3. Measure one checked file on disk and in the commit.

    wc -c < assets/site.css
    git cat-file -s HEAD:assets/site.css
  4. For every check that counts bytes, write down whether the disk file or the committed file ships, and pick the fix from the table above.

  5. After changing .gitattributes, move the affected folder out of the work tree, check it out again, and repeat steps 2 and 3 (Git 2.45.2, checked Nov 21, 2026).

    git checkout-index -a -u
  6. When you remove a guard to watch a test fail, first confirm that the removal actually changed the file.

The asset check in this re-run is the Gradle rule ported to Python; we did not rebuild a fresh clone with Gradle. We did not measure Linux or macOS checkouts. We have not listed the byte-counting checks in the game and spelling apps' harness trees. The utility apps' harness tree existed from October 25, and we only know that the harness logs show no build there before November 4, not why.

As of Nov 21, 2026. Git history (utility-app repository 62488f2 and bcb1f2f; site repository 6ab2edb, 33af6de and eed841d), harness session logs (Nov 1 and Nov 4), the daily ops log written in the Nov 4 run, the desk's drafting memo (Nov 16), output re-run in temporary clones (git 2.45.2.windows.1).

This note is written from values SugarMount measured itself; an AI coding agent was used to draft it.

All notes on Working with agents · All AX notes