/playwright:pixel-perfectfrom playwright
Orchestrates a visual QA loop combining screenshot comparison and CSS property extraction to make a page or Storybook component match a baseline URL pixel-for-pixel.
Ships in playwright. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Drive a page or component to pixel-perfect fidelity with a baseline by orchestrating visual-diff (screenshot comparison) and computed-styles (CSS property extraction) in a converging loop.
visual-diff and computed-styles skills are metAll fixes must use the Bitovi design token system defined in src/styles/bitovi-theme.css. Prefer token-based Tailwind classes over arbitrary values. Only use [arbitrary] syntax when no matching token exists in the theme.
┌─────────────────────────────────────┐
│ For each breakpoint: │
│ desktop → tablet → mobile │
│ │
│ 1. VISUAL DIFF │
│ Screenshot both pages │
│ Run pixel diff │
│ Identify problem regions │
│ diffPercent < 2%? ──── YES ──── next breakpoint (or DONE if all 3 pass)
│ │ │
│ NO │
│ ▼ │
│ 2. COMPUTED STYLES │
│ Extract CSS from both pages │
│ Build property diff table │
│ Fix mismatches with Tailwind │
│ Verify fixes took effect │
│ │ │
│ ▼ │
│ 3. RE-DIFF │
│ Re-screenshot current page │
│ Run pixel diff again │
│ diffPercent < 2%? ──── YES ──── next breakpoint
│ │ │
│ NO │
│ ▼ │
│ Go to step 2 with new regions │
└─────────────────────────────────────┘
Load the visual-diff skill and run the full workflow:
node scripts/visual-diff.mjs to produce the diff image and JSON statsdiffPercent and identify which regions (top, middle, bottom) have red clustersIf diffPercent < 2%, the pages are effectively matching. Report success and stop.
If diffPercent >= 2%, proceed to Step 2.
Map red clusters to specific DOM regions:
| Red cluster location | Likely DOM region | Example |
|---|---|---|
| Top band | Navigation bar | Height, padding, logo, nav items |
| Below nav | Hero section | Font sizes, spacing, background |
| Middle grid | Card layout | Card sizing, gaps, typography |
| Bottom | Footer | Link colors, spacing, background |
| Full-width bands | Container width | Max-width, padding differences |
| Scattered dots only | Font rendering | Usually acceptable, not actionable |
Load the computed-styles skill. Based on the regions identified in Step 1:
mcp_playwright_browser_evaluate on the baseline URLmcp_playwright_browser_evaluate on the current URL (remember the Storybook iframe pattern if applicable)src/styles/bitovi-theme.css first (see the Design System section above). Only use [arbitrary] values when no token matches.Fix differences in this order (highest visual impact first):
After fixing a batch of computed style differences:
Evaluate progress:
| New diffPercent | Action |
|---|---|
| < 2% | Done. Report final stats. |
| Decreased significantly | Good progress. If > 2%, identify remaining red regions and loop back to Step 2. |
| Unchanged or increased | Something went wrong. Check that fixes actually applied (Tailwind theme overrides, specificity conflicts). Use computed-styles to verify. |
Continue the loop (Steps 2-3) until diffPercent < 2% or the remaining differences are confirmed to be not worth further pursuit.
When stopping for one of these reasons, clearly state:
For complex pages with many regions to fix, use subagents to parallelize investigation:
Use the Explore agent to research element structures before extracting styles:
"Explore the DOM structure of [baseline URL]. Find all elements in the
[region] section. Report element tags, class names, and nesting structure.
Thoroughness: medium."
When extracting styles, do both pages in sequence (not parallel, since Playwright MCP shares one browser):
Always run the pixel-perfect loop at all three breakpoints:
| Breakpoint | Width | Height | Order |
|---|---|---|---|
| Desktop | 1280 | 720 | 1st — fix base layout here first |
| Tablet | 768 | 1024 | 2nd — fix responsive breakpoint issues |
| Mobile | 375 | 667 | 3rd — fix mobile-specific issues |
Workflow:
diffPercent < 2%Fix desktop first so you're not chasing responsive issues against a broken base layout. Each breakpoint has its own screenshot files (e.g. temp/vdiff-baseline-tablet.png, temp/vdiff-current-tablet.png, temp/vdiff-diff-tablet.png).
Component-scoped comparison at smaller breakpoints: Re-measure the component height at each breakpoint (it will change) and resize the viewport accordingly before screenshotting.
Keep a running log of what was fixed and verified. This helps avoid re-checking properties and provides a summary at the end.
Use session memory (/memories/session/) to store:
| Level | diffPercent | Description |
|---|---|---|
| Pixel perfect | < 1% | Only sub-pixel rendering differences remain |
| Excellent match | 1–2% | Minor font rendering, anti-aliasing, or shadow differences — stop here |
| Good match | 2-5% | Small spacing or color differences worth fixing |
| Needs work | > 5% | Significant visual differences still present |
The default target is < 2%. Stop and report as soon as this threshold is met — do not keep iterating to squeeze from 1% to 0% unless the user explicitly asks. Flag remaining issues that fall into the "hard to align" bucket (font rendering, sub-pixel spacing, third-party overlays) and let the user decide whether to fix them manually.
User: "Make the nav component match production"
Agent:
1. Load pixel-perfect skill
2. Load visual-diff skill → screenshot production nav + Storybook nav
3. Run diff → diffPercent: 12.3%
4. View diff → red clusters at: nav height, logo area, nav item spacing, CTA button
5. Load computed-styles skill
6. Extract nav properties from production:
nav.height = 80px, nav.padding = 0px 128px, logo.width = 108px ...
7. Extract same from Storybook:
nav.height = 60px, nav.padding = 0px 32px, logo.width = 80px ...
8. Build diff table, fix mismatches with Tailwind — resolve to design tokens from `src/styles/bitovi-theme.css` (e.g. `bg-brand-orange`, `text-teal-500`, `font-semibold`, `p-md`)
9. Verify fixes with re-extraction
10. Re-screenshot + re-diff → diffPercent: 3.1%
11. View diff → remaining red at CTA button border-radius
12. Extract CTA styles, fix borderRadius
13. Re-diff → diffPercent: 0.8%
14. Done! Report final comparison table.
After the session:
rm -f temp/vdiff-*.png
All computed style data lives in conversation context and session memory only.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub bitovi/ai-enablement-prompts --plugin playwright8 skills in this plugin
/computed-stylesExtract and compare computed CSS styles between a baseline URL and a dev/Storybook URL using Playwright MCP evaluate calls. Use when visual differences have been identified and you need to find the exact CSS property mismatches to fix. Pairs with the visual-diff skill for a complete visual QA workflow./debug-e2e-testDebug and fix failing Playwright E2E tests. Use when tests fail, when asked to fix failing tests, or when investigating test failures. Analyzes test output, screenshots, error context, and uses Playwright MCP to identify root causes./debuggingAlways start a fresh browser session after any file change, walk through the full user flow, and monitor for errors before proceeding with further work./discover-visual-statesDiscover all visual states of a component by interactively exploring the production baseline page — not by reading story files. Finds every interactive element (nav items, dropdowns, toggles, buttons) that produces a distinct visual state, records the interactions needed to reach each one, and saves a pixel-perfect.config.json that the pixel-perfect skill uses to replay those same interactions on both production and Storybook. Run this once per component; re-run when the production page changes./test-responsive-designMake UIs responsive across all devices and verify responsiveness using Playwright. Includes scrollbar testing, breakpoint verification, and layout validation. Use when implementing new features, fixing layout issues, or ensuring mobile compatibility./visual-diffCompare a baseline URL against a dev or Storybook URL by taking Playwright screenshots at multiple breakpoints, running a pixel-level image diff, and reporting results to guide style and HTML corrections. Use when replicating an existing page or component, verifying visual accuracy, or checking responsive fidelity.Other plugins' skills for the same job