tailwind-to-stylex
Skill2 starsChanged 59 days agoMITView on GitHub
Migrate a Tailwind CSS v4 codebase to StyleX through a phased, visually verified workflow that ends pixel-identical and token-driven.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- shadcn-labs/skillstheir own version, first seen Sep 25, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- shadcn-labs/skills★ 25same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- zk-model-passSkill
- bootstrap-agents-mdSkill
- update-agents-mdSkill
- zk-design-critiqueSkill
- us-math-standardsSkill
- three-game-starterSkill
- create-prSkill
- gh-cliSkill
- update-prSkill
- zk-app-store-linksSkill
- optimize-audioSkill
- tanstack-querySkill
- tanstack-routerSkill
- implement-plan-phaseSkill
- zk-claude-artifactSkill
- study-writing-styleSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 7 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 22
Create a migration branch.
- Distinctive: line 29
Every file containing Tailwind classes, as a checklist ordered leaf components first, layouts last.
- Very specific: line 40
Run the version check from tooling.md.
- Very specific: line 41
Smoke test: add a throwaway component styled with one distinctive stylex.create rule, render it on a real page, and confirm the rule …
- Very specific: line 50
Use literal ---prefixed keys so escape-hatch CSS and StyleX share one variable namespace (the bridge).
- Distinctive: line 52
Delete the old variable definitions the tokens replace in the same commit, re-pointing whatever consumed them.
- Distinctive: line 54
Done when: every theme token has exactly one home, the build passes, and the full route matrix is diff-clean.
- Distinctive: line 75
Verify the routes that render the component.
- Distinctive: line 78
Done when: every manifest entry is checked off, a grep of each migrated file finds zero Tailwind classes, and every route is diff-clean.
- Distinctive: line 86
Delete unused style keys and dead escape-hatch rules.
- Very specific: line 93
Remove Tailwind entirely: the tailwindcss package and its Vite/PostCSS wiring, plugins, @import "tailwindcss" / @theme / @custom-variant / …
- Very specific: line 95
Run the full verification matrix one final time against the P0 baseline, plus the project's build/typecheck/lint.
- Distinctive: line 96
Write the final report: files converted, restructured patterns, escape-hatch contents and why each line is there, flagged non-conversions, …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Tailwind v4 → StyleX migration
Migrate a Tailwind CSS v4 codebase to StyleX so the site renders pixel-identical while gaining typed, compiler-checked styles. Work the seven phases in order; Tailwind and StyleX coexist until the final teardown. Verification — screenshots plus computed styles — decides whether work passed, never judgment.
Non-negotiables (every phase)
- Ground truth: resolve every utility from the project's own compiled Tailwind CSS captured in P0, never from memorized tables. Models hallucinate v3 values under v4 (ring width/color, shadow scale renames, oklch palette,
color-mix()opacity modifiers). A class missing from the ground-truth CSS gets rendered once and read via computed style, then flagged in the report. - Literal-then-lift: P4 translates values literally so fidelity is checkable; P5 lifts to idiomatic StyleX afterward. Lift only in P5.
- Escape hatch: exactly three sanctioned plain-CSS homes —
reset.css(P3), the token bridge variables (P2), andmarkdown.cssfor subtrees StyleX cannot style (rendered markdown/prose, third-party DOM, container queries). Each consumes thedefineVarsCSS variables. In Astro, scoped<style>blocks are a fourth first-class home for.astrotemplates. Plain CSS anywhere else is a defect to fix. - Diff-clean gate: a unit of work is done only when verification reports no visual or computed-style difference, or every difference is explained in the report and accepted. Never commit past an unexplained diff.
P0 — Baseline
Load references/verification.md now.
- Create a migration branch. Create a gitignored
migration/working directory. - Inventory the codebase into
migration/manifest.md:- Tailwind version and wiring. This skill targets v4; on v3, stop and report that the project should upgrade to v4 first (or accept degraded accuracy).
- Framework(s): plain JSX app, Next.js, Astro (count
.astrotemplates vs framework islands), etc. @theme/@theme inline,@custom-variant,@utility,@plugincontents;:root/.dark-style variable blocks; dark-mode strategy (class, data-attribute, or media).- Dynamic class construction:
cn()/clsx/twMerge/cva,class:list, template literals, shared class-string modules. - Restructuring census — grep for:
prose,space-x-/space-y-,divide-,group/group-,peer,@container/@sm/@lg,animate-,@apply. Also note dead utilities (e.g.groupwith zerogroup-*:consumers) — those get deleted, not migrated. - Every file containing Tailwind classes, as a checklist ordered leaf components first, layouts last.
- Capture ground truth: build the project once and copy the emitted CSS asset(s) to
migration/baseline.css(fallback:npx @tailwindcss/cli -i <global.css> -o migration/baseline.css). - Capture the visual baseline per
references/verification.md: full screenshot matrix plus computed-style dumps.
Done when the manifest lists every Tailwind-bearing file and migration/ holds baseline.css, the screenshot set, and the style dumps.
P1 — Tooling
Load references/tooling.md now; it carries per-framework wiring (Astro included), plugin options, and the version check against live StyleX docs (StyleX is pre-1.0; APIs move).
- Install
@stylexjs/stylex(exact pin) plus the integrationtooling.mdprescribes for this framework, and@stylexjs/eslint-plugin. - Run the version check from
tooling.md. - Smoke test: add a throwaway component styled with one distinctive
stylex.createrule, render it on a real page, and confirm the rule reaches the browser indevmode and in the production build output. Then remove it.
Done when the smoke test passes in both modes. If it cannot be made to pass, stop and report — never start migrating on broken tooling.
P2 — Tokens
Load references/tokens.md now.
- Port every
@themetoken and hand-written theme variable intodefineVars(themeable values: colors, fonts, radii) anddefineConsts(static values: breakpoints, z-index, durations) in.stylex.tsfiles. - Use literal
---prefixed keys so escape-hatch CSS and StyleX share one variable namespace (the bridge). - Encode dark mode per
tokens.md(light-dark()when the project controlscolor-scheme;createThemeotherwise). - Delete the old variable definitions the tokens replace in the same commit, re-pointing whatever consumed them.
Done when every theme token has exactly one home, the build passes, and the full route matrix is diff-clean.
P3 — Reset
- Extract Tailwind Preflight's rules verbatim from
migration/baseline.cssintosrc/styles/reset.cssand import it at the app root. Verbatim extraction — not a lookalike reset — is what keeps the baseline identical after teardown. - While Tailwind is still installed the rules exist twice; that is expected and harmless because they are identical.
Done when reset.css matches the Preflight block in baseline.css and the matrix is diff-clean.
P4 — Migrate (component by component)
Load references/mapping.md and references/gotchas.md before the first component; return to mapping.md whenever a class carries a variant or resists direct mapping.
For each manifest entry, leaf-first:
- Collect the complete class set per element, including every branch of
cn()calls, ternaries,class:listarrays, and template literals — a conversion from a partial class set silently drops styles. - Resolve each class against
migration/baseline.css; reshape permapping.md:- JSX components (React/Preact/Solid/islands):
stylex.createat module top, applied withstylex.props(JSX-spread frameworks) orstylex.attrs(Solid/Svelte/Vue/Qwik). .astrotemplates: a scoped<style>block with semantic class names, declarations copied literally from ground truth, colors/fonts through the bridge variables.- Shared class-string modules (
cn-based builders): one sharedstylex.createmodule; parametrized builders become variant keys selected at the call site. - Caller
classNameoverrides become a style prop passed last tostylex.props(last wins, matchingtwMergesemantics).
- JSX components (React/Preact/Solid/islands):
- Verify the routes that render the component; commit per component (Conventional Commits).
- Record anything that needed restructuring, went to an escape hatch, or would not convert.
Done when every manifest entry is checked off, a grep of each migrated file finds zero Tailwind classes, and every route is diff-clean.
P5 — Lift (global pass)
One pass over the whole migrated codebase, now that repetition is visible across it:
- Replace repeated literal values with token references (
defineVars/defineConsts); a value used once stays inline. - Rename mechanical style keys to semantic ones; factor styles shared across components into shared modules (import
.stylex.tsfiles directly — barrel re-exports break the compiler). - Delete unused style keys and dead escape-hatch rules.
Done when the StyleX ESLint plugin reports clean, no literal value that has a token remains inline in more than one place, and the full matrix is diff-clean.
P6 — Teardown
- Extract the compiled
prose/typography rules frommigration/baseline.cssintomarkdown.cssbefore removing the plugin that generates them. - Remove Tailwind entirely: the
tailwindcsspackage and its Vite/PostCSS wiring, plugins,@import "tailwindcss"/@theme/@custom-variant/@pluginlines,tailwind-mergeand now-unusedcn()/clsxhelpers, and class-sorting formatter config (prettier-plugin-tailwindcssand editor/formatter class-function lists). - Prove removal: grep for
tailwind,@apply, and a sample of utility classes across the repo — zero hits outsidemigration/. - Run the full verification matrix one final time against the P0 baseline, plus the project's build/typecheck/lint.
- Write the final report: files converted, restructured patterns, escape-hatch contents and why each line is there, flagged non-conversions, and the LOC delta (roughly 2× styling LOC is normal for StyleX — expected, not a defect).
Done when the grep is clean, the final matrix is diff-clean against the P0 baseline, the build passes, and the report is delivered.
References
| File | Load when |
references/verification.md | P0, and at every diff-clean gate |
references/tooling.md | P1 — build wiring per framework, version check |
references/tokens.md | P2 — @theme → vars/consts, dark mode |
references/mapping.md | P4 — variants, restructuring, everything past plain utilities |
references/gotchas.md | Before the first stylex.create; again on any compiler or lint error |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

