kerf-app
FreeNo executable scriptsNot checkedBuild UIs in the kerf reactive framework (https://github.com/brianwestphal/kerf). Use this skill whenever the user is writing or modifying code that imports…
by brianwestphal★ 41 GitHub starsAbout this skill
Building apps with kerf
Drop this file into your
~/.claude/skills/kerf-app/SKILL.md(or your project's.claude/skills/kerf-app/SKILL.md) so Claude Code activates it whenever you work on a kerf app.
kerf is a ~12 KB reactive UI framework (~13 KB with arraySignal): signals + DOM morphing + JSX → HTML strings. No virtual DOM, no compiler, no scheduler. The whole public surface fits in 17 exports.
Setup
- Install:
npm install kerfjs tsconfig.json:"jsx": "react-jsx","jsxImportSource": "kerfjs"- Vite / esbuild need no extra config.
- Dev diagnostics are opt-in by import, and only an APP installs them. kerf does not infer dev mode. In the app entry add
if (import.meta.env.DEV) await import('kerfjs/dev');(Vite) orif (process.env.NODE_ENV !== 'production') await import('kerfjs/dev');(webpack/Node). That enables the read-only storeget()snapshot, the throwing dangerous-URL screen, and makes theKERF_DEV_WARN_*family available; omitting it is production shape and sheds ~4.7 KB min+gzip because the condition folds away and the chunk is never emitted. Put it FIRST if relying on the untracked-signal warning —signal()picks its constructor at creation time.- Switch individual warnings on with
enableWarnings(), which is the only switch that works in a browser (noprocessobject there, and a bundlerdefinecannot reach the read):const dev = await import('kerfjs/dev'); dev.enableWarnings({ staleBinding: true, narrowSet: true, invariants: 'throw' });. TheKERF_DEV_WARN_*env vars do the same for Node/SSR/CI; an explicit call wins either way. - A component package must NEVER import
kerfjs/dev. The hooks are process-global, so installing them is the consuming app's decision — a library that does it forces the diagnostics (and the chunk) on every consumer. Put the import in your demo page or test harness instead.
- Switch individual warnings on with
- Recommended companion:
npm install --save-dev eslint-plugin-kerfjsand addkerfjs.configs.recommendedto the project's eslint config. Enforces five of the hard rules below (no inline JSX event handlers, requiredata-keyineach(), capturedelegate()disposers, no nestedmount(), prefer module JSX augmentation) at edit time — useful as a self-correction signal when authoring kerf code.
Public API — one import path
import {
signal, computed, effect, batch, // reactivity
defineStore, resetAllStores, // stores
mount, morph, each, // render (reactive + one-shot) + keyed list
delegate, delegateCapture, // events
toElement, // direct JSX → DOM Element (or DocumentFragment for multi-root)
SafeHtml, isSafeHtml, raw, Fragment,
} from 'kerfjs';
// Optional, only when you need granular collection updates:
import { arraySignal } from 'kerfjs/array-signal';
// Development diagnostics — gate with YOUR build's dev flag, in YOUR code.
if (import.meta.env.DEV) await import('kerfjs/dev');
| Export | Use |
|---|---|
signal(initial) |
atomic reactive state; .value get/set |
computed(fn) |
derived value, read-only |
effect(fn) |
side effect on signal change; returns disposer |
batch(fn) |
coalesce multiple writes into one re-run |
defineStore({initial, actions}) |
named multi-consumer state |
resetAllStores() |
reset every store (test teardown) |
mount(el, render) |
bind reactive render to a DOM element; returns disposer |
morph(liveRoot, template) |
one-shot reconcile against a populated element (SSR hydration, page-refresh diffs). Template = Element, SafeHtml, or HTML string |
each(items, render, cacheKey?) |
keyed list iteration; per-row memoization on identity (+ optional cacheKey — a passive comparator for external state). Distinct from data-key on the rendered element |
each(items, render, { cacheKey, key }) |
same, options form. key gives the list a stable identity — required whenever a conditional list can render before this one, else kerf rebuilds this list and its rows lose focus/scroll/IME. A keyed list takes no positional slot, so keying the conditional list usually fixes its siblings too |
delegate(root, type, sel, h) |
one listener at the root; closest(selector) walk from target |
delegateCapture(root, type, sel, h, opts?) |
capture-phase escape hatch; closest() walk-up by default (same as delegate); pass { match: 'direct' } for strict target.matches() |
attr(name, value) |
pre-computed AttrSpec<N,V> — .selector for delegate(), .attrs to spread into JSX (rename-safe) |
attr(name) |
dynamic factory — attr<N,V=string>(name) returns (value: V) => { readonly [name]: V }; both generics off → N inferred, V defaults to string; specify both to constrain values |
toElement(jsx) |
parse JSX into a DOM node (SVG-aware). Single-root → Element; multi-root (<><svg/> label</>, two icons side by side) → DocumentFragment that appendChild/replaceChildren/ |
Install kerf-app in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the kerf-app skill do?
Build UIs in the kerf reactive framework (https://github.com/brianwestphal/kerf). Use this skill whenever the user is writing or modifying code that imports `kerfjs`, asks to add a feature to a kerf app, or asks "how do I do X in kerf?". Use it proactively the moment you spot a kerf import in the file you're editing.
How do I install the kerf-app skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the kerf-app skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
by Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
by Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
by Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
by Anthropic