design-md
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDESIGN.md Skill
DESIGN.md 技能
DESIGN.md is Google's open spec (Apache-2.0, ) for
describing a visual identity to coding agents. One file combines:
google-labs-code/design.md- YAML front matter — machine-readable design tokens (normative values)
- Markdown body — human-readable rationale, organized into canonical sections
Tokens give exact values. Prose tells agents why those values exist and how to
apply them. The CLI () lints structure + WCAG contrast,
diffs versions for regressions, and exports to Tailwind or W3C DTCG JSON.
npx @google/design.mdDESIGN.md是Google的开放规范(Apache-2.0协议,仓库地址),用于向编码Agent描述视觉标识。单个文件整合了以下两部分:
google-labs-code/design.md- YAML前置元数据 —— 机器可读的设计令牌(标准值)
- Markdown正文 —— 人类可读的设计依据,按规范章节组织
令牌提供精确值,说明性文字则告诉Agent这些值存在的原因以及如何应用它们。CLI工具()可检查结构与WCAG对比度、对比版本差异以发现回归问题,并导出为Tailwind或W3C DTCG JSON格式。
npx @google/design.mdWhen to use this skill
何时使用此技能
- User asks for a DESIGN.md file, design tokens, or a design system spec
- User wants consistent UI/brand across multiple projects or tools
- User pastes an existing DESIGN.md and asks to lint, diff, export, or extend it
- User asks to port a style guide into a format agents can consume
- User wants contrast / WCAG accessibility validation on their color palette
For purely visual inspiration or layout examples, use
instead. For process and taste when designing a one-off HTML artifact
from scratch (prototype, deck, landing page, component lab), use
. This skill is for the formal spec file itself.
popular-web-designsclaude-design- 用户请求DESIGN.md文件、设计令牌或设计系统规范
- 用户希望在多个项目或工具中保持UI/品牌一致性
- 用户粘贴现有DESIGN.md文件,要求进行检查、对比差异、导出或扩展
- 用户请求将样式指南转换为Agent可识别的格式
- 用户希望对其调色板进行对比度/WCAG可访问性验证
如果仅需要视觉灵感或布局示例,请改用技能。如果是从零开始设计一次性HTML制品(原型、演示文稿、着陆页、组件实验室)时需要流程和风格建议,请使用技能。本技能专门用于处理正式规范文件本身。
popular-web-designsclaude-designFile anatomy
文件结构
md
---
version: alpha
name: Heritage
description: Architectural minimalism meets journalistic gravitas.
colors:
primary: "#1A1C1E"
secondary: "#6C7278"
tertiary: "#B8422E"
neutral: "#F7F5F2"
typography:
h1:
fontFamily: Public Sans
fontSize: 3rem
fontWeight: 700
lineHeight: 1.1
letterSpacing: "-0.02em"
body-md:
fontFamily: Public Sans
fontSize: 1rem
rounded:
sm: 4px
md: 8px
lg: 16px
spacing:
sm: 8px
md: 16px
lg: 24px
components:
button-primary:
backgroundColor: "{colors.tertiary}"
textColor: "#FFFFFF"
rounded: "{rounded.sm}"
padding: 12px
button-primary-hover:
backgroundColor: "{colors.primary}"
---md
---
version: alpha
name: Heritage
description: Architectural minimalism meets journalistic gravitas.
colors:
primary: "#1A1C1E"
secondary: "#6C7278"
tertiary: "#B8422E"
neutral: "#F7F5F2"
typography:
h1:
fontFamily: Public Sans
fontSize: 3rem
fontWeight: 700
lineHeight: 1.1
letterSpacing: "-0.02em"
body-md:
fontFamily: Public Sans
fontSize: 1rem
rounded:
sm: 4px
md: 8px
lg: 16px
spacing:
sm: 8px
md: 16px
lg: 24px
components:
button-primary:
backgroundColor: "{colors.tertiary}"
textColor: "#FFFFFF"
rounded: "{rounded.sm}"
padding: 12px
button-primary-hover:
backgroundColor: "{colors.primary}"
---Overview
Overview
Architectural Minimalism meets Journalistic Gravitas...
Architectural Minimalism meets Journalistic Gravitas...
Colors
Colors
- Primary (#1A1C1E): Deep ink for headlines and core text.
- Tertiary (#B8422E): "Boston Clay" — the sole driver for interaction.
- Primary (#1A1C1E): Deep ink for headlines and core text.
- Tertiary (#B8422E): "Boston Clay" — the sole driver for interaction.
Typography
Typography
Public Sans for everything except small all-caps labels...
Public Sans for everything except small all-caps labels...
Components
Components
button-primaryundefinedbutton-primaryundefinedToken types
令牌类型
| Type | Format | Example |
|---|---|---|
| Color | | |
| Dimension | number + unit ( | |
| Token reference | | |
| Typography | object with | see above |
Component property whitelist: , , ,
, , , , . Variants (hover, active,
pressed) are separate component entries with related key names
(), not nested.
backgroundColortextColortypographyroundedpaddingsizeheightwidthbutton-primary-hover| 类型 | 格式 | 示例 |
|---|---|---|
| 颜色 | | |
| 尺寸 | 数字 + 单位( | |
| 令牌引用 | | |
| 排版 | 包含 | 见上方示例 |
组件属性白名单:、、、、、、、。变体(hover、active、pressed)需作为独立的组件条目,使用相关键名(如),而非嵌套结构。
backgroundColortextColortypographyroundedpaddingsizeheightwidthbutton-primary-hoverCanonical section order
规范章节顺序
Sections are optional, but present ones MUST appear in this order. Duplicate
headings reject the file.
- Overview (alias: Brand & Style)
- Colors
- Typography
- Layout (alias: Layout & Spacing)
- Elevation & Depth (alias: Elevation)
- Shapes
- Components
- Do's and Don'ts
Unknown sections are preserved, not errored. Unknown token names are accepted
if the value type is valid. Unknown component properties produce a warning.
章节为可选,但如果存在必须按照以下顺序排列。重复的标题会导致文件被拒绝。
- Overview(别名:Brand & Style)
- Colors
- Typography
- Layout(别名:Layout & Spacing)
- Elevation & Depth(别名:Elevation)
- Shapes
- Components
- Do's and Don'ts
未知章节会被保留,不会报错。如果令牌值类型有效,未知令牌名称会被接受。未知组件属性会产生警告。
Workflow: authoring a new DESIGN.md
工作流:编写新的DESIGN.md
- Ask the user (or infer) the brand tone, accent color, and typography direction. If they provided a site, image, or vibe, translate it to the token shape above.
- Write in their project root using
DESIGN.md. Always includewrite_fileandname:; other sections optional but encouraged.colors: - Use token references () in the
{colors.primary}section instead of re-typing hex values. Keeps the palette single-source.components: - Lint it (see below). Fix any broken references or WCAG failures before returning.
- If the user has an existing project, also write Tailwind or DTCG
exports next to the file (,
tailwind.theme.json).tokens.json
- 询问用户(或推断)品牌基调、强调色和排版方向。如果用户提供了网站、图片或风格参考,将其转换为上述令牌结构。
- **编写**文件到项目根目录,使用
DESIGN.md工具。务必包含write_file和name:字段;其他章节为可选,但建议添加。colors: - 使用令牌引用(如)替代重复输入十六进制值,保持调色板单一数据源。
{colors.primary} - 检查文件(见下文)。在返回结果前修复所有无效引用或WCAG失败问题。
- 如果用户已有项目,同时将文件导出为Tailwind或DTCG格式,保存到文件旁(、
tailwind.theme.json)。tokens.json
Workflow: lint / diff / export
工作流:检查/对比差异/导出
The CLI is (Node). Use — no global install needed.
@google/design.mdnpxbash
undefinedCLI工具为(基于Node.js)。使用无需全局安装。
@google/design.mdnpxbash
undefinedValidate structure + token references + WCAG contrast
验证结构 + 令牌引用 + WCAG对比度
npx -y @google/design.md lint DESIGN.md
npx -y @google/design.md lint DESIGN.md
Compare two versions, fail on regression (exit 1 = regression)
对比两个版本,发现回归则失败(退出码1表示存在回归)
npx -y @google/design.md diff DESIGN.md DESIGN-v2.md
npx -y @google/design.md diff DESIGN.md DESIGN-v2.md
Export to Tailwind theme JSON
导出为Tailwind主题JSON
npx -y @google/design.md export --format tailwind DESIGN.md > tailwind.theme.json
npx -y @google/design.md export --format tailwind DESIGN.md > tailwind.theme.json
Export to W3C DTCG (Design Tokens Format Module) JSON
导出为W3C DTCG(设计令牌格式模块)JSON
npx -y @google/design.md export --format dtcg DESIGN.md > tokens.json
npx -y @google/design.md export --format dtcg DESIGN.md > tokens.json
Print the spec itself — useful when injecting into an agent prompt
打印规范本身——注入到Agent提示词时非常有用
npx -y @google/design.md spec --rules-only --format json
All commands accept `-` for stdin. `lint` returns exit 1 on errors. Use the
`--format json` flag and parse the output if you need to report findings
structurally.npx -y @google/design.md spec --rules-only --format json
所有命令接受`-`作为标准输入。`lint`命令在出错时返回退出码1。如果需要结构化报告结果,可使用`--format json`标志并解析输出内容。Lint rule reference (what the 7 rules catch)
检查规则参考(7条规则的检测内容)
- (error) —
broken-refpoints at a non-existent token{colors.missing} - (error) — same
duplicate-sectionappears twice## Heading - ,
invalid-color,invalid-dimension(error)invalid-typography - (warning/info) — component
wcag-contrastvstextColorratio against WCAG AA (4.5:1) and AAA (7:1)backgroundColor - (warning) — outside the whitelist above
unknown-component-property
When the user cares about accessibility, call this out explicitly in your
summary — WCAG findings are the most load-bearing reason to use the CLI.
- (错误)——
broken-ref指向不存在的令牌{colors.missing} - (错误)——同一个
duplicate-section出现多次## 标题 - 、
invalid-color、invalid-dimension(错误)invalid-typography - (警告/信息)——组件
wcag-contrast与textColor的比率是否符合WCAG AA(4.5:1)和AAA(7:1)标准backgroundColor - (警告)——属性不在上述白名单内
unknown-component-property
当用户关注可访问性时,在总结中明确指出这一点——WCAG检测结果是使用此CLI工具最核心的原因之一。
Pitfalls
注意事项
- Don't nest component variants. is wrong;
button-primary.hoveras a sibling key is right.button-primary-hover - Hex colors must be quoted strings. YAML will otherwise choke on or truncate values like
#oddly.#1A1C1E - Negative dimensions need quotes too. parses as a YAML flow — write
letterSpacing: -0.02em.letterSpacing: "-0.02em" - Section order is enforced. If the user gives you prose in a random order, reorder it to match the canonical list before saving.
- is the current spec version (as of Apr 2026). The spec is marked alpha — watch for breaking changes.
version: alpha - Token references resolve by dotted path. works;
{colors.primary}does not.{primary}
- 不要嵌套组件变体。是错误写法;
button-primary.hover作为同级键才是正确的。button-primary-hover - 十六进制颜色必须用引号包裹。否则YAML会解析时出错,或错误截断
#这类值。#1A1C1E - 负尺寸也需要引号。会被解析为YAML流——应写成
letterSpacing: -0.02em。letterSpacing: "-0.02em" - 章节顺序是强制要求的。如果用户提供的说明性文字顺序混乱,保存前需调整为规范列表中的顺序。
- 是当前规范版本(截至2026年4月)。该规范处于alpha阶段——注意可能存在破坏性变更。
version: alpha - 令牌引用通过点路径解析。有效;
{colors.primary}无效。{primary}
Spec source of truth
规范权威来源
- Repo: https://github.com/google-labs-code/design.md (Apache-2.0)
- CLI: on npm
@google/design.md - License of generated DESIGN.md files: whatever the user's project uses; the spec itself is Apache-2.0.
- 仓库:https://github.com/google-labs-code/design.md(Apache-2.0协议)
- CLI工具:npm上的
@google/design.md - 生成的DESIGN.md文件许可:遵循用户项目的许可;规范本身采用Apache-2.0协议。