open-pencil-design-editor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenPencil Design Editor
OpenPencil 设计编辑器
Skill by ara.so — Daily 2026 Skills collection.
OpenPencil is an open-source, AI-native design editor that reads and writes native Figma () files, provides a headless CLI, an MCP server for AI agents, and a Vue SDK for building custom editors. It is MIT-licensed and runs in the browser, as a desktop app (Tauri/macOS/Windows/Linux), or fully headlessly.
.fig由ara.so提供的Skill — 2026每日技能合集。
OpenPencil是一款原生支持AI的开源设计编辑器,可读写原生Figma()文件,提供无界面CLI、供AI Agent使用的MCP服务器,以及用于构建自定义编辑器的Vue SDK。它采用MIT许可证,可在浏览器中运行,也可作为桌面应用(Tauri/macOS/Windows/Linux)运行,或完全以无界面模式运行。
.figInstallation
安装
Web app (no install)
网页应用(无需安装)
Desktop (macOS)
桌面端(macOS)
sh
brew install open-pencil/tap/open-pencilOr download from releases.
sh
brew install open-pencil/tap/open-pencil或从发布页面下载。
CLI
CLI
sh
bun add -g @open-pencil/clish
bun add -g @open-pencil/cliMCP server
MCP服务器
sh
bun add -g @open-pencil/mcpsh
bun add -g @open-pencil/mcpLocal development
本地开发
sh
git clone https://github.com/open-pencil/open-pencil
cd open-pencil
bun install
bun run dev # Web app at localhost:1420
bun run tauri dev # Desktop (requires Rust)sh
git clone https://github.com/open-pencil/open-pencil
cd open-pencil
bun install
bun run dev # 网页应用运行在localhost:1420
bun run tauri dev # 桌面应用(需要Rust环境)CLI Reference
CLI 参考
The CLI operates on files headlessly. When the desktop app is running, omit the file argument to connect to the live canvas via RPC.
open-pencil.figopen-pencilInspect file structure
检查文件结构
sh
undefinedsh
undefinedPrint the full node tree
打印完整节点树
open-pencil tree design.fig
open-pencil tree design.fig
Find nodes by type
按类型查找节点
open-pencil find design.fig --type TEXT
open-pencil find design.fig --type FRAME
open-pencil find design.fig --type TEXT
open-pencil find design.fig --type FRAME
Get a specific node by ID
通过ID获取特定节点
open-pencil node design.fig --id 1:23
open-pencil node design.fig --id 1:23
File metadata
文件元数据
open-pencil info design.fig
undefinedopen-pencil info design.fig
undefinedXPath queries
XPath 查询
sh
undefinedsh
undefinedAll frames
所有框架
open-pencil query design.fig "//FRAME"
open-pencil query design.fig "//FRAME"
Frames narrower than 300px
宽度小于300px的框架
open-pencil query design.fig "//FRAME[@width < 300]"
open-pencil query design.fig "//FRAME[@width < 300]"
Text nodes whose name contains "Button"
名称包含"Button"的文本节点
open-pencil query design.fig "//TEXT[contains(@name, 'Button')]"
open-pencil query design.fig "//TEXT[contains(@name, 'Button')]"
Nodes with rounded corners
带圆角的节点
open-pencil query design.fig "//*[@cornerRadius > 0]"
open-pencil query design.fig "//*[@cornerRadius > 0]"
Text inside sections
章节内的文本
open-pencil query design.fig "//SECTION//TEXT"
undefinedopen-pencil query design.fig "//SECTION//TEXT"
undefinedExport
导出
sh
undefinedsh
undefinedPNG (default)
PNG(默认格式)
open-pencil export design.fig
open-pencil export design.fig
JPG at 2x scale, quality 90
2倍缩放的JPG,质量90
open-pencil export design.fig -f jpg -s 2 -q 90
open-pencil export design.fig -f jpg -s 2 -q 90
SVG
SVG
open-pencil export design.fig -f svg
open-pencil export design.fig -f svg
WEBP
WEBP
open-pencil export design.fig -f webp
open-pencil export design.fig -f webp
JSX with Tailwind v4 utility classes
带Tailwind v4工具类的JSX
open-pencil export design.fig -f jsx --style tailwind
Example Tailwind output:
```html
<div className="flex flex-col gap-4 p-6 bg-white rounded-xl">
<p className="text-2xl font-bold text-[#1D1B20]">Card Title</p>
<p className="text-sm text-[#49454F]">Description text</p>
</div>open-pencil export design.fig -f jsx --style tailwind
Tailwind输出示例:
```html
<div className="flex flex-col gap-4 p-6 bg-white rounded-xl">
<p className="text-2xl font-bold text-[#1D1B20]">Card Title</p>
<p className="text-sm text-[#49454F]">Description text</p>
</div>Design token analysis
设计令牌分析
sh
open-pencil analyze colors design.fig
open-pencil analyze typography design.fig
open-pencil analyze spacing design.fig
open-pencil analyze clusters design.fig # Repeated structures / component candidatessh
open-pencil analyze colors design.fig
open-pencil analyze typography design.fig
open-pencil analyze spacing design.fig
open-pencil analyze clusters design.fig # 重复结构/组件候选Scripting with Figma Plugin API (eval
)
eval使用Figma插件API脚本化(eval
)
evalsh
undefinedsh
undefinedRead: count children on the current page
读取:统计当前页面的子节点数量
open-pencil eval design.fig -c "figma.currentPage.children.length"
open-pencil eval design.fig -c "figma.currentPage.children.length"
Read: get all text node contents
读取:获取所有文本节点内容
open-pencil eval design.fig -c "figma.currentPage.findAll(n => n.type === 'TEXT').map(n => n.characters)"
open-pencil eval design.fig -c "figma.currentPage.findAll(n => n.type === 'TEXT').map(n => n.characters)"
Write: set opacity of all selected nodes (-w writes back to file)
写入:设置所有选中节点的透明度(-w 表示写回文件)
open-pencil eval design.fig -c "figma.currentPage.selection.forEach(n => n.opacity = 0.5)" -w
open-pencil eval design.fig -c "figma.currentPage.selection.forEach(n => n.opacity = 0.5)" -w
Write: rename all frames on the page
写入:重命名页面上的所有框架
open-pencil eval design.fig -c "figma.currentPage.findAll(n => n.type === 'FRAME').forEach((f, i) => f.name = 'Frame ' + i)" -w
open-pencil eval design.fig -c "figma.currentPage.findAll(n => n.type === 'FRAME').forEach((f, i) => f.name = 'Frame ' + i)" -w
Connect to the live running desktop app (no file arg)
连接到运行中的桌面应用(无需文件参数)
open-pencil eval -c "figma.currentPage.name"
open-pencil tree
open-pencil export -f png
All commands support `--json` for machine-readable output:
```sh
open-pencil find design.fig --type TEXT --json
open-pencil analyze colors design.fig --jsonopen-pencil eval -c "figma.currentPage.name"
open-pencil tree
open-pencil export -f png
所有命令均支持`--json`参数以输出机器可读格式:
```sh
open-pencil find design.fig --type TEXT --json
open-pencil analyze colors design.fig --jsonMCP Server
MCP 服务器
The MCP server exposes 90 tools (87 core + 3 file management) for AI agents to read and write files.
.figMCP服务器暴露90个工具(87个核心工具+3个文件管理工具),供AI Agent读写.fig文件。
Stdio (Claude Code, Cursor, Windsurf)
Stdio(Claude Code、Cursor、Windsurf)
sh
bun add -g @open-pencil/mcpAdd to your MCP client config (e.g. or Cursor settings):
~/.claude/mcp.jsonjson
{
"mcpServers": {
"open-pencil": {
"command": "openpencil-mcp"
}
}
}sh
bun add -g @open-pencil/mcp添加到你的MCP客户端配置文件中(例如或Cursor设置):
~/.claude/mcp.jsonjson
{
"mcpServers": {
"open-pencil": {
"command": "openpencil-mcp"
}
}
}HTTP server (scripts, CI)
HTTP服务器(脚本、CI场景)
sh
openpencil-mcp-httpsh
openpencil-mcp-httpListens at http://localhost:3100/mcp
undefinedundefinedClaude Code desktop integration
Claude Code 桌面集成
- Install the ACP adapter:
sh
npm i -g @zed-industries/claude-agent-acp - Add MCP permission to :
~/.claude/settings.jsonjson{ "permissions": { "allow": ["mcp__open-pencil"] } } - Open the desktop app → → select Claude Code from the provider dropdown.
Ctrl+J
- 安装ACP适配器:
sh
npm i -g @zed-industries/claude-agent-acp - 在中添加MCP权限:
~/.claude/settings.jsonjson{ "permissions": { "allow": ["mcp__open-pencil"] } } - 打开桌面应用 → → 从提供商下拉菜单中选择Claude Code。
Ctrl+J
Agent skill (quick setup)
Agent Skill(快速设置)
sh
npx skills add open-pencil/skills@open-pencilsh
npx skills add open-pencil/skills@open-pencilAI Chat (Built-in)
AI 聊天(内置)
- Open with (macOS) or
⌘J(desktop/web).Ctrl+J - 87 tools: create shapes, set fills/strokes, manage auto-layout, work with components and variables, boolean operations, token analysis, asset export.
- Bring your own API key — no backend or account required.
- 使用(macOS)或
⌘J(桌面/网页)打开。Ctrl+J - 87个工具:创建形状、设置填充/描边、管理自动布局、处理组件和变量、布尔运算、令牌分析、资源导出。
- 使用自有API密钥——无需后端或账户。
Supported providers
支持的提供商
Configure via the provider dropdown in the chat panel:
| Provider | Env var |
|---|---|
| Anthropic | |
| OpenAI | |
| Google AI | |
| OpenRouter | |
| Any compatible endpoint | Custom base URL |
通过聊天面板中的提供商下拉菜单配置:
| 提供商 | 环境变量 |
|---|---|
| Anthropic | |
| OpenAI | |
| Google AI | |
| OpenRouter | |
| 任何兼容端点 | 自定义基础URL |
Real-time Collaboration
实时协作
No server, no account. Peer-to-peer via WebRTC.
- Click the Share button (top-right).
- Share the generated URL: .
app.openpencil.dev/share/<room-id> - Peers see live cursors, selections, and edits.
- Click a peer's avatar to follow their viewport.
无需服务器,无需账户。通过WebRTC实现点对点协作。
- 点击右上角的分享按钮。
- 分享生成的URL:。
app.openpencil.dev/share/<room-id> - 协作方可以看到实时光标、选区和编辑操作。
- 点击协作方的头像可跟随其视口。
Project Structure
项目结构
packages/
core/ @open-pencil/core — engine: scene graph, renderer, layout, codec
cli/ @open-pencil/cli — headless CLI
mcp/ @open-pencil/mcp — MCP server (stdio + HTTP)
docs/ Documentation site
src/ Vue 3 app — components, composables, stores
desktop/ Tauri v2 (Rust + config)
tests/ E2E (188 tests) + unit (764 tests)packages/
core/ @open-pencil/core — 引擎:场景图、渲染器、布局、编解码器
cli/ @open-pencil/cli — 无界面CLI
mcp/ @open-pencil/mcp — MCP服务器(stdio + HTTP)
docs/ 文档站点
src/ Vue 3应用 — 组件、组合式函数、状态管理
desktop/ Tauri v2(Rust + 配置)
tests/ E2E测试(188个测试用例)+ 单元测试(764个测试用例)Tech stack
技术栈
| Layer | Technology |
|---|---|
| Rendering | Skia (CanvasKit WASM) |
| Layout | Yoga WASM (flex + CSS Grid) |
| UI | Vue 3, Reka UI, Tailwind CSS 4 |
| File format | Kiwi binary + Zstd + ZIP |
| Collaboration | Trystero (WebRTC P2P) + Yjs (CRDT) |
| Desktop | Tauri v2 |
| AI/MCP | Anthropic, OpenAI, Google AI, OpenRouter; MCP SDK; Hono |
| 层级 | 技术 |
|---|---|
| 渲染 | Skia(CanvasKit WASM) |
| 布局 | Yoga WASM(flex + CSS Grid) |
| UI | Vue 3、Reka UI、Tailwind CSS 4 |
| 文件格式 | Kiwi二进制 + Zstd + ZIP |
| 协作 | Trystero(WebRTC P2P) + Yjs(CRDT) |
| 桌面端 | Tauri v2 |
| AI/MCP | Anthropic、OpenAI、Google AI、OpenRouter;MCP SDK;Hono |
Development Commands
开发命令
sh
bun run dev # Start web dev server (localhost:1420)
bun run tauri dev # Start desktop app (requires Rust)
bun run check # Lint + typecheck
bun run test # E2E visual regression tests
bun run test:unit # Unit tests
bun run format # Code formatting
bun run tauri build # Production desktop buildDesktop prerequisites: Rust + Tauri v2 platform deps.
sh
bun run dev # 启动网页开发服务器(localhost:1420)
bun run tauri dev # 启动桌面应用(需要Rust环境)
bun run check # 代码检查+类型检查
bun run test # E2E视觉回归测试
bun run test:unit # 单元测试
bun run format # 代码格式化
bun run tauri build # 生产版桌面应用构建桌面应用前置要求:Rust + Tauri v2平台依赖
Common Patterns
常用模式
Batch-rename all text nodes in a .fig file
批量重命名.fig文件中的所有文本节点
sh
open-pencil eval design.fig \
-c "figma.currentPage.findAll(n => n.type === 'TEXT').forEach((t, i) => t.name = 'Text_' + i)" \
-wsh
open-pencil eval design.fig \\
-c "figma.currentPage.findAll(n => n.type === 'TEXT').forEach((t, i) => t.name = 'Text_' + i)" \\
-wExtract all colors as JSON
提取所有颜色为JSON格式
sh
open-pencil analyze colors design.fig --json > colors.jsonsh
open-pencil analyze colors design.fig --json > colors.jsonExport every frame as PNG in CI
在CI中导出所有框架为PNG
sh
for id in $(open-pencil find design.fig --type FRAME --json | jq -r '.[].id'); do
open-pencil export design.fig --id "$id" -f png -o "frames/$id.png"
donesh
for id in $(open-pencil find design.fig --type FRAME --json | jq -r '.[].id'); do
open-pencil export design.fig --id "$id" -f png -o "frames/$id.png"
doneQuery nodes matching a naming convention
查询符合命名规范的节点
sh
undefinedsh
undefinedFind all nodes named with a "btn-" prefix
查找所有以"btn-"前缀命名的节点
open-pencil query design.fig "//*[starts-with(@name, 'btn-')]"
undefinedopen-pencil query design.fig "//*[starts-with(@name, 'btn-')]"
undefinedConnect an MCP client to a running desktop app
将MCP客户端连接到运行中的桌面应用
When the desktop app is open, the MCP stdio server can connect to the live canvas. No file path needed — all reads and writes go to the open document.
json
{
"mcpServers": {
"open-pencil": {
"command": "openpencil-mcp"
}
}
}当桌面应用打开时,MCP stdio服务器可连接到实时画布。无需文件路径——所有读写操作都针对打开的文档。
json
{
"mcpServers": {
"open-pencil": {
"command": "openpencil-mcp"
}
}
}Export a selection as Tailwind JSX programmatically
以编程方式导出选区为Tailwind JSX
sh
open-pencil export design.fig --id 1:23 -f jsx --style tailwindsh
open-pencil export design.fig --id 1:23 -f jsx --style tailwindTroubleshooting
故障排除
openpencil-mcp- Ensure 's global bin dir is on your
bun:PATHexport PATH="$HOME/.bun/bin:$PATH" - Or use as the MCP command value.
npx openpencil-mcp
Desktop app CLI connection fails
- The desktop app must be running before issuing commands without a file argument.
- Check that no firewall rule blocks the local RPC socket.
Tauri dev build errors
- Install platform prerequisites: v2.tauri.app/start/prerequisites
- Ensure Rust is up to date:
rustup update
.fig- Confirm the file was exported from Figma (not a backup or plugin artifact).
.fig - Run to check if the codec can parse the header.
open-pencil info design.fig
AI chat returns no response
- Verify your API key is set correctly in the provider settings panel.
- For OpenRouter, ensure your key has credits and the selected model is available.
Collaboration peers not connecting
- Both peers must use the exact same share URL (room ID is case-sensitive).
- WebRTC requires both peers to allow the browser/app through any firewall.
安装后找不到
openpencil-mcp- 确保的全局bin目录在你的
bun中:PATHexport PATH="$HOME/.bun/bin:$PATH" - 或使用作为MCP命令值。
npx openpencil-mcp
桌面应用CLI连接失败
- 在执行无文件参数的命令前,必须先运行桌面应用。
- 检查是否有防火墙规则阻止了本地RPC套接字。
Tauri开发构建错误
- 安装平台前置依赖:v2.tauri.app/start/prerequisites
- 确保Rust是最新版本:
rustup update
.fig文件无法打开
- 确认文件是从Figma导出的(不是.fig备份或插件产物)。
- 运行检查编解码器能否解析文件头。
open-pencil info design.fig
AI聊天无响应
- 验证你在提供商设置面板中正确配置了API密钥。
- 对于OpenRouter,确保你的密钥有余额且所选模型可用。
协作方无法连接
- 双方必须使用完全相同的分享URL(房间ID区分大小写)。
- WebRTC要求双方允许浏览器/应用通过防火墙。
Links
链接
- Web app: app.openpencil.dev/demo
- Documentation: openpencil.dev
- MCP tools reference: openpencil.dev/reference/mcp-tools
- Releases: github.com/open-pencil/open-pencil/releases
- License: MIT
- 网页应用:app.openpencil.dev/demo
- 文档:openpencil.dev
- MCP工具参考:openpencil.dev/reference/mcp-tools
- 发布页面:github.com/open-pencil/open-pencil/releases
- 许可证:MIT ",