Open Pencil

open-pencil/skills/skills/open-pencil

作者 open-pencil0d850d25f0cc无许可证16 个星标收录于 2026年10月8日更新于 2026年10月8日仓库3周前更新

Work with Figma .fig design files and the running OpenPencil editor — inspect structure, query nodes, analyze design tokens, export PNG/SVG/PDF/JSX, and modify designs programmatically. Use when asked to open, inspect, export, analyze, or edit .fig files, or to control the running OpenPencil app.

已归档仅含说明Design & Creative
AI 生成的概览

通过 CLI 和 MCP 检查、导出、分析并编辑 Figma .fig 设计文件及运行中的 OpenPencil 编辑器。

功能
提供 CLI 和 MCP 服务器,用于处理 .fig 设计文件以及正在运行的 OpenPencil 编辑器。它可以检查文档结构、用 XPath 查询节点、分析颜色、字体和间距、检查设计一致性,并导出 PNG、JPG、WEBP、SVG、PDF、JSX 或 .fig。它还能通过节点更新、JSX 渲染以及兼容 Figma Plugin API 的 eval 运行时以编程方式修改设计。
适用场景
当需要打开、检查、导出、分析或编辑 .fig 设计文件时使用。它也适合控制运行中的 OpenPencil 应用,例如在修改后选择节点或缩放视图。
运行要求
需要 Bun 运行时,以及全局安装的 @open-pencil/cli 和 @open-pencil/mcp 包。桌面应用会暴露本地 HTTP/RPC、WebSocket 和 MCP 端点;可选环境变量用于配置端口、认证令牌、CORS 来源和文件访问根路径。该技能不附带脚本。

OpenPencil

OpenPencil provides a CLI and MCP server for .fig design files and the running OpenPencil editor.

Use two modes:

  • App mode — connect to the running OpenPencil editor by omitting the file argument.
  • Headless mode — work with .fig files directly by passing a file path.
bash
# App mode — operates on the document open in the editoropenpencil tree
# Headless mode — operates on a .fig fileopenpencil tree design.fig

Current reference version: OpenPencil 0.12.x. The MCP server exposes 106 tools in 0.12.0.

Requirements

bash
# CLIbun add -g @open-pencil/cli
# MCP server used by the desktop app and external MCP clientsbun add -g @open-pencil/mcp

The desktop app starts openpencil-mcp-http automatically in production Tauri builds when @open-pencil/mcp is installed globally and exposes automation on:

  • HTTP/RPC: http://127.0.0.1:7600
  • WebSocket bridge: ws://127.0.0.1:7601
  • MCP Streamable HTTP: http://127.0.0.1:7600/mcp

CLI Commands

bash
openpencil --help

Commands in 0.12.x:

  • info — document overview: pages, node counts, fonts
  • tree — print hierarchy with types and sizes
  • pages — list pages
  • node — detailed node properties by ID
  • selection — current selection from the running app
  • find — find nodes by name/type
  • query — XPath selectors for node search
  • variables — list variables and collections
  • export — export PNG/JPG/WEBP/SVG/PDF/JSX/.fig
  • convert — convert between supported document formats
  • analyze — colors, typography, spacing, repeated clusters
  • lint — consistency, structure, and accessibility checks
  • formats — supported document/export formats
  • eval — execute JavaScript with the Figma Plugin API

Inspect

bash
openpencil info design.figopenpencil tree design.figopenpencil tree --page "Components" --depth 3  # app modeopenpencil pages design.figopenpencil node design.fig --id 1:23openpencil node --id 1:23  # app modeopenpencil selection --jsonopenpencil variables design.figopenpencil variables --collection "Colors" --type COLOR

Search and XPath query

bash
openpencil find design.fig --name "Button"openpencil find --type FRAME                          # app modeopenpencil find design.fig --type TEXT --page "Home"openpencil find design.fig --name "Card" --type COMPONENT --limit 50
openpencil query design.fig "//FRAME"openpencil query design.fig "//FRAME[@width < 300]"openpencil query design.fig "//TEXT[contains(@name, 'Button')]"openpencil query design.fig "//COMPONENT[@stackMode]"openpencil query design.fig "//COMPONENT//FRAME//TEXT"openpencil query "//FRAME[@width > 1000]"             # app mode

