Schema validator
A skill for validating that design token files conform to their expected format — DTCG 2025.10, Style Dictionary v3/v4, Tokens Studio, or a custom schema. Catches structural issues before they break build pipelines, cause silent failures, or produce incorrect output.
Context
Token files are infrastructure. When a token file is malformed — a missing $type declaration, a $value that resolves to nothing, an alias that points to a deleted token — the failure mode is rarely loud. The build might still succeed. The wrong value might ship. The design intent might be silently lost.
Schema validation is the first line of defence. It answers a simple question: do these files meet the structural contract they claim to meet? A DTCG file must have $value on every token. A Style Dictionary file must have valid reference syntax. A Tokens Studio export must preserve group hierarchy.
This skill is not about naming conventions or architectural quality — those belong in token-audit. This skill is about structural integrity: can the file be parsed, transformed, and consumed by downstream tools without error?
Boundaries
This skill validates token file structure only. It does not assess naming quality (use naming-audit), token architecture health (use token-audit), or token usage in code (use token-compliance). If the token source format is not recognisable as DTCG, Style Dictionary, Tokens Studio, or a declared custom schema, ask the user to identify the format before proceeding. If no token files are provided or accessible, there is nothing to validate — stop and confirm the file location with the user.
Configuration
Check for .ds-ops-config.yml in the project root. If present, load:
system.token_format — pre-selects the primary format to validate against (dtcg, style-dictionary-v3, style-dictionary-v4, tokens-studio, custom)
integrations.style_dictionary — if enabled, use Style Dictionary's built-in validation as a cross-check
severity.schema_* — overrides for finding severity (e.g. schema_missing_type: critical)
Auto-pull integrations
Style Dictionary v4 (integrations.style_dictionary.enabled: true):
- Run
npx style-dictionary build --config [path] --dry-run to get Style Dictionary's own validation errors
- Cross-reference Style Dictionary errors with this skill's findings for completeness
If no config exists, proceed with defaults.
Step 1: Identify files and target format
Ask for or confirm:
- Path to token files — directory or specific files to validate
- Target format — which specification to validate against:
- DTCG 2025.10 (W3C Design Token Community Group specification)
- Style Dictionary v3 (legacy JSON with
value property)
- Style Dictionary v4 (JSON with DTCG alignment,
$value property)
- Tokens Studio (Figma Tokens plugin export format)
- Custom — if custom, ask for the schema or describe the expected structure
- Strictness level — strict (every violation is an error) or lenient (warnings for non-critical issues)
If the token files contain format indicators (e.g., $type fields suggest DTCG), auto-detect the format and confirm with the user.
Step 2: Parse and inventory
For each file in the provided path:
- Attempt to parse — JSON, YAML, JS module, or CSS custom properties
- Record parse status — parsed successfully, failed with error, or empty file
- Count tokens — total token definitions found
- Identify format signals — which format the file appears to use (based on property names, structure)
Produce the file inventory:
| File |
Format detected |
Tokens |
Parse status |
| colors.json |
DTCG 2025.10 |
47 |
✓ Parsed |
| spacing.json |
Style Dictionary v3 |
12 |
✓ Parsed |
| broken.json |
Unknown |
0 |
✗ Parse error: unexpected token at line 23 |
Step 3: Validate against target format
For each successfully parsed file, run format-specific validation:
DTCG 2025.10 checks
- $value required — every leaf token must have a
$value property
- $type present — every token must declare
$type (or inherit from a parent group's $type)
- $type values valid — must be one of: color, dimension, fontFamily, fontWeight, duration, cubicBezier, number, strokeStyle, border, transition, shadow, gradient, typography, fontStyle
- $description optional but typed — if present, must be a string
- Alias syntax correct — aliases must use
{group.token} syntax with curly braces
- Alias targets exist — every alias must resolve to a real token (no broken references)
- No circular aliases — alias chain must terminate at a concrete value
- Composite token structure — composite types (border, shadow, typography, transition, gradient) must have correct sub-properties
- Color values valid — hex, RGB, HSL, or named colour that resolves correctly
- Dimension values valid — number + unit (px, rem, em, etc.)
- Group $type inheritance — if a group declares
$type, all children without their own $type inherit it
- No
$ prefix on non-spec properties — custom properties should not start with $ to avoid confusion with spec properties
- Extensions namespace — custom metadata should live under
$extensions if present
Style Dictionary v3 checks
value required — every leaf token must have a value property (not $value)
- Reference syntax — aliases use
{group.token.value} with .value suffix
- Reference resolution — all references resolve to existing tokens
- Category-Type-Item (CTI) — if using CTI convention, validate hierarchy consistency
- No reserved property collisions —
value, original, name, comment, themeable, attributes are reserved
Style Dictionary v4 checks
All DTCG checks above, plus:
- DTCG alignment — v4 uses
$value and $type (not legacy value)
- Preprocessor compatibility — if preprocessors are configured, validate custom property shapes
- Platform-specific overrides — if present, validate they follow the platform config schema
Tokens Studio checks
- Group hierarchy preserved — nested groups maintain parent-child relationships
- Token types valid — type field matches Tokens Studio's type system (color, borderRadius, sizing, spacing, opacity, borderWidth, boxShadow, fontFamilies, fontWeights, lineHeights, fontSizes, letterSpacing, paragraphSpacing, textDecoration, textCase, composition, other)
- Math expressions valid — if tokens use math expressions (
{size.base} * 2), validate syntax
- Reference syntax — uses
{group.token} without .value suffix
- Set structure — if multi-set, validate set names and token assignments
- Theme configuration — if themes are defined, validate theme-to-set mappings
Step 4: Cross-format consistency
If files use multiple formats (common during migration):
- Identify format boundaries — which files are which format
- Flag inconsistencies — same token in two formats with different values
- Migration readiness — if migrating from v3 to DTCG, how many files still need conversion
Step 5: Produce the validation report
Structure the report as:
# Token Schema Validation Report
## Summary
- Files scanned: X
- Files valid: Y
- Files with errors: Z
- Target format: [DTCG 2025.10 / Style Dictionary v3 / etc.]
- Strictness: [strict / lenient]
## File Inventory
[Table from Step 2]
## Validation Results
### ✓ Valid Files
[List each valid file with token count]
### ✗ Files with Errors
#### [filename.json]
| # | Check | Status | Detail | Fix |
|---|-------|--------|--------|-----|
| SV-01 | $type required | ❌ FAIL | 3 tokens missing $type: `color.brand.accent`, `spacing.page.gutter`, `font.body.size` | Add `$type: "color"`, `$type: "dimension"`, `$type: "fontFamily"` respectively |
| SV-02 | Alias resolution | ❌ FAIL | `{color.legacy.blue}` referenced by `color.semantic.info` does not exist | Either create `color.legacy.blue` or update the reference to `{color.primitive.blue.500}` |
### ⚠️ Warnings
[Non-critical issues: missing $description, custom $ properties, etc.]
## Format Compliance Score
- DTCG 2025.10: X% compliant (Y/Z checks pass)
- [If migrating] Legacy tokens remaining: N files, M tokens
## Recommendations
[Prioritised list of fixes, grouped by: parse errors first, then broken references, then missing declarations]
Step 6: Produce machine-readable output (optional)
If the user requests it or if the output will feed into another tool:
{
"format": "dtcg-2025.10",
"files_scanned": 12,
"files_valid": 10,
"files_invalid": 2,
"findings": [
{
"id": "SV-01",
"file": "colors.json",
"token": "color.brand.accent",
"check": "$type_required",
"status": "FAIL",
"fix": "Add $type: \"color\""
}
]
}
Quality checks
Before delivering the report, verify:
- Every file in the path was scanned — no files skipped without explanation
- Parse errors include line numbers or error positions — not just "invalid JSON"
- Fix suggestions are specific and copy-pasteable — not "add the missing type" but "add
$type: \"color\" to token color.brand.accent
- Compliance summary denominator matches total applicable checks — if a check doesn't apply (e.g., no composite tokens), it's excluded from the count
- Alias chains are fully traced — broken reference errors identify the full chain, not just the immediate reference
- Cross-format issues are flagged — if the same token exists in two files with different formats, this is noted
- Findings reference specific token names and file paths — never "some tokens are missing types"
Small-system note
For systems with fewer than 5 token files: run the same validation but present results as a single-page summary rather than a per-file breakdown. Include the specific fix for every single issue rather than grouping by pattern.
1---2name: schema-validator3description: Validate token files against DTCG 2025.10, Style Dictionary, or custom schemas. Trigger when someone says: validate token JSON, check my token files for errors, schema validation for tokens, are my token files valid, DTCG compliance check, validate token format, or anything about checking whether token files are structurally correct before they break builds.4---5# Schema validator67A skill for validating that design token files conform to their expected format — DTCG 2025.10, Style Dictionary v3/v4, Tokens Studio, or a custom schema. Catches structural issues before they break build pipelines, cause silent failures, or produce incorrect output.89## Context1011Token files are infrastructure. When a token file is malformed — a missing `$type` declaration, a `$value` that resolves to nothing, an alias that points to a deleted token — the failure mode is rarely loud. The build might still succeed. The wrong value might ship. The design intent might be silently lost.1213Schema validation is the first line of defence. It answers a simple question: do these files meet the structural contract they claim to meet? A DTCG file must have `$value` on every token. A Style Dictionary file must have valid reference syntax. A Tokens Studio export must preserve group hierarchy.1415This skill is not about naming conventions or architectural quality — those belong in `token-audit`. This skill is about structural integrity: can the file be parsed, transformed, and consumed by downstream tools without error?1617## Boundaries1819This skill validates token file structure only. It does not assess naming quality (use `naming-audit`), token architecture health (use `token-audit`), or token usage in code (use `token-compliance`). If the token source format is not recognisable as DTCG, Style Dictionary, Tokens Studio, or a declared custom schema, ask the user to identify the format before proceeding. If no token files are provided or accessible, there is nothing to validate — stop and confirm the file location with the user.2021---2223## Configuration2425Check for `.ds-ops-config.yml` in the project root. If present, load:26- `system.token_format` — pre-selects the primary format to validate against (dtcg, style-dictionary-v3, style-dictionary-v4, tokens-studio, custom)27- `integrations.style_dictionary` — if enabled, use Style Dictionary's built-in validation as a cross-check28- `severity.schema_*` — overrides for finding severity (e.g. `schema_missing_type: critical`)2930## Auto-pull integrations3132**Style Dictionary v4** (`integrations.style_dictionary.enabled: true`):33- Run `npx style-dictionary build --config [path] --dry-run` to get Style Dictionary's own validation errors34- Cross-reference Style Dictionary errors with this skill's findings for completeness3536If no config exists, proceed with defaults.3738---3940## Step 1: Identify files and target format4142Ask for or confirm:43441. **Path to token files** — directory or specific files to validate452. **Target format** — which specification to validate against:46 - **DTCG 2025.10** (W3C Design Token Community Group specification)47 - **Style Dictionary v3** (legacy JSON with `value` property)48 - **Style Dictionary v4** (JSON with DTCG alignment, `$value` property)49 - **Tokens Studio** (Figma Tokens plugin export format)50 - **Custom** — if custom, ask for the schema or describe the expected structure513. **Strictness level** — strict (every violation is an error) or lenient (warnings for non-critical issues)5253If the token files contain format indicators (e.g., `$type` fields suggest DTCG), auto-detect the format and confirm with the user.5455## Step 2: Parse and inventory5657For each file in the provided path:58591. **Attempt to parse** — JSON, YAML, JS module, or CSS custom properties602. **Record parse status** — parsed successfully, failed with error, or empty file613. **Count tokens** — total token definitions found624. **Identify format signals** — which format the file appears to use (based on property names, structure)6364Produce the file inventory:6566| File | Format detected | Tokens | Parse status |67|------|----------------|--------|-------------|68| colors.json | DTCG 2025.10 | 47 | ✓ Parsed |69| spacing.json | Style Dictionary v3 | 12 | ✓ Parsed |70| broken.json | Unknown | 0 | ✗ Parse error: unexpected token at line 23 |7172## Step 3: Validate against target format7374For each successfully parsed file, run format-specific validation:7576### DTCG 2025.10 checks77781. **$value required** — every leaf token must have a `$value` property792. **$type present** — every token must declare `$type` (or inherit from a parent group's `$type`)803. **$type values valid** — must be one of: color, dimension, fontFamily, fontWeight, duration, cubicBezier, number, strokeStyle, border, transition, shadow, gradient, typography, fontStyle814. **$description optional but typed** — if present, must be a string825. **Alias syntax correct** — aliases must use `{group.token}` syntax with curly braces836. **Alias targets exist** — every alias must resolve to a real token (no broken references)847. **No circular aliases** — alias chain must terminate at a concrete value858. **Composite token structure** — composite types (border, shadow, typography, transition, gradient) must have correct sub-properties869. **Color values valid** — hex, RGB, HSL, or named colour that resolves correctly8710. **Dimension values valid** — number + unit (px, rem, em, etc.)8811. **Group $type inheritance** — if a group declares `$type`, all children without their own `$type` inherit it8912. **No `$` prefix on non-spec properties** — custom properties should not start with `$` to avoid confusion with spec properties9013. **Extensions namespace** — custom metadata should live under `$extensions` if present9192### Style Dictionary v3 checks93941. **`value` required** — every leaf token must have a `value` property (not `$value`)952. **Reference syntax** — aliases use `{group.token.value}` with `.value` suffix963. **Reference resolution** — all references resolve to existing tokens974. **Category-Type-Item (CTI)** — if using CTI convention, validate hierarchy consistency985. **No reserved property collisions** — `value`, `original`, `name`, `comment`, `themeable`, `attributes` are reserved99100### Style Dictionary v4 checks101102All DTCG checks above, plus:1031. **DTCG alignment** — v4 uses `$value` and `$type` (not legacy `value`)1042. **Preprocessor compatibility** — if preprocessors are configured, validate custom property shapes1053. **Platform-specific overrides** — if present, validate they follow the platform config schema106107### Tokens Studio checks1081091. **Group hierarchy preserved** — nested groups maintain parent-child relationships1102. **Token types valid** — type field matches Tokens Studio's type system (color, borderRadius, sizing, spacing, opacity, borderWidth, boxShadow, fontFamilies, fontWeights, lineHeights, fontSizes, letterSpacing, paragraphSpacing, textDecoration, textCase, composition, other)1113. **Math expressions valid** — if tokens use math expressions (`{size.base} * 2`), validate syntax1124. **Reference syntax** — uses `{group.token}` without `.value` suffix1135. **Set structure** — if multi-set, validate set names and token assignments1146. **Theme configuration** — if themes are defined, validate theme-to-set mappings115116## Step 4: Cross-format consistency117118If files use multiple formats (common during migration):1191201. **Identify format boundaries** — which files are which format1212. **Flag inconsistencies** — same token in two formats with different values1223. **Migration readiness** — if migrating from v3 to DTCG, how many files still need conversion123124## Step 5: Produce the validation report125126Structure the report as:127128```129# Token Schema Validation Report130131## Summary132- Files scanned: X133- Files valid: Y134- Files with errors: Z135- Target format: [DTCG 2025.10 / Style Dictionary v3 / etc.]136- Strictness: [strict / lenient]137138## File Inventory139[Table from Step 2]140141## Validation Results142143### ✓ Valid Files144[List each valid file with token count]145146### ✗ Files with Errors147148#### [filename.json]149| # | Check | Status | Detail | Fix |150|---|-------|--------|--------|-----|151| SV-01 | $type required | ❌ FAIL | 3 tokens missing $type: `color.brand.accent`, `spacing.page.gutter`, `font.body.size` | Add `$type: "color"`, `$type: "dimension"`, `$type: "fontFamily"` respectively |152| SV-02 | Alias resolution | ❌ FAIL | `{color.legacy.blue}` referenced by `color.semantic.info` does not exist | Either create `color.legacy.blue` or update the reference to `{color.primitive.blue.500}` |153154### ⚠️ Warnings155[Non-critical issues: missing $description, custom $ properties, etc.]156157## Format Compliance Score158- DTCG 2025.10: X% compliant (Y/Z checks pass)159- [If migrating] Legacy tokens remaining: N files, M tokens160161## Recommendations162[Prioritised list of fixes, grouped by: parse errors first, then broken references, then missing declarations]163```164165## Step 6: Produce machine-readable output (optional)166167If the user requests it or if the output will feed into another tool:168169```json170{171 "format": "dtcg-2025.10",172 "files_scanned": 12,173 "files_valid": 10,174 "files_invalid": 2,175 "findings": [176 {177 "id": "SV-01",178 "file": "colors.json",179 "token": "color.brand.accent",180 "check": "$type_required",181 "status": "FAIL",182 "fix": "Add $type: \"color\""183 }184 ]185}186```187188---189190## Quality checks191192Before delivering the report, verify:1931941. **Every file in the path was scanned** — no files skipped without explanation1952. **Parse errors include line numbers or error positions** — not just "invalid JSON"1963. **Fix suggestions are specific and copy-pasteable** — not "add the missing type" but "add `$type: \"color\"` to token `color.brand.accent`1974. **Compliance summary denominator matches total applicable checks** — if a check doesn't apply (e.g., no composite tokens), it's excluded from the count1985. **Alias chains are fully traced** — broken reference errors identify the full chain, not just the immediate reference1996. **Cross-format issues are flagged** — if the same token exists in two files with different formats, this is noted2007. **Findings reference specific token names and file paths** — never "some tokens are missing types"201202## Small-system note203204For systems with fewer than 5 token files: run the same validation but present results as a single-page summary rather than a per-file breakdown. Include the specific fix for every single issue rather than grouping by pattern.