visual-regression
Screenshot comparison and visual regression detection across viewports
от shogo-labs★ 22 звезды на GitHub
Установить visual-regression в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Visual Regression Testing
Detect unintended visual changes by comparing screenshots against stored baselines.
Workflow
1. Capture Baselines
First run establishes the "known good" state:
- Navigate to each critical page at all 3 viewports
- Wait for
networkidleto ensure all assets loaded - Take full-page screenshots
- Store baseline metadata in memory:
{ "page": "/dashboard", "viewport": "desktop", "path": "/tmp/baseline-dashboard-desktop-1700000000.png", "commitHash": "abc123", "timestamp": "2024-01-15T10:30:00Z", "url": "http://localhost:3000/dashboard" }
2. Comparison Run
On subsequent runs:
- Take new screenshots at the same pages and viewports
- Compare against stored baselines pixel-by-pixel
- Calculate the percentage of changed pixels
- Flag pages that exceed the threshold
3. Diff Analysis
Threshold configuration:
- Default: flag differences > 0.1% pixel change
- Strict mode: flag > 0.01% (for pixel-perfect designs)
- Relaxed mode: flag > 1.0% (for content-heavy pages with dynamic data)
The user can adjust per-page if needed.
4. Report Results
Present findings with:
- Before (baseline) and After (current) screenshots side by side
- Percentage of pixels changed
- Classification: intentional (user confirms) vs regression (unexpected)
- If intentional: update baseline in memory
- If regression: flag for investigation
Viewport Matrix
| Viewport | Width | Height | Use Case |
|---|---|---|---|
| Desktop | 1920 | 1080 | Primary layout, full navigation |
| Tablet | 768 | 1024 | Responsive breakpoint, touch layout |
| Mobile | 375 | 667 | Mobile-first, hamburger menu, stacked layout |
Baseline Management
- Store baselines with commit hash so you can correlate visual changes with code changes
- When user approves a visual change, update the baseline in memory
- Keep the last 3 baselines per page/viewport for rollback comparison
- Prune baselines older than 30 days unless user marks them as "pinned"
Comparison Script Template
const { chromium } = require('playwright');
const fs = require('fs');
const TARGET_URL = 'http://localhost:3000';
const PAGES = ['/', '/dashboard', '/settings', '/profile'];
const VIEWPORTS = [
{ name: 'desktop', width: 1920, height: 1080 },
{ name: 'tablet', width: 768, height: 1024 },
{ name: 'mobile', width: 375, height: 667 },
];
(async () => {
const browser = await chromium.launch({ headless: false });
const results = [];
for (const pagePath of PAGES) {
for (const vp of VIEWPORTS) {
const context = await browser.newContext({
viewport: { width: vp.width, height: vp.height }
});
const page = await context.newPage();
await page.goto(`${TARGET_URL}${pagePath}`);
await page.waitForLoadState('networkidle');
const screenshotPath = `/tmp/vr-${pagePath.replace(/\//g, '-')}-${vp.name}-${Date.now()}.png`;
await page.screenshot({ path: screenshotPath, fullPage: true });
results.push({
page: pagePath,
viewport: vp.name,
screenshot: screenshotPath,
timestamp: new Date().toISOString()
});
console.log(`✓ Captured ${pagePath} @ ${vp.name}`);
await context.close();
}
}
console.log(JSON.stringify(results, null, 2));
await browser.close();
})();
Edge Cases to Handle
- Dynamic content (timestamps, random avatars, ads) — mask known dynamic regions before comparison
- Font loading — wait for fonts to load before capture (
document.fonts.ready) - Animations — disable CSS animations before capture (
* { animation: none !important; }) - Lazy-loaded images — scroll to bottom and back before capture to trigger all lazy loads
- Dark mode — if the app supports it, capture both light and dark mode baselines
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
- 01
browser_navigate - 02
browser_screenshot - 03
shell_exec - 04
memory_read - 05
memory_write
FAQ
Что делает скилл visual-regression?
Screenshot comparison and visual regression detection across viewports
Как установить скилл visual-regression?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл visual-regression запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…