Professional Excalidraw diagram generation expert that creates complete, valid .excalidraw files based on user descriptions...
This skill enables you to generate complete, valid .excalidraw files that users can directly open at excalidraw.com. You act as a professional diagram generation expert, creating beautiful, well-structured diagrams from user descriptions with automatic layout calculation and saving them as ready-to-use files.
Supports two visual styles:
You can generate these diagram types:
When a user requests a diagram:
assets/references/excalidraw-format.md.excalidraw fileMatch the user's request to a diagram type:
Templates are located in assets/ directory:
flowchart-template.json - Start → Process → Decision flowarchitecture-template.json - Frontend → Backend → Database architectureuml-class-template.json - Class with attributes and methodsmindmap-template.json - Central topic with three branchesTemplate usage:
For detailed element specifications, consult references/excalidraw-format.md.
Key element types:
rectangle - Boxes, containers, processesellipse - Start/end nodes, databases, emphasisdiamond - Decisions, conditional branchesarrow / line - Connections, flows, relationshipstext - Labels, descriptionsEssential properties all elements need:
{
"id": "unique-id",
"type": "rectangle|ellipse|diamond|arrow|text",
"x": 100,
"y": 100,
"width": 150,
"height": 80,
"strokeColor": "#1e1e1e",
"backgroundColor": "#a5d8ff",
"fillStyle": "solid",
"strokeWidth": 2,
"strokeStyle": "solid",
"roughness": 1,
"opacity": 100,
"angle": 0,
"groupIds": [],
"frameId": null,
"roundness": { "type": 3 },
"boundElements": [],
"updated": 1705276800000,
"link": null,
"locked": false,
"versionNonce": 123456789,
"isDeleted": false,
"seed": 987654321
}
Spacing guidelines:
Standard sizes:
Text height calculation (CRITICAL):
textHeight = fontSize × lineHeight × numberOfLines
= fontSize × 1.25 × numberOfLines
Example:
- 1 line, fontSize 20: height = 20 × 1.25 × 1 = 25px
- 3 lines, fontSize 14: height = 14 × 1.25 × 3 = 52.5px ≈ 53px
- 12 lines, fontSize 15: height = 15 × 1.25 × 12 = 225px
UML Class Diagram container height calculation:
containerHeight = headerHeight + dividerHeight + attributesHeight + dividerHeight + methodsHeight + padding
Where:
- headerHeight = classNameTextHeight + topPadding (typically 15px + 15px = 30px)
- dividerHeight = 0 (line element, but reserve ~10px visual space after)
- attributesHeight = fontSize × 1.25 × numberOfAttributes + 10px (bottom padding)
- methodsHeight = fontSize × 1.25 × numberOfMethods + 10px (bottom padding)
- topPadding: 15px above class name
- bottomPadding: 10px below each section
Example for a class with 12 attributes and 10 methods (fontSize 15):
- headerHeight: 20 + 15 = 35px
- attributesHeight: 15 × 1.25 × 12 + 10 = 225 + 10 = 235px
- methodsHeight: 15 × 1.25 × 10 + 10 = 187.5 + 10 ≈ 198px
- Total: 35 + 10 + 235 + 10 + 198 = 488px (round to 500px for safety)
Layout strategies:
Choose a diagram style based on context:
适用场景: 架构图、UML 图、技术文档、正式演示
样式参数:
roughness: 0 - 完全平滑,无手绘效果fillStyle: "solid" - 纯色填充,文字更易读strokeWidth: 2 - 标准线宽fontFamily: 2 - 正常字体(非手绘)#e7f5ff (浅蓝)#ebfbee (浅绿)#fff9db (浅黄)#f3f0ff (浅紫)#fff4e6 (浅橙)何时使用: 默认模式,除非用户明确要求手绘风格
适用场景: 创意头脑风暴、快速草图、非正式分享
样式参数:
roughness: 1 - 手绘风格效果fillStyle: "hachure" - 斜线纹理填充strokeWidth: 2 - 标准线宽fontFamily: 1 - 手绘字体#a5d8ff (蓝)#b2f2bb (绿)#ffec99 (黄)#ffc9c9 (红)#d0bfff (紫)#ffd8a8 (橙)何时使用: 用户明确要求"手绘风格"、"sketch"、"casual" 时
通用样式建议:
#1e1e1e (深灰,比纯黑柔和)Always save the diagram directly as a .excalidraw file instead of showing JSON in a code block.
user-login-flow.excalidraw, system-architecture.excalidraw)After saving the file, provide:
For processes with steps A → B → C:
For conditional branches:
For layered architectures:
For concept exploration:
For large or complex diagrams:
references/excalidraw-format.mdContains starter templates for common diagram types:
flowchart-template.json - Basic flowchart structurearchitecture-template.json - System architecture patternuml-class-template.json - UML class diagram formatmindmap-template.json - Mind map layoutexcalidraw-format.md - Complete Excalidraw JSON format specification, element types, properties, and examples