Overview
Validate DESIGN.md files before using them as design-system source of truth. Prefer the bundled script for repeatable checks, then interpret the JSON findings into concrete fixes.
Quick Start
Run the validator against one file:
node .codex/skills/design-md-validator/scripts/validate_design_md.mjs DESIGN.md
Scan the current tree for likely DESIGN.md files:
node .codex/skills/design-md-validator/scripts/validate_design_md.mjs --discover .
Compare two versions for regressions:
node .codex/skills/design-md-validator/scripts/validate_design_md.mjs DESIGN.md --diff-before DESIGN.old.md
The script is a Node/npx wrapper around npx --yes @google/design.md, so Node/npm must be available. It returns nonzero when errors exist, or when warnings exist with --strict-warnings.
Workflow
- Locate the target file. Use
--discoverwhen the user says "check design.md" without naming a path. - Run the bundled validator. Use raw
npx @google/design.md lint --format json <file>only if the wrapper is unavailable. - Treat
summary.errors > 0as blocking. Fix errors before addressing warnings. - Explain warnings as design-system quality risks, not syntax failures.
- Re-run validation after edits and report the final error/warning/info counts.
- For migrations or updates, run
--diff-beforeand treatregression: trueas blocking unless the user explicitly accepts it.
Finding Triage
broken-referror: define the missing token or update the reference path.- Unknown component sub-token warning: rename to one of
backgroundColor,textColor,typography,rounded,padding,size,height, orwidth, unless preserving a domain-specific extension is intentional. missing-primarywarning: addcolors.primaryor document why another color role is the main brand color.missing-typographywarning: add at least one typography token withfontFamilyandfontSize.contrast-ratiowarning: adjust componentbackgroundColorortextColorto meet WCAG AA 4.5:1 for normal text.section-orderwarning: reorder known##sections to match the canonical sequence.orphaned-tokenswarning: either reference the token from components or remove it if unused.
Reference
references/design-md-spec-summary.md— schema, canonical section order, accepted component properties, CLI command reference.references/lint-rules.md— per-rule fix recipes for each of the eight lint rules.references/spec-checklist.md— manual review checklist for offline / sandboxed environments wherenpxcannot reach the registry.
Known CLI quirks
- The
summaryblock keys observed from the live CLI areerrors,warnings, andinfos(plural). The upstream README documents this asinfo(singular). Read both keys defensively when parsing JSON directly:summary.infos ?? summary.info ?? 0. - Color values inside
components.*may bergba(...)literals (used for glass surfaces). Don't treat these as broken — they're accepted there even thoughcolors.*only allows#RRGGBB. npx --yes @google/design.mddoes the install on first run; expect a 5-30s delay on a cold cache. The bundled wrapper waits for completion; if a caller hits a fixed timeout, retry once before treating the CLI as unreachable.
Output
When reporting results, include:
- File path checked.
- Error, warning, and info counts.
- The highest-severity findings with paths.
- Exact fixes made, if any.
- Verification command rerun after edits.