golden-file-conventions
БесплатноБез исполняемых скриптовНе проверенUse when snapshot or golden-file tests are noisy or untrusted: snapshots accepted without review, diffs full of timestamps, IDs or PII, baselines that differ…
от testland★ 18 звёзд на GitHubОб этом скилле
golden-file-conventions
Terminology note: "golden file" / "golden master" are practitioner-emergent terms popularized by the Working Effectively with Legacy Code tradition. ISTQB has no canonical entry - the closest formal term is "snapshot test." This catalog uses both interchangeably; assume "golden file" and "snapshot" mean the same thing in the rest of the body.
A reference catalog for how to manage snapshot / golden files. It supplies the conventions that active snapshot-management workflows follow when updating / pruning golden files.
When to use
- A team is starting snapshot-testing on a project.
- A team has an existing snapshot suite and reviews are slow because of unclear conventions.
- A developer is unsure when to update a baseline vs. when to fix the regression.
- A PR review keeps stalling on "is this snapshot diff intentional?"
Naming conventions
Per-test snapshot file
Most snapshot frameworks (Jest, Vitest, pytest-snapshot, RSpec Snapshot) use a path adjacent to the test file:
src/
components/
Button.tsx
Button.test.tsx
__snapshots__/
Button.test.tsx.snap
Convention: one snapshot file per test file, named
<test-file-name>.snap. Do not split snapshots across multiple
files per test.
Per-test name within a snapshot file
Inside a .snap file, each snapshot is keyed by <describe> >
<it> chain:
exports[`Button renders with primary variant 1`] = `<button class="primary">...</button>`;
The trailing 1 is the snapshot index when one test takes multiple
snapshots - keep these to a minimum (≤3 per test); beyond that,
split the test.
Per-OS / per-browser variants (visual snapshots)
For visual / screenshot-based snapshots, the name carries the
platform suffix (per playwright-snapshots, in the qa-visual-regression plugin):
Button-primary-1-chromium-linux.png
Button-primary-1-firefox-linux.png
Button-primary-1-webkit-darwin.png
OS / browser suffixes are load-bearing - anti-aliasing and font metrics differ. Don't strip them.
Directory layout
| Layout | When to use |
|---|---|
Adjacent (__snapshots__/ next to test) |
Default. Reviewer sees the diff in the same PR view as the test. |
Centralized (tests/__fixtures__/) |
Cross-test fixtures (golden inputs reused by many tests). |
External (s3://snapshots-bucket/) |
Visual snapshots that are large; CI uploads / downloads. Common with Percy, Chromatic, Playwright + S3. |
Default to adjacent. Centralized only when fixtures are reused. External only when artifact size makes adjacent impractical.
When to add a baseline
Add a snapshot when:
- A new component / page / output ships and its rendered shape is load-bearing.
- A bug fix changes a specific output that lacked coverage; the snapshot is the regression-prevention asset.
- A redesign locked the new design system; refresh all baselines in one PR.
Don't add a snapshot for:
- Output that's expected to change frequently (e.g. timestamps, randomized IDs). Snapshot the shape, not the volatile values - see Sanitization below.
- Internal-only rendering paths the user never sees.
- Test scaffolding output (e.g. test runner banners).
Sanitization (the load-bearing rule)
A snapshot that contains volatile values (timestamps, UUIDs, random IDs, current dates) breaks every run. Sanitize before snapshotting:
| Volatile field | Sanitization pattern |
|---|---|
| Timestamps | Replace with a fixed string [TIMESTAMP] or freeze the clock (vi.useFakeTimers()). |
| UUIDs | Replace with [UUID] or seed a deterministic generator. |
| Auto-increment IDs | Replace with [ID] or use a sequence-controlled fixture. |
File paths (/var/folders/...) |
Replace with [PATH] or normalize via project root. |
| Memory addresses (object refs) | Avoid in serialized output; use a custom serializer. |
| User-data tokens | Strip before snapshotting; tokens shouldn't be in the test surface anyway. |
Most frameworks support custom serializers / matchers - use them.
Jest's expect.any(Date) matcher pattern is canonical:
expect(result).toMatchSnapshot({
createdAt: expect.any(Date),
uuid: expect.any(String),
});
The serializer normalizes volatile fields before comparison,
so the snapshot shows Any<Date> rather than a specific timestamp.
Update vs. fix decision tree
When a snapshot diff appears in a PR:
Is the diff explained by code changes in the same PR?
├── No → REGRESSION; fix the code, do not update the snapshot.
└── Yes → Did the diff align with the intent (described in the PR title)?
├── No → REG
Установить golden-file-conventions в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл golden-file-conventions?
Use when snapshot or golden-file tests are noisy or untrusted: snapshots accepted without review, diffs full of timestamps, IDs or PII, baselines that differ per OS or runtime, or no rule for where snapshots live. Sets naming and directory layout, when to add, update or remove a baseline, sanitization, per-OS and per-runtime variants, and the PR review workflow for snapshot diffs.
Как установить скилл golden-file-conventions?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл golden-file-conventions запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic