Loading...
Loading...
Create and validate DESIGN.md files that give AI coding agents structured understanding of design systems through machine-readable tokens and human-readable rationale.
npx skill4agent add aradotso/design-skills design-md-formatSkill by ara.so — Design Skills collection.
npm install @google/design.mdnpx @google/design.md lint DESIGN.mdpackage.jsondesignmddesign.md{
"scripts": {
"design:lint": "designmd lint DESIGN.md"
}
}---
name: Heritage
colors:
primary: "#1A1C1E"
secondary: "#6C7278"
tertiary: "#B8422E"
neutral: "#F7F5F2"
typography:
h1:
fontFamily: Public Sans
fontSize: 3rem
body-md:
fontFamily: Public Sans
fontSize: 1rem
rounded:
sm: 4px
md: 8px
spacing:
sm: 8px
md: 16px
components:
button-primary:
backgroundColor: "{colors.tertiary}"
textColor: "#ffffff"
rounded: "{rounded.sm}"
padding: 12px
---
## Overview
Architectural Minimalism meets Journalistic Gravitas.
## Colors
- **Primary (#1A1C1E):** Deep ink for headlines and core text.
- **Tertiary (#B8422E):** "Boston Clay" — interaction driver.version: <string> # optional, current: "alpha"
name: <string> # required
description: <string> # optional
colors:
<token-name>: <Color> # "#" + hex (sRGB)
typography:
<token-name>: <Typography>
rounded:
<scale-level>: <Dimension>
spacing:
<scale-level>: <Dimension | number>
components:
<component-name>:
<property>: <value | token reference>#colors:
primary: "#1A1C1E"
accent: "#B8422E"
on-primary: "#FFFFFF"typography:
h1:
fontFamily: Public Sans
fontSize: 3rem
fontWeight: 700
lineHeight: 1.2
letterSpacing: -0.02em
body-md:
fontFamily: Public Sans
fontSize: 1rem
fontWeight: 400
lineHeight: 1.5pxemremrounded:
sm: 4px
md: 8px
lg: 16px
spacing:
xs: 4px
sm: 8px
md: 16px
lg: 24px{path.to.token}components:
button-primary:
backgroundColor: "{colors.tertiary}"
textColor: "{colors.on-tertiary}"
rounded: "{rounded.sm}"backgroundColortextColortypographyroundedpaddingsizeheightwidthcomponents:
button-primary:
backgroundColor: "{colors.tertiary}"
textColor: "#ffffff"
typography: "{typography.label-caps}"
rounded: "{rounded.sm}"
padding: 12px
button-primary-hover:
backgroundColor: "{colors.tertiary-container}"
card:
backgroundColor: "{colors.neutral}"
rounded: "{rounded.md}"
padding: "{spacing.md}"#### Overview
Brief description of the design philosophy.
## Colors
Rationale for each color token and when to use it.
- **Primary (#1A1C1E):** Deep ink for headlines
- **Tertiary (#B8422E):** Interaction driver
## Typography
Font selection rationale and hierarchy guidance.
## Components
How to apply component tokens in context.# Validate from file
npx @google/design.md lint DESIGN.md
# From stdin
cat DESIGN.md | npx @google/design.md lint -
# Specify output format (only json currently)
npx @google/design.md lint --format json DESIGN.md{
"findings": [
{
"severity": "warning",
"path": "components.button-primary",
"message": "textColor (#ffffff) on backgroundColor (#1A1C1E) has contrast ratio 15.42:1 — passes WCAG AA."
}
],
"summary": { "errors": 0, "warnings": 1, "info": 1 }
}01npx @google/design.md diff DESIGN.md DESIGN-v2.md
npx @google/design.md diff --format json old.md new.md{
"tokens": {
"colors": { "added": ["accent"], "removed": [], "modified": ["tertiary"] },
"typography": { "added": [], "removed": [], "modified": [] }
},
"regression": false
}01# Tailwind v3 JSON config
npx @google/design.md export --format json-tailwind DESIGN.md > tailwind.theme.json
npx @google/design.md export --format tailwind DESIGN.md > tailwind.theme.json # alias
# Tailwind v4 CSS theme
npx @google/design.md export --format css-tailwind DESIGN.md > theme.css
# W3C Design Tokens Format (DTCG)
npx @google/design.md export --format dtcg DESIGN.md > tokens.json
# From stdin
cat DESIGN.md | npx @google/design.md export --format dtcg - > tokens.jsonjson-tailwind{
"colors": {
"primary": "#1A1C1E",
"secondary": "#6C7278",
"tertiary": "#B8422E"
},
"fontFamily": {
"sans": ["Public Sans", "sans-serif"]
},
"fontSize": {
"h1": "3rem",
"body-md": "1rem"
},
"borderRadius": {
"sm": "4px",
"md": "8px"
},
"spacing": {
"sm": "8px",
"md": "16px"
}
}css-tailwind@theme {
--color-primary: #1A1C1E;
--color-secondary: #6C7278;
--color-tertiary: #B8422E;
--font-sans: "Public Sans", sans-serif;
--text-h1: 3rem;
--text-body-md: 1rem;
--radius-sm: 4px;
--radius-md: 8px;
--spacing-sm: 8px;
--spacing-md: 16px;
}# Full spec
npx @google/design.md spec
# Spec + linting rules
npx @google/design.md spec --rules
# Only linting rules
npx @google/design.md spec --rules-only
# JSON format
npx @google/design.md spec --rules-only --format jsonimport { lint } from '@google/design.md/linter';
const markdownString = `
---
name: MyDesign
colors:
primary: "#1A1C1E"
components:
button:
backgroundColor: "{colors.primary}"
textColor: "#ffffff"
---
## Overview
Modern design system.
`;
const report = lint(markdownString);
console.log(report.findings);
// [
// {
// severity: 'warning',
// path: 'components.button',
// message: 'textColor (#ffffff) on backgroundColor (#1A1C1E) has contrast ratio 15.42:1 — passes WCAG AA.'
// }
// ]
console.log(report.summary);
// { errors: 0, warnings: 1, info: 1 }
console.log(report.designSystem);
// Parsed DesignSystemState objectimport { lint, type Finding } from '@google/design.md/linter';
function validateDesignFile(content: string): boolean {
const report = lint(content);
const hasErrors = report.findings.some((f: Finding) => f.severity === 'error');
if (hasErrors) {
console.error('Validation failed:');
report.findings
.filter((f: Finding) => f.severity === 'error')
.forEach((f: Finding) => console.error(` ${f.path}: ${f.message}`));
return false;
}
return true;
}---
version: alpha
name: ProductName
description: Modern SaaS design system
colors:
primary: "#2563eb"
secondary: "#64748b"
tertiary: "#0ea5e9"
neutral: "#f8fafc"
on-primary: "#ffffff"
on-tertiary: "#ffffff"
typography:
h1:
fontFamily: Inter
fontSize: 2.5rem
fontWeight: 700
lineHeight: 1.2
h2:
fontFamily: Inter
fontSize: 2rem
fontWeight: 600
lineHeight: 1.3
body:
fontFamily: Inter
fontSize: 1rem
fontWeight: 400
lineHeight: 1.5
label:
fontFamily: Inter
fontSize: 0.875rem
fontWeight: 500
rounded:
sm: 4px
md: 8px
lg: 12px
full: 9999px
spacing:
xs: 4px
sm: 8px
md: 16px
lg: 24px
xl: 32px
components:
button-primary:
backgroundColor: "{colors.primary}"
textColor: "{colors.on-primary}"
typography: "{typography.label}"
rounded: "{rounded.md}"
padding: 12px 24px
button-primary-hover:
backgroundColor: "#1d4ed8"
card:
backgroundColor: "{colors.neutral}"
rounded: "{rounded.lg}"
padding: "{spacing.lg}"
input:
backgroundColor: "{colors.neutral}"
textColor: "{colors.primary}"
rounded: "{rounded.sm}"
padding: "{spacing.sm}"
---
## Overview
Clean, modern SaaS interface prioritizing readability and trust.
## Colors
- **Primary (#2563eb):** Brand blue for primary actions
- **Secondary (#64748b):** Slate for secondary text and borders
- **Tertiary (#0ea5e9):** Sky blue for links and highlights
- **Neutral (#f8fafc):** Near-white background
## Typography
Single font family (Inter) for consistency. Weight and size establish hierarchy.
## Components
All interactive elements use `button-primary` tokens. Cards use `card` tokens.npx @google/design.md export --format json-tailwind DESIGN.md > design-tokens.json// tailwind.config.js
const designTokens = require('./design-tokens.json');
module.exports = {
theme: {
extend: designTokens
}
};npx @google/design.md export --format css-tailwind DESIGN.md > src/theme.css/* src/styles.css */
@import "./theme.css";
@import "tailwindcss";# ✅ Good - uses references
components:
button-primary:
backgroundColor: "{colors.primary}"
textColor: "{colors.on-primary}"
rounded: "{rounded.md}"
button-secondary:
backgroundColor: "{colors.secondary}"
textColor: "{colors.on-primary}"
rounded: "{rounded.md}"
# ❌ Bad - duplicates values
components:
button-primary:
backgroundColor: "#2563eb"
textColor: "#ffffff"
rounded: 8px
button-secondary:
backgroundColor: "#64748b"
textColor: "#ffffff"
rounded: 8pxcomponents:
button-primary:
backgroundColor: "{colors.primary}"
textColor: "{colors.on-primary}"
rounded: "{rounded.md}"
padding: 12px 24px
button-primary-hover:
backgroundColor: "#1d4ed8"
button-primary-active:
backgroundColor: "#1e40af"
button-primary-disabled:
backgroundColor: "{colors.secondary}"
textColor: "#94a3b8"| Rule | Severity | Description |
|---|---|---|
| error | Token reference doesn't resolve (e.g., |
| warning | No |
| warning | Component backgroundColor/textColor below WCAG AA (4.5:1) |
| warning | Color token defined but never referenced |
| info | Summary of token counts per section |
| info | Optional sections absent when other tokens exist |
| warning | Colors defined but no typography tokens |
| warning | Sections appear out of canonical order |
npm error ENOVERSIONSNo versions available for @google/design.md.npmrc# Check current registry
npm config get registry
# Should be: https://registry.npmjs.org/
# Clear cache and retry
npm cache clean --force
npm install @google/design.mdbroken-ref{colors.accent}colors:
accent: "#0ea5e9" # Add the missing tokencomponents:
button:
backgroundColor: "{colors.primary}" # Use existing tokencontrast-ratio# Before (low contrast)
components:
button:
backgroundColor: "#e0e0e0"
textColor: "#ffffff"
# After (high contrast)
components:
button:
backgroundColor: "#1A1C1E"
textColor: "#ffffff"colors:
primary: "#2563eb"
on-primary: "#ffffff" # Guaranteed high contrast
components:
button:
backgroundColor: "{colors.primary}"
textColor: "{colors.on-primary}"section-order## Overview
...
## Colors
...
## Typography
...
## Components
...package.jsondesignmddesign.md{
"scripts": {
"lint": "designmd lint DESIGN.md",
"export": "designmd export --format tailwind DESIGN.md > tokens.json"
}
}primarylintdiffbutton-primary-hoverbutton-primary# .github/workflows/design.yml
name: Validate Design System
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: npx @google/design.md lint DESIGN.md{
"husky": {
"hooks": {
"pre-commit": "npx @google/design.md lint DESIGN.md"
}
}
}{
"scripts": {
"prebuild": "designmd export --format tailwind DESIGN.md > src/design-tokens.json",
"build": "vite build"
}
}