name: design-token-alias-validation
description: Audit DTCG 2025.10 design-token alias chains offline across curly-brace references, JSON Pointer $ref, $extends, group $type inheritance, cycles, missing targets, and type mismatches.
category: Document Processing
source: antigravity
tags: [python, node, api, ai, agent, design, document, tailwind, rag, cro]
url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/design-token-alias-validation
Design Token Alias Validation
Overview
Validate a focused subset of the Design Tokens Community Group (DTCG) Format Module 2025.10 offline using jsonschema==4.26.0 and referencing==0.37.0: verifies curly-brace {group.token} aliases, RFC 6901 JSON Pointer $ref references, group $type and $extends inheritance, multi-hop alias resolution inside leaf and composite values, circular reference detection, missing alias targets, and incompatible resolved token types.
Distinction from existing design and token skills:
ui-tokens: manages StyleSeed Next.js/Tailwind v4 token files (tokens/*.json mapped to css/theme.css @theme inline) rather than DTCG 2025.10 token validation.
design-how-token-mapping: produces read-only styling audits mapping hardcoded CSS values to semantic CSS variables using OKLCH delta-E rather than DTCG JSON alias/pointer validation.
design-theme-guide: creates business palette/typography registers rather than resolving DTCG $value/$type/$ref alias graphs.
design-system and design-token-contrast: cover frontend layout invariants and WCAG CSS contrast auditing rather than DTCG 2025.10 JSON reference graphs.
When to Use
- Validating DTCG
2025.10 token JSON bundles in CI before exporting CSS/iOS/Android platform artifacts.
- Catching broken token aliases (
{color.missing} or {"$ref": "#/color/missing/$value"}), circular loops (a -> b -> a), or type errors (dimension token aliasing a color token).
- Auditing inherited group
$type and $extends overrides across light/semantic token layers.
- Do not use this skill to treat Style Dictionary v3, Figma Variables exports, or CSS custom properties as universally DTCG
2025.10 compliant without confirming spec conformance.
Prerequisites
- Python
3.10+ with jsonschema, referencing, and pytest (tested with Python 3.12.10, jsonschema==4.26.0, referencing==0.37.0, pytest==9.1.1).
- Local DTCG
2025.10 JSON token document(s).
- No network requests, Figma credentials, or platform build steps required.
How It Works
1. Documented DTCG 2025.10 implemented subset
This validator explicitly implements and documents the following DTCG 2025.10 subset (without claiming full DTCG Resolver Module .resolver.json context evaluation or external URI fetching):
- Token leaf nodes require both an effective
$type (inherited from nearest ancestor group $type or explicit string on the token) and either $value or token-level $ref. Untyped leaf tokens (MISSING_TOKEN_TYPE) and non-string $type values fail explicitly; unrecognized string $type values return UNSUPPORTED.
- Group inheritance via
$extends ("{group.path}" or {"$ref": "#/group/path"}) performs recursive deep-merge with bounded nesting/extends depth (64) so overriding nested subgroups preserves deeper sibling tokens.
- Structured DTCG
2025.10 value validation (color objects with colorSpace + numeric/"none" components, dimension objects with numeric value + px/rem unit, shadow objects validated via a real referencing.Registry with jsonschema.Draft202012Validator); legacy CSS strings are rejected rather than treated as conformant DTCG 2025.10 values.
- Leaf and composite-field curly-brace references (
"{a.b.c}") and intra-document RFC 6901 JSON Pointer references ({"$ref": "#/a/b"} or {"$ref": "#/a/b/$value"}, decoding URI-fragment percent escapes, requiring canonical array indices, unescaping ~1/~0, validating ~ escape syntax, rejecting external non-# URIs as UNSUPPORTED).
2. Validate alias chains, cycles, and inherited types
Run the local verification suite in DTCG alias validation harness:
- Parse JSON cleanly (
INVALID_INPUT on invalid JSON or non-object root).
- Expand
$extends group inheritance with visited-path tracking and recursion bounds (CIRCULAR_EXTENDS / MISSING_ALIAS_TARGET / RESOLUTION_DEPTH_EXCEEDED).
- Compute each token's effective inherited
$type from nearest ancestor group $type -> token $type (bounding group tree nesting at 64).
- Resolve every
{path} and {"$ref": "#/..."} recursively across chains (a -> b -> c) and composite fields (shadow.color, border.width):
- Missing targets ->
MISSING_ALIAS_TARGET.
- Cycles across
{...}, $ref, or mixed references -> CIRCULAR_ALIAS.
- Target effective
$type differs from referencing token's effective $type -> INCOMPATIBLE_RESOLVED_TYPE.
- Unrecognized
$type -> UNSUPPORTED (UNSUPPORTED_TOKEN_TYPE).
Examples
Run the self-contained verification suite in DTCG alias validation harness:
User request: "Audit our tokens.json for DTCG 2025.10 curly-brace and JSON Pointer alias errors and type mismatches."
Inputs: Local DTCG 2025.10 JSON document with inherited group $type, $extends, {a.b}, and {"$ref": "#/a/b/$value"}.
1---2name: design-token-alias-validation3description: Audit DTCG 2025.10 design-token alias chains offline across curly-brace references, JSON Pointer $ref, $extends, group $type inheritance, cycles, missing target4---5---6name: design-token-alias-validation7description: Audit DTCG 2025.10 design-token alias chains offline across curly-brace references, JSON Pointer $ref, $extends, group $type inheritance, cycles, missing targets, and type mismatches. 8category: Document Processing9source: antigravity10tags: [python, node, api, ai, agent, design, document, tailwind, rag, cro]11url: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/design-token-alias-validation12---131415# Design Token Alias Validation1617## Overview1819Validate a focused subset of the **Design Tokens Community Group (DTCG) Format Module `2025.10`** offline using `jsonschema==4.26.0` and `referencing==0.37.0`: verifies curly-brace `{group.token}` aliases, RFC 6901 JSON Pointer `$ref` references, group `$type` and `$extends` inheritance, multi-hop alias resolution inside leaf and composite values, circular reference detection, missing alias targets, and incompatible resolved token types.2021Distinction from existing design and token skills:22- `ui-tokens`: manages StyleSeed Next.js/Tailwind v4 token files (`tokens/*.json` mapped to `css/theme.css` `@theme inline`) rather than DTCG `2025.10` token validation.23- `design-how-token-mapping`: produces read-only styling audits mapping hardcoded CSS values to semantic CSS variables using OKLCH delta-E rather than DTCG JSON alias/pointer validation.24- `design-theme-guide`: creates business palette/typography registers rather than resolving DTCG `$value`/`$type`/`$ref` alias graphs.25- `design-system` and `design-token-contrast`: cover frontend layout invariants and WCAG CSS contrast auditing rather than DTCG `2025.10` JSON reference graphs.2627## When to Use2829- Validating DTCG `2025.10` token JSON bundles in CI before exporting CSS/iOS/Android platform artifacts.30- Catching broken token aliases (`{color.missing}` or `{"$ref": "#/color/missing/$value"}`), circular loops (`a -> b -> a`), or type errors (`dimension` token aliasing a `color` token).31- Auditing inherited group `$type` and `$extends` overrides across light/semantic token layers.32- Do **not** use this skill to treat Style Dictionary v3, Figma Variables exports, or CSS custom properties as universally DTCG `2025.10` compliant without confirming spec conformance.3334## Prerequisites3536- Python `3.10+` with `jsonschema`, `referencing`, and `pytest` (tested with Python `3.12.10`, `jsonschema==4.26.0`, `referencing==0.37.0`, `pytest==9.1.1`).37- Local DTCG `2025.10` JSON token document(s).38- **No network requests, Figma credentials, or platform build steps required.**3940## How It Works4142### 1. Documented DTCG 2025.10 implemented subset4344This validator explicitly implements and documents the following DTCG `2025.10` subset (without claiming full DTCG Resolver Module `.resolver.json` context evaluation or external URI fetching):45- Token leaf nodes require both an effective `$type` (inherited from nearest ancestor group `$type` or explicit string on the token) and either `$value` or token-level `$ref`. Untyped leaf tokens (`MISSING_TOKEN_TYPE`) and non-string `$type` values fail explicitly; unrecognized string `$type` values return `UNSUPPORTED`.46- Group inheritance via `$extends` (`"{group.path}"` or `{"$ref": "#/group/path"}`) performs recursive deep-merge with bounded nesting/extends depth (`64`) so overriding nested subgroups preserves deeper sibling tokens.47- Structured DTCG `2025.10` value validation (`color` objects with `colorSpace` + numeric/`"none"` `components`, `dimension` objects with numeric `value` + `px`/`rem` `unit`, `shadow` objects validated via a real `referencing.Registry` with `jsonschema.Draft202012Validator`); legacy CSS strings are rejected rather than treated as conformant DTCG `2025.10` values.48- Leaf and composite-field curly-brace references (`"{a.b.c}"`) and intra-document RFC 6901 JSON Pointer references (`{"$ref": "#/a/b"}` or `{"$ref": "#/a/b/$value"}`, decoding URI-fragment percent escapes, requiring canonical array indices, unescaping `~1`/`~0`, validating `~` escape syntax, rejecting external non-`#` URIs as `UNSUPPORTED`).4950### 2. Validate alias chains, cycles, and inherited types5152Run the local verification suite in [DTCG alias validation harness](references/dtcg-alias-validation-harness.md):53541. Parse JSON cleanly (`INVALID_INPUT` on invalid JSON or non-object root).552. Expand `$extends` group inheritance with visited-path tracking and recursion bounds (`CIRCULAR_EXTENDS` / `MISSING_ALIAS_TARGET` / `RESOLUTION_DEPTH_EXCEEDED`).563. Compute each token's effective inherited `$type` from nearest ancestor group `$type` -> token `$type` (bounding group tree nesting at `64`).574. Resolve every `{path}` and `{"$ref": "#/..."}` recursively across chains (`a -> b -> c`) and composite fields (`shadow.color`, `border.width`):58 - Missing targets -> `MISSING_ALIAS_TARGET`.59 - Cycles across `{...}`, `$ref`, or mixed references -> `CIRCULAR_ALIAS`.60 - Target effective `$type` differs from referencing token's effective `$type` -> `INCOMPATIBLE_RESOLVED_TYPE`.61 - Unrecognized `$type` -> `UNSUPPORTED` (`UNSUPPORTED_TOKEN_TYPE`).6263## Examples6465Run the self-contained verification suite in [DTCG alias validation harness](references/dtcg-alias-validation-harness.md):6667```text68User request: "Audit our tokens.json for DTCG 2025.10 curly-brace and JSON Pointer alias errors and type mismatches."69Inputs: Local DTCG 2025.10 JSON document with inherited group $type, $extends, {a.b}, and {"$ref": "#/a/b/$value"}.