# Kerf > Kerf is a CSS framework that enforces a design system and accessibility at build time. You write `s="…"` on elements with words from the design system (`kerf.config.js`); Kerf rewrites them to `k-` classes, writes a stylesheet with only what is used, and fails the build on off-scale values, WCAG contrast failures (light and dark mode), small tap targets, unlabelled fields, images without alt or size, and more. npm package: `@kerfcss/kerf`. Node 20+. ```html
Start

No account needed.

``` ## For coding agents - Run `npx kerf check --json` after every change and fix each diagnostic. Each has `file`, `line`, `rule`, `severity`, `message` and usually a `suggestion`; apply the suggestion rather than working around the check. Errors fail the build. - Write `s=`, not inline styles or hand-written `k-` classes. Don't use hex colours: use roles. - Spacing, widths and text sizes must be on the config's scales (`pad 13` is an error; the default space scale is 0 4 8 12 16 24 32 48 64). - Breakpoints are prefixes, phones first: `stack 16 md:row 24`. Colours, components, `hover:`, `prose` and `menu` can't change by breakpoint. - In VS Code, the Kerf extension (https://marketplace.visualstudio.com/items?itemName=kerfcss.kerf) shows the same diagnostics as you type, with quick fixes; other editors can run `npx kerf lsp`. - Static sites and server templates: `npx kerf build` (`--watch` to rebuild on save). Plain HTML shares headers and layouts with `` and ``; folders starting with `_` aren't built as pages. - Vite: `@kerfcss/kerf/vite`. Next.js: `withKerf()` from `@kerfcss/kerf/next` in next.config and `@kerf;` at the top of app/globals.css; `kerf init` writes `kerf-env.d.ts` so TSX accepts `s`. Other PostCSS tools: `@kerfcss/kerf/postcss`. - Your own CSS uses the variables: `var(--k-space-16)`, `var(--k-text-lg)`, `var(--k-text-muted)`, `var(--k-shadow-2)`. `.css` files are checked too. ## Words - Space: `pad 16`, `pad-x`, `pad-y`, `pad-t`, `pad-b`, `gap 16` - Layout: `stack 16` (column), `row 16` (wrapping row), `grid 3`, `span 2`, `max 1024`, `measure`, `align start|center|end|stretch|baseline`, `justify start|center|end|between`, `screen`, `center`, `scroll`, `sticky`, `hide`, `show` - Media: `ratio 16:9`, `cover`, `contain`, `round`, `round full`, `shadow 1|2|3` - Text: `xs`, `sm`, `base`, `lg`, `xl`, `2xl`, `3xl` (text scale), `bold`, `semibold`, `medium`, `mono`, `no-underline` (not on links in a sentence) - Colour roles (defaults): `surface`, `surface-raised`, `border`, `border-field`, `text`, `text-muted`, `text-link`, `accent`, `on-accent`, and for each status (danger, success, warning, info) `text-success` and `surface-success` and so on. Text colour is the role alone (`text-muted`); background `bg-accent`; border `border-border`, `border-t-border`, `border-b-border` - Components: `button`, `button primary`, `card`, `alert` and `badge` with `danger|success|warning|info` (plus any in the config). Say the status in words too, not only colour; a message shown after load needs `role="status"` or `role="alert"` - `hover:` + a colour, `round` or `shadow`: also applies on keyboard focus - `menu`: a popover list of links (`