CLI Commands
@csszyx/cli installs one binary, csszyx.
npx csszyx <command> [options]csszyx --help lists the commands. csszyx --version reads the installed
package’s own manifest, so it reports the version that is actually on disk.
Every command except explain accepts --cwd <dir> and runs against that
directory instead of the shell’s.
Every command
Section titled “Every command”| Command | What it does | Documented in |
|---|---|---|
init | Detects the framework, writes the bundler config, the CSS entry and csszyx.config, and installs the packages those files need. A csszyx.config the project already has is kept; the one init 0.17 wrote is replaced. | Installation |
migrate [dir] | Rewrites className= and class= to sz props, and normalises legacy sz keys under --keys-only. | Migrate from Tailwind |
check [dir] | Scans static sz props and szv()/szr() catalogs for keys that emit nothing, then asks the project’s own Tailwind whether every emitted class produces CSS. It exits 1 on a finding at error, or at the level --fail-on names, and the levels come from csszyx.config, so it is the command to run in CI. | What check reports, Running it in CI |
doctor | Reports on the install itself: csszyx.config and what is wrong in it, Tailwind, packages, build output, optional tooling. | CLI |
explain <sz> | Prints the className one sz value compiles to, lowered by the same engine as the build. csszyx explain "{ p: 4, bg: 'blue-500' }" prints p-4 bg-blue-500. A value read at runtime is named under the className ({ p: `4` } prints p-(--_sz-p) and says --_sz-p is set through style), the build’s warnings follow it, and an object the build leaves to the runtime _sz() helper exits 1 with the build’s reason. | Plugin Config |
generate-types | Turns a Tailwind v3 tailwind.config.js into TypeScript declarations. Only v3 projects have a config to read. | generate-types and Tailwind v3 |
next-prebuild [pattern] | Seeds the Next.js Turbopack safelist and generation manifest before next build. Also spelled csszyx next prebuild. | Installation |
next-watch [pattern] | Keeps that safelist current beside next dev. Also spelled csszyx next watch. | Installation |
audit | Reports the built asset sizes of a dist/ directory. | Below |
scan-collisions | Finds class names in the project’s own CSS that a mangled token could collide with. | Below |
Without --pattern or --files, check reads every module the build lowers:
**/*.{ts,tsx,js,jsx,cts,mts,cjs,mjs}, so a szv() catalog in a
button.styles.ts is checked like a component. Declaration files (.d.ts,
.d.mts, .d.cts), csszyx.config.*, and the folders node_modules, .git,
.next, .nuxt, .astro, .turbo, dist and build are left out. So is
whatever .gitignore covers, as Tailwind and the build’s safelist scan leave it
out, unless a stylesheet names it with @source: then it is read, as both of
them read it, when it is under the project root. The Found N files line says
so on every such run. An output folder git keeps, such as coverage or
storybook-static, is read; leave it out with --ignore. A --pattern reads
every file it matches, gitignored or not.
On Next.js with Turbopack, csszyxTurbopack lowers *.tsx unless its glob
says otherwise, while check reads every flavour above. Narrow check with
--pattern to match a narrower glob.
check does not read your bundler config or the options passed to the csszyx
plugin. An exclude there narrows the build, not the check, so pass the same
files to --ignore, once per glob:
# the plugin has exclude: [/\.stories\.tsx?$/]npx csszyx check --ignore "**/*.stories.tsx" --ignore "**/*.stories.ts"The options, the reports and running it in CI are in
What check reports.
next-prebuild and next-watch
Section titled “next-prebuild and next-watch”Both take the same options; next-watch adds --debounce-ms. Setup is in
Installation.
| Option | Effect |
|---|---|
--root <dir> | The Next.js app root. Defaults to the working directory. |
--tailwind-stylesheet <paths> | The stylesheets the app loads, relative to --root and comma-separated, when the project also holds others. |
--ignore <patterns> | Comma-separated globs, relative to --root, left out of the source scan and of the Tailwind prefix vote. Repeatable. legacy and legacy/** both cover everything under the directory; legacy/* covers only what sits directly in it. A comma inside braces, brackets or parentheses belongs to the glob, as in {legacy,old}/**. A negated pattern (!…) is refused. |
--cache-dir <dir> | Cache directory relative to the root. Defaults to .csszyx/cache. |
The Turbopack loader reads the --ignore patterns the command recorded, so
they are not repeated in next.config.
csszyx audit reads the dist/ directory under the working directory and
reports what the build left there.
npx csszyx auditOne section prints. 📦 Build Output lists the first HTML file and the first
CSS file found under dist/, each at its size on disk. No figure here is
scaled, compared or derived: statSync answers and the report prints what it
said. A project that builds somewhere else — a Next.js app, for one — gets
No built HTML or CSS found under dist/.
The report closes with two notes. Mangling hides class names and does not shrink
a gzip-served payload; the production build weighs that trade and prints its own
verdict. And csszyx/lite is the compiler-free runtime entry.
| Option | Effect |
|---|---|
--json | Prints { output } and nothing else. output.html and output.css are null when dist/ holds no asset of that kind. |
--cwd <dir> | The directory holding dist/. |
scan-collisions
Section titled “scan-collisions”csszyx scan-collisions reads the project’s own stylesheets and names the
classes a mangled token could collide with. It is the command the hybrid hazard
warning points at.
npx csszyx scan-collisionsnpx csszyx scan-collisions --pattern "src/**/*.css"A mangle token is base62 and never contains - or _, so only a short and
purely alphanumeric class name can equal one. The scan reports a name of one
letter followed by at most two alphanumerics and passes over every other name.
Comments, url(…) contents and quoted strings are blanked first, so a .z
written in a comment and an @import 'theme.css' are not read as selectors.
Both forms of the report — the clean line and the list with its paste-ready
mangleExclude — are in CLI.
| Option | Effect |
|---|---|
--pattern <glob> | Replaces the default glob, **/*.{css,scss,sass,less}. |
--ignore <glob> | Appended to the defaults below. Repeatable. |
--cwd <dir> | Project root to scan. |
Ignored by default:
**/node_modules/** **/.next/** **/.vercel/****/dist/** **/.nuxt/** **/.turbo/****/build/** **/.astro/** **/storybook-static/****/out/** **/.output/** **/playwright-report/****/coverage/** **/.svelte-kit/**Every one of those holds CSS a tool wrote, and generated CSS cannot collide with
a mangled token because nothing renders it into the app. A coverage report is
the case that set the list: run in a package that had once collected coverage,
the command reported 32 names, of which 30 were istanbul’s HTML report — .L0
through .L9, .kwd, .pun, .typ — and the paste-ready mangleExclude
reserved 34 token names on behalf of a gitignored artefact.
The command edits nothing. Which fix to apply — rename, mangleExclude or
manglePreserve — is decided in Plugin Config.
Exit codes
Section titled “Exit codes”Every command exits 0 unless a row below applies.
| Command | Exits non-zero when |
|---|---|
check | Any finding, a path passed to --files that names a source file it could not read, or a directory argument that is missing, is a file, or is combined with --files or an absolute --pattern. |
scan-collisions | Any collision-prone class name was found, which makes it a CI gate. |
explain | The argument is not a statically readable sz object literal. |
migrate | A file failed to migrate, or the native engine is not installed. |
generate-types | No Tailwind config was found, or Tailwind v3 is not resolvable. |
next-prebuild | The pattern matched no files, or seeding the safelist threw. |
next-watch | The watcher could not start, including on an out-of-range --debounce-ms, or it failed while running. |
audit, doctor and init report and never fail the shell. doctor closes
with Found {n} issue(s) and still exits 0.