design-extract
它能做什么
这个工具会收集散落在代码文件或图片中的设计信息,比如颜色、字体排版和间距,并把它们整理到一个地方,供其他程序使用。
适用场景
- ✓当你的项目中有各种分散的设计元素时。
- ✓当你要把设计从一个程序迁移到另一个程序时。
- ✓当你想整理网站或应用的视觉样式时。
技能链接
https://github.com/nexu-io/open-design/blob/main/plugins/_official/atoms/design-extract/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“把我代码和图片中的设计元素整理到一个文件里。”
每周 5 个新技能,1 分钟读完。
工作原理
工具会在不同类型的代码文件(如 CSS 或 JavaScript)以及图片中,查找颜色、字体和间距的定义。它会收集这些信息,并以标准化的格式保存下来。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Design extract
Spec §10 / §21.3.2: tokens scattered across a repo's CSS / theme
files / Tailwind config / styled-components helpers / SCSS partials
need to be lifted into one bag before token-map can crosswalk
them onto the active OD design system. This atom does the lifting;
the input shape is intentionally generic so the same atom serves
both code-migration and figma-migration when fed different sources.
Inputs
code/index.jsonfromcode-import(code-migration), ORfigma/tree.jsonfromfigma-extract(figma-migration), OR- A folder of screenshot images (tune-collab quick-tune flows).
Output
project-cwd/
└── code/
└── tokens.json # { colors[], typography[], spacing[], radius[], shadow[] }
Each token entry carries:
{
"kind": "color",
"name": "primary-500", // optional source name
"value": "#5b8def", // canonical value
"sources": ["styles/global.css:42", "tailwind.config.js:24"],
"usage": ["Header.tsx", "Footer.tsx"]
}
sources[] and usage[] are the audit trail token-map.unmatched.json
references when a target token can't be found.
Convergence
The atom completes when code/tokens.json exists. Empty token bags
emit a warning event but do not abort — token-map handles the
empty case by skipping its mapping pass.
Anti-patterns the prompt fragment forbids
- Hard-coded hex values inside JSX literals (
color: '#fff') are tokens for this atom's purposes; record them withkind:'color'and a synthetic name so they don't disappear into the noise. - Tailwind utility scans must dedupe palette references against the
active theme — never list
bg-blue-500andbg-blue-600as one token.
Status
Implemented by the daemon runner in
apps/daemon/src/plugins/atoms/design-extract.ts. It scans the indexed
source files, extracts CSS, Tailwind, and JavaScript token evidence, and
writes code/tokens.json.
常见问题
什么是“设计令牌”(design tokens)?
它们就像项目视觉外观的基本构件,比如实际用到的精确颜色、字体类型,以及元素之间的间距。
为什么要整理这些“令牌”?
整理“令牌”能让整个项目的设计维护和一致性更容易,也让其他工具能更高效地使用这些信息。
这个工具能从任何类型的文件中提取设计吗?
它主要适用于常见的代码文件(CSS、JavaScript、Tailwind 等)和图片。对于比较复杂的设计,比如在 Figma 中做的设计,可能需要多一个步骤。
详情
作者的原始描述
Extract design tokens (color / typography / spacing) from imported source code, screenshots, or Figma exports into the canonical token bag token-map consumes.
repo: nexu-io/open-design
热度
- GitHub 星标
- 101k
- 排名
- #981
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/15
评论
- …