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.
npx skills add aj-geddes/useful-ai-prompts --skill visual-regression-testing -a claude-codeWhat 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-code2Manually: put the files in place
~/.claude/skills/visual-regression-testing/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/visual-regression-testing/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill visual-regression-testing -a codex2Manually: put the files in place
.agents/skills/visual-regression-testing/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill visual-regression-testing -a cursor2Manually: put the files in place
.cursor/skills/visual-regression-testing/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install aj-geddes/useful-ai-prompts visual-regression-testing2Manually: put the files in place
.github/skills/visual-regression-testing/SKILL.md1Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill visual-regression-testing -a gemini-cli2Platform CLI
gemini skills install https://github.com/aj-geddes/useful-ai-prompts --path skills/visual-regression-testingManually: put the files in place
.devin/skills/visual-regression-testing/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add aj-geddes/useful-ai-prompts --skill visual-regression-testing -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
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