重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
agent-canvas by whq25/agent-canvas
npx skills add https://github.com/whq25/agent-canvas --skill agent-canvas一个用于与 Excalidraw 画布交互以创建图表和可视化的 CLI 工具。
使用前,请检查 CLI 是否已安装:
which agent-canvas && agent-canvas --version
如果未安装:询问用户偏好哪种包管理器(bun 或 npm),然后安装:
bun add -g @agent-canvas/cli@0.13.0
npm install -g @agent-canvas/cli@0.13.0
如果已安装但版本不是 0.13.0:使用相同的包管理器升级:
.bun → bun add -g @agent-canvas/cli@0.13.0npm install -g @agent-canvas/cli@0.13.0安装/升级后:使用 agent-canvas --version 验证,确认版本为 0.13.0
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
启动画布(在浏览器中打开):
agent-canvas start &
使用 CLI 命令在画布上绘图。
默认端口:39820 (WebSocket), 39821 (HTTP)。如果端口冲突,通过以下方式配置:
agent-canvas config set port 39820 # 设置 WebSocket 端口
agent-canvas config set http-port 39821 # 设置 HTTP 端口
agent-canvas config list # 显示所有配置(值 + 来源)
agent-canvas config get port # 显示当前端口
agent-canvas config reset port # 重置为默认值
配置保存到 ~/.agent-canvas/config.json。可通过 start 命令一次性覆盖:
agent-canvas start --port 8000 --http-port 8001 &
优先级:--port 标志 > 环境变量 AGENT_CANVAS_WS_PORT > 配置文件 > 默认值。
agent-canvas start & # 在后台启动服务器(一段时间无操作后将自动关闭)
agent-canvas load file.excalidraw # 将 .excalidraw 文件加载到当前画布
从文件加载时:记住文件路径,并使用 agent-canvas save <原始文件> 保存回该文件。
画布支持多个画布。每个画布独立存储,并可在它们之间切换。
agent-canvas list # 列出所有画布([U]=用户活跃,[A]=代理活跃,[F]=文件夹)
agent-canvas new -n "名称" [--use] # 创建新画布,可选择切换到它
agent-canvas use "名称" # 按名称切换到画布
agent-canvas rename "新名称" # 重命名当前画布
文件夹管理 — 将画布组织到文件夹中:
agent-canvas create-folder -n "名称" # 创建新文件夹
agent-canvas delete-folder "名称" # 删除文件夹(画布变为未分组)
agent-canvas move-to-folder "画布" "文件夹" # 将画布移动到文件夹中
agent-canvas move-to-folder "画布" --ungrouped # 将画布从其文件夹中移除
注意:
agent-canvas add-text -t "<文本>" --ax <x> --ay <y> [选项]
选项:--font-size <大小>, --text-align <left|center|right>, -a/--anchor <锚点>, --stroke-color <十六进制>, -n/--note <文本>
字体大小:S=16, M=20 (默认), L=28, XL=36
锚点 (-a):由于文本大小在渲染前未知,锚点通过指定文本边界框的哪个点与 (--ax, --ay) 对齐,为您提供精确的定位控制。默认:bottomLeft。
| 锚点 | 常见文本类型 |
|---|---|
topLeft | 徽章、标签、图标标签 |
topCenter | 副标题、形状下方的描述 |
topRight | 时间戳、版本、状态 |
leftCenter | 侧面注释(形状右侧) |
center | 居中的标题、主标签 |
rightCenter | 侧面注释(形状左侧) |
bottomLeft | 脚注、注释 |
bottomCenter | 标题、形状上方的页眉 |
bottomRight | 脚注、签名 |
文本已创建 (id: <id>, x: <x>, y: <y>, <宽度>x<高度>) — 实际的左上角位置和尺寸,用于精确布局所有绘图命令共享通用样式选项:
--stroke-color <十六进制> (默认: #1e1e1e), --stroke-width <1-4> (默认: 2), --stroke-style <solid|dashed|dotted> (默认: solid)--background-color <十六进制> (默认: transparent), --fill-style <solid|hachure|cross-hatch> (默认: solid)-n/--note <文本> - 元素的语义描述。请大量使用 - 注释有助于在稍后回读时理解图表意图。--animated - 自动滚动视口以显示新添加的元素。小元素会放大,大元素会缩小,普通元素会最小化滚动。推荐颜色 (来自 Excalidraw 调色板):
| 颜色 | 描边 (深色) | 背景 (浅色) |
|---|---|---|
| 红色 | #e03131 | #ffc9c9 |
| 蓝色 | #1971c2 | #a5d8ff |
| 绿色 | #2f9e44 | #b2f2bb |
| 黄色 | #f08c00 | #ffec99 |
| 青色 | #0c8599 | #99e9f2 |
| 紫色 | #6741d9 | #b197fc |
| 灰色 | #495057 | #dee2e6 |
agent-canvas add-shape -t <类型> -x <x> -y <y> [-w <宽度>] [-h <高度>] [-l <标签>]
rectangle, ellipse, diamond-l/--label 在形状内添加文本(默认字体大小: 16),使用 --label-font-size <n> 调整--stroke-color;使用 --label-stroke-color <十六进制> 覆盖形状已创建 (id: <id> x=<x> y=<y> w=<宽度> h=<高度>) — 为标签自动调整大小后的实际尺寸⚠️ 标签尺寸计算 - 关键:在绘图前计算
如果形状尺寸太小,Excalidraw 会自动扩展,破坏箭头坐标。您必须:
步骤 1: 计算文本尺寸 (默认 fontSize=16)
文本宽度 = 字符数 × fontSize × 0.6 (英文/数字)
文本宽度 = 字符数 × fontSize (CJK 字符)
文本高度 = 行数 × fontSize × 1.35
步骤 2: 计算最小形状尺寸 (使用这些值,不要更小!)
矩形: 宽度 = 文本宽度 + 50, 高度 = 文本高度 + 50
椭圆: 宽度 = 文本宽度 × 1.42 + 55, 高度 = 文本高度 × 1.42 + 55
菱形: 宽度 = 文本宽度 × 2 + 60, 高度 = 文本高度 × 2 + 60
示例:椭圆中的标签 "Message Queue" (13 个字符)
文本宽度 = 13 × 16 × 0.6 = 124.8
文本高度 = 1 × 16 × 1.35 = 21.6
椭圆宽度 = 124.8 × 1.42 + 55 = 232
椭圆高度 = 21.6 × 1.42 + 55 = 86
→ 使用: -w 232 -h 86 (或向上取整为 -w 240 -h 90)
提示:对于长标签,手动插入 \n,然后使用更新后的行数重新计算。
agent-canvas add-line -x <x1> -y <y1> --end-x <x2> --end-y <y2>
agent-canvas add-arrow -x <x1> -y <y1> --end-x <x2> --end-y <y2>
--start-arrowhead, --end-arrowhead (arrow, bar, dot, triangle, diamond, none)箭头类型 (--arrow-type):
| 类型 | 描述 | 使用场景 |
|---|---|---|
sharp | 直线 (默认) | 直接连接 |
round | 带控制点的曲线 | 有机流程,避免重叠 |
elbow | 直角转弯 (90°) | 流程图、电路图 |
中间点 (--via):使用 --via 以 "x1,y1;x2,y2;..." 格式指定中间点的绝对坐标:
# 圆角箭头:一个控制点决定曲线方向
# 向左弯曲的垂直箭头(控制点在 x=50,线的左侧)
agent-canvas add-arrow -x 100 -y 100 --end-x 100 --end-y 300 --arrow-type round --via "50,200"
# 直角箭头:多个点用于 90° 转弯
# 循环返回模式:下 → 左 → 上 (用于流程图迭代)
agent-canvas add-arrow -x 175 -y 520 --end-x 175 --end-y 280 --arrow-type elbow --via "120,520;120,280"
提示:
round:曲线向控制点弯曲(偏离直线路径)elbow:点定义 90° 路径的拐角agent-canvas add-polygon -p '[{"x":0,"y":0},{"x":100,"y":0},{"x":50,"y":100}]'
agent-canvas add-image -f <路径> -x <x> -y <y> [-w <宽度>] [-h <高度>] [-n <注释>]
图像已添加 (id: <id>, x: <x>, y: <y>, <宽度>x<高度>)agent-canvas delete-elements -i <id1>,<id2>,...
agent-canvas rotate-elements -i <id1>,<id2>,... -a <度数>
agent-canvas move-elements -i <id1>,<id2>,... --delta-x <dx> --delta-y <dy>
agent-canvas resize-elements -i <id1>,<id2>,... [--top <n>] [--bottom <n>] [--left <n>] [--right <n>]
agent-canvas group-elements -i <id1>,<id2>,...
agent-canvas ungroup-element -i <id>
调整元素大小 (resize-elements):扩展或收缩元素的边缘(矩形、椭圆、菱形、图像)。值在元素的本地坐标系中(考虑旋转)。
示例:
# 底部边缘扩展 50px (增加高度)
agent-canvas resize-elements -i abc123 --bottom 50
# 同时扩展右侧和底部 (像拖动右下角)
agent-canvas resize-elements -i abc123 --right 50 --bottom 30
# 左侧边缘收缩 20px (减小宽度)
agent-canvas resize-elements -i abc123 --left -20
# 所有边均匀扩展
agent-canvas resize-elements -i abc123 --top 25 --bottom 25 --left 25 --right 25
agent-canvas read # TOON 格式 (紧凑,约 JSON 大小的 7%)
agent-canvas read --with-style # 包含描边/背景颜色
agent-canvas read --json # 原始 Excalidraw 场景 JSON
TOON 输出结构:
shapes[N]{id,type,x,y,w,h,angle,labelId,note} # rectangle, ellipse, diamond, polygon
lines[N]{id,type,x,y,endX,endY,via,angle,note} # line, arrow
labels[N]{id,containerId,content,x,y,w,h} # 绑定到形状的文本 (通过 labelId)
texts[N]{id,content,x,y,w,h,angle,note} # 独立的文本元素
groups[N]{id,elementIds} # 元素分组
labelId 链接到标签中的 idvia 以与 --via 输入相同的格式显示中间点 ("x1,y1;x2,y2",如果没有则为 null)--with-style 添加 stroke, bg 字段--json 返回完整的 Excalidraw 格式 (与 jq 结合使用以查询特定元素)agent-canvas save file.excalidraw
agent-canvas export -o out.png [--scale 2] [--dark] [--no-background]
agent-canvas clear # 从画布中清除所有元素,请谨慎使用!
注意:在运行 clear 之前,询问用户是否要先保存或导出当前画布。⚠️始终优先使用 agent-canvas new 而不是 agent-canvas clear,仅在用户确认后使用 clear!⚠️
您是一个完美主义者。如果看起来稍有偏差,那就是有偏差。修复它。
核心理念:一致性反映含义。
相同关系 → 相同的对齐和间距
相同类型 → 相同的颜色和大小
细节至关重要
export 查看并修复任何不完美之处坐标:原点 (0,0) 在左上角。X→右,Y→下。颜色使用十六进制 (#FF5733) 或 transparent。
工作流程:读取画布 → 规划布局 → 绘制形状 → 添加箭头/线条(如有必要) → 调整。
agent-canvas read 以检查现有内容。read 和 export 进行审查。对照设计理念检查:
move-elements 对齐到网格move-elements 使间隙相等move-elements 或 delete-elements 并重画delete-elements 并重画delete-elements 并使用正确的端点重画resize-elements 调整到完美尺寸渐进式画布读取:
read - 从这里开始。紧凑的 TOON 格式 (约 JSON 大小的 7%)read --with-style - 当样式重要时添加颜色信息export -o canvas.png + 查看图像 - 用于视觉/空间理解read --json | jq '.elements[] | select(.id=="<id>")' - 查询特定元素的详细信息批量命令:使用 && 链接以提高效率。不要在绘图命令中编写 BASH 注释
agent-canvas add-shape -t rectangle -x 100 -y 100 -l "A" &&
agent-canvas add-shape -t rectangle -x 300 -y 100 -l "B" &&
agent-canvas add-arrow -x 220 -y 130 --end-x 300 --end-y 130
在绘图之前,确定图表类型并查看教程:
每周安装量
65
仓库
GitHub 星标数
11
首次出现
2026年1月19日
安全审计
安装于
opencode52
gemini-cli48
codex48
claude-code47
cursor43
github-copilot35
A CLI tool to interact with an Excalidraw canvas for creating diagrams and visualizations.
Before using, check if CLI is installed:
which agent-canvas && agent-canvas --version
If not installed : Ask the user which package manager they prefer (bun or npm), then install:
bun add -g @agent-canvas/cli@0.13.0
npm install -g @agent-canvas/cli@0.13.0
If installed but version differs from 0.13.0 : Upgrade using the same package manager:
.bun → bun add -g @agent-canvas/cli@0.13.0npm install -g @agent-canvas/cli@0.13.0After install/upgrade : Verify with agent-canvas --version to confirm version is 0.13.0
Start the canvas (opens in browser):
agent-canvas start &
Use CLI commands to draw on the canvas.
Default ports: 39820 (WebSocket), 39821 (HTTP). If ports conflict, configure via:
agent-canvas config set port 39820 # Set WebSocket port
agent-canvas config set http-port 39821 # Set HTTP port
agent-canvas config list # Show all config (value + source)
agent-canvas config get port # Show current port
agent-canvas config reset port # Reset to default
Config is saved to ~/.agent-canvas/config.json. One-time override via start:
agent-canvas start --port 8000 --http-port 8001 &
Priority: --port flag > env var AGENT_CANVAS_WS_PORT > config file > default.
agent-canvas start & # Start server in the background (will close automatically when no action for a while)
agent-canvas load file.excalidraw # Load .excalidraw file into current canvas
When loading from file : Remember the file path and save back to it with agent-canvas save <original-file>.
The canvas supports multiple canvases. Each canvas is stored independently and can be switched between.
agent-canvas list # List all canvases ([U]=User active, [A]=Agent active, [F]=Folder)
agent-canvas new -n "Name" [--use] # Create new canvas, optionally switch to it
agent-canvas use "Name" # Switch to canvas by name
agent-canvas rename "New Name" # Rename current canvas
Folder Management — Organize canvases into folders:
agent-canvas create-folder -n "Name" # Create a new folder
agent-canvas delete-folder "Name" # Delete folder (canvases become ungrouped)
agent-canvas move-to-folder "Canvas" "Folder" # Move canvas into a folder
agent-canvas move-to-folder "Canvas" --ungrouped # Remove canvas from its folder
Notes:
agent-canvas add-text -t "<text>" --ax <x> --ay <y> [options]
Options: --font-size <size>, --text-align <left|center|right>, -a/--anchor <anchor>, --stroke-color <hex>, -n/--note <text>
Font sizes: S=16, M=20 (default), L=28, XL=36
Anchor (-a): Since text size is unknown until rendered, anchor gives you precise positioning control by specifying which point of the text bounding box aligns to (--ax, --ay). Default: bottomLeft.
| Anchor | Common Text Types |
|---|---|
topLeft | Badge, Tag, Icon label |
topCenter | Subtitle, Description below shape |
topRight | Timestamp, Version, Status |
leftCenter | Side annotation (right of shape) |
center | Centered title, Main label |
rightCenter | Side annotation (left of shape) |
Text created (id: <id>, x: <x>, y: <y>, <width>x<height>) — actual top-left position and dimensions for precise layoutAll drawing commands share common style options:
--stroke-color <hex> (default: #1e1e1e), --stroke-width <1-4> (default: 2), --stroke-style <solid|dashed|dotted> (default: solid)--background-color <hex> (default: transparent), --fill-style <solid|hachure|cross-hatch> (default: solid)-n/--note <text> - semantic description for the element. Use liberally - notes help understand diagram intent when reading back later.--animated - auto-scroll viewport to show the newly added element. Small elements zoom in, large elements zoom out, normal elements scroll minimally.Recommended Colors (from Excalidraw palette):
| Color | Stroke (dark) | Background (light) |
|---|---|---|
| Red | #e03131 | #ffc9c9 |
| Blue | #1971c2 | #a5d8ff |
| Green | #2f9e44 | #b2f2bb |
| Yellow | #f08c00 | #ffec99 |
| Cyan | #0c8599 | #99e9f2 |
| Violet | #6741d9 | #b197fc |
| Gray | #495057 | #dee2e6 |
agent-canvas add-shape -t <type> -x <x> -y <y> [-w <width>] [-h <height>] [-l <label>]
rectangle, ellipse, diamond-l/--label to add text inside the shape (fontSize: 16 by default), --label-font-size <n> to adjust--stroke-color by default; use --label-stroke-color <hex> to overrideShape created (id: <id> x=<x> y=<y> w=<width> h=<height>) — actual dimensions after auto-sizing for labels⚠️ Label Sizing - CRITICAL: Calculate BEFORE drawing
If shape size is too small, Excalidraw auto-expands, breaking arrow coordinates. You MUST:
Step 1: Calculate text dimensions (fontSize=16 by default)
textWidth = charCount × fontSize × 0.6 (English/numbers)
textWidth = charCount × fontSize (CJK characters)
textHeight = lineCount × fontSize × 1.35
Step 2: Calculate minimum shape size (use these values, not smaller!)
rectangle: width = textWidth + 50, height = textHeight + 50
ellipse: width = textWidth × 1.42 + 55, height = textHeight × 1.42 + 55
diamond: width = textWidth × 2 + 60, height = textHeight × 2 + 60
Example : Label "Message Queue" (13 chars) in ellipse
textWidth = 13 × 16 × 0.6 = 124.8
textHeight = 1 × 16 × 1.35 = 21.6
ellipse width = 124.8 × 1.42 + 55 = 232
ellipse height = 21.6 × 1.42 + 55 = 86
→ Use: -w 232 -h 86 (or round up to -w 240 -h 90)
Tip : For long labels, insert \n manually, then recalculate with updated lineCount.
agent-canvas add-line -x <x1> -y <y1> --end-x <x2> --end-y <y2>
agent-canvas add-arrow -x <x1> -y <y1> --end-x <x2> --end-y <y2>
--start-arrowhead, --end-arrowhead (arrow, bar, dot, triangle, diamond, none)Arrow Types (--arrow-type):
| Type | Description | Use Case |
|---|---|---|
sharp | Straight line (default) | Direct connections |
round | Curved line with control point | Organic flows, avoiding overlaps |
elbow | Right-angle turns (90°) | Flowcharts, circuit diagrams |
Intermediate Points (--via): Use --via to specify intermediate points as absolute coordinates in format "x1,y1;x2,y2;...":
# Round arrow: one control point determines curve direction
# Vertical arrow curving left (control point at x=50, left of the line)
agent-canvas add-arrow -x 100 -y 100 --end-x 100 --end-y 300 --arrow-type round --via "50,200"
# Elbow arrow: multiple points for 90° turns
# Loop back pattern: down → left → up (for flowchart iterations)
agent-canvas add-arrow -x 175 -y 520 --end-x 175 --end-y 280 --arrow-type elbow --via "120,520;120,280"
Tips :
round: curve bends toward the control point (offset from straight path)elbow: points define the corners of the 90° pathagent-canvas add-polygon -p '[{"x":0,"y":0},{"x":100,"y":0},{"x":50,"y":100}]'
agent-canvas add-image -f <path> -x <x> -y <y> [-w <width>] [-h <height>] [-n <note>]
Image added (id: <id>, x: <x>, y: <y>, <width>x<height>)agent-canvas delete-elements -i <id1>,<id2>,...
agent-canvas rotate-elements -i <id1>,<id2>,... -a <degrees>
agent-canvas move-elements -i <id1>,<id2>,... --delta-x <dx> --delta-y <dy>
agent-canvas resize-elements -i <id1>,<id2>,... [--top <n>] [--bottom <n>] [--left <n>] [--right <n>]
agent-canvas group-elements -i <id1>,<id2>,...
agent-canvas ungroup-element -i <id>
Resize Elements (resize-elements): Expand or contract element edges (rectangle, ellipse, diamond, image). Values are in element's local coordinate system (respects rotation).
Examples:
# Expand bottom edge by 50px (increase height)
agent-canvas resize-elements -i abc123 --bottom 50
# Expand both right and bottom (like dragging bottom-right corner)
agent-canvas resize-elements -i abc123 --right 50 --bottom 30
# Contract left edge by 20px (decrease width)
agent-canvas resize-elements -i abc123 --left -20
# Expand all sides uniformly
agent-canvas resize-elements -i abc123 --top 25 --bottom 25 --left 25 --right 25
agent-canvas read # TOON format (compact, ~7% of JSON size)
agent-canvas read --with-style # Include stroke/bg colors
agent-canvas read --json # Raw Excalidraw scene JSON
TOON output structure:
shapes[N]{id,type,x,y,w,h,angle,labelId,note} # rectangle, ellipse, diamond, polygon
lines[N]{id,type,x,y,endX,endY,via,angle,note} # line, arrow
labels[N]{id,containerId,content,x,y,w,h} # text bound to shapes (via labelId)
texts[N]{id,content,x,y,w,h,angle,note} # standalone text elements
groups[N]{id,elementIds} # element groupings
labelId in shapes links to id in labelsvia shows intermediate points in same format as --via input ("x1,y1;x2,y2" or null if none)--with-style adds stroke, bg fields--json returns full Excalidraw format (use with jq to query specific elements)agent-canvas save file.excalidraw
agent-canvas export -o out.png [--scale 2] [--dark] [--no-background]
agent-canvas clear # Clear all elements from the canvas, use with caution!
Note : Before running clear, ask the user if they want to save or export the current canvas first. ⚠️ALWAYS prefer agent-canvas new over agent-canvas clear only use clear when user has confirmed!⚠️
You are a perfectionist. If it looks slightly off, it IS off. Fix it.
Core principle: Consistency reflects meaning.
Same relationship → Same alignment & spacing
Same type → Same color & size
Details matter
export and fix any imperfectionsCoordinates : Origin (0,0) is top-left. X→right, Y→down. Colors in hex (#FF5733) or transparent.
Workflow : Read canvas → Plan layout → Draw shapes → Add arrows/lines(if necessary) → Adjust.
agent-canvas read first to check for existing content before drawing.read and export to review. Check against Design Philosophy:
move-elements to snap to gridBefore drawing, identify the diagram type and check for tutorials:
Weekly Installs
65
Repository
GitHub Stars
11
First Seen
Jan 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode52
gemini-cli48
codex48
claude-code47
cursor43
github-copilot35
GitHub Actions 官方文档查询助手 - 精准解答 CI/CD 工作流问题
47,200 周安装
Visual Planner:基于tldraw的可视化工作流与智能体编排图表工具
6 周安装
create-mcp-app 快速构建交互式 MCP 应用 - 工具与资源整合指南
7 周安装
Nuxt Studio 设置与部署指南:为Nuxt Content网站添加可视化CMS编辑器
13 周安装
自主开发代理交付工单技能:AI自动化代码任务处理与PR交付
8 周安装
JSON 转 React Email 渲染器:用 JSON 规范生成 HTML/纯文本邮件 | @json-render/react-email
8 周安装
runtime-context技能:AI智能体运行时环境检测与工具适配,实现跨平台兼容性
9 周安装
bottomLeft | Footnote, Note |
bottomCenter | Title, Header above shape |
bottomRight | Footnote, Signature |
move-elements to equalize gapsmove-elements or delete-elements and redrawdelete-elements and redrawdelete-elements and redraw with correct endpointsresize-elements to adjust to perfect sizeProgressive Canvas Reading :
read - Start here. Compact TOON format (~7% of JSON size)read --with-style - Add color info when styling mattersexport -o canvas.png + view image - For visual/spatial understandingread --json | jq '.elements[] | select(.id=="<id>")' - Query specific element detailsBatch Commands : Chain with && for efficiency. DO NOT WRITE BASH COMMENT IN DRAWING COMMANDS
agent-canvas add-shape -t rectangle -x 100 -y 100 -l "A" &&
agent-canvas add-shape -t rectangle -x 300 -y 100 -l "B" &&
agent-canvas add-arrow -x 220 -y 130 --end-x 300 --end-y 130