/design-process:comparison-modefrom Design Process
Compares two HTML versions side-by-side with DOM, pixel, and style diff overlays. Triggered by phrases like "compare two versions" or "what changed in the layout".
Ships in Design Process. 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.
Не текстовый diff (его делает git). А визуальный + семантический.
comparison/
index.html ← главная
before.html ← (или any path)
after.html
diff-engine.js ← логика
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<title>Comparison</title>
<style>
body { display: grid; grid-template: auto 1fr / 1fr 1fr; height: 100vh; margin: 0; font: 13px ui-monospace, monospace; gap: 1px; background: #888; }
h2 { margin: 0; padding: 8px 16px; background: #222; color: #fff; font-size: 12px; font-weight: normal; }
iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.toolbar { grid-column: 1 / -1; padding: 8px 16px; background: #fafafa; border-bottom: 1px solid #ddd; display: flex; gap: 16px; align-items: center; }
.mode { display: flex; gap: 4px; }
.mode button { padding: 4px 12px; border: 1px solid #ccc; background: #fff; cursor: pointer; }
.mode button.active { background: #111; color: #fff; }
.stats { color: #888; }
.stats b { color: #111; }
</style>
</head>
<body>
<div class="toolbar">
<strong>Comparison</strong>
<div class="mode" id="mode">
<button data-mode="side" class="active">Side by side</button>
<button data-mode="overlay">Overlay diff</button>
<button data-mode="dom">DOM tree</button>
</div>
<span class="stats" id="stats">Loading…</span>
</div>
<h2>Before</h2>
<h2>After</h2>
<iframe id="a" src="before.html"></iframe>
<iframe id="b" src="after.html"></iframe>
<script src="diff-engine.js" defer></script>
</body>
</html>
// 1. Sync scroll
function syncScroll() {
const a = document.getElementById('a').contentWindow;
const b = document.getElementById('b').contentWindow;
let last = 0, fromA = false;
a.addEventListener('scroll', () => {
if (Date.now() - last < 50 && !fromA) return;
fromA = true; b.scrollTo(0, a.scrollY); last = Date.now();
setTimeout(() => fromA = false, 100);
});
b.addEventListener('scroll', () => {
if (Date.now() - last < 50 && fromA) return;
a.scrollTo(0, b.scrollY); last = Date.now();
});
}
// 2. DOM diff (rough)
function domDiff() {
const ad = document.getElementById('a').contentDocument;
const bd = document.getElementById('b').contentDocument;
const aSet = new Set([...ad.querySelectorAll('*')].map(el => el.tagName + (el.id ? '#' + el.id : '') + ' ' + el.className));
const bSet = new Set([...bd.querySelectorAll('*')].map(el => el.tagName + (el.id ? '#' + el.id : '') + ' ' + el.className));
const removed = [...aSet].filter(x => !bSet.has(x));
const added = [...bSet].filter(x => !aSet.has(x));
return { added, removed };
}
// 3. Stats
window.addEventListener('load', () => {
document.getElementById('a').addEventListener('load', update);
document.getElementById('b').addEventListener('load', update);
syncScroll();
function update() {
try {
const d = domDiff();
const stats = document.getElementById('stats');
stats.innerHTML = `<b>+${d.added.length}</b> added · <b>-${d.removed.length}</b> removed`;
} catch (e) { /* not loaded yet */ }
}
});
Свой pixel-diff здесь не нужен: скрипт test.mjs из скилла screenshot-test делает ровно это —
Playwright снимает fullPage, pixelmatch + pngjs считают разницу и пишут подсвеченный PNG.
Там же стабилизация (отключение анимаций, ожидание шрифтов, скрытие каретки, stub времени),
без которой diff шумит на антиалиасе и выдаёт ложную разницу.
Как получить им diff «before vs after»: в test-screenshots.config.json указывается рабочий
файл, снимок «до» делается перед правками.
npm i -D playwright pixelmatch pngjs
node test.mjs --update # снять «до» с текущего index.html
# ...правки...
node test.mjs # сравнить «после» → screenshots/diff/<name>.png
Разница в назначении, а не в коде: screenshot-test сравнивает текущее с сохранённым в репо
эталоном и падает в CI, comparison-mode — две произвольные версии разово, руками, перед тем как
эталон обновлять.
Для глубокого diff'а — text-based рекурсивный обход:
function tree(el, depth = 0) {
let s = ' '.repeat(depth) + el.tagName.toLowerCase();
if (el.id) s += '#' + el.id;
if (el.className) s += '.' + [...el.classList].slice(0,2).join('.');
s += '\n';
for (const c of el.children) s += tree(c, depth + 1);
return s;
}
const treeA = tree(ad.body);
const treeB = tree(bd.body);
// → unified diff (через `diff` lib)
npm i diff
import { diffLines } from 'diff';
const out = diffLines(treeA, treeB);
out.forEach(p => console.log((p.added ? '+' : p.removed ? '-' : ' ') + p.value.split('\n').join('\n' + (p.added?'+':p.removed?'-':' '))));
cp index.html .compare/before.html.cp index.html .compare/after.html..compare/index.html в браузере → side-by-side.screenshot-test (см. раздел выше).file:// работают.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jhamidun/claude-code-config-pack --plugin design-process11 skills in this plugin
/content-rulesАнти-слоп правила дизайна — что НЕ добавлять, чтобы не выглядело ИИ-выхлопом; проверка перед сдачей артефакта. Триггеры: «не лей воду в дизайн»./cookbookГотовые сценарии из скиллов под типовые задачи: питч-дек, прототип, дизайн-система, лендинг. Триггеры: «pitch deck workflow», «готовый сценарий»./critique-modeКритика готового дизайна по чеклисту, конкретно, без «выглядит хорошо». Триггеры: «покритикуй мой дизайн», «design critique».Other plugins' skills for the same job