Claude Skill

developing-preact

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 synta

LLM Mart · 0 points · 4 views 0 listing impressions 0 install-command copies
Download oaustegard-claude-skills-plugins_development-tools_skills_developing-preact-d154993.zip · 499 KB

Install

skills CLI npx skills add https://github.com/oaustegard/claude-skills/tree/main/plugins/development-tools/skills/developing-preact
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install oaustegard-claude-skills@llmmart
Git git clone https://github.com/oaustegard/claude-skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole oaustegard/claude-skills collection as a plugin from our marketplace. Git is the plain clone.

README

developing-preact

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.

Skill manifest

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 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.

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
  • Interactive widgets with keyboard, focus and ARIA requirements (use ui-sdk, below)

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
  • Vendored ESM dependencies (fetched from npm registry via scripts/vendor.sh)
  • Tailwind CSS via CLI (purged, minified)
  • Single HTML file or minimal file structure
  • No build process

Start with: Run bash scripts/vendor.sh to fetch dependencies, then 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. 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.

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\<$ />`}`
Ternary {a ? <X /> : <Y />} ${a ? html\<\({X} />\` : html\`<\) />`}`
Map {items.map(i => <Li />)} ${items.map(i => html\
  • ...
  • `)}`

    Key Differences

    1. Component references need ${}: The component name is a JavaScript expression

      // JSX
      <Button onClick={handleClick}>Save</Button>
      
      // HTM
      <${Button} onClick=${handleClick}>Save</${Button}>
      
    2. 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" />`}
      
    3. No braces for spread: In HTM, spread uses ...${obj} directly

      // JSX
      <Input {...inputProps} />
      
      // 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 <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\<$ />`}`

    Component Patterns

    Use function components with:

    • Hooks for lifecycle and side effects
    • Signals for reactive state (preferred over useState)
    • Suspense for code splitting and async data
    • Context API for cross-component state and dependency injection
    • Error boundaries for graceful error handling

    Styling Strategy

    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.

    Accessible Components (ui-sdk)

    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.

    1. Vendor it: ./scripts/vendor.sh ./vendor --ui-sdk (adds preact/compat and vendor/ui-sdk/; prints the import map).
    2. Find the component in references/ui-sdk.md: one entry per component with what it is for, its module (ui-sdk/<name>.js) and its parts.
    3. Before first use, read its Composition section: ./scripts/ui_sdk_docs.sh <name> --section Composition. Docs are React TSX; the same parts and props work in HTM.
    4. Style by state attributes ([data-open], [data-highlighted], [data-selected]) and start the page CSS with @layer ui-sdk;.

    Requires Preact 11 (vendor.sh pins 11.2.0).

    Dependency Evaluation Framework

    Before recommending any external package, verify:

    1. Native Web APIs cannot accomplish this - Check MDN documentation
    2. Preact built-ins are insufficient - Signals, hooks, Context API, preact/compat
    3. Bundle size cost is justified - Measure actual benefit gained vs. bytes added

    Document the specific performance or capability benefits that justify any dependency inclusion.

    Architecture Considerations

    For complex decisions involving:

    • Client-side routing (hash-based vs. History API vs. library)
    • SSR requirements
    • State management architecture (signals vs. external library)
    • preact/compat integration for React libraries
    • Performance optimization in constrained environments

    Evaluate trade-offs explicitly before committing to an approach. Document reasoning in code comments.

    Domain Standards

    Progressive Enhancement

    Ensure core functionality works without JavaScript where feasible:

    • Use semantic HTML
    • Leverage native form validation
    • Implement keyboard navigation
    • Add ARIA attributes for accessibility
    • Manage focus states properly

    Code Quality

    • Generate simplest working solution first
    • Document non-obvious Preact patterns in code comments
    • Explain hook dependencies
    • Note architectural decisions
    • Infer TypeScript usage from project context

    Development Workflow

    1. Understand Requirements

    Clarify:

    • Target environment (standalone vs. build tools)
    • State complexity
    • Data sources (CSV, JSON, APIs)
    • Accessibility requirements
    • Browser support needs

    2. Choose Architecture Pattern

    Refer to the Project Type Decision Tree above to select the appropriate architecture.

    3. Implement Iteratively

    Start with:

    • Basic HTML structure (use assets/boilerplate.html)
    • Core component hierarchy
    • State management setup
    • Data fetching/parsing logic
    • Styling and polish

    4. Reference Documentation

    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 usage
    • references/architecture-patterns.md - Advanced patterns and best practices

    5. Use Component Patterns

    Leverage assets/component-patterns.md for common UI patterns:

    • Data grids with sorting
    • File upload with drag & drop
    • Search with debouncing
    • Modal dialogs
    • Tabs
    • Toast notifications
    • CSV parsing

    Common Patterns

    Data Parsing (CSV/JSON)

    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>
      `;
    }
    

    WebGL Integration

    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" />`;
    }
    

    Global State with Signals

    // 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';
    

    Constraints

    DO NOT:

    • Recommend npm tooling without confirming user's development environment
    • Suggest dependencies when native solutions exist
    • Optimize prematurely - start with simplest working implementation

    DO:

    • Use HTM syntax by default
    • Create artifacts for all code
    • Prioritize accessibility and progressive enhancement
    • Document architectural decisions in comments

    Resources

    References (Load as Needed)

    • 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 (Copy into Projects)

    • 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

    Examples

    Minimal Counter (Standalone)

    <!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>
    

    Data Visualization App

    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.

    WebGL Shader Visualization

    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.

    Best Practices Summary

    1. Start Simple: Create working prototype before optimizing
    2. Use Signals: Prefer signals over useState for reactive state
    3. Native First: Check if Web APIs can accomplish the task
    4. Progressive Enhancement: Build with accessibility from the start
    5. Document Decisions: Explain non-obvious patterns in comments
    6. Keys in Lists: Always provide stable keys for mapped elements
    7. Error Boundaries: Wrap async operations in error boundaries
    8. Avoid Inline Functions: Don't create handlers inside map() loops

    Validation Checklist

    Before delivering code, verify:

    • Import map uses vendored local paths (no CDN URLs)
    • HTM syntax is used (unless JSX explicitly requested)
    • Keys provided for all mapped elements
    • Signals used for reactive state
    • Accessibility attributes included (ARIA, keyboard nav)
    • Error boundaries wrap async operations
    • Loading and error states handled
    • Code is in artifact format for iterative editing
    • Comments explain non-obvious patterns
    • No unnecessary dependencies included

    Container Testing

    Test Preact apps locally in Claude.ai containers using Playwright. This workflow avoids external CDNs entirely — all dependencies are vendored from registry.npmjs.org.

    Setup (one-time per session)

    # 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
    

    Serve and Test

    # 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
    

    Key guidance

    • Use Playwright directly for local testing — not webctl (webctl is for external sites through the proxy)
    • python3 -m http.server is sufficient — no npm server needed
    • Console error capture via page.on("console") and page.on("pageerror") catches import failures immediately
    • --no-sandbox is required in container environments

    Getting Started

    For immediate implementation:

    1. Run bash scripts/vendor.sh to fetch vendored dependencies
    2. (Optional) Generate Tailwind CSS: npm install tailwindcss@3 --save-dev && npx tailwindcss -o vendor/tailwind.css --content "*.html" --minify
    3. Copy assets/boilerplate.html as the starting point
    4. Read references/preact-v10-guide.md for API details
    5. Reference assets/component-patterns.md for common UI patterns
    6. Consult references/architecture-patterns.md for advanced scenarios

    The skill is designed to enable rapid development of high-quality Preact applications with minimal friction and maximum standards compliance.

    Files (claude-skills)
    • assets
      • ui-sdk
        • chunks
          • c--tDBCIu6.js 3.2 KB
            Loading…
          • c-0E4tiip6.js 700 B
            Loading…
          • c-0tog7R-R.js 3.6 KB
            Loading…
          • c-0unkTJUm.js 4.7 KB
            Loading…
          • c-1hcL5O58.js 568 B
            Loading…
          • c-45Y2dyqP.js 578 B
            Loading…
          • c-7m35sFk6.js 484 B
            Loading…
          • c-AjuBrzYU.js 7.1 KB
            Loading…
          • c-aLmQYemu.js 6.9 KB
            Loading…
          • c-alvTmPZ6.js 11 KB
            Loading…
          • c-aTlUpEgL.js 5.9 KB
            Loading…
          • c-B-JB21Si.js 6.3 KB
            Loading…
          • c-B2TQP8Cw.js 11.6 KB
            Loading…
          • c-B5VtlymT.js 4.2 KB
            Loading…
          • c-B7EgSgjQ.js 290 B
            Loading…
          • c-BapIV0g2.js 2.2 KB
            Loading…
          • c-BAxPgVuz.js 1.8 KB
            Loading…
          • c-BBlH-0tz.js 26.4 KB
            Loading…
          • c-Bc-6YETj.js 15 KB
            Loading…
          • c-BC0vDL4g.js 5.5 KB
            Loading…
          • c-BcIvvnJr.js 24.3 KB
            Loading…
          • c-BEB0x1Ov.js 16.8 KB
            Loading…
          • c-BFE17mCj.js 1.7 KB
            Loading…
          • c-Bg5ClwFE.js 5.3 KB
            Loading…
          • c-BgDMVDhJ.js 24.2 KB
            Loading…
          • c-BgWYSDoF.js 1 KB
            Loading…
          • c-BgZe_wvp.js 1.4 KB
            Loading…
          • c-BHhkHCxd.js 446 B
            Loading…
          • c-BHqpScFd.js 1.8 KB
            Loading…
          • c-BiEHqDrN.js 2.3 KB
            Loading…
          • c-BjRiNpxl.js 201 B
            Loading…
          • c-BJT2b85T.js 1.7 KB
            Loading…
          • c-BkFG5kSg.js 4.3 KB
            Loading…
          • c-BMN1HtwE.js 8.1 KB
            Loading…
          • c-BnTz05JX.js 1.1 KB
            Loading…
          • c-BoGIsTzV.js 8.2 KB
            Loading…
          • c-BOPJ9oAM.js 1.5 KB
            Loading…
          • c-BOXqiKGJ.js 4.6 KB
            Loading…
          • c-BQ8vqKQj.js 7.1 KB
            Loading…
          • c-BQl1vHk4.js 234 B
            Loading…
          • c-BSdzyjnj.js 3.6 KB
            Loading…
          • c-bsj4KFbT.js 2.1 KB
            Loading…
          • c-Bt5Y6egq.js 247 B
            Loading…
          • c-BUwqJvJz.js 1.3 KB
            Loading…
          • c-BX4VPcPn.js 16.2 KB
            Loading…
          • c-BXI1e3Zd.js 15.1 KB
            Loading…
          • c-BXLlKsUP.js 9.2 KB
            Loading…
          • c-Byw_SlD4.js 16.7 KB
            Loading…
          • c-BzO7EDCo.js 9 KB
            Loading…
          • c-BzPTicAa.js 6.9 KB
            Loading…
          • c-C-dK3mHR.js 2.9 KB
            Loading…
          • c-C-Fihs3V.js 167 B
            Loading…
          • c-C1OpjnQw.js 2.5 KB
            Loading…
          • c-C2EKWMLk.js 346 B
            Loading…
          • c-C2ZQkJJM.js 2.4 KB
            Loading…
          • c-C6QipkL_.js 495 B
            Loading…
          • c-C7IYqn3r.js 2.2 KB
            Loading…
          • c-C7JmDObD.js 1.8 KB
            Loading…
          • c-C8w7s5dg.js 668 B
            Loading…
          • c-c9TWY2CF.js 2.1 KB
            Loading…
          • c-C9yODhCQ.js 4.4 KB
            Loading…
          • c-CA4qWTIr.js 808 B
            Loading…
          • c-CaMANmJF.js 3.7 KB
            Loading…
          • c-CcAjnsSy.js 10 KB
            Loading…
          • c-CDc_lW9e.js 591 B
            Loading…
          • c-CDi25heR.js 1.8 KB
            Loading…
          • c-CI22PBAQ.js 636 B
            Loading…
          • c-CK21EtFi.js 436 B
            Loading…
          • c-CkjEfJo3.js 6.4 KB
            Loading…
          • c-CL0NXiFT.js 2.4 KB
            Loading…
          • c-CL2fSyVz.js 897 B
            Loading…
          • c-CL5vKUrt.js 2.2 KB
            Loading…
          • c-ClEnXY1u.js 4.4 KB
            Loading…
          • c-CMg-8UVf.js 65 B
            Loading…
          • c-CmYQR5xg.js 7.9 KB
            Loading…
          • c-CNQpea5E.js 981 B
            Loading…
          • c-CNVlxYE2.js 10.9 KB
            Loading…
          • c-CSK0OQ4h.js 8 KB
            Loading…
          • c-Ctin2U6F.js 3 KB
            Loading…
          • c-Cuep_3Vf.js 834 B
            Loading…
          • c-CumuZ7fc.js 1022 B
            Loading…
          • c-CvcjRQM6.js 268 B
            Loading…
          • c-Cw8lgoH4.js 6 KB
            Loading…
          • c-CwBTG9rX.js 21.4 KB
            Loading…
          • c-CwLHqfPu.js 79 B
            Loading…
          • c-CXajhlTI.js 838 B
            Loading…
          • c-CXnIP6Ch.js 1.5 KB
            Loading…
          • c-CX_2XdB3.js 255 B
            Loading…
          • c-CYbt0Exq.js 1.5 KB
            Loading…
          • c-Czttboj5.js 862 B
            Loading…
          • c-CzUCNSuY.js 1.4 KB
            Loading…
          • c-C_iUIC86.js 2.2 KB
            Loading…
          • c-D-AdvnAW.js 1.9 KB
            Loading…
          • c-D1-s5xKa.js 3 KB
            Loading…
          • c-D5LiaI5R.js 114 B
            Loading…
          • c-Db7ialQL.js 1.3 KB
            Loading…
          • c-DcHAkk9a.js 363 B
            Loading…
          • c-DCqSW8A0.js 18.4 KB
            Loading…
          • c-DdaCLml8.js 180 B
            Loading…
          • c-DDoGbV8M.js 3 KB
            Loading…
          • c-Dea3rxEU.js 17.6 KB
            Loading…
          • c-Delw3ZDT.js 2.9 KB
            Loading…
          • c-DFr1-mrR.js 1.1 KB
            Loading…
          • c-DI1qjWT_.js 2 KB
            Loading…
          • c-Dk4fY8xy.js 1020 B
            Loading…
          • c-DkujFO96.js 76 B
            Loading…
          • c-DletSCC2.js 3.5 KB
            Loading…
          • c-DlqKAdME.js 78.6 KB
            Loading…
          • c-DM978_Uc.js 1.9 KB
            Loading…
          • c-dmbU3S2d.js 4 KB
            Loading…
          • c-DMWX5h-d.js 11.1 KB
            Loading…
          • c-DMXPVO-f.js 11 KB
            Loading…
          • c-DmYAkvBK.js 49 B
            Loading…
          • c-DNa_866N.js 690 B
            Loading…
          • c-DnFXe_lF.js 595 B
            Loading…
          • c-DNFY-UFR.js 19.8 KB
            Loading…
          • c-Dr2iCcRB.js 2.6 KB
            Loading…
          • c-DSUI3yI-.js 825 B
            Loading…
          • c-DUpbyLuH.js 2.9 KB
            Loading…
          • c-DVrGC9E1.js 15.7 KB
            Loading…
          • c-Dw6YFPjr.js 16.1 KB
            Loading…
          • c-DWMT8O1I.js 1.8 KB
            Loading…
          • c-DXCY5p6Z.js 2.9 KB
            Loading…
          • c-DXIAZAk3.js 10.3 KB
            Loading…
          • c-DyjhnVno.js 11.5 KB
            Loading…
          • c-DysTtEsD.js 411 B
            Loading…
          • c-DZjtS89G.js 23.2 KB
            Loading…
          • c-DzOY6BCW.js 1.8 KB
            Loading…
          • c-D_L050wm.js 2.4 KB
            Loading…
          • c-EoTu-JER.js 2.7 KB
            Loading…
          • c-g5oRiFrr.js 190 B
            Loading…
          • c-G6JuKWF7.js 4.1 KB
            Loading…
          • c-GiMJrcx4.js 74 B
            Loading…
          • c-h1dA16jg.js 1 KB
            Loading…
          • c-hi8poQPM.js 3.9 KB
            Loading…
          • c-hM_2W2p2.js 647 B
            Loading…
          • c-Hy3Y8EX_.js 1 KB
            Loading…
          • c-HYrXqSvf.js 11 KB
            Loading…
          • c-k9cLhxp_.js 223 B
            Loading…
          • c-KvctVd-q.js 562 B
            Loading…
          • c-nPICchmp.js 17.9 KB
            Loading…
          • c-nqvPsD_Y.js 264 B
            Loading…
          • c-O7fewNG5.js 1.6 KB
            Loading…
          • c-P47T_Ukc.js 1.7 KB
            Loading…
          • c-pf7Npfet.js 2.1 KB
            Loading…
          • c-RcGJlK7w.js 18.6 KB
            Loading…
          • c-rdavM_ag.js 1.1 KB
            Loading…
          • c-tEhA_RGP.js 2.1 KB
            Loading…
          • c-UjPvmfYz.js 4.7 KB
            Loading…
          • c-V06-jRAj.js 11 KB
            Loading…
          • c-Vh1InUII.js 3.8 KB
            Loading…
          • c-WA23E3CP.js 1.3 KB
            Loading…
          • c-Xr1Q1qD1.js 1.9 KB
            Loading…
          • c-zjseW3c0.js 2.4 KB
            Loading…
          • c-Zk4vsQhP.js 258 B
            Loading…
          • c-zO8ZZaDL.js 1.4 KB
            Loading…
          • c-_DulnfUa.js 1.8 KB
            Loading…
          • c-__wPtCv-.js 498 B
            Loading…
        • core
          • accordion.js 6.9 KB
            Loading…
          • agent.js 26.1 KB
            Loading…
          • alert-dialog.js 155 B
            Loading…
          • async-options.js 1.2 KB
            Loading…
          • autocomplete.js 106 B
            Loading…
          • avatar.js 64 B
            Loading…
          • button.js 1.7 KB
            Loading…
          • calendar.js 1.3 KB
            Loading…
          • carousel.js 98 B
            Loading…
          • checkbox.js 171 B
            Loading…
          • collapsible.js 3.1 KB
            Loading…
          • color-picker.js 104 B
            Loading…
          • color.js 264 B
            Loading…
          • combobox.js 1.3 KB
            Loading…
          • command.js 96 B
            Loading…
          • date-input.js 349 B
            Loading…
          • date-picker.js 102 B
            Loading…
          • date.js 748 B
            Loading…
          • dialog.js 697 B
            Loading…
          • drawer.js 161 B
            Loading…
          • field.js 107 B
            Loading…
          • file-input.js 189 B
            Loading…
          • gesture.js 249 B
            Loading…
          • history.js 122 B
            Loading…
          • hover-card.js 1.1 KB
            Loading…
          • image-cropper.js 106 B
            Loading…
          • image.js 67 B
            Loading…
          • index.js 4.2 KB
            Loading…
          • input.js 3.9 KB
            Loading…
          • label.js 2.1 KB
            Loading…
          • listbox.js 96 B
            Loading…
          • menu.js 1.3 KB
            Loading…
          • menubar.js 3.8 KB
            Loading…
          • meter.js 1.1 KB
            Loading…
          • navigation-menu.js 110 B
            Loading…
          • number-input.js 104 B
            Loading…
          • number.js 588 B
            Loading…
          • observe.js 372 B
            Loading…
          • otp-input.js 98 B
            Loading…
          • overlays.js 527 B
            Loading…
          • pagination.js 135 B
            Loading…
          • password-input.js 4.7 KB
            Loading…
          • popover.js 2 KB
            Loading…
          • progress.js 1.5 KB
            Loading…
          • radio.js 1.5 KB
            Loading…
          • rating.js 3.5 KB
            Loading…
          • renderer.js 2.4 KB
            Loading…
          • resizable.js 137 B
            Loading…
          • scroll-area.js 102 B
            Loading…
          • segmented-control.js 1.9 KB
            Loading…
          • select.js 1.2 KB
            Loading…
          • separator.js 551 B
            Loading…
          • shortcuts.js 217 B
            Loading…
          • slider.js 94 B
            Loading…
          • switch.js 632 B
            Loading…
          • tabs.js 8.3 KB
            Loading…
          • testing.js 43.7 KB
            Loading…
          • text-match.js 150 B
            Loading…
          • time-input.js 371 B
            Loading…
          • timeline.js 4.9 KB
            Loading…
          • toast.js 145 B
            Loading…
          • toggle.js 163 B
            Loading…
          • token-input.js 224 B
            Loading…
          • toolbar.js 96 B
            Loading…
          • tooltip.js 4.3 KB
            Loading…
          • tree.js 342 B
            Loading…
          • trigger-menu.js 175 B
            Loading…
          • waterfall.js 138 B
            Loading…
        • accordion.js 393 B
          Loading…
        • agent.js 154 B
          Loading…
        • alert-dialog.js 672 B
          Loading…
        • async-options.js 770 B
          Loading…
        • autocomplete.js 3.1 KB
          Loading…
        • avatar.js 236 B
          Loading…
        • button.js 579 B
          Loading…
        • calendar.js 442 B
          Loading…
        • carousel.js 2 KB
          Loading…
        • checkbox.js 1.3 KB
          Loading…
        • collapsible.js 329 B
          Loading…
        • color-picker.js 1.8 KB
          Loading…
        • color.js 275 B
          Loading…
        • combobox.js 5.2 KB
          Loading…
        • command.js 3.6 KB
          Loading…
        • date-input.js 749 B
          Loading…
        • date-picker.js 4.3 KB
          Loading…
        • date.js 781 B
          Loading…
        • dialog.js 599 B
          Loading…
        • drawer.js 2.2 KB
          Loading…
        • field.js 2.2 KB
          Loading…
        • file-input.js 2.3 KB
          Loading…
        • gesture.js 259 B
          Loading…
        • history.js 134 B
          Loading…
        • hover-card.js 1.2 KB
          Loading…
        • image-cropper.js 585 B
          Loading…
        • image.js 79 B
          Loading…
        • input.js 687 B
          Loading…
        • label.js 146 B
          Loading…
        • LICENSE 11.1 KB · in bundle
        • listbox.js 1.7 KB
          Loading…
        • menu.js 6.3 KB
          Loading…
        • menubar.js 506 B
          Loading…
        • meter.js 450 B
          Loading…
        • navigation-menu.js 2.3 KB
          Loading…
        • number-input.js 2.4 KB
          Loading…
        • number.js 596 B
          Loading…
        • observe.js 167 B
          Loading…
        • otp-input.js 1.2 KB
          Loading…
        • overlays.js 1.4 KB
          Loading…
        • pagination.js 930 B
          Loading…
        • password-input.js 1 KB
          Loading…
        • popover.js 2 KB
          Loading…
        • preferences.js 1.3 KB
          Loading…
        • primitive.js 198 B
          Loading…
        • progress.js 471 B
          Loading…
        • radio.js 1.1 KB
          Loading…
        • rating.js 1.5 KB
          Loading…
        • resizable.js 312 B
          Loading…
        • scroll-area.js 804 B
          Loading…
        • segmented-control.js 1.1 KB
          Loading…
        • select.js 4.6 KB
          Loading…
        • separator.js 156 B
          Loading…
        • shortcuts.js 922 B
          Loading…
        • slider.js 2.1 KB
          Loading…
        • switch.js 594 B
          Loading…
        • tabs.js 399 B
          Loading…
        • text-match.js 190 B
          Loading…
        • textarea.js 613 B
          Loading…
        • time-input.js 724 B
          Loading…
        • timeline.js 491 B
          Loading…
        • toast.js 237 B
          Loading…
        • toggle.js 946 B
          Loading…
        • token-input.js 2 KB
          Loading…
        • toolbar.js 941 B
          Loading…
        • tooltip.js 1.6 KB
          Loading…
        • tree.js 2.4 KB
          Loading…
        • trigger-menu.js 2.3 KB
          Loading…
        • waterfall.js 1.6 KB
          Loading…
      • boilerplate.html 1.9 KB · in bundle
      • component-patterns.md 13.1 KB
        Loading…
    • references
      • architecture-patterns.md 11.7 KB
        Loading…
      • preact-v10-guide.md 8 KB
        Loading…
      • ui-sdk.md 24.1 KB
        Loading…
    • scripts
      • ui_sdk_docs.sh 2 KB
        Loading…
      • vendor.sh 3.9 KB
        Loading…
    • CHANGELOG.md 1.1 KB
      Loading…
    • README.md 426 B
      # developing-preact
      
      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.
      
    • SKILL.md 19.5 KB
      ---
      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 vendored ESM imports. Also use when a Preact page needs accessible widgets (dialog, menu, select, combobox, tabs, tooltip, popover, toast, date picker, slider, tree); the skill vendors ui-sdk's 55 components built for Preact.
      metadata:
        version: 1.3.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 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.
      
      ## 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
      - **Interactive widgets** with keyboard, focus and ARIA requirements (use ui-sdk, below)
      
      ## 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
      - Vendored ESM dependencies (fetched from npm registry via `scripts/vendor.sh`)
      - Tailwind CSS via CLI (purged, minified)
      - Single HTML file or minimal file structure
      - No build process
      
      **Start with**: Run `bash scripts/vendor.sh` to fetch dependencies, then 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. Dependencies are vendored locally via `scripts/vendor.sh` (fetched from `registry.npmjs.org`):
      
      ```html
      <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.
      
      ### 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\`<li>...</li>\`)}` |
      
      #### Key Differences
      
      1. **Component references need `${}`**: The component name is a JavaScript expression
         ```javascript
         // JSX
         <Button onClick={handleClick}>Save</Button>
         
         // HTM
         <${Button} onClick=${handleClick}>Save</${Button}>
         ```
      
      2. **Nested templates for conditional components**: When conditionally rendering components (not HTML elements), wrap in `html\`\``
         ```javascript
         // JSX
         {isOpen && <Modal title="Hello" />}
         
         // HTM
         ${isOpen && html`<${Modal} title="Hello" />`}
         ```
      
      3. **No braces for spread**: In HTM, spread uses `...${obj}` directly
         ```javascript
         // JSX
         <Input {...inputProps} />
         
         // 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 | `<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} />\`}` |
      
      ### Component Patterns
      
      Use function components with:
      - **Hooks** for lifecycle and side effects
      - **Signals** for reactive state (preferred over useState)
      - **Suspense** for code splitting and async data
      - **Context API** for cross-component state and dependency injection
      - **Error boundaries** for graceful error handling
      
      ### Styling Strategy
      
      **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.
      
      ### Accessible Components (ui-sdk)
      
      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.
      
      1. Vendor it: `./scripts/vendor.sh ./vendor --ui-sdk` (adds `preact/compat` and
         `vendor/ui-sdk/`; prints the import map).
      2. Find the component in `references/ui-sdk.md`: one entry per component with
         what it is for, its module (`ui-sdk/<name>.js`) and its parts.
      3. Before first use, read its Composition section:
         `./scripts/ui_sdk_docs.sh <name> --section Composition`. Docs are React TSX;
         the same parts and props work in HTM.
      4. Style by state attributes (`[data-open]`, `[data-highlighted]`,
         `[data-selected]`) and start the page CSS with `@layer ui-sdk;`.
      
      Requires Preact 11 (`vendor.sh` pins 11.2.0).
      
      ## Dependency Evaluation Framework
      
      Before recommending any external package, verify:
      
      1. **Native Web APIs cannot accomplish this** - Check MDN documentation
      2. **Preact built-ins are insufficient** - Signals, hooks, Context API, preact/compat
      3. **Bundle size cost is justified** - Measure actual benefit gained vs. bytes added
      
      Document the specific performance or capability benefits that justify any dependency inclusion.
      
      ## Architecture Considerations
      
      For complex decisions involving:
      - Client-side routing (hash-based vs. History API vs. library)
      - SSR requirements
      - State management architecture (signals vs. external library)
      - preact/compat integration for React libraries
      - Performance optimization in constrained environments
      
      Evaluate trade-offs explicitly before committing to an approach. Document reasoning in code comments.
      
      ## Domain Standards
      
      ### Progressive Enhancement
      
      Ensure core functionality works without JavaScript where feasible:
      - Use semantic HTML
      - Leverage native form validation
      - Implement keyboard navigation
      - Add ARIA attributes for accessibility
      - Manage focus states properly
      
      ### Code Quality
      
      - Generate simplest working solution first
      - Document non-obvious Preact patterns in code comments
      - Explain hook dependencies
      - Note architectural decisions
      - Infer TypeScript usage from project context
      
      ## Development Workflow
      
      ### 1. Understand Requirements
      
      Clarify:
      - Target environment (standalone vs. build tools)
      - State complexity
      - Data sources (CSV, JSON, APIs)
      - Accessibility requirements
      - Browser support needs
      
      ### 2. Choose Architecture Pattern
      
      Refer to the Project Type Decision Tree above to select the appropriate architecture.
      
      ### 3. Implement Iteratively
      
      Start with:
      - Basic HTML structure (use `assets/boilerplate.html`)
      - Core component hierarchy
      - State management setup
      - Data fetching/parsing logic
      - Styling and polish
      
      ### 4. Reference Documentation
      
      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 usage
      - `references/architecture-patterns.md` - Advanced patterns and best practices
      
      ### 5. Use Component Patterns
      
      Leverage `assets/component-patterns.md` for common UI patterns:
      - Data grids with sorting
      - File upload with drag & drop
      - Search with debouncing
      - Modal dialogs
      - Tabs
      - Toast notifications
      - CSV parsing
      
      ## Common Patterns
      
      ### Data Parsing (CSV/JSON)
      
      For data-heavy applications:
      
      ```javascript
      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>
        `;
      }
      ```
      
      ### WebGL Integration
      
      For shader-based visualizations:
      
      ```javascript
      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" />`;
      }
      ```
      
      ### Global State with Signals
      
      ```javascript
      // 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';
      ```
      
      ## Constraints
      
      **DO NOT**:
      - Recommend npm tooling without confirming user's development environment
      - Suggest dependencies when native solutions exist
      - Optimize prematurely - start with simplest working implementation
      
      **DO**:
      - Use HTM syntax by default
      - Create artifacts for all code
      - Prioritize accessibility and progressive enhancement
      - Document architectural decisions in comments
      
      ## Resources
      
      ### References (Load as Needed)
      
      - **`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 (Copy into Projects)
      
      - **`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
      
      ## Examples
      
      ### Minimal Counter (Standalone)
      
      ```html
      <!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>
      ```
      
      ### Data Visualization App
      
      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.
      
      ### WebGL Shader Visualization
      
      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.
      
      ## Best Practices Summary
      
      1. **Start Simple**: Create working prototype before optimizing
      2. **Use Signals**: Prefer signals over useState for reactive state
      3. **Native First**: Check if Web APIs can accomplish the task
      4. **Progressive Enhancement**: Build with accessibility from the start
      5. **Document Decisions**: Explain non-obvious patterns in comments
      6. **Keys in Lists**: Always provide stable keys for mapped elements
      7. **Error Boundaries**: Wrap async operations in error boundaries
      8. **Avoid Inline Functions**: Don't create handlers inside map() loops
      
      ## Validation Checklist
      
      Before delivering code, verify:
      
      - [ ] Import map uses vendored local paths (no CDN URLs)
      - [ ] HTM syntax is used (unless JSX explicitly requested)
      - [ ] Keys provided for all mapped elements
      - [ ] Signals used for reactive state
      - [ ] Accessibility attributes included (ARIA, keyboard nav)
      - [ ] Error boundaries wrap async operations
      - [ ] Loading and error states handled
      - [ ] Code is in artifact format for iterative editing
      - [ ] Comments explain non-obvious patterns
      - [ ] No unnecessary dependencies included
      
      ## Container Testing
      
      Test Preact apps locally in Claude.ai containers using Playwright. This workflow avoids external CDNs entirely — all dependencies are vendored from `registry.npmjs.org`.
      
      ### Setup (one-time per session)
      
      ```bash
      # 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
      ```
      
      ### Serve and Test
      
      ```bash
      # 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
      ```
      
      ### Key guidance
      
      - **Use Playwright directly** for local testing — not webctl (webctl is for external sites through the proxy)
      - **`python3 -m http.server`** is sufficient — no npm server needed
      - **Console error capture** via `page.on("console")` and `page.on("pageerror")` catches import failures immediately
      - **`--no-sandbox`** is required in container environments
      
      ## Getting Started
      
      For immediate implementation:
      
      1. Run `bash scripts/vendor.sh` to fetch vendored dependencies
      2. (Optional) Generate Tailwind CSS: `npm install tailwindcss@3 --save-dev && npx tailwindcss -o vendor/tailwind.css --content "*.html" --minify`
      3. Copy `assets/boilerplate.html` as the starting point
      4. Read `references/preact-v10-guide.md` for API details
      5. Reference `assets/component-patterns.md` for common UI patterns
      6. Consult `references/architecture-patterns.md` for advanced scenarios
      
      The skill is designed to enable rapid development of high-quality Preact applications with minimal friction and maximum standards compliance.
      

    Comments (0)

    Sign in to join the conversation.

    No comments yet.

    Reviews (0)

    No reviews yet.