agentleFS
KushpawanKushpawan/kmp-mobile-skills/skills/figma-to-mobile-ui/SKILL.md

figma-to-mobile-ui

Skill15 starsChanged 25 days agoApache-2.0View on GitHub

Use when implementing a Figma frame, screen or component as Compose Multiplatform or SwiftUI code in a Kotlin Multiplatform app — a figma.com/design link, "build this from Figma", design-to-code, Figma MCP (get_design_context, get_variable_defs, get_screenshot), mapping Figma variables to design tokens, or the built UI not matching the design (spacing, colours, fonts off).

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the Figma plugin's own design-to-code skill is installed in the agent, load it too: it carries Figma's tool-specific rules.

    line 46
  2. Very specific:

    If the response is truncated or too large: get_metadata for the node tree, then get_design_context on each child section separately.

    line 64
  3. Distinctive:

    Every interactive element gets a test tag / accessibility identifier from the screen's tags object.

    line 115
  4. Distinctive:

    Use only assets returned in the Figma payload.

    line 119
  5. Very specific:

    Run the UI, capture it at the frame's size, compare side by side with get_screenshot, fix, repeat.

    line 127
  6. Distinctive:

    No hits outside token definitions.

    line 169
  7. Distinctive:

    NOT RUN for a platform you could not launch.

    line 170

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Figma to mobile UI (Compose Multiplatform or SwiftUI)

The Figma MCP output is a specification, not code to paste. Implement it with the project's own components and tokens, map every Figma variable to a code token, and finish by comparing a screenshot of the running UI with the Figma screenshot.

When to use

  • A Figma link (figma.com/design/...?node-id=...) and a request to build or update UI from it.
  • Building a new screen or component whose design lives in Figma.
  • The implemented UI drifts from the design and needs a fidelity pass.

When not to use

  • Writing designs into Figma, Code Connect authoring, or FigJam → Figma's own skills (Related).
  • Screen architecture (ViewModel, effects, tests) → compose-multiplatform-screen, after this skill has produced the view.
  • A missing reusable component → compose-design-system-component first, then return here.

Step 0 — Read the project first

  1. Figma MCP is reachable. List the agent's tools and look for the Figma server (get_design_context, get_metadata, get_screenshot, get_variable_defs, get_code_connect_map; the prefix depends on the client). If absent, stop and ask the user to connect it (remote server https://mcp.figma.com/mcp, or the Figma desktop app's server). Follow any instructions the server itself returns (some versions require opening a session first).
  2. Target. Compose Multiplatform (commonMain UI) or SwiftUI (iosApp/ native UI over shared logic)? If the request does not say, check where neighbouring screens live; ask when both exist.
  3. Design system in code. Theme accessors and token names (colours, typography, spacing, shapes), existing components and their variants. For SwiftUI: colour assets / theme types, font helpers, spacing constants.
  4. Code Connect. Whether Figma components are already mapped to code components.
  5. Conventions. Screen file layout, string resources (composeResources or Localizable.xcstrings), test-tag / accessibility-identifier format, preview style.

If the Figma plugin's own design-to-code skill is installed in the agent, load it too: it carries Figma's tool-specific rules. This skill adds the mobile mapping and verification.

Workflow

1. Resolve the node

  • figma.com/design/<fileKey>/<name>?node-id=12-34 → fileKey, nodeId = "12:34" (hyphen → colon).
  • Branch links figma.com/design/<fileKey>/branch/<branchKey>/... → use branchKey as the file key.
  • A link without node-id is a whole file: ask for the frame link instead of guessing.

Done when you have one fileKey and one nodeId per frame to build.

2. Fetch, in this order

  1. get_design_context on the node — structure, styles and a reference implementation (React + Tailwind by default). If the server exposes framework hints (the remote server documents clientFrameworks, matching your Code Connect label such as SwiftUI), pass the target.
  2. If the response is truncated or too large: get_metadata for the node tree, then get_design_context on each child section separately.
  3. get_screenshot of the node — the visual reference for step 7.
  4. get_variable_defs — the variables (colours, spacing, radii, typography) the node uses.
  5. get_code_connect_map — only if the project uses Code Connect; mapped components are used as-is with their real imports.

Done when you have the design context, a screenshot, and a variable list for every section.

3. Build the token map

Map every variable to an existing code token; write the table into your working notes (not into the code):

Figma variableValueCompose tokenSwiftUI token
color/primary#1E5EFFAppTheme.colors.primaryColor.appPrimary
space/md16AppTheme.spacing.mdAppSpacing.md
radius/md8AppTheme.shapes.mediumAppRadius.md
type/body/mdInter 14/20AppTheme.typography.bodyMedium.appFont(.bodyMedium)
  • Figma px at 1x equals Android dp and iOS pt.
  • A raw value with no variable: use the nearest existing token and list it under "design deviations" in the final report. Never introduce the literal.
  • A variable with no code token: stop for that element; add the token through compose-design-system-component (or the iOS equivalent) or ask.

Detailed layout, text, colour and effect mappings: references/figma-mapping.md.

4. Inventory components before writing code

List each element of the frame and decide: existing component (with which variant/size), existing component needs a variant, or new one-off layout. Prefer, in order: Code Connect mapping → existing design-system component → composition of existing components → new local composable. Matching layer names to components is a hint, not proof — compare visuals and props.