Common node types: FRAME, TEXT, RECTANGLE, ELLIPSE, VECTOR, GROUP, COMPONENT, COMPONENT_SET, INSTANCE, SECTION, LINE, STAR, POLYGON, SLICE, BOOLEAN_OPERATION.

Export and convert

bash
openpencil export design.fig -o hero.pngopenpencil export -o hero.png                         # app modeopenpencil export design.fig --node 1:23 -s 2 -o [email protected]openpencil export design.fig -f jpg -q 85 -o preview.jpgopenpencil export design.fig -f svg --node 1:23 -o icon.svgopenpencil export design.fig -f pdf -o page.pdfopenpencil export design.fig -f fig -o roundtrip.figopenpencil export design.fig -f jsx -o component.jsxopenpencil export design.fig -f jsx --style tailwind -o component.tsxopenpencil export design.fig --thumbnail --width 1920 --height 1080openpencil export --page "Components" -o components.png
openpencil convert design.fig -o design.penopenpencil formats

Analyze and lint

bash
openpencil analyze colors design.figopenpencil analyze colors --similar --threshold 10     # app modeopenpencil analyze typography design.fig --group-by sizeopenpencil analyze spacing design.fig --grid 8openpencil analyze clusters design.fig --min-count 3openpencil lint design.figopenpencil lint design.fig --json

Eval (Figma Plugin API)

Execute JavaScript against the document using a Figma Plugin API-compatible runtime:

bash
openpencil eval design.fig -c 'figma.currentPage.findAll(n => n.type === "TEXT").length'
# App mode — modifies the live document in the editoropenpencil eval -c '  const buttons = figma.currentPage.findAll(n => n.name === "Button");  buttons.forEach(b => { b.cornerRadius = 8 });  buttons.length + " buttons updated"'
# Modify and save to the same fileopenpencil eval design.fig -w -c '  const texts = figma.currentPage.findAll(n => n.type === "TEXT");  texts.forEach(t => { t.fontSize = 16 });'
# Save to a different fileopenpencil eval design.fig -o modified.fig -c '...'
# Read code from stdinecho 'figma.currentPage.children.map(n => n.name)' | openpencil eval design.fig --stdin

Every command that reports structured data supports --json when appropriate.

MCP Server

Stdio MCP clients

Use Bun by default:

json
{  "mcpServers": {    "open-pencil": {      "command": "bunx",      "args": ["openpencil-mcp"]    }  }}

If @open-pencil/mcp is installed globally, direct binaries also work:

json
{  "mcpServers": {    "open-pencil": {      "command": "openpencil-mcp"    }  }}

HTTP / Streamable HTTP

bash
export PORT=7600export OPENPENCIL_MCP_AUTH_TOKEN=secret       # optional auth for /mcpexport OPENPENCIL_MCP_CORS_ORIGIN="*"         # optional CORSexport OPENPENCIL_MCP_ROOT=/path/to/files     # enables/scopes open_file/save_file paths
openpencil-mcp-http# or: bunx openpencil-mcp-http

MCP workflow

  1. Open/create a document — open_file { path } when OPENPENCIL_MCP_ROOT is configured, or new_document {}.
  2. Query — get_page_tree, find_nodes, query_nodes, get_node, list_pages, get_current_page.
  3. Inspect — get_jsx, diff_jsx, describe, export_image, export_svg, export_pdf.
  4. Modify — render, batch_update, update_node, set_fill, set_layout, create_shape, import_svg, etc.
  5. Navigate — after creating or editing visible canvas content, call select_nodes and viewport_zoom_to_fit { id } (or node_bounds + viewport_set) so the user can see the result in the running editor.
  6. Save/export — save_file, export_image, export_svg, export_pdf, or CLI export.

MCP Tools in 0.12.0 (106 total)

Read and selection (17): get_selection, get_node, find_nodes, get_page_tree, get_current_page, list_pages, select_nodes, query_nodes, get_components, switch_page, page_bounds, list_fonts, list_available_fonts, get_jsx, diff_jsx, describe, node_tree

Create and import (12): render, create_shape, create_component, create_instance, create_page, create_vector, create_slice, import_svg, search_icons, insert_icon, fetch_icons, stock_photo

Modify (24): update_node, batch_update, set_layout, set_layout_child, set_radius, set_fill, set_stroke, set_text, set_text_properties, set_effects, set_opacity, set_font, set_visible, set_constraints, set_rotation, set_minmax, set_font_range, set_text_resize, set_blend, set_locked, set_stroke_align, set_image_fill, set_variable, bind_variable

