cmd-golden-tests
Set up or extend golden/snapshot tests for a project. Covers fixture design, Makefile targets, snapshot storage, diff workflow, and update protocol.
What this skill does
# Golden Tests
Golden (snapshot) tests capture the exact output of a pipeline or subsystem as a reference file, then fail any run that deviates from it. They are the highest-fidelity regression check: if anything in the pipeline changes — parsing, mapping, migration, export — the diff tells you exactly what shifted.
## Reference Implementation
The paradigm for this skill comes from `boredm/gint_to_boredm`. Read it before adapting anything:
- Makefile targets: `makefiles/golden.mk`
- Snapshot scripts: `scripts/golden_thompson.py`
- Fixtures: `server/tests/fixtures/`
- Workflow golden: `golden.md`
---
## The Five Setup Questions
Answer these before writing any code or Makefile targets.
### 1. What is the fixture / on-device schema?
The input data the pipeline runs against. Must be:
- **Checked in** to the repo (or clearly documented how to obtain it)
- **Small enough** to run in CI without special infra
- **Representative** of real edge cases, not just happy-path data
In boredm: real `.gpj` files in `thompson_sample/` (binary, not committed to the main repo — seeded via `make seed-thompson`).
### 2. What is the API under test?
How the system is invoked in the golden test. Three patterns:
| Pattern | Use when | Example |
|---------|----------|---------|
| **Direct function call** | Testing a pure transformation | `schema_grouping.build_grouping_outputs(schemas)` |
| **HTTP endpoint via TestClient** | Testing a route end-to-end | `POST /api/units/generate-migrations/{schema}` |
| **Full workflow via manifest** | Testing the entire pipeline | Run wf1–wf7, read manifest from disk |
Avoid mixing patterns in the same golden — pick the right scope.
### 3. What is the golden truth dataset?
The reference snapshot file. Key design choices:
**Semantic golden (single compact file):**
- Extracts a stable subset of the output (row counts, field counts, match types, transformation types)
- Intentionally excludes volatile fields: timestamps, file paths, binary hashes, job IDs
- Sorts all dict keys for deterministic JSON output
- Good for: full-pipeline end-to-end tests
**Phase-level goldens (per-schema per-phase files):**
- One file per `{phase}_{schema}.json` — e.g., `wf1_grouping_file_group_1.json`
- Captures the intermediate state after each workflow phase
- Good for: pinpointing which phase introduced a regression
**Unit-test-style fixture (step-by-step JSON):**
- Inline expected values alongside inputs in the same file
- Steps: `baseline → mutation → restored`
- Good for: idempotency tests, lifecycle tests
### 4. When and how do you update it?
Never silently. The update workflow must be:
1. Run the full pipeline
2. Inspect the diff (unified diff, colorized)
3. Decide: expected change or regression?
4. Only then run the explicit update command
Makefile targets enforce this:
```makefile
golden-{dataset}-verify # compare without running pipeline
golden-{dataset}-update # rewrite golden from latest output
golden-{dataset}-wf # run pipeline + compare (fails on diff)
```
### 5. How do you handle failures, updates, false positives, and false negatives?
| Scenario | Action |
|----------|--------|
| **Expected change** (feature added, behavior improved) | Inspect diff → `make golden-{dataset}-update` → commit both code and golden |
| **Regression** (pipeline broke something) | Fix root cause, never update golden to hide it |
| **False positive** (volatile field leaked into snapshot) | Remove volatile field from snapshot extractor, not from golden |
| **False negative** (golden too coarse, misses real change) | Add a phase-level golden or tighten the snapshot to cover the missed surface |
---
## Makefile Target Naming Convention
Follow this naming pattern. Replace `{dataset}` with the fixture dataset name (e.g., `thompson`).
```makefile
## Golden Tests
golden-{dataset}-test ## Unit-test-like suite; pytest against JSON fixtures; no server needed
golden-{dataset}-wf ## Full end-to-end workflow + semantic manifest comparison; server required
golden-{dataset}-verify ## Compare latest manifest to golden without re-running workflow
golden-{dataset}-update ## Rewrite semantic golden from latest manifest output
golden-{dataset}-phase-verify ## Compare all phase-level goldens ({phase}_{schema}.json files)
golden-{dataset}-phase-update ## Update all phase-level goldens from latest manifest
```
Separate into two modes in the help output:
```
[Golden — unit-like]
golden-{dataset}-test Fast; no server; pytest fixtures
[Golden — full workflow]
golden-{dataset}-wf Slow; server required; full e2e
golden-{dataset}-verify Compare only; no re-run
golden-{dataset}-update Rewrite golden (inspect diff first!)
```
---
## Snapshot Storage Layout
```
server/tests/fixtures/
{dataset}_semantic_wf_verification_golden.json # single compact semantic golden
{dataset}_schema_grouping_golden.json # unit-test-style fixture
{dataset}_unit_migration_golden.json # lifecycle fixture with steps
{dataset}_phase_goldens/
wf1_grouping_{schema}.json
wf2_mapping_{schema}.json
wf3_units_{schema}.json
wf3b_migrations_{schema}.json
wf4_normalized_{schema}.json
wf5_qc_{schema}.json
wf6_exports_{schema}.json
wf7_insights_{schema}.json
```
---
## Snapshot Script Pattern
A standalone script (not pytest) manages semantic and phase goldens. Key functions:
```python
def build_snapshot(manifest: dict) -> dict:
"""Extract stable, deterministic subset from full pipeline manifest."""
# 1. Pull only the fields you care about (row counts, match types, etc.)
# 2. Exclude volatile fields: timestamps, paths, binary hashes, job IDs
# 3. Sort all nested dicts for deterministic output
def compare_to_golden(snapshot: dict, golden_path: Path) -> bool:
"""Unified diff, colorized. Returns True if match."""
# Uses difflib.unified_diff with red/green color codes
def write_golden(golden_path: Path, snapshot: dict) -> None:
"""Rewrite golden file. Sort keys, trailing newline."""
# json.dumps(data, indent=2, sort_keys=True) + "\n"
```
CLI flags:
```
--verify compare latest manifest to golden (default)
--update-golden rewrite semantic golden
--phase-goldens verify per-phase files
--update-phase-goldens rewrite per-phase files
--schema target a specific schema only
--all-schemas run across all schemas
```
---
## What NOT to Put in a Golden
These leak into diffs and cause false positives:
- Timestamps (`created_at`, `updated_at`, dataset directory names with dates)
- File system paths (absolute or dataset-relative)
- Binary content or checksums
- Cache fingerprints, job IDs, run UUIDs
- Full JSON payloads when a count or summary suffices
---
## Adding Golden Tests to a New Repo
1. Answer the five setup questions above
2. Seed fixture data and document the seed command (`make seed-{dataset}`)
3. Write the snapshot extractor script (`scripts/golden_{dataset}.py`)
4. Write pytest fixtures for unit-test-like checks (`server/tests/test_*_golden.py`)
5. Add Makefile targets following the naming convention above
6. Run once, capture baseline, commit golden files alongside code
7. Add to CI: fail build on golden diff, never auto-update in CI
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.