figma-ios-hierarchy-preservation

figma-ios-hierarchy-preservation is a skill for Cursor from mythkiven/figma-ios-codegen. It costs 103 tokens per session (8,032 once invoked), scanned A, original, MIT.

A set of rules for turning a Figma design tree into UIKit views, keeping frames and groups as parent containers and preserving their child order and coordinates.

In plain words
What is it for?
It helps generate Swift/UIKit view hierarchies from Figma data, including container views, leaf views, subview order, and relative or absolute positions.
Why use it?
It prevents the generated iOS layout from losing design groups or placing elements incorrectly through duplicated coordinate calculations.

Skill for Cursor

Written for Cursor: installed under .cursor/.

Good fit It helps generate Swift/UIKit view hierarchies from Figma data, including container views, leaf views, subview order, and relative or absolute positions.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mythkiven/figma-ios-codegen/figma-ios-hierarchy-preservation
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.

Any agent
npx skills add mythkiven/figma-ios-codegen --skill figma-ios-hierarchy-preservation
Clone the repo
git clone --depth 1 https://github.com/mythkiven/figma-ios-codegen

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for figma-ios-hierarchy-preservation

README.md
[![agentmods](https://agentmods.dev/badge/skills/mythkiven/figma-ios-codegen/figma-ios-hierarchy-preservation/github.svg)](https://agentmods.dev/skills/mythkiven/figma-ios-codegen/figma-ios-hierarchy-preservation)
Your own site
<a href="https://agentmods.dev/skills/mythkiven/figma-ios-codegen/figma-ios-hierarchy-preservation"><img src="https://agentmods.dev/badge/skills/mythkiven/figma-ios-codegen/figma-ios-hierarchy-preservation/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for figma-ios-hierarchy-preservation

Your own site · 80×15
<a href="https://agentmods.dev/skills/mythkiven/figma-ios-codegen/figma-ios-hierarchy-preservation"><img src="https://agentmods.dev/badge/skills/mythkiven/figma-ios-codegen/figma-ios-hierarchy-preservation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 103 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 8,032 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00103 $0.08032
Opus 5 $0.00051 $0.04016
Sonnet 5 $0.00021 $0.01606
Haiku 4.5 $0.00010 $0.00803

Measured 11d ago against content hash 1e0d4887ce23, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

figma-ios-hierarchy-preservation 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 11d 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/skills/figma-ios-hierarchy-preservation/SKILL.md · 891 lines

How it starts

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

Figma 层级结构保持规则

职责边界(与 figma-ios-snapkit-layout 的分工)

  • 本 Skill 负责:Figma 节点 → UIView 层级映射(建哪些容器、addSubview 顺序、坐标系转换
  • 不负责:约束写法语法(SnapKit make.* 写法)→ 见 figma-ios-snapkit-layout

两者协作:本 Skill 确定"建什么容器、父子关系",snapkit-layout 确定"如何写约束值"。


⚡ QUICK_REF(Agent 优先读此处)

核心规则:每个 Figma <frame> / <group> 必须对应一个 UIView,不得拍平。

Figma 节点类型 iOS 对应 说明
<frame> UIView 容器 保持层级,设置 clipsToBounds 按 clipsContent
<group> UIView 容器 通常透明,仅作分组
<rectangle> UIViewUIImageView 看填充类型
<text> UILabel 直接
<instance> (iconfont) UILabel 见 figma-ios-iconfont-mapping

坐标转换核心规则:

  • 数据包 design.json[node].frame.relative.{x,y}相对直接父容器的坐标,直接用作 SnapKit offset
  • 如需绝对坐标,读 frame.absolute.{x,y}(已由数据包预计算)
  • 禁止跨层累加坐标(会双重计算)
Figma: <frame id="A" x="16" y="100">
           <frame id="B" x="0" y="0">
               <rect id="C" x="45" y="10" />

Swift:
A.snp: leading=16, top=100  ← 用 A 自己的 x/y
B.snp: leading=0, top=0     ← 用 B 自己的 x/y(相对A)
C.snp: leading=45, top=10   ← 用 C 自己的 x/y(相对B)

详细规则、坐标转换公式、addSubview 顺序规范见下文。


目标

确保生成的 Swift/UIKit 代码完整保留 Figma 的层级结构,避免将嵌套的容器"拍平"成扁平结构。


核心原则

✅ 原则 1:每个 Frame/Group 都对应一个 UIView 容器

Figma 中的每个 <frame><group> 节点,在代码中都应该有对应的 UIView 容器。

Figma:

<frame id="1:305" name="编组">
  <frame id="1:309" name="编组 6">
    <rectangle id="1:310" name="图片A" />
    <rectangle id="1:325" name="图片B" />
  </frame>
</frame>

Swift:

// ✅ 正确:保持层级
private lazy var groupContainer: UIView = { ... }()
private lazy var group6Container: UIView = { ... }()
private lazy var imageA: UIImageView = { ... }()
private lazy var imageB: UIImageView = { ... }()

// setupUI
groupContainer.addSubview(group6Container)
group6Container.addSubview(imageA)
group6Container.addSubview(imageB)
// ❌ 错误:拍平层级
private lazy var groupContainer: UIView = { ... }()
private lazy var imageA: UIImageView = { ... }()
private lazy var imageB: UIImageView = { ... }()

// setupUI
groupContainer.addSubview(imageA)  // 缺少中间容器
groupContainer.addSubview(imageB)

Read the full file on GitHub · 891 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. 11d ago First seen · 891 lines · 103 tokens per session scan A 1e0d4887ce23

Subscribe to this mod's changes

figma-ios-hierarchy-preservation is a skill published in the GitHub repository mythkiven/figma-ios-codegen (9 stars, last pushed 2mo ago), licensed MIT. It adds 103 tokens to every session and 8,032 once invoked, about $0.0005 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.

Related

Other skills, from other repositories

figma-codegen

Generate framework-aware code from a Figma design. Reads the project's stack profile and emits code matching the existing framework (React/Vue/Svelte/Next/etc.) and styling (Tailwind/CSS/CSS-in-JS), reusing existing components and design tokens instead of regenerating from scratch. Triggers whenever the user wants a…

awdr74100/figwright · 145 tokens

figma-build

Build a Figma design from code or a description — the reverse of figma-codegen. Reuses the connected file's existing design system (components, variables, styles) instead of drawing primitives with hardcoded values. Triggers whenever the user wants something created or updated IN Figma from code or a spec — e.g.…

awdr74100/figwright · 180 tokens

app-icon-studio

Apple app icons: create, generate, evaluate, export, install, or debug iOS AppIcon.appiconset and macOS .icns assets for small-size clarity.

Xopoko/build-swift-apps · 40 tokens

macos-window-architect

Use SwiftUI scene/window modifiers first; switch to macos-appkit-bridge only when SwiftUI cannot express the behavior.

Xopoko/build-swift-apps · 46 tokens

ios-liquid-glass-designer

Implement, refactor, or review iOS 26+ SwiftUI Liquid Glass with native glassEffect, GlassEffectContainer, button styles, availability gates, and non-glass fallbacks.

Xopoko/build-swift-apps · 47 tokens

unship

Compare agent-made alternatives in a local browser preview with Unship. Use for comparison setup, iteration, Canvas, selection, cleanup, and Unship installation or update troubleshooting.

mbenhard/unship · 37 tokens