# Figma Local Bridge

> UI/UX design guideline plus build workflow for Figma through the figma_local_* tools (the self-hosted Figma MCP Local Bridge). Use whenever you design, redesign

- Skill: `deniahc566/figma-local-bridge` (Agent Skill, multi-file: 18 files)
- Install (CLI): `npx get-skill add deniahc566/figma-local-bridge`
- Raw SKILL.md: https://api.skillmd.com/api/skills/deniahc566/figma-local-bridge/raw
- Safety review: pending
- Works with: any agent that reads SKILL.md (Claude Code, Claude.ai, Cursor, Codex, Windsurf, 60+ more)
- Category: Coding & Dev Tools
- Author: deniahc566 (https://skillmd.com/u/deniahc566)
- Updated: 2026-12-02
- Page: https://skillmd.com/skills/deniahc566/figma-local-bridge

---

---
name: figma-local-bridge
description: UI/UX design guideline plus build workflow for Figma through the figma_local_* tools (the self-hosted Figma MCP Local Bridge). Use whenever you design, redesign or review screens, flows, components or a design system in Figma; write UI copy for (Vietnamese) mobile apps; build or edit anything with figma_local_use_figma; upload images; read designs for code; or check a design visually. Covers the designer's process and principles, layout, typography, colour, components, patterns for finance and insurance flows, UX writing, accessibility, motion, design systems, handoff, review checklists, and the bridge's contract (queue, jobs, helper libraries, uploads, render visibility) with the Plugin API rules that cause most failures.
---

# UI/UX design in Figma through the Local Bridge

This skill has two halves:
- **Part A, the design guideline:** how a senior product designer decides what to build and how it should look and read. Apply it to every design task, whether you build in Figma or only review.
- **Part B, building in Figma:** how to put the design into the file through the bridge. The bridge runs your JavaScript inside Figma desktop through the "Figma MCP Bridge" plugin (`figma_local_use_figma`), and serves reads plugin-first so they cost no REST quota. It is **not** Figma's hosted `use_figma` (see section B6).

## Reference map

Read the reference for the task before starting it; each is self-contained.

| Task | Read |
|---|---|
| Any "design X" request, or a review | [design/process-and-principles.md](references/design/process-and-principles.md) |
| Screen layout, grids, spacing, device sizes, safe areas | [design/layout-and-spacing.md](references/design/layout-and-spacing.md) |
| Type scale, fonts, Vietnamese text | [design/typography.md](references/design/typography.md) |
| Colour roles, semantic colours, contrast, dark mode | [design/color.md](references/design/color.md) |
| Icons, illustration, images, radius, elevation | [design/visual-elements.md](references/design/visual-elements.md) |
| Buttons, inputs, navigation, lists, cards, sheets, dialogs, feedback | [design/components.md](references/design/components.md) |
| Choosing a UI pattern (navigation, overlays, lists vs cards vs tables, feedback, forms, search, onboarding, commerce, AI, deceptive patterns to avoid) | [design/ui-patterns.md](references/design/ui-patterns.md) |
| Flows: onboarding, sign-in/OTP, forms, payments, insurance purchase/claims, cross-sell, errors | [design/patterns-and-flows.md](references/design/patterns-and-flows.md) |
| Labels, buttons, errors, formats (money, dates), Vietnamese copy | [design/content-and-ux-writing.md](references/design/content-and-ux-writing.md) |
| Contrast, targets, screen readers, text scaling | [design/accessibility.md](references/design/accessibility.md) |
| States, loading, gestures, motion, prototyping | [design/interaction-and-motion.md](references/design/interaction-and-motion.md) |
| Tokens, styles, component APIs, DS documentation | [design/design-systems.md](references/design/design-systems.md) |
| Flow boards, screen codes, arrows, annotations, handoff | [design/flows-documentation-handoff.md](references/design/flows-documentation-handoff.md) |
| Checks before "done", design reviews, audit scripts | [design/review-checklists.md](references/design/review-checklists.md) |
| Plugin API code: pages, text, auto layout, variables, components, errors, limits | [plugin-api-rules.md](references/plugin-api-rules.md) |

# Part A: Design guideline

## A1. Process

1. **Understand the job:** user, situation, task, outcome, business goal and constraints, in one line. Ask if you cannot write it.
2. **Study what exists:** the file's screens and design system, platform conventions, how familiar apps solve the same task.
3. **Map the flow before screens:** entry, happy path, decisions, every unhappy path; screen codes and names.
4. **Structure each screen:** the one most important element, the primary action, what is disclosed on demand. Pick each pattern by the problem it solves ([ui-patterns.md](references/design/ui-patterns.md#0-choosing-between-patterns)).
5. **Apply the system:** DS components and tokens first; one focal point.
6. **Design every state:** loading, empty, error, success, disabled, long content, first-time, offline.
7. **Write real content** in the product's language and formats.
8. **Connect and annotate** the flow; mark open questions.
9. **Review** with the checklists, fix, screenshot, stop.

Details and the definition of "done" per deliverable: [process-and-principles.md](references/design/process-and-principles.md).

## A2. The rules that matter most

**Structure and flow**
1. One screen, one main question or decision, one primary action (bottom, sticky on mobile).
2. The user always knows where they are (title, step "2/4") and can go back without losing data.
3. Every flow has its unhappy paths designed: validation, network, rejection, empty, timeout, session expiry.
4. Money and irreversible actions: review screen with totals and fees → explicit confirm naming the action and amount → result with reference and next steps.
5. Offers and promotions never block the main task; opt-in, easy to decline. Consent checkboxes are never pre-ticked, one per purpose, with accept and decline of equal weight (required in Vietnam from 2026).

**Layout and visual**
6. Spacing only from the 4/8 scale; gaps inside a group smaller than gaps between groups; consistent screen margins (16–24).
7. One focal point; hierarchy by size and weight before colour; a strong left edge; centre only short symmetric content.
8. Auto layout for every container; content survives long text and larger font sizes.
9. Type from the DS scale only (4–6 sizes in use), body ≥ 16 px / 17 pt, line height ~1.4–1.5 for body (Vietnamese diacritics need it).
10. Colour through semantic tokens; one primary colour action per screen; status colour always with text or icon; brand colour kept distinct from error/success colours.
11. One elevation language (borders for structure, shadows for floating layers), one icon set, one radius scale.
12. Nothing from the "looks generated" list: gradients/glows by default, emoji icons, identical centred card grids, Lorem/round fake numbers, hero slogans on task screens.

**Components and patterns**
13. Reuse DS components as attached instances, configured through variants and properties; report gaps instead of inventing look-alikes.
14. Use proven patterns chosen by the problem: tab bar for 3–5 destinations, push for drill-down, sheets for quick secondary tasks, dialogs only for blocking decisions, undo for reversible actions and confirmation for irreversible ones, lists for scanning, tables for comparing. Never a deceptive pattern (pre-ticked add-ons, hidden fees, confirmshaming, hard-to-cancel).
15. Forms: one column, visible labels above fields, the right input control and keyboard, validation on blur/submit with the fix in the message, prefill what is known.
16. Lists show identity, key value and status per row; detail screens put summary first, actions last; destructive actions separated and confirmed.

**Content**
17. Real content in the right formats: `1.250.000 đ`, `87,4%`, `01/12/2026`, `14:30`, `0912 345 678`; realistic Vietnamese names; no placeholders.
18. Buttons are verbs naming the outcome; errors say what happened and what to do; one term per concept; sentence case; one form of address.

**Accessibility**
19. Contrast ≥ 4.5:1 text, ≥ 3:1 large text and meaningful UI (not rounded); targets ≥ 44 pt / 48 dp; meaning never by colour alone; labels for icon-only controls; text that scales to 200 %; reduced-motion alternatives.

**Process discipline**
20. Respect the file: change only what was asked; archive before redesigning; ask before restoring missing layers; list assumptions and open questions in the report.

# Part B: Building in Figma

## B0. Before the first call

1. `figma_local_whoami`. Check, for the target file:
   - `bridge.plugins[]` has the file (match `fileKey`). If not: ask the user to run Plugins > Development > Figma MCP Bridge in that file.
   - `version` is `0.2.0` or later. If missing or older: ask the user to close and re-run the plugin (jobs, uploads and `libs` need it).
   - `visible` is `true` before any screenshot or export. If `false`: ask the user to put Figma side by side with this app (not behind it, not minimized). Data reads and writes still work while hidden; renders do not.
   - `libs.names`: the helper libraries you can load with `libs`.
2. Take `fileKey` and `nodeId` from the URL (`node-id=12-34` → `12:34`). Never guess a node ID.

## B1. Build workflow

1. **Scope.** One line: what is delivered (one screen, one component, tokens, a fix) and the acceptance checks (frame size, states, tokens). Don't grow the scope.
2. **Inspect, read-only.**
   - `figma_local_get_metadata` (no nodeId → pages; with nodeId → structure).
   - `figma_local_get_screenshot` of a reference screen (Figma visible).
   - One read-only `use_figma` that inventories a representative screen: instances → main component and key, bound variables, text/effect styles, fonts, frame sizes, spacing.
   - Match what the file already does: naming, sizes, spacing, page layout.
3. **Search the design system before drawing.** `figma_local_get_libraries`, then one `figma_local_search_design_system` call with one intent per query. Priority: local component → library component → create new. An empty local-variables list does not mean there are no tokens (library variables are not local).
4. **Plan.** Sections, the component or token each uses, the product font (look up exact style names, never default to Inter). The design decisions come from Part A.
5. **Build in small, re-runnable steps.**
   - First call: look for the wrapper on the page first (its plugin-data tag, else its exact name), because a timed-out earlier call may already have made it; create it in clear space only when it is missing, and return its ID.
   - Each later call: resolve the wrapper by ID, check whether its section exists (find by name inside the wrapper), build only what is missing, return `{ created, changed, counts }`.
   - One section or one small screen per call; keep scripts readable (about 250 lines). Put shared helpers in a library file and load them with `libs` instead of pasting them.
6. **Verify** (one structural audit + one screenshot, then fix only what is broken and take one more screenshot). See section B5.
7. **Clean up and report.** Remove probes, temporary instances and failed partial builds by exact ID. Report the IDs built, what was reused, raw values or assumptions left in, and gaps.

When the user's expected layers are missing, they are usually the user's own deletions: ask before restoring anything.

## B2. The bridge contract

**Calls run one at a time.** `use_figma` and `upload_assets` calls queue in the plugin in arrival order, so two writes never interleave. Still send writes one after another and wait for each result: the next call usually needs the previous one's IDs. Reads (`get_*`) do not wait behind the queue.

**Every call is a job.** The result ends with `Ran in "<file>", page "<page>" as job <id>.`

**Timeouts do not stop code.** When a call times out, its code keeps running in Figma. The error says `... still running in the plugin as job <id>`.
- Call `figma_local_get_job` with that `jobId` and `waitMs` (e.g. 60000) to get the result. Do **not** re-run the same code: it would apply the changes twice.
- The queue moves on after a timeout, so wait for the timed-out job before sending more writes.
- The same applies to "disconnected before replying" / "instance shut down" errors: check the job once the bridge reconnects.
- Large builds: pass `timeoutMs` (max 300000) up front rather than retrying.

**No rollback.** A call that throws keeps what it changed before the error (as one undo step). Validate all targets before the first change, track created IDs and remove them in `catch`, and read the state before retrying.

**The page persists.** The bridge does not reset to the first page. Resolve pages and nodes by ID; `figma.setCurrentPageAsync` moves the user's view too, so switch at most once per call and only when needed (other pages: `await page.loadAsync()` then read).

**Helper libraries (`libs`).** Files in the library folder (`whoami` → `libs.dir`). Pass `libs: ["name", "prefix_*"]` and during that call `await figma.clientStorage.getAsync(name)` and `mcp.libs[name]` return the file content (`.js`/`.txt` as a string, `.json` as a value). Libraries don't count toward the 50,000-character `code` limit. To change a library, edit its file; don't store code in `clientStorage`.
```js
// use_figma { libs: ["app_lib"] }
const AF = Object.getPrototypeOf(async function () {}).constructor;
const L = await new AF('figma', await figma.clientStorage.getAsync('app_lib'))(figma);
```

**Images in.** `figma_local_upload_assets` with absolute file paths (PNG/JPEG/GIF → image fill, SVG → vectors; max 4096 px per side). With `nodeId` the image becomes that layer's fill; without, a new layer is placed right of existing content. Reuse the returned `imageHash` in other fills instead of uploading again. Never inline large base64 in `code`.

**Images out / visual checks.**
- `figma_local_get_screenshot` saves a PNG and returns its path (read the file to see it), or pass `enableBase64Response: true` to get it inline.
- Inside `use_figma`, `return await mcp.exportAsync(node, { format: 'PNG', constraint: { type: 'SCALE', value: 1 } })` returns the image inline (max 5 per call). `mcp.exportAsync` fails at once with a hint while Figma is not rendering; plain `node.exportAsync` would hang.
- Renders need Figma visible. When hidden, screenshots fail immediately ("Figma is hidden, minimized or covered…"): ask the user to bring Figma to the front, don't retry in a loop. If an export is reported stuck, ask the user to close and re-run the plugin.
- Take screenshots one at a time.

**Return values.** Results over 100,000 characters are cut. Return compact data (`id`, `name`, `type`, counts), never whole property maps across a collection. Nodes serialize as `{id, name, type}`.

**Never** call `figma.closePlugin()` (it closes the bridge). Avoid `figma.notify()`.

## B3. Script skeleton

```js
// 1. Find or create the top-level frame, and validate every target before changing anything.
//    Later calls resolve it by ID. The first call looks on the page before creating:
//    a timed-out earlier call may have made it already.
const WRAPPER_ID = null; // '123:456' once the first call has returned it
const page = figma.currentPage;
let wrapper = WRAPPER_ID
  ? await figma.getNodeByIdAsync(WRAPPER_ID)
  : page.findChild((n) => n.type === 'FRAME' && n.getPluginData('wrapper') === 'Checkout'); // or the exact name
if (WRAPPER_ID && (!wrapper || wrapper.type !== 'FRAME')) return { error: 'wrapper missing', id: WRAPPER_ID };
if (!wrapper) {
  wrapper = figma.createFrame();
  wrapper.name = 'Checkout';
  wrapper.setPluginData('wrapper', 'Checkout');
  const right = page.children.reduce((m, n) => (n === wrapper ? m : Math.max(m, n.x + n.width)), 0);
  wrapper.x = right + 200; wrapper.y = 0; // clear space, not (0,0)
}

// 2. Load what you need once (fonts, components, variables), in parallel.
await Promise.all([{ family: 'Roboto', style: 'Regular' }, { family: 'Roboto', style: 'Medium' }].map((f) => figma.loadFontAsync(f)));

// 3. Build idempotently and track what you create, so a failure can be cleaned up.
const created = [];
try {
  let section = wrapper.findChild((n) => n.name === 'Section/Header');
  if (!section) {
    section = figma.createFrame();
    section.name = 'Section/Header';
    wrapper.appendChild(section); // append before setting FILL
    section.layoutMode = 'VERTICAL';
    section.layoutSizingHorizontal = 'FILL';
    section.layoutSizingVertical = 'HUG';
    created.push(section.id);
  }
  // ... build children ...
} catch (e) {
  for (const id of created) (await figma.getNodeByIdAsync(id))?.remove();
  throw e;
}

// 4. Return evidence, not prose.
return { created, wrapper: wrapper.id, children: wrapper.children.length };
```

## B4. Plugin API rules that cause most failures

Full list and snippets: [references/plugin-api-rules.md](references/plugin-api-rules.md).

- **Async APIs only** (dynamic page loading): `getNodeByIdAsync`, `getMainComponentAsync`, `setTextStyleIdAsync`, `setFillStyleIdAsync`, `setEffectStyleIdAsync`, `getLocal*StylesAsync`. Sync versions throw.
- **Fonts:** load before touching text; discover exact style names with `figma.listAvailableFontsAsync()` ("Semi Bold" vs "SemiBold" varies); for existing text load every font from `getRangeAllFontNames(0, len)`; skip and report `hasMissingFont` text. `lineHeight` / `letterSpacing` take `{ unit, value }`.
- **Auto layout order:** `layoutMode` → `resize()` (resets sizing to FIXED) → sizing → padding/gap/alignment → `appendChild` → child FILL. FILL needs an auto-layout parent with room (a HUG parent gives FILL children none). Wrapping text: `textAutoResize = 'HEIGHT'` + FILL or fixed width.
- **Colours** are 0–1, paints `{r,g,b}` + `opacity`; `fills`/`strokes`/`effects` are immutable: clone, change, reassign.
- **Tokens:** bind, don't hardcode. `setBoundVariableForPaint` returns a new paint to assign back; bind numeric fields with `setBoundVariable(field, variable)`, corners one by one. When a paint is bound, pass the variable's resolved colour as the paint colour too, so nested instances don't show the fallback.
- **Components:** set variants and properties on instances with `setProperties` (text/boolean/swap keys carry `#id`); read definitions from the component set, not a variant; `swapComponent` keeps overrides; avoid `detachInstance` (ancestors get new IDs); you cannot `appendChild` into an instance's sublayers.
- **Traversal:** `findAllWithCriteria({ types })` scoped to the smallest known frame; never `figma.root.findAll`; one page per call on big files. If you set `figma.skipInvisibleInstanceChildren = true` for speed, restore it in `finally` (it persists across calls).

## B5. Before reporting done

Run the checklists in [design/review-checklists.md](references/design/review-checklists.md) (flow, visual QA, content, accessibility, hygiene) with one read-only audit call (snippet there) and one screenshot. In short:
- Every planned section exists; every created ID resolves; counts match.
- No default names (`Frame 12`, `Rectangle 3`), no containers with several children and no auto layout, no collapsed text (width < 4 or height > 2000).
- No unbound solid fills/strokes where tokens exist; text uses text styles; fonts are the product font; no missing fonts.
- Repeated elements are instances; nothing detached without a reason.
- Screenshot (Figma visible): no clipped text, overlaps, placeholder copy or black `currentColor` icons; contrast ≥ 4.5:1 for text, 3:1 for large text and UI parts; tap targets ≥ 44 (iOS) / 48 (Android).
- Probes and temporary nodes removed; `skipInvisibleInstanceChildren` restored; viewport shows the result (`figma.viewport.scrollAndZoomIntoView([wrapper])`).

Fix only what failed, re-check only that, and stop. Budget: two change attempts and one check for bulk edits; if the same error happens twice, read the API typings once and change approach.

## B6. Differences from Figma's hosted tool

Do not copy these from Figma's official skills: `figma.createAutoLayout()`, `node.query()`, `node.set()`, `node.placeholder`, `node.screenshot()` (not in the public Plugin API), automatic rollback, page reset per call, parallel per-page fan-out of writes. The bridge has instead: local desktop fonts, `console.log` capture, single-expression returns, inline image returns, `figma.teamLibrary`, `libs`, `get_job`, `upload_assets`, one undo step per call.

Not available here: `create_new_file`, `generate_figma_design`, `generate_diagram`, `generate_image`, `generate_vector_illustration`, `get_comments`, Code Connect publishing. Tell the user when a request needs one of them.

## B7. Project conventions

Add the rules of your own files here (brand fonts, naming scheme, screen sizes, copy rules, which library to prefer), so every session applies them.

