Agent Skills › tabler/tabler › html-diff

html-diff

GitHub

通过对比开发服务器渲染的HTML与基线快照,验证重构或组件调整是否改变了输出。用于确保无视觉差异的代码变更安全,支持捕获基线、执行比对及解读差异结果。

.agents/skills/html-diff/SKILL.md tabler/tabler

触发场景

验证重构是否改变渲染HTML 检查代码变更是否字节级相同 提取或重命名组件前的安全性确认

安装

npx skills add tabler/tabler --skill html-diff -g -y
更多选项

非标准路径

npx skills add https://github.com/tabler/tabler/tree/dev/.agents/skills/html-diff -g -y

不安装直接使用

npx skills use tabler/tabler@html-diff

指定 Agent (Claude Code)

npx skills add tabler/tabler --skill html-diff -a claude-code -g -y

安装 repo 全部 skill

npx skills add tabler/tabler --all -g -y

预览 repo 内 skill

npx skills add tabler/tabler --list

SKILL.md

Frontmatter
{
    "name": "html-diff",
    "metadata": {
        "internal": true
    },
    "description": "Prove that a refactor changes no rendered HTML, using the `html-diff` harness over every preview page. Use before and after any change that is meant to be output-neutral — extracting or renaming a component, replacing hand-written markup with a `shared\/ui` component, reordering props, restructuring a layout, migrating SCSS class emission — and whenever the user asks whether a change is safe or byte-identical. Covers capturing the baseline, reading the diff, and what counts as an acceptable difference."
}

Prove a refactor changes no HTML

.build/html-diff.ts renders every preview page from a running dev server and compares it to a stored baseline. It is the only fast way to refactor shared components with confidence: one run covers every page that uses them.

1. When to use it

Use it for any change that should not alter output: component extraction, replacing repeated markup with a component, renaming props, moving code between shared/ files, layout restructuring, prettier/format passes.

Do not use it for a change that intentionally alters markup — the whole run will be red and tell you nothing. There, review the diff of the pages you meant to change instead.

2. Capture the baseline first

The baseline must come from the tree before the change. If you have already started editing, stash first.

git stash                     # only if the working tree already has the change
pnpm --dir preview run dev    # or preview_start with the `preview` config
pnpm run html-diff:baseline
git stash pop

Before editing, list the pages that render what you are about to change:

grep -rl "Steps.astro" preview/pages docs/content

Green on everything is not the only result worth checking — knowing that all-elements.html must stay identical while steps.html is allowed to differ is what turns the run into a proof.

Snapshots land in .cache/html-diff/ (one HTML file per page) and the directory is wiped on every baseline run. The dev server must be reachable at http://localhost:3000; override with HTML_DIFF_BASE if you run it elsewhere.

3. Check after the change

Keep the same dev server running — it recompiles pages on demand — and run:

pnpm run html-diff

Every page byte-identical:

✓ All 128 pages are byte-identical to the baseline.

Anything else exits non-zero and prints one line per differing page.

4. Reading the output

Line Meaning
± page: differs at line N with -/+ real difference — the first differing line of that page
± page: WHITESPACE-ONLY difference identical after collapsing inter-tag whitespace
± page: new page (no baseline snapshot) page added since the baseline
± page: page removed page deleted, or it now fails to render
✖ N page(s) failed to render the dev server is down, or a page throws — fix that before reading anything else

A whitespace-only difference is usually inert (flex containers, <select> internals) but is not automatically fine: inside inline contexts whitespace is a rendered space. Open such a page and compare visually before waving it through.

For a full diff of one page, compare the snapshot to the live render:

diff <(cat .cache/html-diff/badges.html) <(curl -s http://localhost:3000/badges)

5. What the harness does not cover

  • Preview pages only. Docs pages and dynamic routes ([...] in the filename) are skipped.
  • Dev output, not built output. The build additionally prettifies HTML; a formatting-only difference can still appear in dist.
  • The Generated <date> footer is normalised away; nothing else is.
  • Pages are compared as text, so an attribute reorder counts as a difference even when the DOM is equivalent. That is the point — Tabler ships the HTML.

6. Checklist

  • Baseline captured from the pre-change tree, with the dev server running
  • Same dev server used for baseline and check
  • pnpm run html-diff green, or every remaining difference explained
  • Whitespace-only pages opened in the browser before accepting them
  • New/removed pages are intentional

版本历史

  • 096491d 当前 2026-11-03 10:26
  • 340f719 2026-09-22 21:47

同 Skill 集合

.agents/skills/astro-dev/SKILL.md
.agents/skills/class-reference/SKILL.md
.agents/skills/core-js/SKILL.md
.agents/skills/core-scss/SKILL.md
.agents/skills/demo-pages/SKILL.md
.agents/skills/generate-changeset/SKILL.md
.agents/skills/mr-description/SKILL.md
.agents/skills/navigation/SKILL.md
.agents/skills/page-layouts/SKILL.md
.agents/skills/screenshots/SKILL.md
.agents/skills/shared-lib/SKILL.md
.agents/skills/ui-component/SKILL.md
docs/lib/agent-skills/tabler/SKILL.md
skills/tabler/SKILL.md
.agents/skills/astro-scripts/SKILL.md
.agents/skills/backward-compat/SKILL.md
.agents/skills/bootstrap-component/SKILL.md
.agents/skills/build-pipeline/SKILL.md
.agents/skills/release-notes/SKILL.md
.agents/skills/upgrade-guide/SKILL.md
.agents/skills/write-docs/SKILL.md

元信息

文件数
0
版本
096491d
Hash
d5fcadcb
收录时间
2026-09-22 21:47

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.156.0. UTC+08:00, 2026-11-06 01:07
浙ICP备14020137号-1