← 返回 Skills 市场
garvin131

figma-optimizer

作者 Garvin131 · GitHub ↗ · v1.0.4 · MIT-0
cross-platform ✓ 安全检测通过
275
总下载
1
收藏
0
当前安装
4
版本数
在 OpenClaw 中安装
/install figma-code-optimizer
功能描述
从Figma设计稿生成符合项目组件库和设计规范的高质量前端代码
使用说明 (SKILL.md)

\r \r

Figma 代码生成优化技能\r

\r

📋 技能概述\r

这个技能帮助AI代理从Figma设计稿生成代码时,能够:\r

  1. 识别并复用你项目中的现有组件库\r
  2. 遵循你的设计规范(颜色token、间距规则、字体系统)\r
  3. 生成结构清晰、可维护的生产级代码\r
  4. 避免常见的代码生成问题(如硬编码值、嵌套过深)\r \r

🔍 使用前提\r

\r

在Figma中的准备\r

为了获得最佳效果,用户的Figma设计稿应该满足以下条件[citation:1][citation:6]:\r \r | 要求 | 说明 | 为什么重要 |\r |------|------|------------|\r | 使用组件和变体 | 将重复元素转为Component,用Variants表示不同状态 | AI能将它们映射为代码组件和props |\r | 应用Auto Layout | 用自动布局代替手动排列 | 便于转换为flex/grid布局 |\r | 使用样式和变量 | 统一用颜色样式、文字样式、间距变量 | 避免生成硬编码值 |\r | 图层命名清晰 | 避免"Frame 42"、"Group Copy"这类自动命名 | 帮助AI理解每个元素的作用 |\r | 避免过度嵌套 | 保持图层层级尽量浅 | 防止生成冗余的div嵌套 |\r | 优先使用Frame | 用Frame而不是Group作为容器 | Group在转换时行为不可预测[citation:6] |\r \r

必要的连接\r

  • 用户需要已连接Figma MCP服务器(官方远程MCP或Figma-Context-MCP均可)[citation:4][citation:5]\r
  • 需要在Figma中选中要生成代码的Frame或组件\r \r

🎯 核心工作流程\r

\r

步骤1:获取设计上下文\r

当用户在Figma中选中一个Frame并请求生成代码时,AI代理应该:\r \r

  1. 通过MCP获取设计信息:\r
    • 获取选中的Frame及其所有子图层\r
    • 提取应用的样式和变量(颜色、字体、间距)\r
    • 识别使用的组件及其属性[citation:2][citation:7]\r \r
  2. 分析设计结构:\r
    • 识别哪些部分可以映射到现有组件库\r
    • 分析布局方式(Auto Layout对应flex/grid)\r
    • 检查是否有不符合规范的地方\r \r

步骤2:映射到项目组件库\r

根据用户的组件库文档,将Figma中的元素映射到代码组件[citation:9]:\r \r | Figma中的元素 | 应映射到的代码组件 |\r |--------------|-------------------|\r | Button组件 | \x3CButton variant="primary\|secondary"> |\r | Input组件 | \x3CInput size="md\|lg" /> |\r | Card组件 | \x3CCard padding="md" /> |\r | Icon实例 | \x3CIcon name="..." size={16} /> |\r \r 映射规则示例:\r

  • 如果Figma中的Button有"Primary"变体 → 使用variant="primary"\r
  • 如果Button有"Small"/"Medium"/"Large"属性 → 映射为size="sm"/"md"/"lg"\r
  • 如果Button有"Icon Left"属性 → 添加leftIconprop\r \r

步骤3:应用设计规范\r

根据用户的设计规范文档,将Figma中的样式值转换为代码token[citation:2][citation:7]:\r \r | Figma中的值 | 应转换为的token |\r |------------|----------------|\r | #1890FF (蓝色) | colors.primary.500 |\r | 16px间距 | spacing.md |\r | Inter 14px medium | typography.body.medium |\r | 8px圆角 | radius.md |\r \r

步骤4:生成代码\r

生成符合以下标准的代码:\r \r

代码结构要求\r

  • 使用组件库导入import { Button, Card } from 'your-component-library'\r
  • 使用token变量color: ${theme.colors.primary.500} 而不是 #1890FF\r
  • 响应式布局:使用flex/grid,配合断点实现响应式[citation:2]\r
  • 可访问性:包含ARIA属性和语义HTML[citation:7]\r
  • 避免硬编码值:除非是临时占位内容\r
  • 避免多余的wrapper div:除非必要\r \r

框架适配示例\r

\r React组件示例:\r

