Repository navigation
chore(design-system): narrow the scan set, widen the utility guard - #200
Conversation
`@import "tailwindcss"` detects sources from the project root on its own, and `@source` adds to that set rather than replacing it. The three lines therefore changed not one byte of the build, and the production stylesheet was a function of the repo's prose: 18 utilities came from Markdown, code comments and test fixtures. Six of them came from doc lines telling a reader not to write the class — `max-w-[400px]`, `text-[16px]`, `px-[17px]`, `font-[500]` and `text-[#7b7b7b]` from a Claude skill file, `min-h-11` from the design-system rule. Editing a sentence changed what every visitor downloaded. `source(none)` removes that property for one line. Measured on b448e10 by building both ways: 83,171 → 81,792 bytes, 13,912 → 13,694 gzipped. Diffing the class selectors, those 18 disappear and nothing new appears. `focus-ring` still emits its box-shadow and all twelve `sm:col-span-*` still compile, so the `@source inline()` declaration is unaffected. Nothing outside the three directories authors a className: `grep -rl className` over `*.ts`/`*.tsx` finds only the two guards' fixtures. `hooks/` is the one live code directory outside the set and authors no class today. Ladle needs no `@source "../.ladle"`: `.ladle/components.tsx` uses inline styles because Tailwind never scanned that directory, `story-overrides.css` is plain CSS, and stories live under `components/`. Refs #186 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VrKQJ4TDGiXYupefsRxEBa
`bg-error-light` names no declared token: `--color-error` and `--color-error-dark` exist, `--color-error-light` does not. The class has emitted no CSS since it was written, so the API-error banner and the geolocation-error state have both rendered on a bare white background. `bg-error/10` is what the repo's other error banner already uses (`FormBuilder.tsx:310`), and it tints the declared token rather than adding a new one. The compiled stylesheet is unchanged, because that banner already compiles the class. The widened guard in the next commit is what found this. Refs #186 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VrKQJ4TDGiXYupefsRxEBa
The guard matched colour utilities by scale and `font-*` by prefix, so a token off a numeric scale (`error-light` beside the declared `error-dark`), the `radius` and `shadow` namespaces, and a mistyped scale name all passed. Widening the hand-rolled rule meant answering the keyword half per namespace — `text-` carries `text-center` as well as `text-<color>`, which is why `font-stretch-*` already needed a special case — and deriving a colour family from a token name breaks on `--color-bg-warm`. `candidatesToCss` answers both for free: it compiles a candidate against the real stylesheet and returns `null` when it emits nothing. No token sets, no keyword list, no variant or opacity or important parsing, and the `font-stretch-*` case goes away. All five classes in #186's table now fail, by file and line. What stays a choice is reach, now one list of watched prefixes. A prefix missing from it is unwatched, never wrongly flagged, so adding one costs a line. Two shapes are out of scope: an arbitrary value names no token, and a match preceded by `<word>-` is a slug — without that, `how-to-begin` read as a gradient stop. An inline `<style>` block is blanked before scanning, because `stroke-width` there is a CSS property, not a class. Fixtures now spell dead classes outright. They could not before: Tailwind scanned this file, so a literal shipped its CSS to every page. `source(none)` ended that. Closes #186 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VrKQJ4TDGiXYupefsRxEBa
From the /simplify pass over the branch. **Reach is derived, not listed.** A root takes a colour exactly when `<root>-<a declared colour token>` compiles, so the compiler already holding the rule can supply the reach too. That replaces 21 of the 23 hand-written prefixes with 51 probed ones, adding `mask-*-from`, `scrollbar-thumb` and the eight `border-<side>` roots, and it follows a Tailwind version bump on its own — the property the old header comment claimed and the first draft gave up. Measured over the scanned tree: 2334 matches, 0 dead, so no false positive comes with the extra reach. `font` and `rounded` stay hand-written. Probing them needs an ambiguous value — `lg` compiles under `w-`, `blur-` and `basis-` too, which leaks 78 roots. Deriving from every functional root instead of the colour-valued ones leaks differently: `left-channel`, `content-index`, `align-left` and SVG path data all read as utilities, 11 false positives on this tree. **The scan set is checked against the tree.** `source(none)` turns a harmless failure — extra CSS ships — into a silent one, where a directory outside the set compiles no classes and the symptom is an unstyled first render. A new test fails when a top-level directory authors a `className` with no `@source` line, so the rule is enforced rather than only written down twice. **Plumbing moved to `_source-scan.ts`.** The `loadStylesheet` resolver, with its non-obvious `tailwindcss` → `index.css` mapping, was byte-identical in `layouts/tailwind.test.ts`; the blank-but-keep-newlines idiom was written three times. Both now have one definition, and `layouts/` is spelled once rather than derived two incompatible ways. Also collapses fixtures that only existed because Tailwind used to scan this file, and trims the `layouts/tailwind.css` comment to what matters at the edit site — its longer form had already drifted from the doc's measurement. Refs #186 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01VrKQJ4TDGiXYupefsRxEBa
From the /code-review pass.
- `globSync` ignores `.gitignore`, so `git worktree add .claude/worktrees/<slug>`
made the scan-set check read a whole second checkout as a top-level directory
authoring classNames. Reproduced against the main checkout: it reports
`.claude` and fails, green only in a fresh clone. `.claude` is now ignored.
- A candidate had to open on an alphanumeric but not close on one, so an
interpolated `` `bg-teal-${step}` `` matched as `bg-teal-`, compiled to
nothing, and was reported as a dead utility nobody wrote.
- `stripStyleBlocks` matched a bare `<style>` only, leaving
`<style type="text/css">` and its `stroke-width` to read as utilities.
- The scan-set check walked directories only, so a `.ts` at the repo root — the
one place no `@source` line covers — went unexamined.
Also corrects two comments that overstated what the code does: variants are
dropped before compiling rather than passed through, and the canary now names a
project `@utility` (`text-glow-light`) instead of `shadow-lg`, which is one of
Tailwind's own.
Refs #186
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VrKQJ4TDGiXYupefsRxEBa
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | c559c3e | Commit Preview URL Branch Preview URL |
Oct 27 2026, 02:43 AM |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The shape is right and the diff stays the size of #186. Part 1 is one line; Part 2 deletes more rule than it adds by handing deadness to Tailwind. Delegating deadness but keeping extraction bespoke looked like half a job — it is not: Oxide's Scanner returns 431 candidates for LocationSearch.tsx alone, import and react among them, which is free for the build and fatal for an inverted guard. WATCHED_PREFIXES is forced, not a shortcut. The joined bg-error/10 fix and the tree check both belong here.
Findings
should-fix—theme-utilities.test.ts:75: nine common CSS keyword values are watched and dead, so each is a future false failure.consider—theme-utilities.test.ts:158: the test name claims more than it checks.consider—_source-scan.ts:50:stripStyleBlocksis a single-caller helper in the shared module.
What was checked
- #186's seven acceptance criteria against the diff; all hold.
vitest tests/guards/ layouts/tailwind.test.tsfrom a fresh clone: 35 passed, as claimed.- Probed the design system: 51 colour roots +
font/rounded= 53, matching the body.bg-error-lightdead,bg-error/10live. - All six Preview links 200. Deployed stylesheet is 81,792 bytes at
…CTDo4sEX, as claimed.bg-error-light,min-w-2/5,max-w-[400px],text-[16px],ring-offset-teal-900absent;sm:col-span-7andsm:col-span-12present;.focus-ring:focus-visiblestill emits its box-shadow. source(none)risk:className,class=,clsx/cvaoutside the three dirs finds only the two guards' fixtures and two Illustrator SVGs.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
`stripStyleBlocks` had one caller, in the module that exists to hold what needs one definition. Folding it into `readSource` instead would have detached it from the matcher that needs it: the other guards only ever read a file, while `findDeadUtilities` is handed a bare string by six of this file's own cases, so a strip applied at file-read time would not run in any of them. `blank` is exported in its place — the "blank it, keep the newlines" idiom is what the shared module is for, and `stripComments` already composes it. Refs #186 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUzu1fFLPf6Ky6vBAS
The matcher read any `<watched root>-<value>` as a candidate, so CSS written in a `.tsx` file read as a dead utility. Measured against the real stylesheet: 44 kebab-case CSS property names sit under a watched root and compile to nothing, `stroke-width`, `font-family`, `text-align` and `border-radius` among them, plus the `border-box` / `text-top` / `text-bottom` values. None is in the tree today, so each was a future red test on correct code. A declaration, an arbitrary property (`[stroke-width:2px]`) and an SVG attribute all put a `:` or `=` straight after the name, and a class never has one there, so the trailing lookahead now excludes both. That covers the property names wherever they are written, rather than per region: it is also why `<style>` needed stripping at all. Across the 277 scanned files it drops 3 of 2334 matches, all of them live. The values are not followed by a separator, and they belong to the one region a class cannot reach: a `style` prop, whose keys React spells in camelCase. That region joins `<style>`. Refs #186 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUzu1fFLPf6Ky6vBAS
The name claimed a directory authoring "a class"; the body reads the literal `className` in a `.ts`/`.tsx`. The gap is real: `assets/chart.svg` reaches the DOM through `SubtleSystem`'s `dangerouslySetInnerHTML` with `class="cls-N"`, and `assets/` has no `@source` line. Those are Illustrator classes the SVG styles itself, so nothing is wrong — but the name said otherwise. Refs #186 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUzu1fFLPf6Ky6vBAS
The rule doc counted two out-of-scope shapes and promised a directory check over "a className", both of which the branch has now moved. Refs #186 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjUzu1fFLPf6Ky6vBAS
|
Pushed
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
#200 moved `layouts/tailwind.test.ts`'s compile plumbing into `tests/guards/_source-scan.ts`; this branch had added a band-gradient case to the same import block. Took the shared helpers and kept the new case, reading the component source from the helper's `repoRoot` rather than a second local path. `@source "../components"` still covers `OrnateTextBox.tsx`, so #200's `source(none)` leaves the verbatim-candidate premise intact. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYtQC69PjzVdUcfhBC
Summary
source(none)makes the three@sourcelines the whole scan set. 18 utilities leave the production stylesheet, none appear.bg-error-lightcall sites the widened guard found. Both drew no background at all.Change outline
Behaviour — what counts as a dead utility
The rule moves out of the guard and into Tailwind.
candidatesToCsscompiles a candidate against the real stylesheet and answersnullwhen it emits nothing, so every token set, keyword list and syntax special case goes away.Reach is derived the same way, rather than listed:
What this adds over the two old families: a colour token off a numeric scale (
text-error-light), a mistyped scale (text-grey-700), the radius and shadow namespaces (rounded-pill,shadow-brand), and roots no hand-written list had —mask-*-from,scrollbar-thumb, the eightborder-<side>.What the two exclusions keep out. Measured against the real stylesheet: 44 kebab-case CSS property names sit under a watched root and compile to nothing —
stroke-width,font-family,text-align,border-radiusamong them. A declaration, an arbitrary property ([stroke-width:2px]) and an SVG attribute all put a separator straight after the name, and a class never has one there, so a trailing:or=ends the match. That drops 3 of 2334 matches across the 277 scanned files, all of them live. Theborder-box/text-top/text-bottomvalues carry no separator, so thestyleprop — whose keys React spells in camelCase — joins<style>as a region blanked whole.Contract — what Tailwind scans
@import "tailwindcss"detects sources from the project root on its own, and@sourceadds to that rather than replacing it. So the three lines changed not one byte, and the stylesheet every visitor downloads was a function of the repo's prose.That invariant is now enforced rather than written down:
Files — guard plumbing with one definition
Preview
Both previews serve the narrowed stylesheet —
layouts_tailwind-…CTDo4sEX.cssandassets/index-CpkHkP8H.css, the exact hashes built locally. The whole risk of this PR is a utility that silently stopped compiling, so each link is a page to look at rather than interact with.bg-error/10already belonged to@source "../.ladle"addedTest results
.claude/skills/pr-prep/check.sh— eslint 0 errors,tsc --noEmitclean, vitest 897 passed / 88 filestests/guards/+layouts/tailwind.test.tspnpm buildat b448e10's stylesheet. 83,171 → 81,792 bytes, 13,912 → 13,694 gzipped. The review commits touchtests/anddocs/only, so no build input movedpnpm ladle:build: ✓Manual verification
bg-error-lightcompiled to nothing, so the LocationSearch API-error banner and the nearby-geolocation error state have always rendered on bare white. They now carry the same faint tintFormBuilder's error banner uses.--page-widthcaptured at 1136px in a 1440px window,px-12gutter,.ladle-mainoverride applied). Worth a second look if you open it.Notes for reviewer
bg-error/10is not a new design choice. It is exactly whatcomponents/organisms/FormBuilder/FormBuilder.tsx:310already uses for an error banner. The alternative — adding a--color-error-lighttoken — would have been a new token for one call site.text-errormeasures 3.94:1 on white and 3.50:1 on this tint, both under the 4.5:1 AA bar for body text. That is fix(components): text and button colour pairings fail the 4.5:1 AA bar #179's subject, acrossFormField,FormBuilderandDropdownas well; this PR neither introduces nor fixes it.main's own source when first widened, namingLocationSearch.tsx:286andNearbyOption.tsx:85. That is the one acceptance criterion that did not hold as written — both are fixed in their own commit, first on the branch, so every later commit is green.class=the tree renders stays outside the scan-set check.assets/chart.svgreaches the DOM throughSubtleSystem.tsx:275'sdangerouslySetInnerHTMLcarryingclass="cls-N", andassets/has no@sourceline. Those are Illustrator classes the SVG styles itself, so nothing is dead — the test's name anddocs/rules/tailwind.mdnow both stop at aclassNamein a.ts/.tsxrather than claiming more.Detail
The 18 utilities
source(none)removes, diffing the class selectors of both builds at b448e10. Nothing appears.bg-fg/50,bg-highlight,block-1,ease-out,font-[500],from-white,list-item,lowercase,max-w-[400px],min-h-11,min-w-2/5,pt-[height],px-[17px],ring-2,ring-offset-teal-900,text-[#7b7b7b],text-[16px],text-on-highlightSix come from doc lines telling a reader not to write the class: five from
.claude/skills/design-extraction/SKILL.md:35,37andmin-h-11fromdocs/rules/design-system.md. Others come fromDESIGN_SYSTEM.mdandSTORYBOOK.mdprose, a sentence in a code comment, and the substring in.toLowerCase(). The ticket measured 16 at 8209bed;min-h-11andtext-[#7b7b7b]are new since, both from prose, which is the point rather than a discrepancy.Probes.
min-w-2/5andmax-w-[400px]return 0 in the built stylesheet; all twelvesm:col-span-*still compile;.focus-ring:focus-visiblestill emits itsbox-shadow.Rejected: deriving reach from every functional root.
utilities.keys('functional')returns 315. Using all of them flags 11 false positives onmain's own source —left-channel,content-index,align-left,right-aligned,content-blocks, SVG path data. The compiler decides deadness, but the prefix set decides what gets asked, and asking about a slug yields a false failure. Probing for colour-valued roots only gives 51, and 0 dead across 2331 matches.Rejected: batching
candidatesToCssacross files. Measured: one call for all 2351 candidates is 20.3ms against 26.1ms today — 6ms, for threading per-file line attribution through a flattened array and losing per-directory failure isolation. The whole guard runs in ~280ms.Rejected:
SCANNED_DIRSfromcompile().sources. A different entry point from the one the guard loads, and it returns base/pattern pairs rather than the directory names the glob needs.Rejected: folding the CSS strip into
readSource. Six of the guard's own cases handfindDeadUtilitiesa bare string, so a strip applied at file-read time would run in none of them. It moved to the guard instead, andblankis exported in its place.Four false-positive paths found in review and closed, each reproduced first:
globSyncreading.claude/worktrees/<slug>as a top-level directory (fails from the main checkout, green in a fresh clone); an interpolated`bg-teal-${step}`matching asbg-teal-;<style type="text/css">escaping the CSS blanking; and a repo-root.tsfile — the one place no@sourceline covers — going unexamined.Measured risk of
source(none). Nothing outside the three directories authors a className:grep -rl classNameover*.ts/*.tsxfinds only the two guards' fixtures..ladle/needs no@sourceline —components.tsxuses inline styles because Tailwind never scanned it,story-overrides.cssis plain CSS, and stories live undercomponents/.Closes #186
🤖 Generated with Claude Code
https://claude.ai/code/session_01VrKQJ4TDGiXYupefsRxEBa