Convert Figma designs to mobile UI code with interactive clarification.
Supported: Android Compose, Android XML, iOS SwiftUI, iOS UIKit.
FIGMA_TOKEN environment variable set (Figma > Settings > Personal Access Tokens). Never paste tokens into chat.requests package$env:FIGMA_TOKEN = "figd_..."setx FIGMA_TOKEN "figd_..."export FIGMA_TOKEN="figd_..."If you insist on using a .env file, edit it locally (not in chat) and ensure it is ignored by git (e.g. via .gitignore).
This skill activates when a user provides a Figma link.
The user may also include inline hints alongside the link, such as:
If the user provides hints, respect them and skip the corresponding questions.
For example, if the user says "Android XML, the 3 cards are a RecyclerView list", do NOT ask about output format or whether the cards are dynamic/static.
When user provides Figma link(s):
A. Link without specific node-id (no node-id, or node-id=0-1):
This link points to the entire page, not a specific frame. Tell the user:
> This link points to the whole page. Please select the frame you want in Figma, right-click it, and choose "Copy link to selection", then send that link.
> If you want to convert multiple frames, send multiple links.
B. Single frame link (has specific node-id):
Run scripts/figma_fetch.py " → returns that frame's design data.
Proceed to analysis.
C. Multiple links (user sends 2+ URLs):
First, determine the relationship by examining frame names and user context:
--compare mode to fetch all and get a diff summary. Generate multi-state code (conditional visibility, state switching).
> Frame 1 ("首页") and Frame 2 ("首页-抽屉") look like a main page + side drawer.
> I've generated two separate layout files. How you wire them together (DrawerLayout, Navigation, etc.) depends on your project architecture.
The Skill's job is generating UI layout code, not deciding architecture (Activity vs Fragment vs Navigation).
Rate limit protection for multiple links: When fetching multiple nodes, wait 2-3 seconds between requests. Never fire more than 2 requests in parallel.
variantProperties for component state (e.g. State=Default, Size=Large) — these map to multi-state code
Detailed interpretation rules: Read references/figma-interpretation.md
Before asking any questions, present a brief structure summary to the user so they can confirm your understanding:
> I see: [navigation bar with back button + title] → [2 content sections: user profile card, settings list (8 items)] → [bottom action button]. Total ~25 nodes.
Keep it to 2-3 lines. Mention:
If the user says "that's wrong" or corrects the structure, adjust understanding before proceeding to Step 2.
If the design has ≤10 leaf nodes (visible elements that map to actual views), skip this step — the structure is simple enough to proceed directly.
Question priority (strict order — ask earlier questions first):
→ Android XML / Compose / SwiftUI / UIKit
This determines all subsequent analysis phrasing and code output.
→ "These N items look similar — dynamic list or fixed layout?"
→ "This area: single image asset or icon-on-background combo?"
→ "Any custom components to use? (otherwise I'll use platform defaults)"
Rules for questions:
Confidence guide — when to ask vs. when to just generate:
If the target project is available locally, run a project scan:
python scripts/project_scan.py /path/to/project --json --output scan-report.json
How to use scan results in code generation: Read references/scan-usage.md
After user confirms (or if no questions needed), generate code files.
Detailed generation rules: Read references/generation-rules.md
If multiple files are needed, output each with a clear filename header:
📄 activity_notification_settings.xml
[code]
📄 item_expert_notification.xml
[code]
After showing code, ask briefly:
> Matches the design? Any adjustments?
The user can then give feedback to refine the output. Common iterations:
Continue iterating until the user is satisfied.
Iteration output rule:
// replaces lines 12-18 in activity_main.xml). Do NOT repeat the entire file.
Feedback capture (optional, opt-in):
If (and only if) the user explicitly agrees to persistent logging, record mapping corrections to .trae/figma-to-mobile/feedback-log.md under the target project root (create directories/files if missing). Each entry follows this format:
## YYYY-MM-DD HH:MM
- **Platform**: Android XML / Compose / SwiftUI / UIKit
- **Figma node type**: (e.g., FRAME with icon, Tab bar, Button group)
- **Issue**: Brief description of what was wrong
- **Before**: What the agent generated (snippet or description)
- **After**: What the user wanted (snippet or description)
- **Rule candidate**: (optional) If this correction suggests a general pattern rule, note it here
Log entries should be:
Do NOT log:
Periodically (or when asked), run scripts/feedback_analyze.py to identify patterns and generate rule candidates.
FIGMA_TOKEN_NOT_SET) → do NOT ask the user to paste tokens into chat. Instead:FIGMA_TOKEN in their local environment / secrets manager (recommended), then retry.env, instruct them to edit .env locally (not in chat) and ensure .env is ignored by githttps://www.figma.com/design//?node-id=
共 4 个版本