specimen-cli
The specimen binary. One JSON result on stdout, and exit code 1 when
a check fails.
Agent-First Development: software built as commands that people and agents both call. Not AI that writes your code.
Preview, on npm
A test bench for components.
Every run leaves evidence.
Specimen renders a component in real Chromium and writes down its markup, layout, styles, state and accessibility tree. Compare two captures to see what changed. It runs Storybook-format stories without Storybook.
npm install --save-dev @lushly-dev/specimen-cli@preview
specimen diff bar.json bar-token-changed.json
What that says The markup is identical. It still moved.
Try itPick a line under the prompt, or type your own. The captures are files a real browser wrote. The comparison runs here.
One capture is one JSON file. It carries where it came from and how complete each channel is. A comparison refuses captures from different browsers, and a missing channel is never read as unchanged.
| Channel | Status | What it covers |
|---|
Read from the capture file when this page loaded.
The bench knows nothing about AFD and needs none of it. The command layer sits on the bench, and the command line and the server sit on the commands. The project you inspect needs none of them installed.
The specimen binary. One JSON result on stdout, and exit code 1 when
a check fails.
An MCP server over stdio, with every command as a tool. It runs from a checkout for now and is not on npm.
The 19 commands and their schemas. The command line and the server both run these.
A plugin for FAST-AF components: their schema, their commands and their themes.
The bench, the comparison, the story runner and the schemas.
The native host, in Rust. It bundles each case, serves it from memory and drives Chromium. One prebuilt package per platform.
import { createSpecimenBench, diffObservations } from '@lushly-dev/specimen';
const bench = await createSpecimenBench({ root: './components' });
try {
const before = await bench.render({ id: 'button' });
const after = await bench.render({ id: 'button-padded' });
const comparison = diffObservations(before, after);
// { status: 'changed', differences: [...], limitations: [...] }
} finally {
await bench.close(); // ends the host and its browser
}
export const Primary: SpecimenDefinition = {
render,
targets: { control: { role: 'button', name: 'Save' } },
events: [{ type: 'click', target: 'control' }],
scenario: [
{ id: 'activate', action: { click: 'control' } },
{ id: 'clicked', expect: { event: 'click', since: 'activate' } },
{ capture: 'after-click' },
],
};
// specimen.config.json
{ "specimens": [{ "id": "button-primary", "title": "Components/Button",
"module": "./button.specimens.ts", "exportName": "Primary", "component": "my-button" }] }
import { expect, userEvent, within } from '@lushly-dev/specimen/test';
import type { Meta, StoryObj } from '@lushly-dev/specimen/types';
// specimen.config.json
{ "stories": ["src/**/*.stories.ts"], "preview": "specimens/preview.ts" }
# one story, or a suite with a retry for flakes
specimen run button--primary
specimen run --tag smoke --workers 2 --retry
storybook/test bundles, at the same
versions. specimen migrate --helpers switches the imports, one at a
time, and shows the change before it writes.
specimen run --retry # every story: render, play, accessibility
specimen a11y # axe at a checkpoint, with reasons for exceptions
specimen themes # a screen that ignores the theme, undeclared
specimen pack-check # committed component records that have drifted
import { createSpecimenBench } from '@lushly-dev/specimen';
import { createSpecimenCommands } from '@lushly-dev/specimen-afd';
const bench = await createSpecimenBench({ root: process.cwd() });
const commands = createSpecimenCommands(bench);
// Pass commands to an AFD MCP host. Its owner must await bench.close().
Specimen runs a story the way Storybook's test runner does: compose the annotations, render, run the play, then check accessibility with axe. A story that leans on something Specimen does not reproduce fails. It is never run without it.
A component pack is one JSON file for each component and one for the library's shared rules. Specimen builds it from the cases you already run, and every fact in it carries a basis: verified, observed, declared or authored.
specimen pack
Runs every case twice and writes the records. A case that fails, or shows something different in each pass, contributes nothing.
specimen pack-check
Builds the same way, writes nothing, and exits 1 when a committed record differs. This is the drift check for CI.
specimen pack-export ./dist
Adds a catalog with a digest for every record, from the committed files alone. It needs no browser.
The names come from the command definitions loaded on this page.
npm install --save-dev @lushly-dev/specimen-cli@preview
npx playwright install --only-shell chromium
npm install @lushly-dev/specimen@preview zod
npm install @lushly-dev/specimen-afd@preview @lushly-dev/afd-core @lushly-dev/afd-server zod
Preview. On npm under the preview tag, with prebuilt
hosts for macOS and for Linux on glibc. On Windows the host builds from source
until its package is released. It runs in Chromium only. A diff compares
structure, and pixel comparison exists only in the theme audit. The first render
that cannot find the browser names the version to install.