--- name: developing-preact description: Specialized Preact development skill for standards-based web applications with native-first architecture and minimal dependency footprint. Use when building Preact projects, particularly those involving data visualization, interactive applications, single-page apps with HTM syntax, Web Components integration, CSV/JSON data parsing, WebGL shader visualizations, or zero-build solutions with CDN imports. metadata: version: 1.1.0 --- # 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: ```html ``` **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 | ` // HTM <${Button} onClick=${handleClick}>Save ``` 2. **Nested templates for conditional components**: When conditionally rendering components (not HTML elements), wrap in `html\`\`` ```javascript // JSX {isOpen && } // HTM ${isOpen && html`<${Modal} title="Hello" />`} ``` 3. **No braces for spread**: In HTM, spread uses `...${obj}` directly ```javascript // JSX // HTM <${Input} ...${inputProps} /> ``` 4. **class vs className**: Both work in Preact, but prefer `class` for consistency and smaller output #### Common Mistakes | Mistake | Wrong | Correct | |---------|-------|---------| | Missing `${}` on component | `