open-pencil
它能做什么
这个技能让你的 AI 处理 .fig 设计文件和 OpenPencil 编辑器,包括读取结构、导出图片和修改设计。适合处理这些文件的设计师和开发者。
适用场景
- ✓当你请 AI 打开或检查某个 .fig 设计文件时。
- ✓当你想把设计导出为 PNG、SVG、PDF 或 JSX 时。
- ✓当你想通过脚本分析设计令牌或修改设计时。
技能链接
https://github.com/open-pencil/open-pencil/blob/master/skills/open-pencil/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把这个设计文件中的 Login 画框导出为 SVG。”
每周 5 个新技能,1 分钟读完。
工作原理
这个技能有两种工作方式。它可以连接已经打开的 OpenPencil 应用,也可以直接处理你指定的 .fig 文件。它使用 OpenPencil 命令行工具及其 MCP 服务器来读取和修改设计。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
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
.figfiles directly by passing a file path.
# App mode — operates on the document open in the editor
openpencil tree
# Headless mode — operates on a .fig file
openpencil tree design.fig
Use openpencil --help, per-command help, and the connected MCP server’s tool schemas to check the installed version’s capabilities. See the CLI reference and MCP guide for current documentation.
Variable formulas
Inside eval, use openpencil.setVariableFormula('Spacing', 'large', '{base} * 2') for numeric formulas or openpencil.setVariableFormula('State', 'visible', '{viewport} > 1024 and not {loading}') for Boolean formulas, which use and, or, not and number comparisons. Collections and variables must already exist. An optional fourth argument selects a mode by name; otherwise the default mode is edited. The call validates before mutation and returns the resolved value. Length formulas use stored pixels. The CSS stylesheet writes number formulas as calc(); design-token files hold the result with the formula in $extensions.
Variables follow Figma's plugin API: figma.variables.getLocalVariables(), createVariable(name, collection, type), variable.setValueForMode(modeId, value), and node.setBoundVariable(field, variable) with Figma's field names (characters, width, paddingLeft) and types; paint colours bind through figma.variables.setBoundVariableForPaint. To bind as the layer panel does, use openpencil.bindVariable(node, field, variable) and openpencil.unbindVariable(node, field) with OpenPencil names (text, visible, opacity, fills/0/color): text content takes a text or number variable, shown as text; visibility a boolean or text one. openpencil also sets layout and text direction (setLayoutDirection, setTextDirection), OkHCL paint colors (setFillOkHCL, setStrokeOkHCL), writes styled text from Markdown (setTextMarkdown(text, markdown), or set_text with markdown: true), exposes instance swaps (exposeInstanceSwap), and reports font availability (getFontStatus()); booleans and flattening are Figma's figma.union, subtract, intersect, exclude and figma.flatten.
Requirements
# CLI
bun add -g @open-pencil/cli
# MCP server used by the desktop app and external MCP clients
bun 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
openpencil --help
Common commands:
info— document overview: pages, node counts, fontstree— print hierarchy with types and sizespages— list pagesnode— detailed node properties by IDselection— current selection from the running appfind— find nodes by name/typequery— XPath selectors for node searchvariables— list variables and collectionstokens— variables as a CSS custom-property stylesheet, a Tailwind v4 theme, or W3C design token files (--format dtcg --out <folder>)export— export PNG/JPG/WEBP/SVG/PDF/JSX/.figconvert— convert between supported document formatsanalyze— colors, typography, spacing, repeated clusterslint— consistency, structure, and accessibility checksformats— supported document/export formatseval— execute JavaScript with the Figma Plugin APItool— list, describe, and call any MCP tool from the shell, in app or headless modedocuments— list, open, create, save, close, and activate documents in the running appundo/redo— step back through your own (automation) changes in the running appsettings— read and change editor settings in the running app
Inspect
openpencil info design.fig
openpencil tree design.fig
openpencil tree --page "Components" --depth 3 # app mode
openpencil pages design.fig
openpencil node design.fig --id 1:23
openpencil node --id 1:23 # app mode
openpencil selection --json
openpencil variables design.fig
openpencil variables --
常见问题
我需要打开应用吗?
不需要。你可以传入文件路径直接处理文件,或者不传,改为使用已打开的应用。
它会修改我的设计吗?
会。它可以通过程序修改设计,因此修改后请检查结果。
我在哪里可以查阅命令?
技能会指向你所安装版本的 OpenPencil 命令行帮助和参考文档。
详情
作者的原始描述
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.
repo: open-pencil/open-pencil
热度
- GitHub 星标
- 9.5k
- 排名
- #12225
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …