/development-tools:developing-preactfrom development-tools
Specialized Preact development skill for standards-based web apps with native-first architecture. Covers HTM syntax, Web Components, data visualization, WebGL shaders, zero-build solutions, and accessible widgets via vendored ui-sdk.
Ships in development-tools. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Transform Claude into a specialized Preact developer with expertise in building standards-based web applications using native-first architecture. This skill prioritizes native JavaScript, HTML, and Web APIs over external dependencies, enabling creation of performant, maintainable applications with minimal tooling overhead.
Native-First Development: Leverage ES modules, Import Maps, Web Components, native form validation, Fetch API, and built-in DOM methods before reaching for external libraries. Default to zero-build solutions with HTM and vendored ESM imports for rapid prototyping and small-to-medium applications.
Always Deliver in Artifacts: All code should be created as artifacts to enable iterative editing across sessions.
Trigger this skill when working on:
Follow this decision tree to determine the optimal architecture:
Characteristics: Quick prototype, demo, educational example, or proof of concept
Architecture:
scripts/vendor.sh)Start with: Run bash scripts/vendor.sh to fetch dependencies, then use assets/boilerplate.html as the foundation
Characteristics: Production application without existing build infrastructure, <10 components, straightforward state management
Architecture:
State Management: Use global signals for shared state, useSignal for component-local state
Characteristics: Large codebase, TypeScript requirement, multiple entry points, advanced optimizations needed
Architecture:
When to Recommend: Only after confirming team's development environment and build requirements
Approach: Match existing patterns and tooling. Analyze the codebase to determine current architecture before suggesting changes.
Always use this exact import map structure for standalone examples. Dependencies are vendored locally via scripts/vendor.sh (fetched from registry.npmjs.org):
<script type="importmap">
{
"imports": {
"preact": "./vendor/preact.module.js",
"preact/hooks": "./vendor/hooks.module.js",
"@preact/signals-core": "./vendor/signals-core.mjs",
"@preact/signals": "./vendor/signals.mjs",
"htm": "./vendor/htm.module.js",
"htm/preact": "./vendor/htm.module.js"
}
}
</script>
Critical — modular files, not standalone bundle: Do NOT use htm/preact/standalone.module.js. The standalone bundle embeds its own Preact copy, which causes @preact/signals to get a different Preact instance (it imports from 'preact' as a bare specifier). Modular files + import map = one shared Preact instance for everything.
Why vendored, not CDN: esm.sh is a pass-through to the entire npm registry — allowlisting it opens arbitrary code execution surface. registry.npmjs.org is already on the container egress allowlist and provides scoped, versioned tarballs.
Default to HTM tagged template literals unless:
When mentally converting from React/JSX patterns to HTM, apply these rules:
HTM uses JavaScript template literals. Everything that was {expression} in JSX becomes ${expression}. Component names are also expressions, hence <${Component}>.
| Pattern | JSX | HTM |
|---|---|---|
| Component tag | <Button /> | <${Button} /> |
| Component with children | <Modal>...</Modal> | <${Modal}>...</${Modal}> |
| Closing tag | </Modal> | </${Modal}> |
| Expression | {value} | ${value} |
| Props | prop={val} | prop=${val} |
| Spread props | {...obj} | ...${obj} |
| Event handler | onClick={fn} | onClick=${fn} |
| Conditional | {show && <X />} | ${show && html\<${X} />`}` |
| Ternary | {a ? <X /> : <Y />} | ${a ? html\<${X} />` : html`<${Y} />`}` |
| Map | {items.map(i => <Li />)} | ${items.map(i => html\ |
Component references need ${}: The component name is a JavaScript expression
// JSX
<Button onClick={handleClick}>Save</Button>
// HTM
<${Button} onClick=${handleClick}>Save</${Button}>
Nested templates for conditional components: When conditionally rendering components (not HTML elements), wrap in html\``
// JSX
{isOpen && <Modal title="Hello" />}
// HTM
${isOpen && html`<${Modal} title="Hello" />`}
No braces for spread: In HTM, spread uses ...${obj} directly
// JSX
<Input {...inputProps} />
// HTM
<${Input} ...${inputProps} />
class vs className: Both work in Preact, but prefer class for consistency and smaller output
| Mistake | Wrong | Correct |
|---|---|---|
Missing ${} on component | <Button> | <${Button}> |
| Wrong closing syntax | </MyComponent> | </${MyComponent}> |
| Braces instead of template | {count} | ${count} |
| Spread with braces | {...props} | ...${props} |
| Missing html wrapper in conditional | ${show && <${X} />} | ${show && html\<${X} />`}` |
Use function components with:
Default: Tailwind CSS via CLI — install with npm install tailwindcss@3 --save-dev, then generate purged CSS with npx tailwindcss -o vendor/tailwind.css --content "*.html" --minify. This produces ~6KB of CSS containing only used classes.
Avoid: Tailwind CDN (cdn.tailwindcss.com) — not on container egress allowlist, and loads the full 100KB+ JIT compiler.
Avoid: Inline styles except for dynamic values impossible to express through utilities.
Alternative: CSS modules or styled-components only when project requires scoped styling.
For any widget with a WAI-ARIA pattern (dialog, popover, menu, menubar, select, combobox, autocomplete, listbox, tabs, tooltip, toast, drawer, date picker, slider, tree, toolbar and the rest of 55 components), use ui-sdk instead of writing focus traps, arrow-key handling and ARIA by hand.
./scripts/vendor.sh ./vendor --ui-sdk (adds preact/compat and
vendor/ui-sdk/; prints the import map).references/ui-sdk.md: one entry per component with
what it is for, its module (ui-sdk/<name>.js) and its parts../scripts/ui_sdk_docs.sh <name> --section Composition. Docs are React TSX;
the same parts and props work in HTM.[data-open], [data-highlighted],
[data-selected]) and start the page CSS with @layer ui-sdk;.Requires Preact 11 (vendor.sh pins 11.2.0). To see a component in action
before using it: https://austegard.com/ai-tools/ui-sdk-preact/#.
Before recommending any external package, verify:
Document the specific performance or capability benefits that justify any dependency inclusion.
For complex decisions involving:
Evaluate trade-offs explicitly before committing to an approach. Document reasoning in code comments.
Ensure core functionality works without JavaScript where feasible:
Clarify:
Refer to the Project Type Decision Tree above to select the appropriate architecture.
Start with:
assets/boilerplate.html)Consult bundled references as needed:
references/preact-v10-guide.md - Comprehensive Preact API reference (written for v10; vendor.sh now ships 11, where function components receive ref as a prop)references/ui-sdk.md - Accessible component catalog and HTM usagereferences/architecture-patterns.md - Advanced patterns and best practicesLeverage assets/component-patterns.md for common UI patterns:
For data-heavy applications:
import { useSignal } from '@preact/signals';
function parseCSV(text) {
const lines = text.trim().split('\n');
const headers = lines[0].split(',').map(h => h.trim());
return lines.slice(1).map(line => {
const values = line.split(',').map(v => v.trim());
return Object.fromEntries(headers.map((h, i) => [h, values[i]]));
});
}
function DataAnalyzer() {
const data = useSignal([]);
const handleFile = async (e) => {
const text = await e.target.files[0].text();
data.value = parseCSV(text);
};
return html`
<input type="file" accept=".csv" onChange=${handleFile} />
<div>Loaded ${data.value.length} rows</div>
`;
}
For shader-based visualizations:
import { useEffect, useRef } from 'preact/hooks';
function ShaderCanvas({ fragmentShader }) {
const canvasRef = useRef(null);
useEffect(() => {
const canvas = canvasRef.current;
const gl = canvas.getContext('webgl2');
// Setup WebGL context, shaders, buffers
// Render loop
return () => {
// Cleanup
};
}, [fragmentShader]);
return html`<canvas ref=${canvasRef} class="w-full h-full" />`;
}
// state.js
import { signal, computed } from '@preact/signals';
export const users = signal([]);
export const currentUser = signal(null);
export const isAuthenticated = computed(() => currentUser.value !== null);
// Any component can import and use
import { users, isAuthenticated } from './state.js';
DO NOT:
DO:
references/ui-sdk.md: ui-sdk for Preact: setup, writing parts in HTM, state and controllers, styling, and a catalog of all 55 components with their modules and parts
references/preact-v10-guide.md: Complete Preact v10 API reference (the vendored version is now 11.2.0) covering import maps, HTM syntax, React differences, Signals API, Web Components, SSR, performance patterns, Context, error boundaries, and common gotchas
references/architecture-patterns.md: Advanced patterns including zero-build architecture, state management strategies, data fetching, routing, forms, progressive enhancement, accessibility, performance optimization, testing, and security best practices
assets/ui-sdk/: ui-sdk 0.1.0-beta.10 built for Preact 11 as split ES modules (ui-sdk/<name>.js, ui-sdk/core/<name>.js); copied by vendor.sh --ui-sdk
assets/boilerplate.html: Complete HTML template with import maps, Tailwind CSS, and basic Preact app structure - use as starting point for all standalone examples
assets/component-patterns.md: Reusable component implementations for data grids, file uploads, search, modals, tabs, toast notifications, and CSV parsing
<!DOCTYPE html>
<html>
<head>
<!-- Run: bash scripts/vendor.sh -->
<script type="importmap">
{
"imports": {
"preact": "./vendor/preact.module.js",
"preact/hooks": "./vendor/hooks.module.js",
"@preact/signals-core": "./vendor/signals-core.mjs",
"@preact/signals": "./vendor/signals.mjs",
"htm": "./vendor/htm.module.js",
"htm/preact": "./vendor/htm.module.js"
}
}
</script>
</head>
<body>
<div id="app"></div>
<script type="module">
import { render } from 'preact';
import { useSignal } from '@preact/signals';
import { html } from 'htm/preact';
function App() {
const count = useSignal(0);
return html`
<button onClick=${() => count.value++}>
Count: ${count}
</button>
`;
}
render(html`<${App} />`, document.getElementById('app'));
</script>
</body>
</html>
For applications processing CSV data and displaying interactive charts, reference the DataGrid pattern in assets/component-patterns.md and combine with a charting library like Chart.js or use native Canvas/SVG for custom visualizations.
For mathematical visualizations using WebGL shaders, create a canvas element, initialize WebGL2 context, compile shaders, and set up a render loop. Reference MDN WebGL documentation for shader setup patterns.
Before delivering code, verify:
Test Preact apps locally in Claude.ai containers using Playwright. This workflow avoids external CDNs entirely — all dependencies are vendored from registry.npmjs.org.
# 1. Vendor JS dependencies
bash scripts/vendor.sh
# 2. Generate Tailwind CSS (if using Tailwind)
npm install tailwindcss@3 --save-dev
npx tailwindcss -o vendor/tailwind.css --content "*.html" --minify
# 3. Serve locally
python3 -m http.server 8765 &
# 4. Test with Playwright
python3 << 'PYEOF'
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
page = browser.new_page()
errors = []
page.on("console", lambda m: errors.append(m.text) if m.type == "error" else None)
page.on("pageerror", lambda e: errors.append(str(e)))
page.goto("http://localhost:8765", wait_until="networkidle")
# Verify no console errors (catches import failures immediately)
assert not errors, f"Console errors: {errors}"
# Verify app rendered
assert page.locator("#app").inner_html() != "", "App did not render"
# Example: test interaction
# page.click("button")
# assert "Count: 1" in page.content()
browser.close()
print("All tests passed")
PYEOF
python3 -m http.server is sufficient — no npm server neededpage.on("console") and page.on("pageerror") catches import failures immediately--no-sandbox is required in container environmentsFor immediate implementation:
bash scripts/vendor.sh to fetch vendored dependenciesnpm install tailwindcss@3 --save-dev && npx tailwindcss -o vendor/tailwind.css --content "*.html" --minifyassets/boilerplate.html as the starting pointreferences/preact-v10-guide.md for API detailsassets/component-patterns.md for common UI patternsreferences/architecture-patterns.md for advanced scenariosThe skill is designed to enable rapid development of high-quality Preact applications with minimal friction and maximum standards compliance.
CHANGELOG.md (opens in a new tab)README.md (opens in a new tab)assets/boilerplate.html (opens in a new tab)assets/component-patterns.md (opens in a new tab)assets/ui-sdk/LICENSE (opens in a new tab)assets/ui-sdk/accordion.js (opens in a new tab)assets/ui-sdk/agent.js (opens in a new tab)assets/ui-sdk/alert-dialog.js (opens in a new tab)assets/ui-sdk/async-options.js (opens in a new tab)assets/ui-sdk/autocomplete.js (opens in a new tab)assets/ui-sdk/avatar.js (opens in a new tab)assets/ui-sdk/button.js (opens in a new tab)assets/ui-sdk/calendar.js (opens in a new tab)assets/ui-sdk/carousel.js (opens in a new tab)assets/ui-sdk/checkbox.js (opens in a new tab)assets/ui-sdk/chunks/c--tDBCIu6.js (opens in a new tab)assets/ui-sdk/chunks/c-0E4tiip6.js (opens in a new tab)assets/ui-sdk/chunks/c-0tog7R-R.js (opens in a new tab)assets/ui-sdk/chunks/c-0unkTJUm.js (opens in a new tab)assets/ui-sdk/chunks/c-1hcL5O58.js (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
preact, htm, web-components, zero-build, accessible-widgets, data-visualization
10 skills in this plugin
/capturing-browser-logsGets runtime evidence from a web page the agent cannot run itself, using Agent Log (austegard.com/web-utilities/agent-log.html), a script that records console calls, errors, fetch/XHR traffic and the events and DOM changes of elements the user picks, as OpenTelemetry logs in the user's browser. Use when debugging a page, web app, browser game or bookmarklet that misbehaves on the user's device, when the user says "it doesn't work" about a page and you need to see what happened, when you want to add console.log instrumentation and read it back, when you need to see what happens on a specific button, field or element, or when the user hands you an OTLP JSON log export or a file named agent-log-*.json./check-toolsValidates development tool installations across Python, Node.js, Java, Go, Rust, C/C++, Git, and system utilities. Use when verifying environments or troubleshooting dependencies./coding-mojoDevelop and run Mojo code in Claude.ai containers. Handles installation, compilation, and execution. Use when writing Mojo code, benchmarking Mojo vs Python, or when user mentions Mojo, Modular, or MAX. Routes to Modular's official skills (mojo-syntax, mojo-python-interop, mojo-gpu-fundamentals) for language-specific correction layers.npx claudepluginhub oaustegard/claude-skills --plugin development-toolsOther plugins' skills for the same job