Prettier Races Agent Edits
P2 priority Donep2-is-prettier-races-agent-editsPrettier reformats files behind a running agent
- Stage
- 03-done
- Author
- Ivan Hawkes
- Created
- Completed
Prettier reformats theme CSS and layout HTML after an agent has read them, so the text the next edit quotes no longer exists on disk.
Cause
- The husky
pre-commithook runslint-staged, which runsprettier --writeover staged css, md, html, yaml, json and js. - VSCodium keeps
editor.formatOnSaveon with the Prettier extension, so a file saved in the editor is reformatted as well. - At
printWidth: 80andtabWidth: 4a CSS declaration at indent 1 wraps past 76 columns into three lines, andproseWrap: alwaysreflows markdown prose at 80, so hand written text rarely survives a formatter pass. - Ruled out: line endings (
.gitattributespins LF, no tracked file carries CRLF), the Git LFS hooks, devenv tasks, CI, and prettier version drift, as the project’s 3.9.9 and the extension’s 3.7.4 agree byte for byte. - A trap beside the cause: root
assets/css/main.cssis Tailwind output, gitignored and over the read limit, so no edit of it can ever match.
Fix
printWidth: 100for**/*.css. The theme carried its own Prettier block, which resolved ahead of the root one for every file underbe-best/, so a root-only override was inert; the block andbe-best/.prettierignoreare gone and the root config is the only one.- Dead weight is gone with it:
prettier-plugin-go-templateand its*.htmlparser override,prettier-plugin-tailwindcsswithtailwindStylesheet, a.prettierrcoverride for a file that does not exist,cross-var, and the theme manifest whose devDependencies were never installed (be-best/is not a workspace member). Formatting 329 tracked files without the plugins changed 0 of them. editor.formatOnSaveoff for[css],prettier.prettierPathpinned to the project copy, andprettier.requireConfig: true..editorconfigkeeps the load bearing trailing space after-}}in layouts and the hard-break pair at the end of a markdown line.- Rules in
AGENTS.mdand.pi/APPEND_SYSTEM.md: re-read immediately before an edit, keep lines inside the wrap limits, never edit generated CSS, never format layout templates.
Acceptance Criteria
Every tracked layout HTML reads as Prettier-ignored by the root file
Exactly one Prettier config, the root manifest, covers the theme too
The config wires in no plugin, and no override routes to a Go-template one
pnpm run test:prettierasserts those invariants insidepnpm run testpnpm run testpasses against the reflowed theme CSSA theme CSS edit lands without a follow-up edit quoting stale text
Since the config landed, edits to theme CSS, TypeScript, JSON and markdown all matched on the first attempt. The one failure in the session was an edit that followed a `prettier --write` I ran myself, which is the documented re-read case, not the editor and commit race this card is about.