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).
In this repository34 other files it gives its agents.
- AGENTS.mdAGENTS.md
- android-to-kmp-migrationSkill
- compose-design-system-componentSkill
- compose-multiplatform-localizationSkill
- compose-multiplatform-navigationSkill
- compose-multiplatform-screenSkill
- kmp-api-endpointSkill
- kmp-build-checkSkill
- kmp-build-failure-triageSkill
- kmp-ci-github-actionsSkill
- kmp-code-reviewSkill
- kmp-crash-triageSkill
- kmp-data-layerSkill
- kmp-dev-machine-cleanupSkill
- kmp-expect-actualSkill
- kmp-feature-moduleSkill
- kmp-flaky-test-triageSkill
- kmp-gradle-version-catalogSkill
- kmp-koin-diSkill
- kmp-module-healthSkill
- kmp-room-databaseSkill
- kmp-secure-storageSkill
- kmp-swiftui-interopSkill
- kmp-test-coverage-backfillSkill
- kmp-testing-patternsSkill
- kmp-xcframework-distributionSkill
- mobile-accessibility-test-idsSkill
- mobile-bug-fixSkill
- mobile-feature-implementSkill
- mobile-feature-planSkill
- mobile-performance-fixSkill
- mobile-platform-paritySkill
- mobile-releaseSkill
- mobile-security-reviewSkill
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
- Distinctive: line 46
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.
- Very specific: line 64
If the response is truncated or too large: get_metadata for the node tree, then get_design_context on each child section separately.
- Distinctive: line 115
Every interactive element gets a test tag / accessibility identifier from the screen's tags object.
- Distinctive: line 119
Use only assets returned in the Figma payload.
- Very specific: line 127
Run the UI, capture it at the frame's size, compare side by side with get_screenshot, fix, repeat.
- Distinctive: line 169
No hits outside token definitions.
- Distinctive: line 170
NOT RUN for a platform you could not launch.
≈ “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.
Files
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-componentfirst, then return here.
Step 0 — Read the project first
- 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 serverhttps://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). - Target. Compose Multiplatform (
commonMainUI) or SwiftUI (iosApp/native UI over shared logic)? If the request does not say, check where neighbouring screens live; ask when both exist. - 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.
- Code Connect. Whether Figma components are already mapped to code components.
- Conventions. Screen file layout, string resources (
composeResourcesorLocalizable.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>/...→ usebranchKeyas the file key. - A link without
node-idis 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
get_design_contexton the node — structure, styles and a reference implementation (React + Tailwind by default). If the server exposes framework hints (the remote server documentsclientFrameworks, matching your Code Connect label such asSwiftUI), pass the target.- If the response is truncated or too large:
get_metadatafor the node tree, thenget_design_contexton each child section separately. get_screenshotof the node — the visual reference for step 7.get_variable_defs— the variables (colours, spacing, radii, typography) the node uses.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 variable | Value | Compose token | SwiftUI token |
color/primary | #1E5EFF | AppTheme.colors.primary | Color.appPrimary |
space/md | 16 | AppTheme.spacing.md | AppSpacing.md |
radius/md | 8 | AppTheme.shapes.medium | AppRadius.md |
type/body/md | Inter 14/20 | AppTheme.typography.bodyMedium | .appFont(.bodyMedium) |
- Figma
pxat 1x equals Androiddpand iOSpt. - 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()orModifier.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 followscompose-multiplatform-screen. SwiftUI: aViewstruct 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-xxhdpietc.; 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
| Figma | Compose Multiplatform | SwiftUI |
| Auto layout → horizontal / vertical | Row / Column | HStack / VStack |
| Gap | Arrangement.spacedBy(AppTheme.spacing.x) | spacing: AppSpacing.x |
| Space between | Arrangement.SpaceBetween | Spacer() between items |
| Fill container (main axis) | Modifier.weight(1f) | .frame(maxWidth: .infinity) |
| Hug contents | default | default / .fixedSize() |
| Absolute position in frame | Box + Modifier.align / offset | ZStack + .offset / alignment |
| Corner radius | clip(shape) / shape token | .clipShape(RoundedRectangle(cornerRadius:)) |
| Stroke | Modifier.border(width, color, shape) | .overlay(RoundedRectangle(...).stroke(...)) |
| Image fill / fit | ContentScale.Crop / ContentScale.Fit | .scaledToFill().clipped() / .scaledToFit() |
| Letter spacing 2% | letterSpacing = 0.02.em | .tracking(fontSize * 0.02) |
| Text style | AppTheme.typography.x | the 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> # SwiftUINo 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
| Mistake | Why it bites | Fix |
| Pasting the React/Tailwind reference into Kotlin or Swift | Wrong idioms, web units, no tokens | Treat it as a spec; translate |
| Copying hex values and px sizes | Breaks dark mode and theming; drifts from tokens | Map to tokens; report raw values as deviations |
| Rebuilding a component that already exists | Two divergent buttons | Inventory first; reuse or add a variant |
| Trusting layer names as component identity | Misnamed layers map to the wrong component | Compare visuals and properties; use Code Connect when present |
| Fixed widths copied from the frame | Breaks on other screen sizes and large fonts | Fill/hug semantics; fixed only for icons/avatars |
| Fixed heights around text | Clipping at large font sizes | Min height, padding |
Letter spacing copied as sp from a percentage | Spacing wrong at every size | Percent → em in Compose |
| Building the whole frame from one huge context call | Truncated response; missed details | get_metadata, then per-section get_design_context |
| Designing only the happy state | Empty, loading, error, disabled missing in code | Ask for or infer each state; list assumptions |
| Literal strings from the mock | Not translatable | String resources |
| No screenshot comparison | Spacing/typography drift ships | Compare, 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.
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
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.

