← 返回 Skills 市场
wangzhiming1999

Design To Code

作者 wangzhiming · GitHub ↗ · v1.0.1 · MIT-0
cross-platform ✓ 安全检测通过
1778
总下载
0
收藏
15
当前安装
2
版本数
在 OpenClaw 中安装
/install design-to-code
功能描述
Implements UI from design mockups (Figma, Sketch, or image) with pixel-accurate layout, responsive behavior, and design tokens. Use when 还原设计图, implementing...
使用说明 (SKILL.md)

\r \r

还原设计图(Design to Code)\r

\r 将设计稿(Figma/Sketch/图片)高保真还原为前端代码,保证布局、间距、字体、颜色与交互一致。\r \r

触发场景\r

\r

  • 用户说「还原设计图」「按设计稿实现」「切图」「设计转代码」\r
  • 提供 Figma/Sketch 链接、设计图截图或标注\r
  • 需要实现某个页面/组件的 UI\r \r

执行流程\r

\r

1. 先确认用户给了什么\r

\r | 用户给的 | 第一步 |\r |---------|-------|\r | Figma 链接 | 问:有没有 Figma 访问权限?如果没有,让用户截图或导出标注 |\r | 设计图截图 | 直接分析,提取尺寸/颜色/字体/间距,列出关键标注 |\r | 只有描述,没有设计图 | 问:「有没有设计稿?如果没有,我可以按常见 UI 规范实现,但可能和你预期有出入」 |\r | 有设计图 + 现有代码 | 先读现有代码,了解技术栈和已有组件,再还原设计 |\r \r

2. 分析设计稿,提取关键信息\r

\r 读设计图时,按这个顺序提取(不要跳过):\r \r 布局结构\r

  • 整体是几列?用 Flex 还是 Grid?\r
  • 各区块的宽度是固定的还是弹性的?\r
  • 有没有响应式断点?\r \r 间距与尺寸(精确到 px)\r
  • 容器的 padding\r
  • 元素之间的 gap/margin\r
  • 组件的宽高(固定值还是百分比)\r \r 字体\r
  • 字号、字重、行高、字间距\r
  • 颜色(含透明度)\r \r 颜色\r
  • 背景色、文字色、边框色、阴影\r
  • 是否能映射到项目已有的 design token 或 Tailwind 颜色\r \r 交互状态(设计稿里有没有标注)\r
  • hover、focus、active、disabled\r
  • 没有标注的,按项目现有规范处理,不要自己发明\r \r

3. 实现顺序,不要乱\r

\r 按这个顺序写代码,不要一上来就写细节:\r \r

  1. HTML 骨架:先把语义化结构搭出来,不加任何样式\r
  2. 布局:Flex/Grid 定位,保证对齐和间距\r
  3. 字体排版:字号、字重、行高、颜色\r
  4. 视觉装饰:背景、边框、圆角、阴影\r
  5. 交互状态:hover/focus/disabled\r
  6. 响应式:断点适配\r
  7. 动效:最后加,设计稿有说明才加\r \r

4. 遇到这些情况,按以下方式处理\r

\r 设计稿里的颜色/字号在项目 token 里没有\r → 先问用户:「这个颜色 #3B82F6 是不是对应 blue-500?」不要直接写魔法值\r → 如果确认没有对应 token,用 CSS 变量命名(--color-brand-primary),便于后续统一\r \r 设计稿标注不清晰,看不出具体数值\r → 说明哪里看不清,给出合理推测值,让用户确认:「这里间距看起来是 16px,对吗?」\r \r 设计稿有动效但没有说明\r → 不要自己发明动效,问用户:「这里有过渡动画吗?如果有,持续时间和缓动函数是什么?」\r \r 实现后和设计稿有出入\r → 主动说明差异和原因,不要假装没有:「这里字体用了系统字体代替,因为项目没有引入 Inter」\r \r

5. 还原度自检(提交前必做)\r

\r

  • 关键尺寸与设计稿一致(容忍 1-2px 差异)\r
  • 字体、颜色与设计一致\r
  • 主要断点下布局正常,无错位\r
  • 可交互元素有明确的状态反馈(hover/focus/disabled)\r
  • 语义化 HTML(按钮用 \x3Cbutton>,链接用 \x3Ca>,不用 \x3Cdiv> 代替)\r
  • 图片有 alt 属性\r \r

