token-map
它能做什么
这个程序可以整理设计稿的视觉样式(比如颜色和字体),让它们与现有的设计系统协调一致。它会将你设计稿中的样式与设计系统中定义的样式进行比对,并生成一份映射表,确保两者保持统一。
适用场景
- ✓将设计稿从 Figma 迁移到代码时。
- ✓将现有设计更新为使用新的设计系统时。
- ✓当你想确保设计稿与设计系统之间的所有视觉样式(颜色、字体、间距)保持一致时。
技能链接
https://github.com/nexu-io/open-design/blob/main/plugins/_official/atoms/token-map/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把我设计稿中的颜色和排版令牌(token)映射到当前激活的设计系统中。”
每周 5 个新技能,1 分钟读完。
工作原理
程序会分析你的设计稿中的视觉样式(即令牌 token,可以从 Figma 或代码中提取)。它会根据每种样式在设计中的使用方式,推测其用途(例如是主色还是标题样式)。然后生成一个文件,显示你设计稿中的每个样式对应设计系统中的哪个样式。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Token map
Spec §10 / §21.3.1: every figma-migration / code-migration run crosses the same boundary — "the source has its own tokens; the target uses the active OD design system; we need a deterministic mapping". This atom produces that mapping.
Inputs
figma/tokens.jsonfromfigma-extract(figma-migration), ORcode/tokens.jsonfromdesign-extract(code-migration).- The active design system DESIGN.md (already injected into the prompt; the atom reads from the staged design-system context).
Output
project-cwd/
└── token-map/
├── colors.json # { source: '#hex' | 'tokenName', target: '--ds-token' }[]
├── typography.json # font + size + weight pairings
├── spacing.json # spacing scale crosswalk
├── unmatched.json # { source: ..., reason: 'no-target-equivalent' }[]
└── meta.json # { sourceKind: 'figma' | 'code', generatedAt, atomDigest }
unmatched.json is the audit list a human reviews; the agent must
not invent target tokens silently.
Semantic token inference
Figma often exports anonymous source names such as color-3,
paint/17, or raw #5B8DEF. Do not ask the user to rename those
before mapping. First infer the semantic role from usage evidence:
- Node path, component name, instance overrides, variant/state labels,
frame name, layer name, and nearby text such as
Primary,Selected,Link,Error,Focus,Nav,Button, orCTA. - CSS-like position in the rendered tree: background fill, foreground text/icon, border, divider, overlay, shadow tint, focus ring, status badge, chart series, or brand/accent treatment.
- Contrast relationships: a color paired repeatedly with the main canvas is likely foreground; one paired with foreground inside CTA components is likely primary/accent background; a thin outline around interactive elements is likely border or focus-ring.
- Reuse topology: a value that appears across primary buttons,
selected tabs, and active nav items is stronger evidence for
--ds-color-primarythan a value that appears once in an illustration.
Use that role evidence to choose among existing active design-system
tokens and to decide whether an anonymous token should be renamed or
left unmatched before the executable mapping pass. Keep the on-disk
token-map contract unchanged: the atom still writes the existing bucket
files, unmatched.json, and meta.json only.
For example, this is a useful reasoning note for deciding whether
color-3 should map to the active primary token:
{
"source": "color-3",
"value": "#5B8DEF",
"role": "primary",
"targetCandidates": ["--ds-color-primary", "--ds-color-link"],
"evidence": [
"Button/Primary fill",
"Selected tab indicator",
"Link text in Settings frame"
]
}
Then map to an active design-system token only when the evidence is
role-based, not value-only. If the top candidates are too close to
call, or if the evidence points to conflicting roles (primary vs
link vs focus-ring), leave the source token unmatched using the
existing no-target-equivalent reason and include the competing
candidates in the hint. This keeps automation useful for common
anonymous-token cases while preserving human review for ambiguous
brand decisions.
Before / after expectation
Without semantic inference, an anonymous Figma token can only produce an uncertain value-level mapping:
{
"source": "color-3",
"value": "#5B8DEF",
"target": null,
"reason": "no-target-equivalent"
}
With semantic inference, the same token should carry role evidence before it is accepted:
{
"source": "color-3",
"value": "#5B8DEF",
"target": "--ds-color-primary",
"via": "name"
}
This deterministic v1 atom does not claim a measured accuracy lift by
itself. Treat the expected improvement as coverage of previously
manual anonymous-token cases when the Figma tree contains enough role
evidence. Real accuracy numbers require a fixture suite with known
source tokens, expected semantic roles, and a before/after agent run.
See examples/semantic-inference-before-after.json for a deterministic
same-token-batch simulation that compares the old value-level output
with the semantic inference output.
Convergence
The atom completes when every input token is either mapped or
explicitly recorded under unmatched.json with a non-empty
reason. The until evaluator reads tokens.unmatched.length === 0
…
常见问题
什么是令牌(token)?
令牌是设计视觉样式的基本构件,比如一种具体的颜色(例如蓝色 #0000FF)、一个字号(例如 16px)或一个间距值(例如 8px)。
如果设计稿中的某个样式在设计系统中找不到对应项,会怎样?
程序会把这些样式列在一个名为 unmatched.json 的文件中,并说明无法映射的原因。这样你就可以自行检查并决定如何处理,而不是让程序随意生成一个样式。
程序如何判断设计稿中的哪个样式对应设计系统中的哪个样式?
它会参考设计中的一些线索,比如组件名称、样式的使用场景(例如按钮文字),以及颜色之间的关系,从而推断样式的用途,并在设计系统中找到最匹配的样式。
详情
作者的原始描述
Map an extracted Figma / source-code token bag onto the active OD design system, producing a deterministic mapping the generate stage can consume.
repo: nexu-io/open-design
热度
- GitHub 星标
- 101k
- 排名
- #990
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/15
评论
- …