| name | pixel-perfect-ui |
| description | Autonomous pixel-perfect UI implementation loop for Next.js/React using Figma MCP and Playwright. Converts Figma designs to production-ready components with iterative visual validation. **AUTO-TRIGGERS** on ANY request to implement Figma designs including: 'implement this Figma', 'build this page/component from Figma', 'create from Figma design', 'implement design', 'build this block', 'create component from design'. Use for: (1) Building pages/components from Figma, (2) Pixel-perfect accuracy, (3) Responsive layouts, (4) Design token conversion. |
Pixel-Perfect UI Implementation
Autonomous workflow for converting Figma designs to production-ready, pixel-perfect React/Next.js implementations with visual validation.
๐ AUTO-TRIGGER CONDITIONS
This skill MUST be invoked automatically when the user requests ANY of:
- "implement this Figma design"
- "build this page/component from Figma"
- "create from Figma"
- "implement the design"
- "build this block/section"
- "create component matching design"
- Any request involving Figma URL or node ID
- Any request to implement a page, block, or component from a design
Prerequisites
- Figma MCP server connected (for design extraction)
- Playwright MCP server connected (for visual validation)
- Next.js or React project initialized
๐ PHASE 0: MANDATORY CHECKLIST CREATION (ALWAYS FIRST)
CRITICAL: Before ANY implementation, you MUST:
Step 0.1: Analyze Design & Identify Sections
First, get the full page/component from Figma and identify ALL sections:
mcp0_get_design_context --nodeId <page-node-id>
mcp0_get_metadata --nodeId <page-node-id>
List all sections/blocks in the design (e.g., Header, Hero, Features, CTA, Footer).
Step 0.2: Create Implementation Checklist File
Create a markdown checklist file at .windsurf/implementation-checklist.md:
# Implementation Checklist: [Component/Page Name]
**Created**: [Date]
**Figma Source**: [URL or Node ID]
**Target Path**: [e.g., src/app/page.tsx or src/components/MyComponent.tsx]
**Status**: ๐ก Pending Approval
---
## ๐ Sections to Implement
[List each section identified from Figma]
1. **Section Name 1** (node-id: xxx)
2. **Section Name 2** (node-id: xxx)
3. **Section Name 3** (node-id: xxx)
...
---
## ๐ SECTION-BY-SECTION IMPLEMENTATION
> โ ๏ธ **CRITICAL RULE**: For EACH section below:
> 1. First EXTRACT fresh Figma data for that specific section
> 2. Then IMPLEMENT based on that fresh extraction
> 3. Mark section complete
> 4. Move to next section
>
> **NEVER rely on old/cached Figma data. Always re-extract before implementing!**
---
### Section 1: [Section Name]
**Node ID**: [figma-node-id]
**Status**: โฌ Not Started
#### 1.1 Extract from Figma
- [ ] mcp0_get_design_context for this section
- [ ] mcp0_get_screenshot for visual reference
- [ ] Export any images/assets needed
- [ ] Note typography, colors, spacing
#### 1.2 Implement
- [ ] Create/update component structure
- [ ] Implement desktop layout (1440px)
- [ ] Implement tablet layout (768px)
- [ ] Implement mobile layout (375px)
- [ ] Add images with Next.js Image
- [ ] Apply styles (typography, colors, spacing)
#### 1.3 Validate
- [ ] Visual check matches Figma
- [ ] Responsive on all viewports
- [ ] No horizontal scroll
โ
**Section 1 Complete**: [ ]
---
### Section 2: [Section Name]
**Node ID**: [figma-node-id]
**Status**: โฌ Not Started
#### 2.1 Extract from Figma
- [ ] mcp0_get_design_context for this section
[ ] mcp0screenshot for visual reference
[ ] Export any images/assets needed
[ ] Note typography, colors, spacing
[ ] Create/update component structure
[ ] Implement desktop layout (1440px)
[ ] Implement tablet layout (768px)
[ ] Implement mobile layout (375px)
[ ] Add images with Next.js Image
[ ] Apply styles (typography, colors, spacing)
[ ] Visual check matches Figma
[ ] Responsive on all viewports
[ ] No horizontal scroll
โ
: [ ]
---
[Repeat for each section...]
---
[ ] All sections implemented
[ ] Full page visual comparison
[ ] Resource validation passed (no broken links/images)
[ ] Production checklist complete
---
[Add any specific notes here]
---
: [Date when finished]
: [Pending/Complete]
Step 0.3: Present Plan to User
After creating the checklist, ALWAYS:
- Display the plan to the user in chat (show all identified sections)
- Ask for confirmation: "I've created the implementation checklist at
.windsurf/implementation-checklist.md with X sections. Should I proceed?"
- WAIT for user approval before proceeding
Step 0.4: Execute Section-by-Section
FOR EACH SECTION (in order):
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SECTION WORKFLOW (repeat for each section) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ 1. ๐ฅ EXTRACT: Get fresh Figma data for section โ
โ - mcp0_get_design_context --nodeId <section-id> โ
โ - mcp0_get_screenshot --nodeId <section-id> โ
โ - Export images if needed โ
โ โ
โ 2. ๐จ IMPLEMENT: Build based on fresh extraction โ
โ - Use the data you JUST extracted โ
โ - Do NOT use old/cached data โ
โ - Implement responsive (desktopโtabletโmobile) โ
โ โ
โ 3. โ
VALIDATE: Check section matches Figma โ
โ โ
โ 4. ๐ UPDATE CHECKLIST: Mark items [x] complete โ
โ โ
โ 5. โก๏ธ MOVE TO NEXT SECTION โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
CRITICAL:
- Do NOT batch extract all sections at once
- Do NOT implement from memory or old data
- ALWAYS re-extract Figma data immediately before implementing each section
- Update checklist after completing each section
Step 0.5: Track Progress
As you complete each section:
- Update the checklist file - Change
- [ ] to - [x] for completed items
- Update section status: โฌ Not Started โ ๐ต In Progress โ โ
Complete
- Update overall Status field:
- ๐ก Pending Approval
- ๐ต In Progress - Section X of Y
- ๐ข Complete
- ๐ด Blocked (with reason)
๐จ CRITICAL PRODUCTION RULES
Mobile-First Responsive Design (MANDATORY)
- NEVER use hardcoded pixel widths (e.g.,
w-[1728px], width: 1728px)
- ALWAYS use responsive units:
max-w-7xl, percentages, or viewport units
- ALWAYS test on mobile viewports (375px, 768px, 1024px, 1440px)
- NO horizontal scroll - Use
overflow-x-hidden on body if needed
- Container pattern: Use
max-w-[size] mx-auto px-4 sm:px-6 lg:px-8
Image Requirements (MANDATORY)
- EXPORT all images from Figma - Never use placeholder paths
- CHECK image existence before referencing
- USE Next.js Image component with proper dimensions
- PROVIDE fallbacks for missing images
- OPTIMIZE images - WebP format preferred
Production Checklist (MUST COMPLETE)
Core Workflow
โ ๏ธ REMINDER: Always complete Phase 0 (Checklist Creation) before starting these steps!
1. Design Extraction
Extract comprehensive design data from Figma:
mcp0_get_design_context --nodeId <node-id>
mcp0_get_variable_defs --nodeId <node-id>
mcp0_get_screenshot --nodeId <node-id>
Parse extracted data for:
- Typography (font-family, size, weight, line-height, letter-spacing)
- Colors (hex values, opacity)
- Spacing (padding, margin, gap)
- Layout (flexbox/grid properties, alignment)
- Borders, shadows, radius values
- Asset URLs and SVG exports
2. Project Analysis
Detect project configuration:
- Framework: Next.js App Router vs Pages Router
- Styling: Tailwind, CSS Modules, styled-components
- Component library: shadcn/ui, MUI, Radix
- Design tokens location: tailwind.config, theme.ts
Map Figma tokens to existing project tokens.
3. Implementation
Generate component with extracted values:
STRICT Implementation Rules:
- โ FORBIDDEN: Hardcoded widths like
w-[1728px], width: 1728px
- โ
REQUIRED: Responsive containers
max-w-7xl mx-auto px-4
- โ
REQUIRED: Mobile-first breakpoints
sm:, md:, lg:, xl:
- โ
REQUIRED: Export and validate all images from Figma
- โ
REQUIRED: Flexible layouts using Flexbox/Grid
- โ
REQUIRED: Test on 375px, 768px, 1024px, 1440px viewports
Image Handling:
mcp0_get_screenshot --nodeId <id> --filename "hero-image.png"
<Image src="/assets/hero-image.png" alt="..." width={...} height={...} />
4. Multi-Device Validation Loop
Mandatory: Run validation on ALL viewports:
python scripts/visual-compare.py --viewport 1440x900
python scripts/visual-compare.py --viewport 768x1024
python scripts/visual-compare.py --viewport 375x667
python scripts/responsive-validation.py --url <url>
python scripts/resource-validator.py --directory src/app --strict
Validation Requirements:
- โ
No horizontal scroll on any viewport
- โ
All images loading correctly (verified by resource-validator.py)
- โ
No broken links or missing resources
- โ
No placeholder content (lorem ipsum, temp images)
- โ
Touch targets โฅ 44x44px on mobile
- โ
Text legible without zooming
- โ
Proper stacking on mobile (no overlaps)
- โ
Interactive elements accessible
Common Failures to Fix:
- โ Hardcoded widths causing overflow
- โ Missing or broken images (detected by resource-validator.py)
- โ Broken internal/external links
- โ Placeholder content (lorem ipsum, temp images)
- โ External dependencies not cached locally
- โ Text too small on mobile (<14px)
- โ Elements overlapping on small screens
- โ Fixed positioning breaking on mobile
5. Responsive Implementation
Extract breakpoint variations from Figma:
- Desktop (1440px)
- Tablet (768px)
- Mobile (375px)
Apply responsive rules using project's breakpoint system.
Quick Commands
Full page implementation:
python scripts/extract-and-implement.py --figma-url <url> --output-path <path>
Component extraction:
python scripts/extract-component.py --node-id <id> --component-name <name>
Visual validation:
python scripts/visual-compare.py --implementation-url <url> --figma-node <id>
Resource validation (broken links, missing images):
python scripts/resource-validator.py --file src/app/page.tsx
python scripts/resource-validator.py --directory src/app --strict --report validation-report.txt
File Organization
- Pages: Follow project routing convention
- App Router:
app/[route]/page.tsx
- Pages Router:
pages/[route].tsx
- Components:
components/ui/[component].tsx
- Assets:
public/assets/ or src/assets/
- Styles: Co-located or in
styles/
Token Mapping
See references/token-mapping.md for:
- Figma โ Tailwind mapping
- Figma โ CSS variables mapping
- Shadow and gradient conversion
- Typography scale mapping
Component Patterns
See references/component-patterns.md for:
- Card layouts
- Navigation patterns
- Form components
- Modal implementations
- Grid systems
Validation Thresholds
Acceptable differences:
- Font kerning: ยฑ2px
- Line height: ยฑ1px
- Anti-aliasing variations
Must match exactly:
- Colors (hex values)
- Border radius
- Spacing values
- Component dimensions
- Shadow properties