DesignLatch compares expected design token values with computed styles from a live product surface.
It currently ships two user-facing adapters:
@designlatch/clifor file-based workflows, Playwright collection, and HTML reports@designlatch/mcpfor AI-agent workflows overstdiowith inline JSON inputs
@designlatch/core- pure validation, token resolution, compare, evaluate, and scoring logic
@designlatch/app- shared in-memory workflows used by both adapters
@designlatch/cliinit,collect,validate,scan, andserve
@designlatch/mcpstdioMCP server withvalidate_inputsandscan_compliance
Use the CLI when you want:
- file-based inputs
- Playwright collection from a live site
- offline JSON and HTML reports
- a local report server
Use MCP when you want:
- AI-agent integration
- inline JSON inputs already held in memory
- JSON-only results
- no file workflow and no Playwright dependency
DesignLatch keeps the engine and adapters separated:
core <- app <- cli
core <- app <- mcp
The CLI and MCP packages are sibling adapters. Neither depends on the other.
npm install -D @designlatch/cli
npx designlatch helpnpx designlatch init --forceEdit .designlatch.json so it contains your real URL, selectors, and property rules.
--config accepts either:
- a single JSON config file such as
.designlatch.json - a directory such as
test_componentsthat contains multiple.jsonconfig files
Example directory-based scan:
npx designlatch scan --config test_components --tokens designlatch/tokens.json --snapshots designlatch/snapshots.json --report-dir reportRecommended naming for split config files:
button.test.jsoncard.test.jsonform.test.json
Directory merge behavior:
- all
.jsonfiles in the directory are included - files are merged in alphabetical filename order
rulesarrays are concatenatedurl,thresholds, anddefaultscome from the first file in sorted order
Create designlatch/tokens.json manually.
Example:
{
"color.primary": { "kind": "color", "rgba": { "r": 17, "g": 17, "b": 17, "a": 1 } },
"space.md": { "kind": "dimension", "value": 16, "unit": "px" }
}npx designlatch collect --config .designlatch.json --url https://app.example.com --out designlatch/snapshots.json --wait-for "body"
npx designlatch collect --config test_components --url https://app.example.com --out designlatch/snapshots.json --wait-for "body"If Chromium is missing:
npx playwright install chromiumValidate inputs only:
npx designlatch validate --config .designlatch.json --tokens designlatch/tokens.json --snapshots designlatch/snapshots.json
npx designlatch validate --config test_components --tokens designlatch/tokens.json --snapshots designlatch/snapshots.jsonRun the compliance scan:
npx designlatch scan --config .designlatch.json --tokens designlatch/tokens.json --snapshots designlatch/snapshots.json --report-dir report
npx designlatch scan --config test_components --tokens designlatch/tokens.json --snapshots designlatch/snapshots.json --report-dir reportThis writes:
report/report.jsonreport/index.html
npx designlatch serve --report-dir reportInstall the MCP adapter:
npm install -D @designlatch/mcpRun the MCP server:
npx designlatch-mcpMCP v1 characteristics:
- transport:
stdioonly - input mode: inline JSON
- output mode: JSON only
- no
collecttool
Exposed MCP tools:
validate_inputsscan_compliance
Use MCP when your agent already has config, tokens, and snapshots as JSON and only needs validation or compliance scan results.
Create starter config and template files.
npx designlatch init --forceCapture computed styles from the live site.
npx designlatch collect --config .designlatch.json --url https://app.example.com --out designlatch/snapshots.json --wait-for "body"
npx designlatch collect --config test_components --url https://app.example.com --out designlatch/snapshots.json --wait-for "body"Useful flags:
--timeout-ms <ms>--headed
Validate config, tokens, and snapshots without running the compare engine.
npx designlatch validate --config .designlatch.json --tokens designlatch/tokens.json --snapshots designlatch/snapshots.json
npx designlatch validate --config test_components --tokens designlatch/tokens.json --snapshots designlatch/snapshots.jsonRun the compliance engine and generate reports.
npx designlatch scan --config .designlatch.json --tokens designlatch/tokens.json --snapshots designlatch/snapshots.json --report-dir report
npx designlatch scan --config test_components --tokens designlatch/tokens.json --snapshots designlatch/snapshots.json --report-dir reportOptional diff flow:
npx designlatch scan --config .designlatch.json --tokens designlatch/tokens.json --snapshots designlatch/snapshots.json --baseline report/report.json --diff-out diff.jsonServe a generated report directory or specific HTML file.
npx designlatch serve --report-dir report
npx designlatch serve --file report/index.html --no-openMaps selectors to token-backed expectations.
{
"url": "https://app.example.com",
"rules": [
{
"id": "primary-button",
"selector": ".btn-primary",
"properties": {
"backgroundColor": { "token": "color.primary", "tolerance": { "kind": "rgba", "value": 0 } },
"padding": { "token": "space.md", "tolerance": { "kind": "px", "value": 1 } }
}
}
]
}The expected design values.
The computed styles collected from the live site.