Complete Figma control for AI agents: read via REST API, write via a local plugin. Change design layers, extract design tokens, audit accessibility, export assets.
text
Craw ──→ figma_client.mjs (REST API) ──────→ Figma cloud (read: file, styles, export)
──→ figma_send.js (WebSocket) ──→ figma_connector.js ──→ Figma Plugin → Figma Desktop
──→ style_auditor.mjs (design system analysis, CSS tokens)
──→ accessibility_checker.mjs (WCAG AA/AAA, contrast, touch targets)
bash
export FIGMA_ACCESS_TOKEN="figd_your_token_here"
bash
node scripts/figma_client.mjs get-file <file-key>
# Example: node scripts/figma_client.mjs get-file "ABC123xyz" --depth 4
Get a file key from: https://www.figma.com/design/<FILE_KEY>/...
plugin/manifest.json from this skill's directorybash
# Terminal 1: Start the local WebSocket server
node scripts/figma_connector.js
# → Listening on ws://localhost:9199
In Figma Desktop:
bash
# Create a rectangle
node scripts/figma_send.js createRectangle \
--payload '{"x":100,"y":100,"width":400,"height":300,"fillColor":{"r":0.14,"g":0.49,"b":1},"cornerRadius":12,"name":"Hero Card"}'
# Get current selection
node scripts/figma_send.js getSelection
CommandPayload (JSON)DescriptioncreateRectangle``{x, y, width, height, fillColor?, cornerRadius?, name?}New rectanglecreateFrame``{x, y, width, height, fillColor?, name?}New frame/artboardcreateEllipse``{x, y, width, height, fillColor?, name?}New ellipsecreateText``{x, y, characters, fontSize?, fontName?, fillColor?, name?}New text layerselectNode``{id}Select + zoom into nodeupdateNode``{id, x?, y?, resize?{width,height}, fillColor?, name?}Modify existing nodedeleteNode``{id}Remove nodesetFillColor``{id, color{r,g,b}, opacity?}Set fill colorgroupSelection``{}Group selected nodesgetSelection``{}List selected nodesgetPageInfo``{}Current page infocreatePolygon``{x, y, width, height, pointCount, fillColor?, name?}Regular polygon (N sides)createStar``{x, y, width, height, pointCount, innerRadius?, fillColor?, name?}Star shapecreateVectorNetwork``{x, y, width, height, vectorNetwork: {vertices, segments}, fills?, strokes?}Custom vector pathbooleanOperation`{operation: UNIONSUBTRACTupdateNode (auto-layout){id, layoutMode?, paddingLeft?, ..., itemSpacing?, primaryAxisAlignItems?, ...}Apply Auto Layout to frame
ScriptDescriptionnode scripts/shape_generator.js test-basicDemo: rectangle, ellipse, polygon, star, heart in gridnode scripts/shape_generator.js test-unionDemo: union of two overlapping circlesnode scripts/shape_generator.js generate '{"type":"heart","width":200}'Single shape by type
ScriptDescriptionnode scripts/auto_layout.js card '{"width":320}'Create card with auto-layoutnode scripts/auto_layout.js button '{"name":"CTA"}'Create button with paddingnode scripts/auto_layout.js row '{"padding":8}'Horizontal rownode scripts/auto_layout.js column '{"padding":16}'Vertical column
ScriptDescriptioncd scripts/style-dictionary && npx style-dictionary buildGenerate CSS variables + Figma tokensOutput: scripts/style-dictionary/build/variables.cssDR's Lab CSS custom properties ( --color-*, --spacing-*, etc.)Output: scripts/style-dictionary/build/figma-tokens.jsonFigma-compatible nested tokens
ActionArgsDescriptionget-file``<key> [--depth N]Full file document treeget-file-nodes``<key> <id>...Specific nodes by IDget-styles``<key>Published styles (color, text, effects)get-components``<key>Published componentsget-versions``<key>Version historyrender-images``<key> <id> [--format png|svg|pdf] [--scale N]Export as imagesget-image-fills``<key>Image fill URLs used in fileget-metadata``<key>Lightweight file infome—Current user info
ActionArgsDescriptionstyle_auditor.mjs``<key> [--brand-colors "#HEX,#HEX"] [--generate-css]Analyze colors, fonts, consistency, CSS tokensaccessibility_checker.mjs``<key> [--level AA|AAA] [--format json|report]WCAG contrast, touch targets, font sizes
Figma uses RGB in 0–1 range:
json
{"r": 0.14, "g": 0.49, "b": 1} // #247DFF (blue)
{"r": 1, "g": 0.42, "b": 0.21} // #FF6B35 (orange)
{"r": 1, "g": 1, "b": 1} // #FFFFFF (white)
When a user installs this skill, the AI agent should:
FIGMA_ACCESS_TOKEN is set — if not, instruct the user to generate one and export itplugin/manifest.json in Figma Desktopnode scripts/figma_connector.js separatelyfigma_connector.js if the agent has shell accessfigma_client.mjs me before proceedingfigma_connector.js running while working with write commandshttp://localhost:9200 shows status and pending queue--generate-css to extract Figma styles as CSS custom propertiesFIGMA_CMD_TIMEOUT=60000 node figma_connector.jstext
skills/craw-figma/
├── SKILL.md
├── scripts/
│ ├── figma_client.mjs — Figma REST API client (read)
│ ├── figma_connector.js — Local HTTP server (run this) — timeout 30s configurable
│ ├── figma_send.js — Send commands to Figma plugin
│ ├── shape_generator.js — General-purpose shape creation (polygons, stars, hearts, union)
│ ├── auto_layout.js — Auto Layout module (cards, rows, buttons, spacing)
│ ├── heart_generator.js — Legacy heart shape generator
│ ├── star_generator.js — Legacy star generator
│ ├── design_engine.js — Design orchestration engine
│ ├── design_orchestrator.js — Orchestrator with NotebookLM consultation
│ ├── design_critic.js — Design critique pipeline
│ ├── craw_design_cmd.sh — Shell wrapper for design commands
│ ├── svg_to_figma.js — SVG path → Figma Vector Network converter
│ ├── style_auditor.mjs — Design system analysis
│ ├── accessibility_checker.mjs — WCAG compliance
│ └── style-dictionary/
│ ├── config.json — Style Dictionary configuration
│ ├── tokens/ — DTCG tokens → SD format
│ ├── build/variables.css — Generated CSS custom properties
│ └── build/figma-tokens.json — Figma-compatible tokens
├── plugin/
│ ├── manifest.json — Figma plugin manifest
│ ├── code.js — Plugin code (ES5, production)
│ ├── code.ts — Plugin code (TypeScript source)
│ └── ui.html — Plugin panel UI
├── design-tokens/
│ ├── design-tokens.json — Core tokens (DTCG format)
│ ├── projects/drs-lab.json — DR's Lab project tokens
│ └── load-tokens.js — Token loader utility
└── references/
├── figma-api-reference.md — REST API docs
└── design-patterns.md — UI patterns & best practices