Skip to content

ketcx/pixel-check

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pixel Check: Pixel-Perfect Validation Skill for Claude Code

Automated pixel-perfect comparison between Figma designs and implementation screenshots. Uses ImageMagick for pixel diffing and Claude Code's multimodal vision for intelligent discrepancy analysis.

Works as both a Skill (auto-detected by Claude) and a Slash Command (/pixel-check) for guided workflows.

What It Does

  1. Exports your Figma design (via Figma MCP or REST API)
  2. Normalizes resolutions between design and screenshot
  3. Generates a pixel diff with ImageMagick
  4. Claude visually analyzes all 3 images (reference, implementation, diff)
  5. Produces a structured report with severity-classified discrepancies

Installation

Global (all projects)

# Clone into Claude Code skills directory
git clone https://github.com/ketcx/pixel-check.git ~/.claude/skills/pixel-check-skill

# Install the slash command
cp ~/.claude/skills/pixel-check-skill/pixel-check-skill/commands/pixel-check.md ~/.claude/commands/pixel-check.md

Project-level

# Clone into your project's .claude directory
git clone https://github.com/ketcx/pixel-check.git .claude/skills/pixel-check-skill

# Install the slash command
cp .claude/skills/pixel-check-skill/pixel-check-skill/commands/pixel-check.md .claude/commands/pixel-check.md

Restart Claude Code after installation. The skill loads automatically.

One-liner (global)

git clone https://github.com/ketcx/pixel-check.git ~/.claude/skills/pixel-check-skill && cp ~/.claude/skills/pixel-check-skill/pixel-check-skill/commands/pixel-check.md ~/.claude/commands/pixel-check.md

Prerequisites

The skill auto-detects missing dependencies and asks permission to install them.

Dependency Required Install
ImageMagick Yes brew install imagemagick
curl Yes brew install curl
Python 3 Yes brew install python3
Knox No go install github.com/pinterest/knox/cmd/knox-client@latest
Node.js (npx) No brew install node
Figma MCP No See Figma Setup

If Figma MCP is not configured, you can provide a local reference image instead.

Usage

Slash Command (recommended)

/pixel-check

Claude will guide you through:

  1. Dependency check (installs missing with your permission)
  2. Provide your implementation screenshot
  3. Provide a Figma URL or local reference image
  4. Automated comparison and analysis
  5. Structured report with actionable recommendations

Natural Language (skill auto-detection)

"Compare this screenshot against the Figma design"
"Check if my implementation matches the mockup"
"Run a pixel-perfect validation on homepage.png vs the Figma link"

Scripts (standalone)

# Check dependencies
bash pixel-check-skill/scripts/check_deps.sh

# Compare two images directly
bash pixel-check-skill/scripts/compare.sh design.png screenshot.png ./output

# Fetch a Figma frame as PNG (token resolved via Knox or env var)
bash pixel-check-skill/scripts/fetch_figma.sh "https://www.figma.com/design/ABC/Name?node-id=42-1337" reference.png 2

# Generate report
python3 pixel-check-skill/scripts/report.py \
    --reference reference.png \
    --implementation screenshot.png \
    --diff diff.png \
    --rmse "1842.17 (0.0281)" \
    --output report.md

Example Output

# Pixel-Perfect Validation Report

**Date:** 2026-03-05 14:30
**Figma:** https://www.figma.com/design/ABC123/MyProject?node-id=42-1337
**Screenshot:** ./screenshots/homepage-chrome.png
**RMSE:** 1842.17 (0.0281)
**Result:** FAIL (1 BLOCKER)

## Summary
Implementation is 97% faithful to design. 1 blocker in hero section
spacing, 3 minor warnings in shadows and font weights.

## Discrepancies

| # | Element      | Severity   | Design | Implementation | Recommendation          |
|---|--------------|------------|--------|----------------|-------------------------|
| 1 | Hero padding | BLOCKER    | 64px   | 48px           | Change py-12 to py-16   |
| 2 | Card shadow  | WARNING    | 0 4 6  | 0 2 4          | Use shadow-md            |
| 3 | Font weight  | WARNING    | 600    | 500            | Use font-semibold        |
| 4 | Border radius| ACCEPTABLE | 12px   | 12px           | Subpixel rendering diff  |

Figma Token Setup

Getting a Personal Access Token

  1. Log in to Figma
  2. Click your profile icon (top-left) and select Settings
  3. Scroll down to Personal access tokens
  4. Click Generate new token
  5. Give it a descriptive name (e.g. pixel-check)
  6. Set the expiration as needed (or no expiration for personal use)
  7. For scopes, grant File content → Read only (minimum required)
  8. Click Generate token
  9. Copy the token immediately — it starts with figd_ and is only shown once

Once you have the token, store it using one of the options below.

Option 1 — Knox (recommended)

Store the token securely with Knox:

echo -n "figd_xxxxx" | knox create pixelcheck:figmatoken

The scripts automatically retrieve it at runtime. No env vars needed.

To rotate the token:

echo -n "figd_new_token" | knox add pixelcheck:figmatoken
knox promote pixelcheck:figmatoken

Option 2 — Environment Variable

export FIGMA_ACCESS_TOKEN="figd_xxxxx"

Token Resolution Order

The fetch_figma.sh script resolves the token in this order:

  1. Knoxknox get pixelcheck:figmatoken
  2. Env varFIGMA_ACCESS_TOKEN

If neither is available, the script exits with instructions.

Figma MCP (optional)

For automatic Figma design export within Claude Code, configure the Figma MCP.

Add to .claude/settings.json or .mcp.json:

{
  "mcpServers": {
    "figma": {
      "command": "npx",
      "args": ["-y", "@anthropic/figma-mcp-server"],
      "env": {
        "FIGMA_ACCESS_TOKEN": "figd_xxxxx"
      }
    }
  }
}

Without Figma MCP, you can still use the skill via fetch_figma.sh with Knox/env token, or provide a local reference image.

Thresholds

Metric PASS WARNING FAIL
RMSE (normalized) < 0.03 0.03 - 0.05 > 0.05
BLOCKERs 0 0 >= 1
WARNINGs 0-2 3-5 > 5

File Structure

pixel-check-skill/
  SKILL.md                      # Skill definition (auto-detected by Claude)
  scripts/
    check_deps.sh               # Dependency checker & installer
    compare.sh                  # ImageMagick normalize + compare
    fetch_figma.sh              # Figma API image export (fallback)
    report.py                   # Markdown report generator
  commands/
    pixel-check.md              # Slash command definition

Known Limitations

  • Font rendering: Browsers render text differently than Figma. Antialiasing diffs are classified as ACCEPTABLE if font and weight are correct.
  • Responsive: Screenshot viewport must match the Figma frame. Mismatched viewports produce misleading diffs.
  • Dynamic content: User photos, avatars, or API-driven content won't match. Use identical mock data.
  • Figma export fidelity: API exports may differ slightly from the Figma editor (especially blur/shadow effects).

License

MIT

About

Pixel-perfect validation skill for Claude Code: compare Figma designs vs implementation screenshots using ImageMagick + AI vision

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors