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---56# Schema validator78A 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.910## Context1112Token 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.1314Schema 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.1516This 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?1718## Boundaries1920This 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.2122---2324## Configuration2526Check for `.ds-ops-config.yml` in the project root. If present, load:27- `system.token_format` — pre-selects the primary format to validate against (dtcg, style-dictionary-v3, style-dictionary-v4, tokens-studio, custom)28- `integrations.style_dictionary` — if enabled, use Style Dictionary's built-in validation as a cross-check29- `severity.schema_*` — overrides for finding severity (e.g. `schema_missing_type: critical`)3031## Auto-pull integrations3233**Style Dictionary v4** (`integrations.style_dictionary.enabled: true`):34- Run `npx style-dictionary build --config [path] --dry-run` to get Style Dictionary's own validation errors35- Cross-reference Style Dictionary errors with this skill's findings for completeness3637If no config exists, proceed with defaults.3839---4041## Step 1: Identify files and target format4243Ask for or confirm:44451. **Path to token files** — directory or specific files to validate462. **Target format** — which specification to validate against:47 - **DTCG 2025.10** (W3C Design Token Community Group specification)48 - **Style Dictionary v3** (legacy JSON with `value` property)49 - **Style Dictionary v4** (JSON with DTCG alignment, `$value` property)50 - **Tokens Studio** (Figma Tokens plugin export format)51 - **Custom** — if custom, ask for the schema or describe the expected structure523. **Strictness level** — strict (every violation is an error) or lenient (warnings for non-critical issues)5354If the token files contain format indicators (e.g., `$type` fields suggest DTCG), auto-detect the format and confirm with the user.5556## Step 2: Parse and inventory5758For each file in the provided path:59601. **Attempt to parse** — JSON, YAML, JS module, or CSS custom properties612. **Record parse status** — parsed successfully, failed with error, or empty file623. **Count tokens** — total token definitions found634. **Identify format signals** — which format the file appears to use (based on property names, structure)6465Produce the file inventory:6667| File | Format detected | Tokens | Parse status |68|------|----------------|--------|-------------|69| colors.json | DTCG 2025.10 | 47 | ✓ Parsed |70| spacing.json | Style Dictionary v3 | 12 | ✓ Parsed |71| broken.json | Unknown | 0 | ✗ Parse error: unexpected token at line 23 |7273## Step 3: Validate against target format7475For each successfully parsed file, run format-specific validation:7677### DTCG 2025.10 checks78791. **$value required** — every leaf token must have a `$value` property802. **$type present** — every token must declare `$type` (or inherit from a parent group's `$type`)813. **$type values valid** — must be one of: color, dimension, fontFamily, fontWeight, duration, cubicBezier, number, strokeStyle, border, transition, shadow, gradient, typography, fontStyle824. **$description optional but typed** — if present, must be a string835. **Alias syntax correct** — aliases must use `{group.token}` syntax with curly braces846. **Alias targets exist** — every alias must resolve to a real token (no broken references)857. **No circular aliases** — alias chain must terminate at a concrete value868. **Composite token structure** — composite types (border, shadow, typography, transition, gradient) must have correct sub-properties879. **Color values valid** — hex, RGB, HSL, or named colour that resolves correctly8810. **Dimension values valid** — number + unit (px, rem, em, etc.)8911. **Group $type inheritance** — if a group declares `$type`, all children without their own `$type` inherit it9012. **No `$` prefix on non-spec properties** — custom properties should not start with `$` to avoid confusion with spec properties9113. **Extensions namespace** — custom metadata should live under `$extensions` if present9293### Style Dictionary v3 checks94951. **`value` required** — every leaf token must have a `value` property (not `$value`)962. **Reference syntax** — aliases use `{group.token.value}` with `.value` suffix973. **Reference resolution** — all references resolve to existing tokens984. **Category-Type-Item (CTI)** — if using CTI convention, validate hierarchy consistency995. **No reserved property collisions** — `value`, `original`, `name`, `comment`, `themeable`, `attributes` are reserved100101### Style Dictionary v4 checks102103All DTCG checks above, plus:1041. **DTCG alignment** — v4 uses `$value` and `$type` (not legacy `value`)1052. **Preprocessor compatibility** — if preprocessors are configured, validate custom property shapes1063. **Platform-specific overrides** — if present, validate they follow the platform config schema107108### Tokens Studio checks1091101. **Group hierarchy preserved** — nested groups maintain parent-child relationships1112. **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)1123. **Math expressions valid** — if tokens use math expressions (`{size.base} * 2`), validate syntax1134. **Reference syntax** — uses `{group.token}` without `.value` suffix1145. **Set structure** — if multi-set, validate set names and token assignments1156. **Theme configuration** — if themes are defined, validate theme-to-set mappings116117## Step 4: Cross-format consistency118119If files use multiple formats (common during migration):1201211. **Identify format boundaries** — which files are which format1222. **Flag inconsistencies** — same token in two formats with different values1233. **Migration readiness** — if migrating from v3 to DTCG, how many files still need conversion124125## Step 5: Produce the validation report126127Structure the report as:128129```130# Token Schema Validation Report131132## Summary133- Files scanned: X134- Files valid: Y135- Files with errors: Z136- Target format: [DTCG 2025.10 / Style Dictionary v3 / etc.]137- Strictness: [strict / lenient]138139## File Inventory140[Table from Step 2]141142## Validation Results143144### ✓ Valid Files145[List each valid file with token count]146147### ✗ Files with Errors148149#### [filename.json]150| # | Check | Status | Detail | Fix |151|---|-------|--------|--------|-----|152| 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 |153| 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}` |154155### ⚠️ Warnings156[Non-critical issues: missing $description, custom $ properties, etc.]157158## Format Compliance Score159- DTCG 2025.10: X% compliant (Y/Z checks pass)160- [If migrating] Legacy tokens remaining: N files, M tokens161162## Recommendations163[Prioritised list of fixes, grouped by: parse errors first, then broken references, then missing declarations]164```165166## Step 6: Produce machine-readable output (optional)167168If the user requests it or if the output will feed into another tool:169170```json171{172 "format": "dtcg-2025.10",173 "files_scanned": 12,174 "files_valid": 10,175 "files_invalid": 2,176 "findings": [177 {178 "id": "SV-01",179 "file": "colors.json",180 "token": "color.brand.accent",181 "check": "$type_required",182 "status": "FAIL",183 "fix": "Add $type: \"color\""184 }185 ]186}187```188189---190191## Quality checks192193Before delivering the report, verify:1941951. **Every file in the path was scanned** — no files skipped without explanation1962. **Parse errors include line numbers or error positions** — not just "invalid JSON"1973. **Fix suggestions are specific and copy-pasteable** — not "add the missing type" but "add `$type: \"color\"` to token `color.brand.accent`1984. **Compliance summary denominator matches total applicable checks** — if a check doesn't apply (e.g., no composite tokens), it's excluded from the count1995. **Alias chains are fully traced** — broken reference errors identify the full chain, not just the immediate reference2006. **Cross-format issues are flagged** — if the same token exists in two files with different formats, this is noted2017. **Findings reference specific token names and file paths** — never "some tokens are missing types"202203## Small-system note204205For 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.