输出约定\r

\r

  • 使用项目现有技术栈(如 Next.js、Tailwind、SCSS、组件库)\r
  • 组件化:可复用部分拆成组件并命名清晰\r
  • 语义化 HTML + 合理 ARIA(按钮、链接、表单)\r
  • 必要时注明:某处与设计稿差异及原因(如兼容性、可访问性)\r \r

常用对照\r

\r | 设计稿 | 实现方式 |\r |--------|----------|\r | 8px 栅格 | 间距用 8 的倍数(8/16/24/32) |\r | 字体层级 | 对应 heading/body/caption 等语义类或 design token |\r | 模糊/毛玻璃 | backdrop-filter + 半透明背景 |\r | 多行截断 | line-clamp 或 -webkit-line-clamp |\r | 安全区域 | padding 配合 env(safe-area-inset-*) |\r

安全使用建议
This skill appears coherent and low-risk: it only contains step-by-step guidance for converting designs to frontend code and asks users to provide design assets or existing project code when necessary. Before using it, avoid pasting secrets or private tokens into messages; grant only the minimal access needed (for example, Figma view links or a code snippet rather than entire private repos) and confirm whether the agent will make commits or only generate code snippets. If you need the agent to use a Figma API token or push to a repository, treat those actions as separate and supply credentials through secure channels only when you explicitly intend that behavior.
功能分析
Type: OpenClaw Skill Name: design-to-code Version: 1.0.1 The skill bundle provides a set of instructions for an AI agent to act as a frontend developer, converting design mockups (Figma, Sketch, or images) into code. The instructions in SKILL.md focus on standard UI/UX practices such as layout analysis, design token mapping, and accessibility (ARIA). There are no indicators of malicious intent, data exfiltration, or harmful prompt injection.
能力评估
Purpose & Capability
Name/description (convert Figma/Sketch/images to frontend code) matches the SKILL.md: the instructions focus on analyzing designs, extracting sizes/colors/typography, and producing front-end components. No unrelated services, binaries, or credentials are requested.
Instruction Scope
Runtime instructions are scoped to reading provided design assets and, if the user supplies it, existing project code to align tokens/tech stack. The skill does not instruct the agent to read unrelated system files, environment variables, or transmit data to unexpected endpoints. It does ask to inspect 'existing code' when provided, which is appropriate for this task.
Install Mechanism
No install spec or code files — purely instruction-only. That minimizes disk writes and arbitrary code execution risk.
Credentials
No environment variables, credentials, or config paths are required. The instructions mention Figma/Sketch links and asking about access permissions, but do not request API tokens or other secrets.
Persistence & Privilege
always is false (good). The skill allows normal autonomous invocation (platform default). When invoked autonomously it may read user-supplied project files to determine tech stack — this is expected for the task but users should be aware and only provide repos/designs they consent to share.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install design-to-code
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /design-to-code 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.1
Publish from oliver-skill repository
v1.0.0
Initial release of the design-to-code skill. - Converts Figma, Sketch, or image mockups into pixel-accurate, responsive frontend code. - Ensures alignment with design tokens for colors, fonts, and spacing. - Supports component-based architecture and semantic HTML with accessibility best practices. - Outputs code according to the project's tech stack (e.g. Next.js, Tailwind, SCSS). - Handles hover, focus, and other interactive states, with notes on any necessary deviations from the design.
元数据
Slug design-to-code
版本 1.0.1
许可证 MIT-0
累计安装 15
当前安装数 15
历史版本数 2
常见问题

Design To Code 是什么?

Implements UI from design mockups (Figma, Sketch, or image) with pixel-accurate layout, responsive behavior, and design tokens. Use when 还原设计图, implementing... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 1778 次。

如何安装 Design To Code?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install design-to-code」即可一键安装,无需额外配置。

Design To Code 是免费的吗?

是的,Design To Code 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Design To Code 支持哪些平台?

Design To Code 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Design To Code?

由 wangzhiming(@wangzhiming1999)开发并维护,当前版本 v1.0.1。

💬 留言讨论