mcpField
D
deep-component-figma

deep-component-figma

github.com/southleftDesign & UI2073 installsUpdated 21w ago
Repository

About deep-component-figma

deep-component-figma is a Figma skill that recursively reads a node tree to a chosen depth, including resolved design tokens and interaction details. It is intended for design-system and code-generation work requiring richer component data than a flat structure.

Key features

  1. 01Recursively inspect nodes to a chosen depth
  2. 02Capture layout, visual, and text properties
  3. 03Resolve bound variables to token names and syntax
  4. 04Read component references, variants, and properties
  5. 05Include prototype reactions and dev annotations

Use cases

  1. 01Generate code from detailed Figma components
  2. 02Reuse design tokens instead of raw color values
  3. 03Inspect component variants and interaction flows

MCP support

The skill runs its script through `use_figma` and relies on the official `figma-use` skill. It provides a deeper component-tree read than the native MCP `get_design_context` or `get_metadata`.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/southleft/skills-for-figma --skill deep-component-figma

After installing, type/deep-component-figmain Claude Code to confirm it loaded.

Bundled filesscripts/deep-component.js

Details

From the project README

deep-component-figma — unlimited-depth tree with resolved tokens

Walk one node (usually a COMPONENT / COMPONENT_SET / INSTANCE, but any node works) recursively to a depth you choose, capturing at every level: layout (auto-layout, padding, spacing, sizing), visual properties (fills, strokes, stroke weight, corner radius, effects, opacity), typography for text nodes, boundVariables resolved to token names + code syntax, INSTANCE main-component references (including whether the main is a variant and its set), prototype reactions, and dev-mode annotations. This is the richest single-component read for high-fidelity code generation.

Skill boundaries

  • use_figma rules — load the official figma-use skill first; it is the full Figma Plugin API reference. Essentials these scripts rely on: plain JS with top-level await + return (no IIFE, no figma.closePlugin(); console.log is not returned), inputs inlined as const at the top of each script, colors in 0–1 range, load fonts before any text op, await figma.getNodeByIdAsync(...), and atomic errors (a failed script applies nothing — read the error, fix, retry).
  • Whole-file inventory (all tokens/components/styles at once) → use design-system-inventory-figma.
  • Variant set as a CSS state machine (per-state diffs, pseudo-class mapping) → use analyze-component-set-figma.
  • This depth of tree + resolved tokens + reactions is not what the native MCP's get_design_context (rendered single-selection summary) or get_metadata (flat structure) return — it is a design-system code-gen capability layered on top.

Workflow

  1. Get the node id. From selection (figma_get_selection), search, or a pasted id.
  2. Choose a depth. Set const DEPTH (default 10). Deep design components rarely exceed ~6 levels; use a smaller number first to keep the payload manageable, then go deeper if needed.
  3. Run scripts/deep-component.js via use_figma (skillNames: "deep-component-figma"). Set const NODE_ID and const DEPTH at the top.
  4. Generate code. The returned tree mirrors the DOM you should build. Prefer boundVariables token names (and their codeSyntax) over raw hex; use mainComponent refs to reuse imported components; use reactions to wire up interaction/navigation.
  5. If the payload is too big, lower DEPTH (nodes past the limit are summarized with a childCount + _depthLimitReached marker) or target a smaller sub-node id.

What each node carries

  • Identity: id, name, type, visible. Hidden non-component nodes are marked _hidden and not recursed.
  • Layout: layoutMode, axis sizing/align, padding*, itemSpacing, counterAxisSpacing, layoutWrap, min/max width/height, clipsContent.
  • Visual: fills, strokes, strokeWeight, cornerRadius, effects, opacity (only when non-default; figma.mixed values are skipped safely).
  • Typography (TEXT): characters, fontSize, fontFamily/fontStyle, fontWeight, lineHeight, letterSpacing, alignment, truncation, case, decoration.
  • Tokens: boundVariables resolved to { id, name, collection, resolvedType, codeSyntax } per bound property.
  • Instances: mainComponent (id, name, key, isVariant, set name/id) + componentProperties.
  • Definitions (COMPONENT/COMPONENT_SET): componentPropertyDefinitions, variantProperties.
  • Prototype: reactions (trigger + action: navigation/transition/destination).
  • Dev: annotations (label markdown + categorized properties).

Notes

  • Resolved tokens work on ANY plan — the variable lookup is built via the Plugin API, so even non-Enterprise files get token names instead of opaque VariableID: aliases.
  • The root node echoes _variableMapSize and _maxDepthUsed for sanity-checking.
  • Returns affectedNodeIds: [NODE_ID] even though this is a read — keeps the convention uniform.

Comments

Markdown supported