乐于分享
好东西不私藏

Google给AI编程立了一套设计规范,但不是什么新魔法

Google给AI编程立了一套设计规范,但不是什么新魔法

你知道 README.md 是项目的说明书。 你也知道 AGENTS.md 是给AI编程Agent看的攻略。 那你听说过 DESIGN.md 吗?

它是Google最近提出的一套设计规范格式,专门给AI编程工具读。可以简单理解为:设计侧的 AGENTS.md。AGENTS.md告诉AI怎么写代码,DESIGN.md告诉AI界面长什么样。

现状

方案不少,但没有统一标准

目前业内其实不缺方案——W3C有Design Token标准格式,JSON/YAML都能承载精确的颜色、字体、间距数值,Figma插件也能导出token文件。 问题在于各自独立,互不兼容。

A团队用W3C DTCG格式,B团队用Figma Tokens插件,C团队手写JSON。没有统一标准意味着工具之间无法互操作,AI每次换工具都要重新理解一遍设计系统。

 Google这次做的事,就是提出一个公共标准:大家都按这个格式写,AI工具就能统一理解,设计系统在工具之间也能流转。

DESIGN.md 的核心思路

它分两层: YAML头部:精确的原始值,供AI直接抄

colors:  primary: "#6366f1"  surface: "#ffffff"rounded:  md: 8px

Markdown正文:语义说明,让AI知道”为什么用在这里”

## Colors- **Primary** (#6366f1): main actions, active navigation, selected state- **Success** (#18a058): online, enabled, registered, ready- **Error** (#d03050): errors and destructive actions

语义命名是核心。primary不是”主色调”,而是”主要操作、激活状态”。success不是”绿色”,而是”在线、启用、就绪”。AI看到这个就知道设备状态灯该用什么色。

完整示例

以下是这个规范的实际项目文件,可以直接复制使用: 提示: 直接把下面这段Markdown内容丢给你的AI编程工具,它就知道这个项目的设计规范了。

---name: Admin Console Design Systemcolors:  primary: "#6366f1"  primary-strong: "#4f46e5"  surface: "#ffffff"  background: "#f3f5f7"  text: "#1f2329"  muted: "#6b7280"  border: "#e5e9f0"  success: "#18a058"  warning: "#f0a020"  error: "#d03050"  dark:    surface: "#18181c"    background: "#101014"    text: "#f4f6fb"    muted: "#a6adbb"    border: "#2b2c35"typography:  body:    fontFamily: Manrope    fontSize: 14-16px    fontWeight: 400-500  mono:    fontFamily: IBM Plex Mono    fontSize: 13-14pxrounded:  sm: 6px  md: 8px  lg: 12px---# Design System## OverviewA compact admin operations console.Clean surfaces, high information density, clear device state, and predictable workflows.## Colors- **Primary** (#6366f1): main actions, active navigation, selected state- **Primary Strong** (#4f46e5): emphasized active state and key focus- **Background** (#f3f5f7): page canvas behind cards- **Surface** (#ffffff): cards, dialogs, sidebar, header- **Text** (#1f2329): primary content- **Muted** (#6b7280): hints, helper text, inactive icons- **Border** (#e5e9f0): panels, tables, dividers- **Success** (#18a058): online, enabled, registered, ready- **Warning** (#f0a020): incomplete, degraded, unsupported- **Error** (#d03050): errors and destructive actionsDark mode uses the same hierarchy with `#101014` background, `#18181c` surface, `#f4f6fb` text, and `#2b2c35` borders.## Typography- **Body**: Manrope, regular/medium, 14-16px- **Headlines**: Manrope, bold, 20-24px max for page sections- **Labels**: Manrope, semi-bold, 12-13px- **Badges**: Manrope, semi-bold, 12-13px- **Technical values**: IBM Plex Mono, 13-14px for IDs, serial numbers, ports, technical output## Layout- **Shell**: fixed left sidebar, top header, tab bar, scrollable content- **Sidebar**: 248px expanded, 64px collapsed- **Header**: 56px height- **Content padding**: 16px desktop, 12px mobile- **Cards**: compact headers, subtle border, low shadow- **Forms**: two columns on desktop, one column on mobile- **Dialogs**: max viewport fit; keep footer actions stable## Components- **Buttons**: 8px radius; primary only for the main action in a local context- **Secondary buttons**: refresh, edit, scan, copy, open dialog- **Danger buttons**: destructive data/config actions only- **Inputs**: 1px border, visible labels, no placeholder-only forms- **Cards**: border-first, low elevation, compact vertical spacing- **Tables**: clear row dividers, muted headers, monospace for IDs- **Badges**: pill shape, semantic color, short labels- **Help icons**: gray, no background, `question-circle`, tooltip on hover- **Icon buttons**: use `.soy-icon-button`, always include `aria-label`## Domain Patterns- **Device list**: show status, operator, signal, port, and actions without extra hero height- **Terminal**: dark console, command history below input, common commands in a popover- **Call dialog**: prioritize call state, route, number, and primary call actions- **Settings**: labels first, runtime status as disabled/read-only display, advanced options grouped- **Gateway**: dense two-column forms; help icons inline with labels; route summaries first## Icons- Use Iconify Solar line duotone icons.- Verify icon names before use.- Prefer:  - `solar:sim-card-line-duotone`  - `solar:chat-round-line-duotone`  - `solar:phone-calling-rounded-line-duotone`  - `solar:command-line-duotone`  - `solar:settings-line-duotone`  - `solar:bell-bing-line-duotone`  - `solar:question-circle-line-duotone`## Do's and Don'ts- Do keep screens compact and scannable- Do use existing CSS tokens from `web_src/src/styles/main.css`- Do use Naive UI components before custom controls- Do make read-only data look read-only- Do keep Simplified Chinese complete by default- Do maintain text contrast in light and dark mode- Don't create one-off colors, radii, or shadows- Don't use oversized hero sections- Don't use placeholder-only inputs- Don't add colored backgrounds to neutral help icons- Don't use missing Iconify icon names

配套工具:CLI校验与格式转换

Google还提供了配套的CLI工具,安装方式:

npm install -g @google/design.md

四个核心命令:

  • 七条内置校验规则,从error到info级别:
  • broken-ref:token引用断裂 → error
  • missing-primary:定义了颜色但没有primary → warning
  • contrast-ratio:对比度低于WCAG AA标准 → warning
  • orphaned-tokens:定义了但从未引用 → warning
  • missing-typography:有颜色但没有字体规范 → warning
  • section-order:章节顺序不对 → warning
  • token-summary:各章节token数量统计 → info
    怎么用 DESIGN.md

把这个完整文件放到项目根目录,取名 DESIGN.md 让AI改下适配项目,或者懒人接发给你的编程 AI 发一句话

https://github.com/google-labs-code/design.md 根据这个设计规范,初始化我们项项目下的 DESIGN.md

然后在你的 AGENTS.md 里加一句:

Always reference DESIGN.md when generating or modifying UI components.

AI每次启动都会读到这套规范,生成的界面天然对齐设计系统。

Google已经把格式开源,文档在: 👉 GitHub – google-labs-code/design.md: A format specification for describing a visual identity to codi 如果你的工作流涉及AI生成UI,这个思路值得一试。