excalidraw-diagrams
Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
Use when asked to create or update Excalidraw diagrams. Provides guidance on Excalidraw best practices.
16installs
Sourcesammcj/agentic-coding
Added on
NPX Install
npx skill4agent add sammcj/agentic-coding excalidraw-diagramsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Creating Excalidraw Diagrams
When creating Excalidraw diagrams, ensure you:
- Generate the layout with correct spacing
- Make consistent and logical use of colours, fonts, and shapes
- Text is correctly added within shapes, not as separate text elements (unless desired)
- Arrows and lines are correctly anchored / connected to shapes (not floating) so that when objects are moved any connections remain intact
- You save the Excalidraw diagram content to a file and link the file path
- Call before your first
read_mecall each session - it provides the colour palette, camera sizes, layout rules, and element format reference.create_view - If the user has asked you to create Excalidraw diagrams but you do not have the Excalidraw MCP enabled, you should ask them to add it for you, they can configured it by using the HTTP MCP URL of: https://excalidraw-mcp-app.vercel.app/mcp and they can view the MCP documentation here: https://github.com/excalidraw/excalidraw-mcp
Choose your workflow
Pick one based on what the user needs. Do not default to doing both.
Inline preview only (create_view
)
create_viewUse when the diagram is for the conversation only - the user wants to see it in the chat and does not need a file.
- Use with
create_viewon shapes (works fine here)label - Use to animate and guide attention
cameraUpdate - No file output needed
File output only (Python script)
Use when the user needs a file to open, share, edit, or keep. Skip entirely.
.excalidrawcreate_view- Generate the file with (see below)
scripts/generate_excalidraw.py - Provide the file path to the user
- Files can be opened by dragging into excalidraw.com, the Excalidraw desktop app, or VS Code with the Excalidraw extension
Both (inline preview + file)
Use when the user wants to see the diagram in the chat AND keep a file. Note: these are built independently with different element formats. There is no data bridge between them - you define the diagram structure once conceptually but render it twice.
- with
create_viewfor the inline previewlabel - Python script with for the
labeled_rectfile.excalidraw
Critical: text does not survive export
The property on shapes is a convenience only. It does NOT work in:
labelcreate_view- uploads (shapes render, text is invisible)
export_to_excalidraw - files written from
.excalidrawcheckpoint datacreate_view
Do NOT use for shareable diagrams. It seems to have a bug that can silently drop all text.
export_to_excalidrawNative Excalidraw represents text inside shapes as two linked elements:
- Shape:
"boundElements": [{"id": "text-id", "type": "text"}] - Text: ,
"containerId": "shape-id","textAlign": "center""verticalAlign": "middle"
The text element requires fields the shorthand omits: (1), , , , (1.25), (true).
labelfontFamilywidthheightoriginalTextlineHeightautoResizeAll elements in .excalidraw files also need: , , , , , , , , , .
angleseedversionversionNonceisDeletedgroupIdsframeIdupdatedlinklockedHand-writing this JSON is error-prone. Use the Python script instead.
Python script: scripts/generate_excalidraw.py
scripts/generate_excalidraw.pyGenerates native .excalidraw files with all required fields. Can be used inline in a bash heredoc or imported as a library.
Key functions:
| Function | Returns | Purpose |
|---|---|---|
| | Shape with centred bound text (handles all binding and field generation) |
| element | Rectangle without text |
| element | Standalone or bound text |
| element | Arrow anchored to two shapes (mutates shapes' boundElements) |
| element | Unbound/floating arrow (use |
| element | Other shape types |
| writes file | Wraps in scene structure and saves |
Example:
bash
python3 << 'PYEOF'
import sys, random
sys.path.insert(0, "/Users/samm/.claude/skills/excalidraw-diagrams/scripts")
from generate_excalidraw import *
random.seed(42)
elements = []
elements.append(txt("t1", 200, 10, 300, 30, "My Diagram", 24))
elements.extend(labeled_rect("a", 50, 60, 200, 70, "#a5d8ff", "#4a9eed", "Step One"))
elements.extend(labeled_rect("b", 350, 60, 200, 70, "#b2f2bb", "#22c55e", "Step Two"))
elements.append(bound_arrow("a1", elements, "a", [1, 0.5], "b", [0, 0.5]))
write_scene(elements, "/path/to/output.excalidraw")
PYEOFFor shapes without the convenience, pair with .
labeled_rectrect(..., bound_text="tid")txt(..., container="rid", align="center", valign="middle")Arrow anchoring
By default, arrows float free - moving a shape leaves the arrow behind. Use instead of to anchor arrows to shapes. It handles the bidirectional binding automatically (arrow references shapes, shapes list the arrow in ).
bound_arrowarrowboundElementsfixedPoint[0.5, 0][1, 0.5][0.5, 1][0, 0.5][fx, fy]Important:
- Shapes must already exist in before calling
elements, since it looks them up and mutates theirbound_arrow.boundElements - Minimum 60px between connected shapes. Excalidraw recalculates bound arrow geometry at render time. When shapes are too close together (under ~60px gap), arrows overlap and pass through boxes instead of connecting at edges. The script warns if this threshold is violated. Plan layouts with adequate spacing.
- Avoid large background rectangles that overlap connectable shapes. Excalidraw's binding resolution can misfire when a bound arrow's endpoint falls inside a background rect that overlaps the intended target shape. If you need section backgrounds, add them after all bound arrows, or use standalone text labels and colour-coded boxes instead.
For the inline workflow, use / with directly on arrow elements.
create_viewstartBindingendBindingfixedPointPrivacy
Note that if the diagram contains potentially sensitive information (e.g. detailed network diagrams, identifiable information etc...) and the user asks you to upload the diagram to excalidraw.com - you should first warn them that this will make the diagram publicly accessible and ask if they want to proceed.