figma-ios-codegen-workflow

A required workflow for generating Swift/UIKit code from Figma designs, using a prepared package of design data before writing code.

In plain words
What is it for?
It helps convert Figma screens into UIKit code while preserving design nodes, using configured colors and fonts, recording unresolved items, and comparing the result with the design.
Why use it?
It reduces incomplete or visually inaccurate output by requiring node coverage checks, project-specific mappings, an audit file, and screenshot verification.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/mythkiven/figma-ios-codegen/figma-ios-codegen-workflow
Clone the repo
git clone --depth 1 https://github.com/mythkiven/figma-ios-codegen

Made for: Cursor.

Per session 65 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,973 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00065 $0.03973
Opus 5 $0.00032 $0.01987
Sonnet 5 $0.00013 $0.00795
Haiku 4.5 $0.00006 $0.00397

Measured 2d ago against content hash 620448c93e9b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

figma-ios-codegen-workflow scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/figma-ios-codegen-workflow.mdc · 346 lines

How it starts

The opening of the file, as written. The whole thing — 346 lines — stays where its author put it; the contents beside it link to each section on GitHub.

⛔ 全量还原原则(最高优先级,覆盖所有阶段)

本节优先级高于下文所有阶段细节。任何阶段产物若与本节冲突,以本节为准。

📌 适用范围:本原则管的是阶段 2 的 UI 节点覆盖率(视觉/布局/样式还原)。 业务逻辑、接口对接、数据流、埋点等属于阶段 3(仓外:PRD + 接口文档),不在本原则约束范围内——阶段 2 遇到这类需求,用 mock + // TODO(阶段3): ... 即可。

默认承诺:把数据包 {data_dir}/design.json所有应实现的节点(按 figma-ios-to-code-conventions 跳过 Home Indicator / Status Bar / Device Frame / 设计标注后的剩余集合)全部生成对应代码禁止「先做主体后补细节」式的渐进交付。

禁止行为

❌ 禁止 ✅ 正确
把缺失节点伪装成「可选增量」 列出缺失节点 ID,声明违反全量还原,继续补齐
「为简化示例省略了 …」 直接生成完整代码;上下文不足用「未完成模板」
用截图比对替代节点对账 阶段 4 之前先做节点 ID 对账(figma-ios-screenshot-verification
把完成度当「偏好」征求意见 完成度是默认值,无需征求

唯一允许的简化场景(须显式列出,并标 TODO)

  1. 节点对应后端动态数据 → mock + // TODO(阶段3): 接入 xxx 接口
  2. 用户在本轮请求中显式说「只做某某区块」/「快速验证某某」
  3. 节点已被 figma-ios-to-code-conventions 明确列入跳过规则

**TODO 格式(强制)**仅允许:

  • // TODO(阶段3): … — 业务 / 数据 / 接口
  • // TODO(阶段2): … — 本轮未决(map 未命中、VECTOR 未拆等)

禁止裸 // TODO: / FIXME:。交付前不得残留无限定语 TODO。

未完成处置模板(强制)

若无法一次性完成全量代码,回复开头声明:

⚠️ 本轮未完成全量还原。
已实现节点:…
缺失节点:…(节点 ID + name)
缺失原因:上下文/时间限制(不是设计选择)
下一步:继续补齐,除非用户喊停。

与「视觉差异」的边界

  • 颜色稍偏 / 间距 2pt → 视觉差异,阶段 4 报告
  • 整块未生成 / 只画示意 → 节点缺失,必须补全

跨客户端摘要见根目录 AGENTS.md;Skill 总入口见 figma-ios-playbook


适用场景(按描述触发)

当且仅当同时满足:

  1. 提到 figma 或给出 figma.com/... 链接,且
  2. 表达「转/生成代码」意图(figma → iOS / 根据设计稿生成 Swift 等)

❌ 不触发:只问 Figma 用法;「写个登录页」但未提 Figma。

当前版本只支持 iOS Swift(UIKit)。扩展其它端须另起 workflow,禁止往本文件叠多端逻辑。

alwaysApply: false:非 Figma 会话不灌入本规则。命中上述意图时 Agent 应主动加载本 rule。


整体架构(1 → 2 → 4;阶段 3 在仓外)

┌──────────────────────────────────────────────────────────────────┐
│  阶段 1:数据包(本地 CLI;可选自建 MCP)· 无 LLM                   │
│  Figma URL → design.json / audit.json / assets / screenshot …    │
└──────────────────────────────────────────────────────────────────┘
                              ↓
┌──────────────────────────────────────────────────────────────────┐
│  阶段 2:基础 UI(LLM + skills + .cursor/bindings)               │
│  包 → Swift UIKit;mock + TODO(阶段3);禁止再调 Figma API         │
└──────────────────────────────────────────────────────────────────┘
                              ↓
┌──────────────────────────────────────────────────────────────────┐
│  阶段 4:验收(本 workflow 内强制)                                │
│  节点覆盖率对账 → screenshot 视觉比对                               │
└──────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────┐
│  阶段 3:商用二次加工(PRD + 接口 · **不在本仓流程**)              │
│  grep TODO(阶段3) → 换真实数据 / 业务 / 路由 / 埋点                 │
└──────────────────────────────────────────────────────────────────┘

Read the full file on GitHub · 346 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 346 lines · 65 tokens per session scan A 620448c93e9b

Subscribe to this mod's changes

figma-ios-codegen-workflow is a cursor rule published in the GitHub repository mythkiven/figma-ios-codegen (9 stars, last pushed 1mo ago), licensed MIT. It adds 65 tokens to every session and 3,973 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.