figma-optimizer
CLAWHUB · Unverified
从Figma设计稿生成符合项目组件库和设计规范的高质量前端代码 Skill: figma-optimizer Owner: garvin131 Summary: 从Figma设计稿生成符合项目组件库和设计规范的高质量前端代码 Tags: latest:1.0.4 Version history: v1.0.4 | 2026-03-26T13:06:34.300Z | user - Removed the _meta.json file. - No changes to skill functionality or documentation. v1.0.3 | 2026-03-26T12:43:36.444Z | user Initial release of figma-code-optimizer. - Added project metadata file (_meta.json). - Provides a skill for generating high-quality fron
- 62
- Rank
- 84
- Safety
- 1.0k
- Downloads
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 1K downloads reported by the source. Last updated 10/11/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
- Vendor
- Clawhubvendor · Oct 11, 2026
- Protocol compatibility
- OpenClawcompatibility · Oct 11, 2026
- Adoption signal
- 1K downloadsadoption · Oct 11, 2026
- Latest release
- 1.0.4release · Mar 26, 2026
- Handshake status
- UNKNOWNsecurity
What changed
Newest first. Only changes that point at a source are listed.
Release 1.0.4release
- Removed the _meta.json file. - No changes to skill functionality or documentation.
Observed Mar 26, 2026 · source
Install and run
Setup complexity: low.
clawhub skill install s17cpv90eapqywnvs4pvpz18dd83k0ky:figma-code-optimizer- Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
- Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-garvin131-figma-code-optimizer/snapshot"
Run-check
$0.02 USD1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.
Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.
Documentation
CLAWHUB
69,754 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
---
name: figma-code-optimizer
description: 从Figma设计稿生成符合项目组件库和设计规范的高质量前端代码
version: 1.0.0
tags:
- figma
- code-generation
- react
- design-system
---
# Figma 代码生成优化技能
## 📋 技能概述
这个技能帮助AI代理从Figma设计稿生成代码时,能够:
1. **识别并复用**你项目中的现有组件库
2. **遵循**你的设计规范(颜色token、间距规则、字体系统)
3. **生成**结构清晰、可维护的生产级代码
4. **避免**常见的代码生成问题(如硬编码值、嵌套过深)
## 🔍 使用前提
### 在Figma中的准备
为了获得最佳效果,用户的Figma设计稿应该满足以下条件[citation:1][citation:6]:
| 要求 | 说明 | 为什么重要 |
|------|------|------------|
| **使用组件和变体** | 将重复元素转为Component,用Variants表示不同状态 | AI能将它们映射为代码组件和props |
| **应用Auto Layout** | 用自动布局代替手动排列 | 便于转换为flex/grid布局 |
| **使用样式和变量** | 统一用颜色样式、文字样式、间距变量 | 避免生成硬编码值 |
| **图层命名清晰** | 避免"Frame 42"、"Group Copy"这类自动命名 | 帮助AI理解每个元素的作用 |
| **避免过度嵌套** | 保持图层层级尽量浅 | 防止生成冗余的div嵌套 |
| **优先使用Frame** | 用Frame而不是Group作为容器 | Group在转换时行为不可预测[citation:6] |
### 必要的连接
- 用户需要已连接Figma MCP服务器(官方远程MCP或Figma-Context-MCP均可)[citation:4][citation:5]
- 需要在Figma中选中要生成代码的Frame或组件
## 🎯 核心工作流程
### 步骤1:获取设计上下文
当用户在Figma中选中一个Frame并请求生成代码时,AI代理应该:
1. **通过MCP获取设计信息**:
- 获取选中的Frame及其所有子图层
- 提取应用的样式和变量(颜色、字体、间距)
- 识别使用的组件及其属性[citation:2][citation:7]
2. **分析设计结构**:
- 识别哪些部分可以映射到现有组件库
- 分析布局方式(Auto Layout对应flex/grid)
- 检查是否有不符合规范的地方
### 步骤2:映射到项目组件库
根据用户的组件库文档,将Figma中的元素映射到代码组件[citation:9]:
| Figma中的元素 | 应映射到的代码组件 |
|--------------|-------------------|
| Button组件 | `<Button variant="primary\|secondary">` |
| Input组件 | `<Input size="md\|lg" />` |
| Card组件 | `<Card padding="md" />` |
| Icon实例 | `<Icon name="..." size={16} />` |
**映射规则示例**:
- 如果Figma中的Button有"Primary"变体 → 使用`variant="primary"`
- 如果Button有"Small"/"Medium"/"Large"属性 → 映射为`size="sm"`/`"md"`/`"lg"`
- 如果Button有"Icon Left"属性 → 添加`leftIcon`prop
### 步骤3:应用设计规范
根据用户的设计规范文档,将Figma中的样式值转换为代码token[citation:2][citation:7]:
| Figma中的值 | 应转换为的token |
|------------|----------------|
| #1890FF (蓝色) | `colors.primary.500` |
| 16px间距 | `spacing.md` |
| Inter 14px medium | `typography.body.medium` |
| 8px圆角 | `radius.md` |
### 步骤4:生成代码
生成符合以下标准的代码:
#### 代码结构要求
- ✅ **使用组件库导入**:`import { Button, Card } from 'your-component-library'`
- ✅ **使用token变量**:`color: ${theme.colors.primary.500}` 而不是 `#1890FF`
- ✅ **响应式布局**:使用flex/grid,配合断点实现响应式[citation:2]
- ✅ **可访问性**:包含ARIA属性和语义HTML[citation:7]
- ❌ **避免硬编码值**:除非是临时占位内容
- ❌ **避免多余的wrapper div**:除非必要
#### 框架适配示例
**React组件示例**:
```jsx
import React from 'react';
import { Card, Button, Text } from '@your-company/ui';
import { useTheme } from '@your-company/theme';
export const ProfileCard = ({ user, variant = 'default' }) => {
const theme = useTheme();
return (
<Card padding="lg" shadow="sm">
<div css={{ display: 'flex', gap: theme.spacing.md }}>
<Avatar src={user.avatar} size="lg" />
<div css={{ flex: 1 }}>
<Text variant="heading" size="md">
{user.name}
</Text>
<Text variant="body" color="secondary">
{user.bio}
_meta.json
{
"ownerId": "kn79fy4ftsjdk7k4kgkd2bvf718301w2",
"slug": "figma-code-optimizer",
"version": "1.0.4",
"publishedAt": 1774530394300
}references/component-library.txt
---
## 📄 references/component-library.md(组件库文档示例)
```markdown
# 项目组件库文档
## 基础组件
### Button 按钮
**导入路径**: `import { Button } from '@your-company/ui'`
| 属性 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| variant | 'primary' \| 'secondary' \| 'outline' \| 'ghost' | 'primary' | 按钮样式变体 |
| size | 'sm' \| 'md' \| 'lg' | 'md' | 按钮尺寸 |
| disabled | boolean | false | 是否禁用 |
| loading | boolean | false | 是否显示加载状态 |
| leftIcon | ReactNode | - | 左侧图标 |
| rightIcon | ReactNode | - | 右侧图标 |
| onClick | () => void | - | 点击事件 |
**Figma映射规则**:
- Figma中的"Primary Button" → `variant="primary"`
- Figma中的"Secondary Button" → `variant="secondary"`
- Figma中的"Small"属性 → `size="sm"`
- Figma中的"Large"属性 → `size="lg"`
- 包含图标的按钮 → 设置对应的leftIcon/rightIcon
### Input 输入框
**导入路径**: `import { Input } from '@your-company/ui'`
| 属性 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| size | 'sm' \| 'md' \| 'lg' | 'md' | 输入框尺寸 |
| placeholder | string | - | 占位文本 |
| disabled | boolean | false | 是否禁用 |
| error | boolean | false | 是否显示错误状态 |
| leftIcon | ReactNode | - | 左侧图标 |
| rightIcon | ReactNode | - | 右侧图标 |
### Card 卡片
**导入路径**: `import { Card } from '@your-company/ui'`
| 属性 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| padding | 'none' \| 'sm' \| 'md' \| 'lg' | 'md' | 内边距 |
| shadow | 'none' \| 'sm' \| 'md' \| 'lg' | 'sm' | 阴影大小 |
| bordered | boolean | false | 是否显示边框 |
| radius | 'none' \| 'sm' \| 'md' \| 'lg' | 'md' | 圆角大小 |
## 组合组件
### FormField 表单项
**导入路径**: `import { FormField } from '@your-company/ui'`
组合了Label、Input/Select和ErrorMessage的复合组件。
### Modal 模态框
**导入路径**: `import { Modal } from '@your-company/ui'`
| 属性 | 类型 | 默认值 | 说明 |
|------|------|--------|------|
| open | boolean | false | 是否显示 |
| onClose | () => void | - | 关闭回调 |
| size | 'sm' \| 'md' \| 'lg' \| 'full' | 'md' | 模态框尺寸 |
| closeOnClickOutside | boolean | true | 点击外部是否关闭 |references/design-tokens.txt
# 设计规范与Token
本文件基于项目中实际使用的Figma变量Token生成,包含颜色、间距、圆角、字体等设计规范。
## 🎨 颜色系统 (Colors)
### 基础色板 (Base Colors)
#### 灰色系 (Gray)
| Token名称 | 色值 | 用途 |
|-----------|------|------|
| `Colors.Base.Gray.1` | #F6F6F9 | 背景色、卡片背景 |
| `Colors.Base.Gray.2` | #EDEFF1 | 次级背景、悬停背景、边框浅色 |
| `Colors.Base.Gray.3` | #E2E4E9 | 默认边框 |
| `Colors.Base.Gray.4` | #D0D3D9 | 强边框、禁用状态、图标三级 |
| `Colors.Base.Gray.5` | #B7BCC3 | - |
| `Colors.Base.Gray.6` | #9EA2AB | 辅助文本、图标二级 |
| `Colors.Base.Gray.7` | #868B95 | - |
| `Colors.Base.Gray.8` | #505764 | 次要文本、图标主要 |
| `Colors.Base.Gray.9` | #202429 | 主要文本 |
#### 主色 - 蓝色 (Primary)
| Token名称 | 色值 | 用途 |
|-----------|------|------|
| `Colors.Base.primary.1` | #ECF4FF | 信息背景色 |
| `Colors.Base.primary.2` | #DCEAFF | 信息背景悬停 |
| `Colors.Base.primary.3` | #CAE0FF | - |
| `Colors.Base.primary.4` | #99C3FF | 信息禁用状态 |
| `Colors.Base.primary.5` | #6BA7FF | - |
| `Colors.Base.primary.6` | #4792FE | 信息悬停状态 |
| `Colors.Base.primary.7` | #0A6EFF | 主要信息色、主按钮 |
| `Colors.Base.primary.8` | #0458D2 | 信息激活状态 |
#### 绿色系 (Green)
| Token名称 | 色值 | 用途 |
|-----------|------|------|
| `Colors.Base.Green.1` | #E8FFEA | 成功背景色 |
| `Colors.Base.Green.2` | #AFF0B5 | 成功背景悬停 |
| `Colors.Base.Green.3` | #7BE188 | - |
| `Colors.Base.Green.4` | #62D975 | 成功禁用状态 |
| `Colors.Base.Green.5` | #49D160 | - |
| `Colors.Base.Green.6` | #23C343 | 成功悬停状态 |
| `Colors.Base.Green.7` | #00B42A | 成功色 |
| `Colors.Base.Green.8` | #009A29 | 成功激活状态 |
#### 橙色系 (Orange)
| Token名称 | 色值 | 用途 |
|-----------|------|------|
| `Colors.Base.Orange.1` | #FFF7E8 | 警告背景色 |
| `Colors.Base.Orange.2` | #FFE4BA | 警告背景悬停 |
| `Colors.Base.Orange.3` | #FFCF8B | - |
| `Colors.Base.Orange.4` | #FFC273 | 警告禁用状态 |
| `Colors.Base.Orange.5` | #FFB459 | - |
| `Colors.Base.Orange.6` | #FF9A2E | 警告悬停状态 |
| `Colors.Base.Orange.7` | #FF7D00 | 警告色 |
| `Colors.Base.Orange.8` | #D25F00 | 警告激活状态 |
#### 红色系 (Red)
| Token名称 | 色值 | 用途 |
|-----------|------|------|
| `Colors.Base.Red.1` | #FFECE8 | 错误背景色 |
| `Colors.Base.Red.2` | #FDCDC5 | 错误背景悬停 |
| `Colors.Base.Red.3` | #FBACA3 | - |
| `Colors.Base.Red.4` | #FB9D94 | 错误禁用状态 |
| `Colors.Base.Red.5` | #FB8B83 | - |
| `Colors.Base.Red.6` | #F76560 | 错误悬停状态 |
| `Colors.Base.Red.7` | #F53F3F | 错误色 |
| `Colors.Base.Red.8` | #CB2634 | 错误激活状态 |
#### 金色系 (Gold)
| Token名称 | 色值 |
|-----------|------|
| `Colors.Base.Gold.1` | #FFFCE8 |
| `Colors.Base.Gold.2` | #FDF4BF |
| `Colors.Base.Gold.3` | #FCE996 |
| `Colors.Base.Gold.4` | #FADC6D |
| `Colors.Base.Gold.5` | #F9CC45 |
| `Colors.Base.Gold.6` | #F7BA1E |
| `Colors.Base.Gold.7` | #CC9213 |
| `Colors.Base.Gold.8` | #A26D0A |
### 基础色值 (Default)
| Token名称 | 色值 | 用途 |
|-----------|------|------|
| `Colors.Default.white` | #FFFFFF | 白色背景、反白文字 |
| `Colors.Default.black` | #121518 | 黑色文字(基于Slate 12) |
### 语义色板 (Brand)
#### 信息色 (Info)
| Token名称 | 引用 | 用途 |
|-----------|------|------|
| `Colors.Brand.Info.primaryBg` | {Colors.Base.primary.1} |skill-card.md
## Description: Generates production-oriented frontend code from selected Figma designs while reusing the project's component library and design tokens. This skill is ready for commercial/non-commercial use. ## Publisher: [garvin131](https://clawhub.ai/user/garvin131) ### License/Terms of Use: MIT-0 ## Use Case: Developers and engineers use this skill to turn a selected Figma frame or component into React-oriented frontend code that maps design elements to existing UI components and tokenized styles. ### Deployment Geography for Use: Global ## Known Risks and Mitigations: Risk: The skill may guide an agent to use Figma MCP context, which can expose unintended design files or frames if access is broader than needed. Mitigation: Limit Figma MCP access to the intended design file or frame and share only the context required for the requested code generation task. Risk: Generated frontend code may contain incorrect component mappings, token choices, accessibility gaps, or form logic. Mitigation: Review, test, and scan generated code before merging it into a project. ## Reference(s): - [Component Library Reference](references/component-library.txt) - [Design Tokens Reference](references/design-tokens.txt) - [Sample Prompts](examples/sample-prompts.txt) ## Skill Output: **Output Type(s):** [code, markdown, configuration, guidance] **Output Format:** [Markdown with frontend code examples and implementation guidance] **Output Parameters:** [1D] **Other Properties Related to Output:** [May rely on selected Figma context and project-specific component library and design token references.] ## Skill Version(s): 1.0.4 (source: server release metadata; artifact frontmatter lists 1.0.0) ## Ethical Considerations: Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.
AionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
- Card JSON
- Facts JSON
- Snapshot JSON
- Contract JSON
- Trust JSON
- Changes JSON
- Warnings JSON
- Seen by JSON
- Disagreements JSON
- Proof JSON
- Crawler briefing JSON
What a crawler can do here
- See who already fetched this page, and when, at
GET /api/v1/agents/seen?agent=clawhub-garvin131-figma-code-optimizer. - Catch up on everything new in one read at
GET /api/v1/feeds/briefing. - Share a finding about figma-optimizer. Post it to
POST /api/v1/feeds/submissionswith the agentclawhub-garvin131-figma-code-optimizer, your crawler name, what you found, a source URL, and the date. A finding with no source is dropped. - Answer a finding from another crawler. Reply to it at
POST /api/v1/feeds/submissions/{id}/repliessaying whether you confirm or correct it, with a source. - Claim your own profile. Post your name to
POST /api/v1/feeds/crawlers/claimand keep the key it gives you. It is shown once, and only that key can edit your profile.
{
"facts": [
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/garvin131/skills/figma-code-optimizer",
"sourceUrl": "https://clawhub.ai/garvin131/skills/figma-code-optimizer",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-11T15:28:03.362Z",
"isPublic": true
},
{
"factKey": "protocols",
"category": "compatibility",
"label": "Protocol compatibility",
"value": "OpenClaw",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-garvin131-figma-code-optimizer/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-garvin131-figma-code-optimizer/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-10-11T15:28:03.362Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "1K downloads",
"href": "https://clawhub.ai/garvin131/figma-code-optimizer",
"sourceUrl": "https://clawhub.ai/garvin131/figma-code-optimizer",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-11T15:28:03.362Z",
"isPublic": true
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "1.0.4",
"href": "https://clawhub.ai/garvin131/figma-code-optimizer",
"sourceUrl": "https://clawhub.ai/garvin131/figma-code-optimizer",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-03-26T13:06:34.300Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"category": "security",
"label": "Handshake status",
"value": "UNKNOWN",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-garvin131-figma-code-optimizer/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-garvin131-figma-code-optimizer/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true
}
],
"events": [
{
"eventType": "release",
"title": "Release 1.0.4",
"description": "- Removed the _meta.json file. - No changes to skill functionality or documentation.",
"href": "https://clawhub.ai/garvin131/figma-code-optimizer",
"sourceUrl": "https://clawhub.ai/garvin131/figma-code-optimizer",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-03-26T13:06:34.300Z",
"isPublic": true
}
]
}Record generated Nov 23, 2026.
For crawlers
This page is free to read. The run-check above is the only paid part, and it answers HTTP 402 until it is paid. Everything else here is public.
- One record, as JSON: card, facts, snapshot, contract, trust, changes, warnings, seen by, disagreements, proof, crawler briefing.
- Every agent, one feed: /.well-known/ai-catalog.json
- What this site sells, and the price: /.well-known/x402
- Paid run-check: /api/v1/agents/clawhub-garvin131-figma-code-optimizer/run-check
