excalidraw-skill
Use for planning, creating, refining, validating, or exporting Excalidraw technical diagrams, including text-only layout proposals before drawing
- License 许可
- MIT
- 所属仓库
- OrestesK/omp
- 最近更新
- 2026-10-16
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- excalidraw-skill
- description
- Use for planning, creating, refining, validating, or exporting Excalidraw technical diagrams, including text-only layout proposals before drawing
02 资源文件 16
- 参考文档evals/evals.json7.5 KB
- 其他evals/fixtures/bad-overview.excalidraw12.7 KB
- 参考文档evals/fixtures/decision-flow.json1.1 KB
- 参考文档evals/fixtures/narrow-review.md307 B
- 参考文档evals/fixtures/semantic-inventory.json4.3 KB
- 其他evals/fixtures/style-a.excalidraw3.0 KB
- 其他evals/fixtures/style-b.excalidraw2.8 KB
- 其他evals/fixtures/style-c.excalidraw4.0 KB
- 参考文档references/change-explanations.md6.9 KB
- 参考文档references/cheatsheet.md9.5 KB
- 参考文档references/orestes-clean-style.md5.2 KB
- 参考文档references/quality-gates.md5.9 KB
- 脚本scripts/audit_scene.py20.2 KB
- 脚本scripts/validate_semantic_cut.py16.7 KB
- 脚本tests/test_audit_scene.py17.7 KB
- 脚本tests/test_validate_semantic_cut.py9.8 KB
03 SKILL.md 正文
Excalidraw Skill
Plan the explanation
- For a before/after diagram or an explanation of what changes, read
references/change-explanations.mdbefore choosing the layout - For a text-only layout request, apply the design guidance and return the proposed composition without opening or changing a canvas
- Rendered-image gates apply when drawing is requested. Do not claim visual validation from a text plan
Design and validation for new diagrams
For every nontrivial new rendered diagram, complete these design and validation steps before you call the result complete:
- Read
references/orestes-clean-style.md. It is the default style - Read
references/quality-gates.md - If the user supplies visual references or native
.excalidrawfiles, inspect them before layout. Reference-established traits override every generic default - Decide who will read the diagram, its one-sentence takeaway, output size, overview or detail level, required claims, and non-goals
- Make a semantic cut: choose the facts the diagram needs to show. Do not force every source fact onto one canvas. Ask for approval before omitting or materially abstracting facts
- Use the overview budget and view-specific checks in
references/quality-gates.md. Split into panels or another diagram when exceeded - Construct and screenshot in stages: skeleton → primary arrows → optional clusters
- Run the native scene audit and inspect the final export at native, 50%, 35%, and grayscale sizes
- For nontrivial work, run a broad blind adversarial review
The diagram must have complete labels, the allowed arrow count, no clipping at full zoom, and pass the required reviews
Step 0: Pick an Interface
Three interfaces drive the same live canvas. Pick the first one that applies:
- MCP tools — if
excalidraw/*tools (e.g.batch_create_elements) are in your tool list, prefer them: results land directly in your context, and screenshots come back as images without touching disk - CLI (default when no MCP tools are present):
No setup needed — any canvas-touching command auto-starts the canvas server onnpx -y mcp-excalidraw-server <command>http://127.0.0.1:3000(firstnpxrun downloads the package). If the CLI is installed globally (npm i -g mcp-excalidraw-server), the shorter aliasexcalidraw-canvas <command>works too - REST API (last resort, e.g. from application code): HTTP endpoints on
http://127.0.0.1:3000— seereferences/cheatsheet.mdfor payloads. The server must already be running
The canvas URL comes from EXPRESS_SERVER_URL (default http://127.0.0.1:3000). Remind the user to open that URL in a browser — screenshots, image export, mermaid conversion, and viewport control need an open tab (CLI exits with code 4 when it's missing)
CLI Quick Reference
Results are JSON on stdout — except describe (plain text) and raw-content output when --out is omitted (export scene JSON, screenshot --format svg). Diagnostics on stderr. Exit codes: 0 ok, 1 error, 2 usage, 3 canvas unreachable, 4 browser tab required
| Task | Command |
|---|---|
| Start / stop / inspect server | start, stop, status |
| Create elements (batch) | add elements.json or echo '[...]' | add or add --one '{...}' |
| Multi-op patch in one call | apply patch.json — {"create":[...],"update":[{"id":"a","set":{...}}],"delete":[...]} |
| Read one / query many | get <id>, query [--type t] [--bbox x0,y0,x1,y1] [--filter k=v] [--filter-json '{...}'] |
| Update / delete | update <id> --set '{...}', delete <id> [...] |
| Understand the scene | describe (plain-text summary: ids, positions, labels, connections) |
| See the scene | screenshot [--out f.png] (PNG without --out → temp file path in JSON |
SVG without --out → raw SVG) |
|
| Layout operations | arrange align|distribute|group|ungroup|lock|unlock|duplicate --ids a,b,c [--to left|horizontal|...] |
| Scene files | export [--out scene.excalidraw], `import [scene.excalidraw |
| Mermaid → canvas | `mermaid [diagram.mmd |
| Snapshots | snapshot save|list|restore <name> |
| Share link | share (encrypted upload → excalidraw.com URL) |
| Wipe canvas | clear --yes |
| Install / upgrade this skill | install-skill --dir <skills-root> (agent chooses project/global root) |
Element Format (CLI and MCP)
The CLI and MCP tools accept the same agent-friendly format and normalize it automatically:
- Labels: put
"text": "My Label"on any shape — converted to Excalidraw's bound-label format for you - Arrow binding:
"startElementId": "a"/"endElementId": "b"— arrows auto-route to element edges - fontFamily: pass a string name (
"helvetica","cascadia","excalifont", ...) or string number"1"–"8" - points: both
[[x,y], ...]tuples and[{"x":..,"y":..}]objects are accepted - Patch updates: in
apply, update entries can use either direct fields ({"id":"a","x":120}) or asetobject ({"id":"a","set":{"x":120}}). Do not mix both forms in one update entry
Raw REST is stricter: labels must be "label": {"text": "..."}, bindings must be "start": {"id": "..."} / "end": {"id": "..."}. Only worry about this when POSTing to the API directly
Coordinate System
The canvas uses a 2D coordinate grid: (0, 0) is the origin, x increases rightward, y increases downward. Plan your layout before writing any JSON
General spacing guidelines:
- Vertical spacing between tiers: 80–120px (enough that arrows don't crowd labels)
- Horizontal spacing between siblings: 40–60px minimum:
- give labeled arrows 120px+
- Shape width:
max(160, labelCharCount * 12)to keep the label on one line - Shape height: 60px single-line, 80px two-line labels
- Background/zone padding: 50px on all sides around contained elements
Default local style:
- White canvas
- roughness
1 - black or near-black linework
- Transparent rounded rectangles by default. Use pale semantic fills sparingly and only when they improve role recognition
- Body labels are normally 20px
- titles 30–36px
- small boundary/arrow annotations never below 16px
- Semantic arrows are black, solid, 2px, short/direct, and bound to both endpoints
- Dashed light-gray rectangles represent real scope boundaries only. Do not start with decorative background zones
- The palette in the cheatsheet is a fallback library, not a requirement to create color categories
Layout Anti-Patterns (Critical for Complex Diagrams)
These are the most common mistakes that produce unreadable diagrams. Avoid all of them
1. Do NOT use label.text (or text) on large background zone rectangles
When you put a label on a background rectangle, Excalidraw creates a bound text element centered in the middle of that shape — right where your service boxes will be placed. The text overlaps everything inside the zone and cannot be repositioned
Wrong:
{"id": "vpc-zone", "type": "rectangle", "x": 50, "y": 50, "width": 800, "height": 400, "text": "VPC (10.0.0.0/16)"}
Right — use a free-standing text element anchored at the top of the zone:
{"id": "vpc-zone", "type": "rectangle", "x": 50, "y": 50, "width": 800, "height": 400, "backgroundColor": "transparent", "strokeColor": "#adb5bd", "strokeStyle": "dashed"},
{"id": "vpc-label", "type": "text", "x": 70, "y": 60, "width": 300, "height": 30, "text": "VPC (10.0.0.0/16)", "fontSize": 18}
The free-standing text element sits at the top corner of the zone and doesn't interfere with elements placed inside
2. Avoid cross-zone arrows in complex diagrams
An arrow from an element in one layout zone to an element in a distant zone will draw a long diagonal line crossing through everything in between. In a multi-zone infra diagram this produces an unreadable tangle of spaghetti
Design rule: Keep arrows within the same zone or tier. To show cross-zone relationships, make zone edges adjacent, use one explicit cross-panel edge, or split the content into separate views
Do not use a canvas-spanning perimeter arrow as the usual workaround. A long return path, multi-bend route, or global loop usually means the diagram should move responsibilities, merge duplicate concepts, or split into views
3. Use arrow labels sparingly
Arrow labels are placed at the midpoint of the arrow. On short arrows, they overlap the shapes at both ends. On crowded diagrams, they collide with nearby elements:
- Only add an arrow label when the relationship name is genuinely essential (e.g., protocol, port number, data direction)
- If you're adding a label to every arrow, reconsider — it usually adds visual noise, not clarity
- Keep arrow labels to ≤ 12 characters. Prefer omitting them entirely on dense diagrams
Check each staged batch
After every staged add, apply, or batch_create_elements, take a screenshot and check:
- Primary story — Can the main comparison, central relationship, or primary route be identified in under three seconds without reading supporting notes? For a flow, is its endpoint clear?
- Hierarchy — Is the main takeaway dominant, with supporting concerns visibly subordinate?
- Text truncation — Is all label text fully visible? Increase the shape or reduce copy never solve this by shrinking below the style floor
- Overlap — Do any semantic shapes share space? Do boundaries contain children with real padding?
- Arrow topology — Do arrows cut through unrelated elements, cross without bridge/junction meaning, or point into empty space? Prefer moving nodes or splitting the view over complex routing
- Binding — Is every semantic relationship one arrow bound to both endpoints? Free arrows must be explicit annotations
- Arrow-label ownership — Is every route label visibly attached to exactly one route?
- Spacing and balance — At least 40px between elements no large empty void beside a congested cluster
- Readability — Default body text is 20px no annotation below 16px. Judge the rendered target size, not canvas zoom
- Color independence — Do critical distinctions survive grayscale? Is color meaning consistent and limited?
- Zone label placement — Keep boundary titles as free-standing text at the top, not centered bound labels
- Reference fidelity — Does the result match the extracted style contract rather than generic palette defaults?
If any issue appears: stop, fix it, re-screenshot, then continue. The complete final gates are in references/quality-gates.md
Workflow: Drawing a New Diagram
Mermaid vs. Direct Creation — Which to Use?
Use mermaid / create_from_mermaid when: the user already has a Mermaid diagram, or the structure maps cleanly to a flowchart/sequence/ER diagram with standard Mermaid syntax. It's fast and handles conversion automatically, though you get less control over exact layout
Create elements directly when: you need precise layout control, the diagram type doesn't map to Mermaid well (e.g., custom architecture, annotated cloud diagrams), or you want elements positioned in a specific coordinate grid
Steps (CLI shown: MCP tools are 1:1 — see cheatsheet)
- Complete the design steps above.
references/quality-gates.mdgives the required detail - Plan the coordinate grid, panels, and main comparison, central relationship, or route before writing JSON. Identify endpoints for flows
- Only after the user approves discarding the current scene, or after a named snapshot under an approved replacement workflow, run
npx -y mcp-excalidraw-server clear --yes - Create only title/boundaries and primary nodes first. Use descriptive IDs. Screenshot and correct hierarchy/whitespace before arrows:
(Thenpx -y mcp-excalidraw-server add - <<'EOF' [ {"id": "lb", "type": "rectangle", "x": 300, "y": 50, "width": 180, "height": 60, "text": "Load Balancer"}, {"id": "svc-a", "type": "rectangle", "x": 100, "y": 200, "width": 160, "height": 60, "text": "Web Server 1"}, {"id": "svc-b", "type": "rectangle", "x": 450, "y": 200, "width": 160, "height": 60, "text": "Web Server 2"}, {"id": "db", "type": "rectangle", "x": 275, "y": 350, "width": 210, "height": 60, "text": "PostgreSQL"} ] EOF-positional is optional — with no file argument,addreads stdin) - Set shape widths using
max(160, labelLength * 12)and use the 20px body-text default - Add the primary semantic arrows in a second batch. Bind each arrow with
startElementIdandendElementIdscreenshot and trace the main relationships - Add optional branches and callouts one bounded cluster at a time. Screenshot after each cluster and stop when the one-sentence takeaway is complete
- Export the native scene. Resolve the skill directory from the loaded
SKILL.md, then run:
Exitpython /absolute/path/to/excalidraw-skill/scripts/audit_scene.py path/to/diagram.excalidraw --mode overview0is clean,1is blocked,2is invalid input, and3means review is required before acceptance - Export the intended PNG/SVG and complete native, 50%, 35%, grayscale, semantic, and blind visual reviews before reporting readiness
Arrow Routing — Avoid Overlaps
Straight arrows can cross through elements in complex diagrams. Use curved or elbowed arrows when needed:
Curved arrows (smooth arc over obstacles):
{
"type": "arrow", "x": 100, "y": 100,
"points": [[0, 0], [50, -40], [200, 0]],
"roundness": {"type": 2}
}
The intermediate waypoint [50, -40] lifts the arrow upward. roundness: {type: 2} makes it smooth
Elbowed arrows (right-angle / L-shaped routing):
{
"type": "arrow", "x": 100, "y": 100,
"points": [[0, 0], [0, -50], [200, -50], [200, 0]],
"elbowed": true
}
When to use which:
- Default semantic relationship: direct two-point arrow, bound at both ends
- Fan-out: slightly curved bound arrows only when spacing alone cannot separate them
- Cross-panel edge: one short explicit edge between adjacent boundaries
- Annotation pointer: may be unbound only when marked with
customData.auditRole = "annotation"
Rule: If an arrow would pass through an unrelated shape, move the elements first. If that cannot produce a local route, split or panelize the content. Waypoints are a last resort, not the primary layout mechanism
Workflow: Iterative Refinement
Use describe to inspect scene data and screenshot to inspect the rendered result:
describe(describe_scenein MCP) returns element IDs, types, positions, labels, and connections. Use it before programmatic updates to find IDs and understand bounding boxesscreenshot(get_canvas_screenshotin MCP) returns a PNG of the rendered canvas. Use it to check what the user sees, including truncation, overlap, and arrow routing. The CLI prints the saved file path as JSON read or view that file
Feedback loop:
add elements
→ screenshot → view → "text truncated on auth-svc"
→ update auth-svc --set '{"width": 220}' → screenshot → "overlap between auth-svc and rate-limiter"
→ update rate-limiter --set '{"x": 520}' → screenshot → "check the next cluster; final gates still remain"
→ continue to the next staged cluster; final gates still remain
Workflow: Refine an Existing Diagram
- Classify the change:
- Localized non-semantic: one move, resize, typo, or style correction that does not alter the final scene's story or topology
- Material: adds or removes nodes or routes, changes hierarchy, scope, or visual grammar, or prepares the final deliverable
- For a material change, repeat the applicable design steps and complete the native audit plus the target-size, 50%, 35%, grayscale, semantic, and blind visual reviews. Do not classify a redesign as a localized refinement
describeto understand current state — note element IDs and positions- Identify elements by
idor label text, not coordinates - Update, delete, or use one
applypatch. Bound arrows re-route when endpoints move do not replace a semantic edge with disconnected line pieces screenshotafter the local change. For material changes, use staged cluster screenshots and the complete final gates- If updates fail: check the ID exists with
get <id>unlock it if needed
Workflow: Mermaid Conversion
echo 'graph TD
A[Client] --> B[API]
B --> C[(DB)]' | npx -y mcp-excalidraw-server mermaid
Requires an open browser tab (conversion runs in the frontend
exit code 4 tells you to open the canvas URL). Afterwards screenshot to verify layout. If the auto-layout is poor (nodes crowded, edges crossing), find problem elements with describe and reposition them with update
Workflow: File I/O
- Export scene:
export --out diagram.excalidraw(no--out→ JSON to stdout) - Import scene:
import diagram.excalidraw(append) orimport diagram.excalidraw --replace - Image:
screenshot --out diagram.png/screenshot --format svg --out diagram.svg(browser tab required) - Share link:
share— encrypts the scene and returns a shareable excalidraw.com URL
This is how diagrams live in a repo: commit the .excalidraw file, and re-import + edit + export it when the architecture changes
Workflow: Snapshots
snapshot save <name>before risky changes- Make changes, evaluate with
describe/screenshot snapshot restore <name>to roll back if needed.snapshot listshows what's saved
Workflow: Duplication
arrange duplicate --ids a,b --offset 40,40 (default offset 20,20). Useful for repeated patterns or copying layouts
Error Recovery
- Exit code 3 (canvas unreachable)? Auto-start is disabled (
EXCALIDRAW_NO_AUTOSTART=1) or a non-loopbackEXPRESS_SERVER_URLis set. Runstartexplicitly or fix the env - Exit code 4 (browser required)? Open
http://127.0.0.1:3000in a browser, then retry — screenshots, image export, viewport, and mermaid conversion render in the frontend - Elements not appearing? Check
describe— they may be off-screen. In MCP mode,set_viewportwithscrollToContent: truein a browser, press the zoom-to-fit button - Arrow not connecting? Verify element IDs with
get <id>. Make surestartElementId/endElementIdmatch existing element IDs - Canvas in a bad state? Prefer
snapshot restorewhen a suitable snapshot exists. Otherwise, save a named snapshot and obtain approval to discard the current scene beforeclear --yesand rebuild - Element won't update? It may be locked —
arrange unlock --ids <id>first - Duplicate text elements / element count doubling? The frontend auto-sync timer periodically writes the full Excalidraw scene back to the server. Excalidraw internally generates a bound text element for every shape with a label
clearing and re-sending elements can re-inject cached bound texts. Clean up:
query --type textto find elements with acontainerId,deletethe unwanted ones, wait a few seconds for auto-sync to settle. To prevent this, follow the background-zone labeling rule above
References
references/change-explanations.md: before/after composition, core and supporting concerns, local rationale, and text-only planningreferences/orestes-clean-style.md: default visual grammar and reference-matching rulesreferences/quality-gates.md: intake, semantic reduction, complexity budgets, staged construction, target-scale/grayscale, and adversarial review gatesreferences/cheatsheet.md: full CLI reference, MCP tools, REST API endpoints, payload shapes, and fallback colors/sizingscripts/audit_scene.py: deterministic native-scene structural audit:- use visual review in addition to it
04 同仓库更多 Skills
vals-memory
暂无简介
skill-authoring
Write or revise reusable skill instructions. Use when defining a skill's activation boundary, workflow, constraints, examples, or instructional prose. Do not use for runtime configuration or placement
session-analysis
Use to analyze past sessions, reconstruct what happened, identify errors and unresolved work, or extract user preferences and workflow friction that could improve agent configuration
semantic-git
Use for structural Git analysis such as changed functions, semantic diffs, impact analysis, and blame
review
Use for independent review of nontrivial implementation proposals before approval and nontrivial implementations before final evidence; also use for explicit code, plan, feedback, pull-request, issue, or deep code-quality, structural, or simplification review
pr-slack-post
Draft a short Slack message that posts a pull request for review. Use when asked to write, craft, or suggest a Slack message or post for one or more PRs