developing-preact
My collection of Claude skills
npx skills add https://github.com/oaustegard/claude-skills --skill developing-preactSKILL.md
Preact Developer
Overview
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.
Core Philosophy
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 CDN 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.
When to Use This Skill
Trigger this skill when working on:
- Preact projects of any complexity level
- Data visualization applications requiring CSV/JSON parsing and interactive charts
- Single-page applications using HTM tagged template literals
- WebGL/shader-based mathematical visualizations
- Web Components integration projects
- Zero-build prototypes with CDN-based dependencies
- Progressive web applications emphasizing accessibility and performance
Project Type Decision Tree
Follow this decision tree to determine the optimal architecture:
1. Standalone Prototype or Demo
Characteristics: Quick prototype, demo, educational example, or proof of concept
Architecture:
- HTM syntax with import maps
- CDN-based dependencies (esm.sh)
- Tailwind CSS via CDN
- Single HTML file or minimal file structure
- No build process
Start with: Use assets/boilerplate.html as the foundation
2. Small-to-Medium Application (No Build Tooling)
Characteristics: Production application without existing build infrastructure, <10 components, straightforward state management
Architecture:
- HTM syntax with import maps
- ES modules for code organization
- Signals for reactive state management
- Native routing (hash-based or History API)
- Static hosting (Netlify, Vercel, GitHub Pages)
State Management: Use global signals for shared state, useSignal for component-local state
3. Complex Application (Build Tooling Required)
Characteristics: Large codebase, TypeScript requirement, multiple entry points, advanced optimizations needed
Architecture:
- JSX with build tooling (Vite, Webpack)
- TypeScript for type safety
- Consider preact/compat for React ecosystem libraries
- Advanced code splitting and lazy loading
- Professional CI/CD pipeline
When to Recommend: Only after confirming team's development environment and build requirements
4. Existing Project
Approach: Match existing patterns and tooling. Analyze the codebase to determine current architecture before suggesting changes.
Technical Standards
Import Map Configuration
Always use this exact import map structure for standalone examples:
<script type="importmap">
{
"imports": {
"preact": "https://esm.sh/*preact@10.23.1",
"preact/": "https://esm.sh/*preact@10.23.1/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.3.0",
"htm/preact": "https://esm.sh/*htm@3.1.1/preact"
}
}
</script>
Critical: Always use the * prefix in esm.sh URLs to mark all dependencies as external, preventing duplicate Preact instances.
Syntax Preference
Default to HTM tagged template literals unless:
- User explicitly requests JSX
- Project already uses JSX tooling
- TypeScript strict mode requires JSX
JSX to HTM Translation Reference
When mentally converting from React/JSX patterns to HTM, apply these rules:
Mental Model
HTM uses JavaScript template literals. Everything that was {expression} in JSX becomes ${expression}. Component names are also expressions, hence <${Component}>.
Translation Rules
| 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\ |
Key Differences
-
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\``/
...