New 'AI & Automation' top-level nav section with 9 pages: - AI Chat: setup, 87 tools, example prompts - Collaboration: room sharing, cursors, follow mode - JSX Renderer: elements, style props, visual diffing - CLI (4 pages): inspecting, exporting, analyzing, scripting - MCP Server: moved from Reference, setup + 90 tools New CLI reference page in Reference with all 12 commands, every option, alias, and default value. Formatting fixes across all 7 locales: - Wrap enum values in backticks (FRAME, SOLID, ROUND, etc.) - Fix single-backtick code blocks → triple backticks - Use <kbd> for all keyboard shortcuts - Remove implementation details from user guide - Delete stale eval-command.md and mcp-tools.md (14 files) - Update dead links to new locations
1.8 KiB
1.8 KiB
| title | description |
|---|---|
| Scripting | Execute JavaScript with the Figma Plugin API — query nodes, batch-modify designs, create frames. |
Scripting
open-pencil eval gives you the full Figma Plugin API in the terminal. Read nodes, modify properties, create shapes — then write changes back to the file.
Basic Usage
open-pencil eval design.fig -c "figma.currentPage.children.length"
The -c flag takes JavaScript. The figma global works like the Figma Plugin API.
Query Nodes
open-pencil eval design.fig -c "
figma.currentPage.findAll(n => n.type === 'FRAME' && n.name.includes('Button'))
.map(b => ({ id: b.id, name: b.name, w: b.width, h: b.height }))
"
Modify and Save
open-pencil eval design.fig -c "
figma.currentPage.children.forEach(n => n.opacity = 0.5)
" -w
-w writes changes back to the input file. Use -o output.fig to write to a different file instead.
Read from Stdin
For longer scripts:
cat transform.js | open-pencil eval design.fig --stdin -w
Live App Mode
Omit the file to run against the running desktop app:
open-pencil eval -c "figma.currentPage.name"
Available API
The figma object supports:
figma.currentPage— the active pagefigma.root— the document rootfigma.createFrame(),figma.createRectangle(),figma.createEllipse(),figma.createText(), etc..findAll(),.findOne()— search descendants.appendChild(),.insertChild()— tree manipulation- All property setters:
.fills,.strokes,.effects,.opacity,.cornerRadius,.layoutMode,.itemSpacing, etc.
This is the same API Figma plugins use, so existing knowledge and code snippets transfer directly.
JSON Output
open-pencil eval design.fig -c "..." --json