Stitch HTML → shadcn/ui Converter
Prerequisites
- •Query shadcn MCP before implementing ANY component
- •Project has shadcn/ui installed (
@/components/ui) - •
cn()utility exists (@/lib/utils)
Mode Selection
| Mode | Trigger | Workflow |
|---|---|---|
| Single | 1 HTML file | Phases 0→1→2→3→4 sequentially |
| Batch | Multiple files | Phase 0-1 on ALL files first, dedupe, then 2→3→4 |
Single File Workflow
Phase 0: Extract Theme
- •Find
<script id="tailwind-config">→ extract colors - •Map to CSS variables in
globals.css - •List
material-symbols-outlinedicons → map to Lucide (see component-mapping.md)
Phase 1: Audit
- •Scan HTML for repeating patterns
- •Classify using atomic-design.md
- •Output inventory table:
code
| Pattern | Count | Classification | shadcn Mapping | |---------|-------|----------------|----------------|
Phase 2: Build Atoms
- •Query shadcn MCP first
- •Use CVA for variants (see cva-patterns.md)
- •Forward
classNameviacn() - •
React.forwardReffor DOM access - •
"use client"only if interactive
Phase 3: Build Molecules
- •Compose atoms from
@/components/ui - •Generic props, no hardcoded data
- •Compound pattern for multi-part components
Phase 4: Build Organisms
- •Compose molecules/atoms
- •Generic interfaces with
<T> - •Internal UI state only (no data fetching)
- •Support loading/error/empty states
Batch Workflow
CRITICAL: Scan ALL files before creating ANY component.
Phase A: Global Audit
- •List all HTML files
- •Scan each → extract patterns + variants + theme
- •Build master inventory with deduplication:
code
| Component | Variants | Files | Action | |-----------|----------|-------|--------| | Button | default,ghost,outline | file1,file2,file3 | CREATE |
Phase B: Theme Consolidation
Merge all tailwind configs → single globals.css
Phase C: Deduplicated Creation
Before each component:
- •Check inventory → already marked CREATE?
- •Check filesystem → file exists?
- •If exists with same variants → SKIP
- •If exists with new variants → EXTEND
- •If doesn't exist → CREATE
Deduplication Rules
| Scenario | Action |
|---|---|
| Doesn't exist | CREATE |
| Exists, same variants | SKIP |
| Exists, new variants | EXTEND existing |
| Similar, different purpose | CREATE with new name |
Output Structure
code
src/components/ ├── ui/ # Atoms ├── [molecules] # Composed atoms ├── [organisms] # Major sections └── layouts/ # Page structures
References
- •cva-patterns.md - CVA variant patterns
- •component-mapping.md - HTML→shadcn mapping, icon conversion
- •atomic-design.md - Classification rules