Work with AI
Prompts to paste into your AI coding agent: set Kerf up in a project, start a new site, or move a page to Kerf. The agent checks its own work with kerf check.
Why it works well with agents
An agent guessing at CSS drifts: a padding of 13 here, a grey that fails contrast there. With Kerf, every value has to come from your design system, and kerf check --json tells the agent exactly what's wrong and what to write instead. So it fixes its own mistakes before you see them.
These prompts work in Claude Code, Cursor, GitHub Copilot, Codex, Windsurf and other agents that can run commands. Copy one, paste it into the agent in your project's folder, and change the parts in angle brackets.
Set up Kerf in this project
For a project you already have. The agent picks npm or the standalone kerf for your stack, connects Kerf to it, and leaves your existing styles alone.
Set up Kerf (https://kerfcss.dev) in this project. Kerf is a CSS framework: elements get s="…" with words from a design system in kerf.config.js, and the build fails on off-scale values and accessibility problems, each with a suggested fix.
1. Read https://kerfcss.dev/llms.txt first: it lists Kerf's words and rules.
2. Install it. If the project has a package.json (or uses Vite or Next.js): npm install --save-dev @kerfcss/kerf, and run it as npx kerf. Otherwise (PHP, Laravel, WordPress, Django, Rails, plain HTML): curl -fsSL https://kerfcss.dev/install.sh | sh (on Windows: irm https://kerfcss.dev/install.ps1 | iex), and run it as kerf, or ~/.kerf/bin/kerf until a new terminal picks up the PATH.
3. Run kerf init in the project root. It writes kerf.config.js (or .mjs) and AGENTS.md. If an AGENTS.md was already there, add Kerf's part of llms.txt to it.
4. Connect it to the stack:
- Vite: add kerf() from "@kerfcss/kerf/vite" to the plugins in vite.config.
- Next.js: wrap the config next.config exports in withKerf() from "@kerfcss/kerf/next", and put @kerf; at the top of app/globals.css (or src/app/globals.css).
- Anything else: set input in kerf.config to the folder with the pages or templates, and outDir to the folder the site is served from, then link /kerf.css in the page head. If that means moving files, ask me first.
5. If the project has a main brand colour, set brand.hue in kerf.config to match it (0 to 360, OKLCH).
6. Don't rewrite the existing styles: Kerf works next to them. Use s= in markup you write from now on.
7. Run kerf check --json and fix every diagnostic with its suggestion, until it reports none. Don't work around a check.
8. Tell me what you changed, and the commands to build and to rebuild as I work.
Start a new site
For an empty folder: plain HTML pages with a shared header and footer, built by Kerf and ready for any static host.
Build a website with Kerf (https://kerfcss.dev) in this folder: <what the site is for, its pages, and its main colour>.
1. Read https://kerfcss.dev/llms.txt first: it lists Kerf's words and rules. Write all styling as s="…" with those words. No inline styles, no hand-written k- classes, no hex colours.
2. Install Kerf: npm install --save-dev @kerfcss/kerf if Node is available (run it as npx kerf), otherwise curl -fsSL https://kerfcss.dev/install.sh | sh (on Windows: irm https://kerfcss.dev/install.ps1 | iex) and run it as kerf, or ~/.kerf/bin/kerf until a new terminal picks up the PATH.
3. Run kerf init, then set brand.hue in kerf.config to the main colour (0 to 360, OKLCH).
4. Put pages in src/. Share the header and footer with <kerf-include src="_partials/header.html"></kerf-include>, and a page layout with <kerf-layout>, as https://kerfcss.dev/docs/templates/ shows.
5. Use the built-in components (button, card, alert, badge, menu for the mobile nav) before making new ones. Make a new component in kerf.config only when the same set of words repeats.
6. Run kerf check --json after each page and fix every diagnostic with its suggestion, until it reports none.
7. Run kerf build, and tell me how to preview dist/ (for example npx serve dist) and how to rebuild as I edit (kerf build --live).
Move a page to Kerf
Once Kerf is set up: one page at a time, so you can compare it with the original.
Move <page or component> to Kerf. Read https://kerfcss.dev/llms.txt first, and https://kerfcss.dev/docs/tailwind/ if it uses Tailwind.
- Replace its classes and inline styles with s="…" words. Keep the look as close as the design system allows. Where a value isn't on a scale, use the nearest step, and list those changes for me.
- Keep classes that scripts or tests use. Leave other pages alone.
- If the same set of words repeats, suggest a component for kerf.config instead of copying it.
- Run kerf check --json and fix every diagnostic with its suggestion, until it reports none.
- Afterwards, list the CSS rules that page no longer needs, but don't delete them: other pages may use them.
After setup
kerf initwrites anAGENTS.md, which most agents read on their own, so later sessions keep usings=and checking their work without being told. See AI coding agents for the JSON they read.- llms.txt is the short version of these docs, for agents and chat assistants. Point a chat at it before asking about Kerf.
- In VS Code, Cursor and Windsurf, the Kerf extension shows the same problems as you read the agent's changes, with one-click fixes.
- Review what the agent did as you would any change. The checks catch off-scale values and accessibility mistakes; they can't tell whether the page says the right thing.