Structure (16): delete_node, reparent_node, node_resize, clone_node, node_move, rename_node, group_nodes, ungroup_node, flatten_nodes, node_to_component, node_bounds, node_ancestors, node_children, node_bindings, node_replace_with, arrange

Variables (9): list_variables, list_collections, get_variable, find_variables, create_variable, delete_variable, get_collection, create_collection, delete_collection

Vector and viewport (15): boolean_union, boolean_subtract, boolean_intersect, boolean_exclude, path_get, path_set, path_scale, path_flip, path_move, viewport_get, viewport_set, viewport_zoom_to_fit, export_svg, export_pdf, export_image

Analyze and generation (9): analyze_colors, analyze_typography, analyze_spacing, analyze_clusters, diff_create, diff_show, design_to_tokens, design_to_component_map, calc

File and prompts (4): save_file, open_file, new_document, get_codegen_prompt

Tool availability can depend on server mode. open_file, save_file, and disk-writing export paths require OPENPENCIL_MCP_ROOT for path scoping.

Key tools for agents

  • query_nodes — XPath selectors to find specific nodes without fetching the full tree.
  • get_jsx — inspect any node as JSX in the same format accepted by render.
  • diff_jsx — compare two nodes structurally before editing.
  • describe — semantic analysis of role, visual style, layout, and design issues.
  • batch_update — apply multiple node updates efficiently.
  • export_image / export_svg / export_pdf — visual verification and deliverables.
  • viewport_zoom_to_fit / viewport_set / viewport_get — keep the live editor focused on the created or edited design.
  • get_codegen_prompt — retrieve OpenPencil's current JSX/codegen guidance.

JSX Rendering

Use the render tool or eval to create component trees. If unsure about JSX syntax, call get_codegen_prompt first.

jsx
<Frame name="Card" w={320} h="hug" flex="col" gap={16} p={24} bg="#FFF" rounded={16}>  <Text size={18} weight="bold" color="#111">Title</Text>  <Text size={14} color="#666">Description text</Text>  <Frame flex="row" gap={8}>    <Frame w={80} h={36} bg="#3B82F6" rounded={8} justify="center" items="center">      <Text size={14} color="#FFF" weight="600">Action</Text>    </Frame>  </Frame></Frame>

Elements: Frame, Text, Rectangle, Ellipse, Line, Star, Polygon, Group, Section, Component, Instance.

Text content is the child content of <Text>. Use design-JSX props, not Figma API field names:

jsx
<Text size={48} weight="bold" font="Inter" color="#111">Design faster with AI</Text>

Common props:

PropMeaning
w, hWidth, height (number or "hug" / "fill")
flex"row" or "col"
grid, columns, rowsCSS Grid, e.g. columns="1fr 200px 1fr"
gap, rowGap, columnGapItem spacing
p, px, py, pt, pr, pb, plPadding
justify"start", "center", "end", "between"
items"start", "center", "end", "stretch"
growFlex grow factor
bgFill color (hex)
rounded, roundedTL/TR/BL/BRCorner radius
stroke, strokeWidthStroke color and weight
opacity0–1
rotateDegrees
overflow"hidden" to clip children
shadow"offsetX offsetY blur #color"
blurLayer blur
size, weight, font, color, textAlignText properties
colStart, rowStart, colSpan, rowSpanGrid child positioning

Tips

  • Omit the file path to work with the document open in the running OpenPencil editor.
  • Start with info or get_page_tree to understand the document.
  • Use tree --depth 2 or query_nodes to avoid overwhelming output on large files.
  • Export specific nodes with --node for faster visual checks.
  • Use export_image after changes to verify visual quality.
  • After creating a visible design, select it and zoom the editor to it: select_nodes { ids: [id] } then viewport_zoom_to_fit { id }.
  • If zoom-to-fit is unavailable in a client, use node_bounds to calculate the center and call viewport_set { x, y, zoom }.
  • Use analyze colors --similar to find near-duplicate colors.
  • Use eval for Figma Plugin API operations not covered by a dedicated CLI/MCP tool.
  • Use --json when piping CLI output to scripts.
  • In app mode, eval and MCP modifications are reflected live in the editor.

来源与署名

来源:open-pencil/skills位于skills/open-pencil提交0d850d2

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架