import React from 'react';\r
import { Card, Button, Text } from '@your-company/ui';\r
import { useTheme } from '@your-company/theme';\r
\r
export const ProfileCard = ({ user, variant = 'default' }) => {\r
  const theme = useTheme();\r
  \r
  return (\r
    \x3CCard padding="lg" shadow="sm">\r
      \x3Cdiv css={{ display: 'flex', gap: theme.spacing.md }}>\r
        \x3CAvatar src={user.avatar} size="lg" />\r
        \x3Cdiv css={{ flex: 1 }}>\r
          \x3CText variant="heading" size="md">\r
            {user.name}\r
          \x3C/Text>\r
          \x3CText variant="body" color="secondary">\r
            {user.bio}\r
          \x3C/Text>\r
        \x3C/div>\r
      \x3C/div>\r
      \x3Cdiv css={{ marginTop: theme.spacing.lg }}>\r
        \x3CButton variant="primary" size="sm" onClick={handleFollow}>\r
          Follow\r
        \x3C/Button>\r
      \x3C/div>\r
    \x3C/Card>\r
  );\r
};
安全使用建议
This skill appears coherent for generating component-library-aligned React code from Figma. Before installing: 1) Confirm how the Figma MCP connection is provided (platform-built connector vs. an external endpoint) and whether any API tokens will be used or stored. 2) Verify that the agent will not be granted access to unrelated repos or system secrets while doing component-matching. 3) Review any generated code before using it in production (check tokens, ARIA/accessibility, and external calls). 4) If you are concerned about automatic access to your private Figma files, restrict the skill's runtime permissions or avoid enabling autonomous invocation.
功能分析
Type: OpenClaw Skill Name: figma-code-optimizer Version: 1.0.4 The figma-code-optimizer skill bundle provides structured instructions and reference documentation to help an AI agent generate React code from Figma designs. It includes detailed mapping rules for components and design tokens (colors, spacing, typography) in files like SKILL.md and references/design-tokens.txt. The bundle relies on standard Model Context Protocol (MCP) patterns for data retrieval and contains no evidence of malicious intent, data exfiltration, or harmful prompt injection.
能力评估
Purpose & Capability
The name/description (generate component-library‑aligned front-end code from Figma) match the instructions: the SKILL.md describes extracting frames, styles, mapping to components/tokens and producing React code. Nothing requested (no binaries, no env vars) appears unrelated to the stated purpose. The only external dependency the instructions expect is a Figma MCP connection (MCP server or Figma-Context-MCP), which is coherent for a Figma integration but is not declared as a required credential in the registry metadata.
Instruction Scope
Instructions stay on task: fetch selected Frame via MCP, extract styles/variables/components, map to the user's component library and design tokens, and generate code. The doc does not instruct the agent to read arbitrary system files, secrets, or unrelated configuration. It does permit some open-ended mapping decisions (e.g., find best-match components in the user's library), which is expected for code-generation but could lead to broad reads of project documentation if the agent has access — confirm what project artifacts the agent will actually be allowed to access at runtime.
Install Mechanism
This is an instruction-only skill with no install spec and no bundled code. That is the lowest-risk install profile — nothing will be written to disk by the skill itself.
Credentials
The skill declares no required environment variables or credentials, which is consistent with the registry metadata. However, the SKILL.md explicitly expects a Figma MCP connection (official MCP or Figma-Context-MCP). If your platform provides a built-in Figma connector this is reasonable; if the skill expects the agent to call an external MCP endpoint you should confirm which credentials/endpoints will be used and whether any tokens are required or stored.
Persistence & Privilege
The skill does not request always: true and makes no claims about modifying other skills or persisting system-wide configuration. Autonomous invocation (model-invocation enabled) is the platform default and appropriate for this type of skill.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install figma-code-optimizer
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /figma-code-optimizer 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.4
- Removed the _meta.json file. - No changes to skill functionality or documentation.
v1.0.3
Initial release of figma-code-optimizer. - Added project metadata file (_meta.json). - Provides a skill for generating high-quality frontend code from Figma designs, following existing component libraries and design tokens. - Includes full usage prerequisites, optimal Figma setup, and required Figma server connections. - Details a step-by-step workflow: extracting design context, mapping to component libraries, applying design tokens, and generating maintainable, accessible code. - Sample React component code structure and mapping rules included for easy adoption.
v0.0.1
- Initial release of figma-code-optimizer skill. - Enables code generation from Figma designs using your component library and design tokens. - Supports mapping Figma components and styles to project code components and tokens. - Guides on Figma file best practices for optimal code output. - Ensures generated code is clean, maintainable, and avoids hardcoded values or unnecessary wrappers.
v1.0.0
- Initial release of figma-code-optimizer - Generates high-quality front-end code from Figma designs - Reuses existing project component library and follows design tokens/rules - Produces maintainable, production-ready code; avoids hardcoded values and deep nesting - Requires Figma MCP setup and well-structured Figma files for optimal results
元数据
Slug figma-code-optimizer
版本 1.0.4
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 4
常见问题

figma-optimizer 是什么?

从Figma设计稿生成符合项目组件库和设计规范的高质量前端代码. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 275 次。

如何安装 figma-optimizer?

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

figma-optimizer 是免费的吗?

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

figma-optimizer 支持哪些平台?

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

谁开发了 figma-optimizer?

由 Garvin131(@garvin131)开发并维护,当前版本 v1.0.4。

💬 留言讨论