Stylebook CLI
Data Validation
Schema validation for brand data
Production
The Stylebook validates generated brand data against JSON Schemas
to protect the contract between generate and build.
Pipeline Position
brand/ → generate → output/ → **validate** → build → packages/
Validation runs after generate produces JSON and before build consumes it.
If validation fails, build does not proceed.
Running Validation
# Validate everything
stylebook validate
# Validate a single domain
stylebook validate --domain color
# Detailed output
stylebook validate --verbose
Via Taskfile: task validate. The task build command runs validation automatically.
Schema Structure
Schemas live in stylebook/domains/validator/schemas/.
Shared Schemas
| Schema | Purpose |
|---|---|
_envelope.json | Domain envelope: {metadata, config, data, artefacts} |
_metadata.json | Domain metadata: title, icon, version, description |
_doc.json | Documentation object pattern (progressively tightenable) |
Domain Schemas
Each domain has a schema validating its data key deeply:
| Domain | Schema File |
|---|---|
color | color.json |
logo | logo.json |
typography | typography.json |
voice | voice.json |
writing | writing.json |
accessibility | accessibility.json |
avatars | avatars.json |
imagery | imagery.json |
layout | layout.json |
messaging | messaging.json |
motion | motion.json |
Root Schema
brand.json validates the complete output/brand.json — root metadata keys
(brand, identity, audience, etc.) plus all domain keys referencing their
individual schemas.
Adding a New Domain
When adding a new domain to brand/:
- Create
stylebook/domains/validator/schemas/<domain>.json - Follow the pattern:
allOf: [{$ref: _envelope.json}]plusdataproperties - Inspect actual output:
uv run python -c "import json; print(json.dumps(json.load(open('output/data/<domain>.json'))['data'], indent=2))" - Run
stylebook validateto verify
Progressive Tightening
Schemas start matching current output and can be tightened over time:
- Phase 1 (current): Schemas match existing data structure
- Phase 2: Standardize
docobjects — requiredescriptioneverywhere - Phase 3: Tighten metadata — require
status,overview - Phase 4: Enforce naming conventions