design-spec
它能做什么
这项技能讲解如何编写 DESIGN.md 文件,它是一份涵盖项目颜色、字体、间距和组件的统一指南。适合希望保持风格一致的设计师和开发者。
适用场景
- ✓当你要开始一个新网站或应用,并希望在搭建页面前先定下外观的时候。
- ✓当项目需要一套共用的颜色、字体和间距设计值时。
- ✓当你想给 AI 一份清晰的视觉说明,让它照着执行的时候。
技能链接
https://github.com/vudovn/ag-kit/blob/main/.agents/skills/design-spec/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请为我的新咖啡馆网站写一份 DESIGN.md,在搭建任何页面之前,先定好颜色、字体和间距规则。”
每周 5 个新技能,1 分钟读完。
工作原理
文件顶部是可供机器读取的设计值,后面是解释各项选择的文字说明。AI 在搭建界面时,以它为准。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
DESIGN.md Specification
A DESIGN.md is the single source of truth for a project's visual language. Create it BEFORE building UI. Two layers: machine-readable design tokens (YAML front matter) + human-readable rationale (markdown body). Tokens are normative; prose gives context. Prose may use descriptive names ("Midnight Forest Green") that map to systematic token names (
primary).Format adapted from the DESIGN.md spec (Google Labs, Apache-2.0). A linter/exporter exists:
npx @google/design.md.📚 Reference library: collection.md — 70+ real-world DESIGN.md files (Airbnb, Stripe, Linear, Vercel, Apple…) to study or adapt as a starting point.
When to produce a DESIGN.md
This is a hard gate for UI work (see .agents/rules/design-rules.md): before writing components, pages, or styles, a DESIGN.md must exist at the project root. If absent, create it first from the brief; if present, read it and conform.
The token block converts cleanly to/from tokens.json, Figma variables, and Tailwind theme config — so it is the bridge between design intent and code.
1. File structure
---
<YAML token front matter>
---
# Project Name (optional title)
## Overview
## Colors
## Typography
## Layout
## Elevation & Depth
## Shapes
## Components
## Do's and Don'ts
Front matter MUST begin and end with a line containing exactly ---. Sections use ## headings, appear in the order above, and may be omitted if irrelevant. Domain-specific sections may be added.
2. Token schema (YAML front matter)
version: alpha # optional
name: Daylight Prestige
description: ... # optional
colors:
<token-name>: "#RRGGBB"
typography:
<token-name>:
fontFamily: Public Sans
fontSize: 48px
fontWeight: 600
lineHeight: 1.1
letterSpacing: -0.02em
rounded:
<scale>: 8px
spacing:
<scale>: 16px # Dimension or unitless number
components:
<component-name>:
backgroundColor: "{colors.primary}"
rounded: "{rounded.md}"
padding: 12px
<scale> is a named level: xs sm md lg xl full (any descriptive key is valid).
3. Type system
| Type | Format | Example |
|---|---|---|
| Color | # + hex (sRGB) |
"#1A1C1E" |
| Dimension | number + unit (px/em/rem) |
48px, -0.02em |
| Token Reference | {path.to.token} |
{colors.primary} |
| Typography | composite object | see §4 |
Typography properties: fontFamily (string), fontSize (Dimension), fontWeight (number — bare or quoted are equivalent in YAML), lineHeight (Dimension or unitless multiplier — unitless recommended), letterSpacing (Dimension), fontFeature (string), fontVariation (string).
Token references: wrapped in {} pointing to another value in the tree. Most groups must reference a primitive ({colors.primary-60}), not a group. Inside components, references to composite values are allowed ({typography.label-md}).
Component property tokens: backgroundColor, textColor (Color); typography (Typography); rounded, padding, size, height, width (Dimension).
Variants: define UI states as separate entries with a related key — button-primary, button-primary-hover.
4. Sections (canonical order)
| # | Section | Aliases | Purpose |
|---|---|---|---|
| 1 | Overview | Brand & Style | Brand personality, audience, emotional tone. Fallback context when a token isn't defined. |
| 2 | Colors | Palettes; at least primary. Common: primary/secondary/tertiary/neutral. |
|
| 3 | Typography | 9–15 levels, each a semantic role (headline/body/label) × size. | |
| 4 | Layout | Layout & Spacing | Grid model, spacing scale, containment. |
| 5 | Elevation & Depth | Elevation | Shadows, OR for flat designs the alternative (borders, tonal layers, contrast). |
| 6 | Shapes | Corner radii, edge treatment, shape language. | |
| 7 | Components | Per-atom guidance: Buttons, Inputs, Cards, Chips, Lists, etc. | |
| 8 | Do's and Don'ts | Guardrails during generation. |
5. Recommended token names (guidance, not required)
- Colors:
primary secondary tertiary neutral surface on-surface error - Typography:
headline-display headline-lg headline-md body-lg body-md body-sm label-lg label-md label-sm - Rounded:
none sm md lg xl full
6. Consumer behavior for unknown content
The
常见问题
DESIGN.md 文件里应该写什么?
文件包含颜色、字体、间距和圆角等设计变量,以及它们的文字理由。
我可以从示例开始吗?
可以。技能指向一个收集了真实 DESIGN.md 文件的合集,你可以参考或改编。
在构建用户界面之前必须有它吗?
技能把它当作一道关口,因此在编写组件或页面之前,应先有 DESIGN.md。
详情
作者的原始描述
How to author a DESIGN.md file — the machine-readable design-token + human-rationale format that must exist before any UI is built. YAML front-matter token schema (colors, typography, spacing, rounded, components), type system, token references, and canonical section order.
repo: vudovn/ag-kit
热度
- GitHub 星标
- 8.2k
- 排名
- #12531
- 许可证
- MIT
- 更新时间
- 2026/10/18
评论
- …