Skip to main content
skill CX Codex

visual-regression-testing — Claude Code skill for UI screenshot diffs

Catches unintended UI changes by capturing screenshots of pages and components and comparing them across versions.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add aj-geddes/useful-ai-prompts --skill visual-regression-testing -a claude-code
Open on GitHub

What visual-regression-testing does

The skill teaches your agent to write and read visual tests. It covers capturing screenshots of pages and components, comparing them against baselines, and spotting the breakage functional tests walk past: shifted layout, CSS conflicts, overlapping elements.

Inside you get a short starter example built on @playwright/test with toHaveScreenshot and maxDiffPixels, a list of situations worth testing, and a references/ folder with separate guides for Playwright, Percy, Chromatic for Storybook, Cypress, BackstopJS, dynamic content and responsive components. The quick start cuts off at the third test, so full implementations live in the reference guides.

Dynamic content is where this gets painful. Timestamps, ads and random data produce false diffs, so the skill tells you to hide or mock that content and disable animations during capture. The maxDiffPixels: 100 value in the example is a suggestion to start from, not a hard limit. Baselines have to live in version control and be refreshed after every design change, otherwise the suite starts failing on legitimate edits.

What it helps with

  • catch a CSS regression after refactoring styles
  • check how a page renders at mobile and tablet viewports
  • compare component screenshots before and after a theme change
  • filter out false diffs from timestamps and ad slots
  • review visual changes in a pull request before merging

Example prompts for the agent

  • set up visual tests for the homepage with Playwright
  • add a responsive check for the 375x667 mobile viewport
  • how do I mock dynamic content so screenshots stop drifting

How to install visual-regression-testing

1Skills CLI (Vercel)

npx skills add aj-geddes/useful-ai-prompts --skill visual-regression-testing -a claude-code

2Manually: put the files in place

~/.claude/skills/visual-regression-testing/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/visual-regression-testing/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about visual-regression-testing

How do I install visual-regression-testing in Claude?

Run npx skills add aj-geddes/useful-ai-prompts --skill visual-regression-testing -a claude-code. The skill lands at ~/.claude/skills/visual-regression-testing/SKILL.md.

What does visual-regression-testing do?

It helps the agent write tests that screenshot the UI and compare shots across versions, so unintended visual changes surface before they ship.

Which tools does the skill cover?

The reference guides walk through Playwright, Percy, Chromatic for Storybook, Cypress and BackstopJS, plus separate material on dynamic content and responsive components.

Source text

SKILL.md · MIT
---
name: visual-regression-testing
description: >
  Detect unintended visual changes in UI by comparing screenshots across
  versions. Use for visual regression, screenshot diff, Percy, Chromatic, UI
  testing, and visual validation.
---

# Visual Regression Testing

## Table of Contents

- [Overview](#overview)
- [When to Use](#when-to-use)
- [Quick Start](#quick-start)
- [Reference Guides](#reference-guides)
- [Best Practices](#best-practices)

## Overview

Visual regression testing captures screenshots of UI components and pages, then compares them across versions to detect unintended visual changes. This automated approach catches CSS bugs, layout issues, and design regressions that traditional functional tests miss.

## When to Use

- Detecting CSS regression bugs
- Validating responsive design across viewports
- Testing across different browsers
- Verifying component visual consistency
- Catching layout shifts and overlaps
- Testing theme changes
- Validating design system components
- Reviewing visual changes in PRs

## Quick Start

Minimal working example:

```typescript
// tests/visual/homepage.spec.ts
import { test, expect } from "@playwright/test";

test.describe("Homepage Visual Tests", () => {
  test("homepage matches baseline", async ({ page }) => {
    await page.goto("/");

    // Wait for images to load
    await page.waitForLoadState("networkidle");

    // Full page screenshot
    await expect(page).toHaveScreenshot("homepage-full.png", {
      fullPage: true,
      maxDiffPixels: 100, // Allow small differences
    });
  });

  test("responsive design - mobile", async ({ page }) => {
    await page.setViewportSize({ width: 375, height: 667 }); // iPhone SE
    await page.goto("/");

    await expect(page).toHaveScreenshot("homepage-mobile.png");
  });

  test("responsive design - tablet", async ({ page }) => {
// ... (see reference guides for full implementation)
```

## Reference Guides

Detailed implementations in the `references/` directory:

| Guide | Contents |
|---|---|
| [Playwright Visual Testing](references/playwright-visual-testing.md) | Playwright Visual Testing |
| [Percy Visual Testing](references/percy-visual-testing.md) | Percy Visual Testing |
| [Chromatic for Storybook](references/chromatic-for-storybook.md) | Chromatic for Storybook |
| [Cypress Visual Testing](references/cypress-visual-testing.md) | Cypress Visual Testing |
| [BackstopJS Configuration](references/backstopjs-configuration.md) | BackstopJS Configuration |
| [Handling Dynamic Content](references/handling-dynamic-content.md) | Handling Dynamic Content |
| [Testing Responsive Components](references/testing-responsive-components.md) | Testing Responsive Components |

## Best Practices

### ✅ DO

- Hide or mock dynamic content (timestamps, ads)
- Test across multiple viewports
- Wait for animations and images to load
- Use consistent viewport sizes
- Disable animations during capture
- Test interactive states (hover, focus)
- Review diffs carefully before approving
- Store baselines in version control

### ❌ DON'T

- Test pages with constantly changing content
- Ignore small legitimate differences
- Skip responsive testing
- Forget to update baselines after design changes
- Test pages with random data
- Use overly strict thresholds (0% diff)
- Skip browser/device variations
- Commit unapproved diffs

© aj-geddes · MIT · aj-geddes/useful-ai-prompts

Similar skills

All skills for Testing and QA →

From the same set143

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor