design-tokens-extraction by arustydev/ai
npx skills add https://github.com/arustydev/ai --skill design-tokens-extraction从设计文件中提取并规范化设计令牌,转换为标准化格式。
此技能支持通过相应的 MCP 服务器从 Figma、Sketch 和 Penpot 设计文件中提取设计令牌。提取的令牌将被规范化为 W3C 设计令牌社区组格式,以便进行平台无关的存储和转换。
此技能涵盖:
此技能不涵盖:
design-to-swiftui 技能)| 服务器 | 工具 | 用途 |
|---|---|---|
figma | get_file | 读取 Figma 文件结构 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
figma | get_styles | 提取已发布的样式 |
figma | get_local_variables | 提取变量/令牌 |
sketch-context | get_document | 读取 Sketch 文档 |
sketch-context | get_shared_styles | 提取共享样式 |
sketch-context | get_color_assets | 提取颜色变量 |
penpot | get_file | 读取 Penpot 文件 |
penpot | get_components | 列出设计组件 |
| 类别 | 提取的属性 |
|---|---|
| 颜色 | hex、rgb、hsl、不透明度、描述 |
| 排版 | 字体族、大小、粗细、行高、字间距 |
| 间距 | 值(px、rem)、描述 |
| 阴影 | 颜色、offsetX、offsetY、模糊、扩散 |
| 边框半径 | 值(px、rem) |
| 持续时间 | 值(ms) |
确定设计源并使用相应的 MCP 服务器:
Figma:
Use figma MCP server with get_file tool
Input: file_key from Figma URL (e.g., "abc123" from figma.com/file/abc123/...)
Sketch:
Use sketch-context MCP server with get_document tool
Input: file path to .sketch file
Penpot:
Use penpot MCP server with get_file tool
Input: project_id and file_id from Penpot URL
向 MCP 服务器查询设计令牌:
颜色:
get_styles,Sketch:get_shared_styles)get_local_variables,Sketch:get_color_assets)排版:
间距:
阴影:
将提取的数据转换为 W3C 设计令牌结构:
{
"$schema": "https://design-tokens.github.io/community-group/format/",
"color": {
"<category>": {
"<name>": {
"$value": "#hexcode",
"$type": "color",
"$description": "From design file"
}
}
},
"typography": {
"fontFamily": { ... },
"fontSize": { ... },
"fontWeight": { ... }
},
"spacing": { ... },
"shadow": { ... }
}
使用适当的输出样式:
design-token-json - W3C DTCG 格式(默认)design-token-swift - Swift 扩展design-token-css - CSS 自定义属性design-token-tailwind - Tailwind 配置从 Figma 读取时:
已发布的样式(首选):
get_styles 并设置 style_type: "FILL"变量(Figma 变量):
get_local_variablesresolvedType: "COLOR" 筛选组件填充(备用方案):
从 Sketch 读取时:
共享样式:
get_shared_styles 并设置 style_type: "layer"颜色资源:
get_color_assets文档颜色:
从 Penpot 读取时:
颜色库:
组件颜色:
| 源格式 | 目标格式 |
|---|---|
rgba(r, g, b, a) | #RRGGBBAA |
rgb(r, g, b) | #RRGGBB |
hsl(h, s%, l%) | #RRGGBB(已转换) |
{ r, g, b } (0-1) | #RRGGBB(已缩放) |
{ r, g, b } (0-255) | #RRGGBB |
| 属性 | 源格式变体 | 目标 |
|---|---|---|
| 字体大小 | 12px、0.75rem、12 | "0.75rem" 或 12 |
| 字体粗细 | "bold"、700、"semibold" | 700(数值) |
| 行高 | 1.5、150%、24px | 1.5(无单位比率) |
| 字间距 | 0.5px、0.02em | "0.02em" |
| 源样式 | 目标样式 | 示例 |
|---|---|---|
color/primary/500 | color.primary.500 | 嵌套分组 |
Primary Color | primaryColor | 驼峰命名法 |
primary-color | primaryColor | 驼峰命名法 |
PRIMARY_COLOR | primaryColor | 驼峰命名法 |
保留源信息以便追溯:
{
"color": {
"primary": {
"$value": "#2196F3",
"$type": "color",
"$extensions": {
"com.figma": {
"variableId": "VariableID:1234",
"styleId": "S:abc123",
"collectionName": "Brand Colors"
}
}
}
}
}
症状: 提取返回空或极少的令牌
解决方案:
症状: MCP 服务器返回 401 或访问被拒绝
解决方案:
FIGMA_ACCESS_TOKEN症状: 令牌名称与预期格式不匹配
解决方案:
design-token-json 样式 - W3C 格式输出design-token-swift 样式 - Swift 代码输出design-to-swiftui 技能 - 根据令牌生成 SwiftUI 视图design-system-management 技能 - 管理令牌库每周安装次数
1
代码仓库
GitHub 星标数
6
首次出现
1 天前
安全审计
安装于
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
Extract and normalize design tokens from design files into standardized formats.
This skill enables extraction of design tokens from Figma, Sketch, and Penpot design files using their respective MCP servers. Extracted tokens are normalized to the W3C Design Tokens Community Group format for platform-agnostic storage and conversion.
This skill covers:
This skill does NOT cover:
design-to-swiftui skill)| Server | Tool | Purpose |
|---|---|---|
figma | get_file | Read Figma file structure |
figma | get_styles | Extract published styles |
figma | get_local_variables | Extract variables/tokens |
sketch-context | get_document | Read Sketch document |
sketch-context | get_shared_styles | Extract shared styles |
sketch-context | get_color_assets | Extract color variables |
penpot | get_file | Read Penpot file |
penpot | get_components | List design components |
| Category | Properties Extracted |
|---|---|
| Color | hex, rgb, hsl, opacity, description |
| Typography | family, size, weight, lineHeight, letterSpacing |
| Spacing | value (px, rem), description |
| Shadow | color, offsetX, offsetY, blur, spread |
| Border Radius | value (px, rem) |
| Duration | value (ms) |
Determine the design source and use the appropriate MCP server:
Figma:
Use figma MCP server with get_file tool
Input: file_key from Figma URL (e.g., "abc123" from figma.com/file/abc123/...)
Sketch:
Use sketch-context MCP server with get_document tool
Input: file path to .sketch file
Penpot:
Use penpot MCP server with get_file tool
Input: project_id and file_id from Penpot URL
Query the MCP server for design tokens:
Colors:
get_styles, Sketch: get_shared_styles)get_local_variables, Sketch: get_color_assets)Typography:
Spacing:
Shadows:
Transform extracted data to W3C Design Tokens structure:
{
"$schema": "https://design-tokens.github.io/community-group/format/",
"color": {
"<category>": {
"<name>": {
"$value": "#hexcode",
"$type": "color",
"$description": "From design file"
}
}
},
"typography": {
"fontFamily": { ... },
"fontSize": { ... },
"fontWeight": { ... }
},
"spacing": { ... },
"shadow": { ... }
}
Use the appropriate output style:
design-token-json - W3C DTCG format (default)design-token-swift - Swift extensionsdesign-token-css - CSS custom propertiesdesign-token-tailwind - Tailwind configWhen reading from Figma:
Published Styles (preferred):
get_styles with style_type: "FILL"Variables (Figma variables):
get_local_variablesresolvedType: "COLOR"Component Fills (fallback):
When reading from Sketch:
Shared Styles :
get_shared_styles with style_type: "layer"Color Assets :
get_color_assetsDocument Colors :
When reading from Penpot:
Color Library :
Component Colors :
| Source Format | Target Format |
|---|---|
rgba(r, g, b, a) | #RRGGBBAA |
rgb(r, g, b) | #RRGGBB |
hsl(h, s%, l%) | #RRGGBB (converted) |
{ r, g, b } (0-1) | #RRGGBB (scaled) |
| Property | Source Variations | Target |
|---|---|---|
| Font Size | 12px, 0.75rem, 12 | "0.75rem" or 12 |
| Font Weight | "bold", 700, "semibold" | 700 (numeric) |
| Source Style | Target Style | Example |
|---|---|---|
color/primary/500 | color.primary.500 | Nested groups |
Primary Color | primaryColor | camelCase |
primary-color | primaryColor | camelCase |
PRIMARY_COLOR |
Preserve source information for traceability:
{
"color": {
"primary": {
"$value": "#2196F3",
"$type": "color",
"$extensions": {
"com.figma": {
"variableId": "VariableID:1234",
"styleId": "S:abc123",
"collectionName": "Brand Colors"
}
}
}
}
}
Symptoms: Extraction returns empty or minimal tokens
Solution:
Symptoms: MCP server returns 401 or access denied
Solution:
FIGMA_ACCESS_TOKEN is set for FigmaSymptoms: Token names don't match expected format
Solution:
design-token-json style - W3C format outputdesign-token-swift style - Swift code outputdesign-to-swiftui skill - Generate SwiftUI views from tokensdesign-system-management skill - Manage token librariesWeekly Installs
1
Repository
GitHub Stars
6
First Seen
1 day ago
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
zencoder1
amp1
cline1
openclaw1
opencode1
cursor1
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
147,400 周安装
{ r, g, b } (0-255) | #RRGGBB |
| Line Height | 1.5, 150%, 24px | 1.5 (unitless ratio) |
| Letter Spacing | 0.5px, 0.02em | "0.02em" |
primaryColor |
| camelCase |