design-md
Operates on DESIGN.md files — the Google Labs format that pairs a YAML token block with a Markdown rationale. The skill knows how to lint an existing file, diff two versions, export tokens to Tailwind or DTCG, and author a fresh DESIGN.md grounded in five Refero exemplars.
When To Use
Trigger this skill when the request involves any of the following:
- The user mentions "DESIGN.md", "design tokens", "design system spec", or "@google/design.md".
- The user asks to extract a design system from existing CSS, Tailwind config, or component code into a single source of truth.
- The user wants to lint, validate, or diff a DESIGN.md file.
- The user wants to export design tokens to Tailwind v3 (
json-tailwind), Tailwind v4 (css-tailwind), or W3C DTCG (dtcg).
- The user wants to author a fresh DESIGN.md and asks for examples or a starting point.
When Not To Use
- Generating UI components or page layouts from scratch — DESIGN.md is a token spec, not a component library.
- Auditing visuals for taste, polish, or AI-generation tells — that is
design-critique.
- Accessibility audits beyond contrast (axe / WCAG full-coverage). The DESIGN.md linter only checks
contrast-ratio on declared component pairs.
- Animation, motion, or breakpoint tokens — the format does not cover them.
Operations
The skill exposes four operations. They share one entry point: scripts/run_cli.sh, which pins the CLI version in a single place. Always invoke through the wrapper.
lint
Validate a DESIGN.md file's structure, references, and contrast.
bash <skill-dir>/scripts/run_cli.sh lint path/to/DESIGN.md
bash <skill-dir>/scripts/run_cli.sh lint --format json path/to/DESIGN.md
cat path/to/DESIGN.md | bash <skill-dir>/scripts/run_cli.sh lint -
Steps:
- Run
lint against the file. Read the JSON findings.
- Group findings by rule. The seven rules and their meanings are in
references/format-primer.md. Surface errors first, then warnings, then info.
- For each finding, suggest a concrete fix:
broken-ref → fix the typo or define the missing token.
contrast-ratio → propose a darker text color or a lighter background that lands above 4.5:1.
orphaned-tokens → either reference the token from a component or remove it.
section-order → reorder the Markdown sections to match canonical order.
- If exit code is non-zero, the file has at least one error. Do not move on to
export or diff until errors clear.
diff
Compare two DESIGN.md versions and summarize what changed.
bash <skill-dir>/scripts/run_cli.sh diff path/to/old/DESIGN.md path/to/new/DESIGN.md
Steps:
- Run
diff and parse the JSON output.
- Separate material changes (token values, new components, removed tokens, contrast regressions) from cosmetic changes (renames, prose rewrites, section reordering).
- Report the material changes first with one-line consequences for downstream code (Tailwind config, component CSS, generated tokens).
- Exit code
1 means regressions were detected (more errors or warnings in the new version). Call this out explicitly.
export
Convert tokens to Tailwind or DTCG.
bash <skill-dir>/scripts/run_cli.sh export --format json-tailwind path/to/DESIGN.md > tailwind.theme.json
bash <skill-dir>/scripts/run_cli.sh export --format css-tailwind path/to/DESIGN.md > theme.css
bash <skill-dir>/scripts/run_cli.sh export --format dtcg path/to/DESIGN.md > tokens.json
Format selection:
- Tailwind v3 project →
json-tailwind. Merge into tailwind.config.{js,ts} under theme.extend.
- Tailwind v4 project →
css-tailwind. Drop the output into the project's main stylesheet inside @theme { ... }.
- Style-Dictionary, Token Studio, or any DTCG-aware tool →
dtcg.
Steps:
- Lint first. Never export an unlinted file — broken refs land in the output as raw
{path.to.token} strings.
- Run
export with the chosen format and write the output where the user's build expects it.
- After writing, show the user the diff against any prior token file so they can review before committing.
author
Write a fresh DESIGN.md from scratch when the project does not yet have one.
Inputs the agent should gather first:
- The product's mood and audience (technical-studio, marketing, consumer, internal tool, etc.).
- Color preferences (warm/cool, light/dark, brand hex if known).
- Typography constraints (system fonts only, custom face available, monospace required for code surfaces).
- Existing CSS / Tailwind config the system should align with.
Before drafting — format gotchas the linter will surface loudly:
orphaned-tokens is the dominant warning. Every color token must be referenced by a component ({colors.foo} from a components.bar.backgroundColor or similar) or it fires orphaned-tokens. Plan your component set up front so muted-text tokens, border tokens, hover-state tokens, and link tokens all have a component slot to land on. Fabricating a prose-body component (with textColor + typography refs) is a legitimate way to anchor global text colors.
- Components have no
borderColor key. Valid keys are backgroundColor, textColor, typography, rounded, padding, size, height, width. Border colors will be perma-orphaned no matter what; either accept the warning or document the border color in prose only and skip the token.
- Source CSS using
rgba() must be resolved to hex before tokenizing. The Color type is #-prefix sRGB hex only. For dark themes, resolve rgba(255,255,255,0.6) to its solid equivalent on the canvas color (≈ #999999 on #000). Document the original alpha value in the Markdown rationale if it matters.
- Inverted themes (white CTA on black canvas) should still set
colors.primary. The missing-primary rule fires whenever colors are defined without a primary entry, regardless of whether primary is a brand color or a CTA-fill role. For dark-first sites, set primary to the CTA fill (often #FFFFFF) and document the inversion in the Overview prose.
Steps:
- Read
references/exemplars/README.md and pick the exemplar that anchors the closest aesthetic pole. The five exemplars cover warm-technical (Cursor), dark-geometric (Linear), clean-blue (Stripe), monochrome-minimal (Vercel), and colorful-playful (Figma).
- Read the chosen exemplar for voice, taste, and depth of rationale — not for structural shape. The exemplars use Refero's Style Reference export format, which has richer prose sections and no YAML frontmatter. Treat them as taste anchors, not as structural templates.
- Read
references/format-primer.md for the canonical structure the linter expects: frontmatter schema, token types, and section order. The output must conform to the primer, not the exemplar.
- Draft the frontmatter first. Define
colors, typography, and at least three components — one interactive (a button), one surface (a card or container), and one prose role (e.g. prose-body with textColor and typography refs to anchor global body styles). "Text style" here means a component entry, not a typography token. Use token references rather than raw values wherever possible.
- Draft the Markdown body in canonical section order. Each section is short — a paragraph of rationale, not an essay.
- Lint the draft via stdin:
printf '%s' "<draft>" | bash <skill-dir>/scripts/run_cli.sh lint -. Stdin is the canonical path for in-context drafts; reserve a temp file for iterative editing across multiple turns. Resolve any errors before showing it to the user. Surface warnings as discussion points rather than fixing them silently — the orphaned-tokens warnings on global text/border/hover tokens are often the right tradeoff to accept.
- Save the file as
DESIGN.md at the project root unless the user specifies a different path.
Inputs The Skill Accepts
- A path to an existing DESIGN.md file (lint, diff, export).
- Two paths for
diff.
- A path to a project root and a description of its aesthetic for
author.
- Pasted DESIGN.md content piped through stdin (use
- as the file argument).
Output Shape
For lint and diff, return a structured summary:
## Findings
### Errors
- broken-ref at colors.brand: undefined token referenced by components.button-primary.backgroundColor
Fix: define `colors.brand` or change the reference to `{colors.primary}`.
### Warnings
- contrast-ratio on button-secondary: 3.1:1 (AA fails for body)
Fix: darken textColor toward #0F172A or lighten background toward #F8FAFC.
### Info
- token-summary: 12 colors, 6 typography, 3 spacing, 8 components
For export, write the file and print the path plus a one-line summary of token counts.
For author, return the drafted file path plus the lint result.
References
references/format-primer.md — DESIGN.md schema, token types, linting rules, export formats.
references/exemplars/README.md — index of the five Refero-sourced exemplars.
references/exemplars/{cursor,linear,stripe,vercel,figma}.md — full DESIGN.md exemplars covering distinct aesthetic poles.
Maintenance
The format is version: alpha and the CLI is at 0.1.1. Both may move. Two signals indicate this skill needs a refresh:
- The user reports lint findings that mention rules not listed in
format-primer.md.
npx @google/design.md@latest --version returns a version newer than 0.1.1 and a smoke run produces unfamiliar output.
To refresh:
- Bump
DESIGN_MD_VERSION in scripts/run_cli.sh.
- Re-fetch the upstream README from
github.com/google-labs-code/design.md.
- Run
bash scripts/run_cli.sh spec --rules-only --format json and reconcile any rule additions, removals, or severity changes against the table in format-primer.md.
- Run
bash scripts/run_cli.sh lint against each of the five exemplars to confirm none of them regressed under the new version.
Verification
A run is complete when:
Sibling skills
The four design skills compose into a pipeline: spec → build → review. Hand off when the request crosses an axis.
frontend-design — generative UI builder. If a fresh DESIGN.md is being authored alongside a build, draft tokens here and consume them there.
design-critique — visual taste audit against a closed 37-pattern slop catalog. Orthogonal to token-spec linting; run it on the built UI, not on the DESIGN.md.
web-design-guidelines — accessibility / UX rule-compliance review (Vercel WIG, fetched live). Orthogonal to token-spec linting.
1---2name: design-md3description: Read, write, lint, diff, and export DESIGN.md files using the Google @google/design.md format. Use when the user mentions DESIGN.md, design tokens, extracting a design system, linting design tokens, exporting tokens to Tailwind, DTCG, or CSS variables, or when authoring a fresh design-system reference for a project.4---56# design-md78Operates on DESIGN.md files — the Google Labs format that pairs a YAML token block with a Markdown rationale. The skill knows how to lint an existing file, diff two versions, export tokens to Tailwind or DTCG, and author a fresh DESIGN.md grounded in five Refero exemplars.910## When To Use1112Trigger this skill when the request involves any of the following:1314- The user mentions "DESIGN.md", "design tokens", "design system spec", or "@google/design.md".15- The user asks to extract a design system from existing CSS, Tailwind config, or component code into a single source of truth.16- The user wants to lint, validate, or diff a DESIGN.md file.17- The user wants to export design tokens to Tailwind v3 (`json-tailwind`), Tailwind v4 (`css-tailwind`), or W3C DTCG (`dtcg`).18- The user wants to author a fresh DESIGN.md and asks for examples or a starting point.1920## When Not To Use2122- Generating UI components or page layouts from scratch — DESIGN.md is a token spec, not a component library.23- Auditing visuals for taste, polish, or AI-generation tells — that is `design-critique`.24- Accessibility audits beyond contrast (axe / WCAG full-coverage). The DESIGN.md linter only checks `contrast-ratio` on declared component pairs.25- Animation, motion, or breakpoint tokens — the format does not cover them.2627## Operations2829The skill exposes four operations. They share one entry point: `scripts/run_cli.sh`, which pins the CLI version in a single place. Always invoke through the wrapper.3031### lint3233Validate a DESIGN.md file's structure, references, and contrast.3435```bash36bash <skill-dir>/scripts/run_cli.sh lint path/to/DESIGN.md37bash <skill-dir>/scripts/run_cli.sh lint --format json path/to/DESIGN.md38cat path/to/DESIGN.md | bash <skill-dir>/scripts/run_cli.sh lint -39```4041Steps:42431. Run `lint` against the file. Read the JSON findings.442. Group findings by rule. The seven rules and their meanings are in `references/format-primer.md`. Surface errors first, then warnings, then info.453. For each finding, suggest a concrete fix:46 - `broken-ref` → fix the typo or define the missing token.47 - `contrast-ratio` → propose a darker text color or a lighter background that lands above 4.5:1.48 - `orphaned-tokens` → either reference the token from a component or remove it.49 - `section-order` → reorder the Markdown sections to match canonical order.504. If exit code is non-zero, the file has at least one error. Do not move on to `export` or `diff` until errors clear.5152### diff5354Compare two DESIGN.md versions and summarize what changed.5556```bash57bash <skill-dir>/scripts/run_cli.sh diff path/to/old/DESIGN.md path/to/new/DESIGN.md58```5960Steps:61621. Run `diff` and parse the JSON output.632. Separate **material** changes (token values, new components, removed tokens, contrast regressions) from **cosmetic** changes (renames, prose rewrites, section reordering).643. Report the material changes first with one-line consequences for downstream code (Tailwind config, component CSS, generated tokens).654. Exit code `1` means regressions were detected (more errors or warnings in the new version). Call this out explicitly.6667### export6869Convert tokens to Tailwind or DTCG.7071```bash72bash <skill-dir>/scripts/run_cli.sh export --format json-tailwind path/to/DESIGN.md > tailwind.theme.json73bash <skill-dir>/scripts/run_cli.sh export --format css-tailwind path/to/DESIGN.md > theme.css74bash <skill-dir>/scripts/run_cli.sh export --format dtcg path/to/DESIGN.md > tokens.json75```7677Format selection:7879- Tailwind v3 project → `json-tailwind`. Merge into `tailwind.config.{js,ts}` under `theme.extend`.80- Tailwind v4 project → `css-tailwind`. Drop the output into the project's main stylesheet inside `@theme { ... }`.81- Style-Dictionary, Token Studio, or any DTCG-aware tool → `dtcg`.8283Steps:84851. Lint first. Never export an unlinted file — broken refs land in the output as raw `{path.to.token}` strings.862. Run `export` with the chosen format and write the output where the user's build expects it.873. After writing, show the user the diff against any prior token file so they can review before committing.8889### author9091Write a fresh DESIGN.md from scratch when the project does not yet have one.9293Inputs the agent should gather first:9495- The product's mood and audience (technical-studio, marketing, consumer, internal tool, etc.).96- Color preferences (warm/cool, light/dark, brand hex if known).97- Typography constraints (system fonts only, custom face available, monospace required for code surfaces).98- Existing CSS / Tailwind config the system should align with.99100**Before drafting — format gotchas the linter will surface loudly:**101102- **`orphaned-tokens` is the dominant warning.** Every color token must be referenced by a component (`{colors.foo}` from a `components.bar.backgroundColor` or similar) or it fires `orphaned-tokens`. Plan your component set up front so muted-text tokens, border tokens, hover-state tokens, and link tokens all have a component slot to land on. Fabricating a `prose-body` component (with `textColor` + `typography` refs) is a legitimate way to anchor global text colors.103- **Components have no `borderColor` key.** Valid keys are `backgroundColor`, `textColor`, `typography`, `rounded`, `padding`, `size`, `height`, `width`. Border colors will be perma-orphaned no matter what; either accept the warning or document the border color in prose only and skip the token.104- **Source CSS using `rgba()` must be resolved to hex before tokenizing.** The Color type is `#`-prefix sRGB hex only. For dark themes, resolve `rgba(255,255,255,0.6)` to its solid equivalent on the canvas color (≈ `#999999` on `#000`). Document the original alpha value in the Markdown rationale if it matters.105- **Inverted themes (white CTA on black canvas) should still set `colors.primary`.** The `missing-primary` rule fires whenever colors are defined without a `primary` entry, regardless of whether `primary` is a brand color or a CTA-fill role. For dark-first sites, set `primary` to the CTA fill (often `#FFFFFF`) and document the inversion in the Overview prose.106107Steps:1081091. Read `references/exemplars/README.md` and pick the exemplar that anchors the closest aesthetic pole. The five exemplars cover warm-technical (Cursor), dark-geometric (Linear), clean-blue (Stripe), monochrome-minimal (Vercel), and colorful-playful (Figma).1102. Read the chosen exemplar for **voice, taste, and depth of rationale** — not for structural shape. The exemplars use Refero's Style Reference export format, which has richer prose sections and no YAML frontmatter. Treat them as taste anchors, not as structural templates.1113. Read `references/format-primer.md` for the **canonical structure** the linter expects: frontmatter schema, token types, and section order. The output must conform to the primer, not the exemplar.1124. Draft the frontmatter first. Define `colors`, `typography`, and at least three components — one interactive (a button), one surface (a card or container), and one prose role (e.g. `prose-body` with `textColor` and `typography` refs to anchor global body styles). "Text style" here means a component entry, not a typography token. Use token references rather than raw values wherever possible.1135. Draft the Markdown body in canonical section order. Each section is short — a paragraph of rationale, not an essay.1146. Lint the draft via stdin: `printf '%s' "<draft>" | bash <skill-dir>/scripts/run_cli.sh lint -`. Stdin is the canonical path for in-context drafts; reserve a temp file for iterative editing across multiple turns. Resolve any errors before showing it to the user. Surface warnings as discussion points rather than fixing them silently — the orphaned-tokens warnings on global text/border/hover tokens are often the right tradeoff to accept.1157. Save the file as `DESIGN.md` at the project root unless the user specifies a different path.116117## Inputs The Skill Accepts118119- A path to an existing DESIGN.md file (lint, diff, export).120- Two paths for `diff`.121- A path to a project root and a description of its aesthetic for `author`.122- Pasted DESIGN.md content piped through stdin (use `-` as the file argument).123124## Output Shape125126For `lint` and `diff`, return a structured summary:127128```129## Findings130131### Errors132- broken-ref at colors.brand: undefined token referenced by components.button-primary.backgroundColor133 Fix: define `colors.brand` or change the reference to `{colors.primary}`.134135### Warnings136- contrast-ratio on button-secondary: 3.1:1 (AA fails for body)137 Fix: darken textColor toward #0F172A or lighten background toward #F8FAFC.138139### Info140- token-summary: 12 colors, 6 typography, 3 spacing, 8 components141```142143For `export`, write the file and print the path plus a one-line summary of token counts.144145For `author`, return the drafted file path plus the lint result.146147## References148149- `references/format-primer.md` — DESIGN.md schema, token types, linting rules, export formats.150- `references/exemplars/README.md` — index of the five Refero-sourced exemplars.151- `references/exemplars/{cursor,linear,stripe,vercel,figma}.md` — full DESIGN.md exemplars covering distinct aesthetic poles.152153## Maintenance154155The format is `version: alpha` and the CLI is at 0.1.1. Both may move. Two signals indicate this skill needs a refresh:1561571. The user reports lint findings that mention rules not listed in `format-primer.md`.1582. `npx @google/design.md@latest --version` returns a version newer than 0.1.1 and a smoke run produces unfamiliar output.159160To refresh:1611621. Bump `DESIGN_MD_VERSION` in `scripts/run_cli.sh`.1632. Re-fetch the upstream README from `github.com/google-labs-code/design.md`.1643. Run `bash scripts/run_cli.sh spec --rules-only --format json` and reconcile any rule additions, removals, or severity changes against the table in `format-primer.md`.1654. Run `bash scripts/run_cli.sh lint` against each of the five exemplars to confirm none of them regressed under the new version.166167## Verification168169A run is complete when:170171- [ ] The intended subcommand (`lint`, `diff`, `export`, `spec`) has been invoked via `scripts/run_cli.sh` (not bare `npx`) so the pinned `DESIGN_MD_VERSION` is honored.172- [ ] For `lint`: every reported finding has either been resolved in the DESIGN.md or annotated with the rule ID and a justification comment.173- [ ] For `diff`: the changed token surface has been reported back to the user and the consuming skill (typically `frontend-design`) has been told what moved.174- [ ] For `export`: the produced artifact (Tailwind config / DTCG JSON) is referenced from the consumer and lints clean against its own validator.175- [ ] No edits were made directly to the exemplars under `references/exemplars/` unless the user explicitly asked.176177## Sibling skills178179The four design skills compose into a pipeline: **spec → build → review**. Hand off when the request crosses an axis.180181- `frontend-design` — generative UI builder. If a fresh DESIGN.md is being authored alongside a build, draft tokens here and consume them there.182- `design-critique` — visual taste audit against a closed 37-pattern slop catalog. Orthogonal to token-spec linting; run it on the *built* UI, not on the DESIGN.md.183- `web-design-guidelines` — accessibility / UX rule-compliance review (Vercel WIG, fetched live). Orthogonal to token-spec linting.