5. Translate the structure

  • Auto layout horizontal → Row / HStack; vertical → Column / VStack; gap → Arrangement.spacedBy(token) / spacing: token; padding → Modifier.padding(...) / .padding(...).
  • Fill container → fillMaxWidth() or Modifier.weight(1f) / .frame(maxWidth: .infinity); hug → default wrap; fixed size only where the design is fixed on purpose (icons, avatars).
  • Scrollable content → LazyColumn/verticalScroll / ScrollView/List; repeated items get a stable key.
  • Name composables/views after what they are (NoteCard), not after layer names (Frame 427).
  • Compose: write a pure XView(state, onAction) plus previews; wiring to a ViewModel follows compose-multiplatform-screen. SwiftUI: a View struct taking plain values/bindings, plus #Preview.
  • Text from the design goes into string resources, not literals.
  • Every interactive element gets a test tag / accessibility identifier from the screen's tags object.

6. Assets

  • Use only assets returned in the Figma payload. Do not substitute icon packs or placeholders.
  • Icons: SVG → vector drawable in commonMain/composeResources/drawable/ (Compose) or an SVG/PDF in the asset catalog with "Preserve Vector Data" (SwiftUI).
  • Raster images: export at the needed densities (Compose qualifiers drawable-xxhdpi etc.; asset catalog @2x/@3x).

7. Verify visually

Run the UI, capture it at the frame's size, compare side by side with get_screenshot, fix, repeat. Checklist and commands: references/visual-verification.md.

8. Report

List: files created/changed; the token map; components reused vs created; design deviations (raw values mapped to nearest token, missing states you had to assume); verification results.

Quick reference

FigmaCompose MultiplatformSwiftUI
Auto layout → horizontal / verticalRow / ColumnHStack / VStack
GapArrangement.spacedBy(AppTheme.spacing.x)spacing: AppSpacing.x
Space betweenArrangement.SpaceBetweenSpacer() between items
Fill container (main axis)Modifier.weight(1f).frame(maxWidth: .infinity)
Hug contentsdefaultdefault / .fixedSize()
Absolute position in frameBox + Modifier.align / offsetZStack + .offset / alignment
Corner radiusclip(shape) / shape token.clipShape(RoundedRectangle(cornerRadius:))
StrokeModifier.border(width, color, shape).overlay(RoundedRectangle(...).stroke(...))
Image fill / fitContentScale.Crop / ContentScale.Fit.scaledToFill().clipped() / .scaledToFit()
Letter spacing 2%letterSpacing = 0.02.em.tracking(fontSize * 0.02)
Text styleAppTheme.typography.xthe project's font helper (relativeTo: for Dynamic Type)

Verify

Report each check as PASS, FAIL or NOT RUN (reason).

./gradlew :composeApp:compileKotlinMetadata     # Compose target compiles in common code
./gradlew :composeApp:assembleDebug             # Android build
xcodebuild -project iosApp/iosApp.xcodeproj -scheme iosApp \
  -destination 'platform=iOS Simulator,name=iPhone 16' build   # SwiftUI / iOS host builds (adjust names)

Then, by search on the new files:

grep -nE "Color\(0x|#[0-9A-Fa-f]{6}|[0-9]+\.dp|[0-9]+\.sp" <new compose files>       # Compose
grep -nE "Color\(red:|Color\(hex|\.font\(\.system\(size:|padding\([0-9]" <new swift files>   # SwiftUI

No hits outside token definitions. Finally the visual comparison (step 7) on Android and iOS — report NOT RUN for a platform you could not launch.

Common mistakes

MistakeWhy it bitesFix
Pasting the React/Tailwind reference into Kotlin or SwiftWrong idioms, web units, no tokensTreat it as a spec; translate
Copying hex values and px sizesBreaks dark mode and theming; drifts from tokensMap to tokens; report raw values as deviations
Rebuilding a component that already existsTwo divergent buttonsInventory first; reuse or add a variant
Trusting layer names as component identityMisnamed layers map to the wrong componentCompare visuals and properties; use Code Connect when present
Fixed widths copied from the frameBreaks on other screen sizes and large fontsFill/hug semantics; fixed only for icons/avatars
Fixed heights around textClipping at large font sizesMin height, padding
Letter spacing copied as sp from a percentageSpacing wrong at every sizePercent → em in Compose
Building the whole frame from one huge context callTruncated response; missed detailsget_metadata, then per-section get_design_context
Designing only the happy stateEmpty, loading, error, disabled missing in codeAsk for or infer each state; list assumptions
Literal strings from the mockNot translatableString resources
No screenshot comparisonSpacing/typography drift shipsCompare, fix, re-compare

Related skills

  • compose-design-system-component — add a missing component or token.
  • compose-multiplatform-screen — wire the view to a ViewModel, effects and tests.
  • compose-multiplatform-localization — move design copy into string resources.
  • figma/mcp-server-guide — Figma's MCP guide and official skills (skills/figma-design-to-code, skills/figma-swiftui, skills/figma-code-connect).
  • AvdLee/SwiftUI-Agent-Skill and twostraws/SwiftUI-Agent-Skill — SwiftUI best practices for the SwiftUI target.
  • chrisbanes/skills — compose-component-design.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.