Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Generate Excalidraw .excalidraw JSON diagram files from natural language descriptions of processes and systems.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: excalidraw-diagram-generator3description: 'Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.'4---56# Excalidraw Diagram Generator78A skill for generating Excalidraw-format diagrams from natural language descriptions. This skill helps create visual representations of processes, systems, relationships, and ideas without manual drawing.910## When to Use This Skill1112Use this skill when users request:1314- "Create a diagram showing..."15- "Make a flowchart for..."16- "Visualize the process of..."17- "Draw the system architecture of..."18- "Generate a mind map about..."19- "Create an Excalidraw file for..."20- "Show the relationship between..."21- "Diagram the workflow of..."2223**Supported diagram types:**24- 📊 **Flowcharts**: Sequential processes, workflows, decision trees25- 🔗 **Relationship Diagrams**: Entity relationships, system components, dependencies26- 🧠 **Mind Maps**: Concept hierarchies, brainstorming results, topic organization27- 🏗️ **Architecture Diagrams**: System design, module interactions, data flow28- 📈 **Data Flow Diagrams (DFD)**: Data flow visualization, data transformation processes29- 🏊 **Business Flow (Swimlane)**: Cross-functional workflows, actor-based process flows30- 📦 **Class Diagrams**: Object-oriented design, class structures and relationships31- 🔄 **Sequence Diagrams**: Object interactions over time, message flows32- 🗃️ **ER Diagrams**: Database entity relationships, data models3334## Prerequisites3536- Clear description of what should be visualized37- Identification of key entities, steps, or concepts38- Understanding of relationships or flow between elements3940## Step-by-Step Workflow4142### Step 1: Understand the Request4344Analyze the user's description to determine:451. **Diagram type** (flowchart, relationship, mind map, architecture)462. **Key elements** (entities, steps, concepts)473. **Relationships** (flow, connections, hierarchy)484. **Complexity** (number of elements)4950### Step 2: Choose the Appropriate Diagram Type5152| User Intent | Diagram Type | Example Keywords |53|-------------|--------------|------------------|54| Process flow, steps, procedures | **Flowchart** | "workflow", "process", "steps", "procedure" |55| Connections, dependencies, associations | **Relationship Diagram** | "relationship", "connections", "dependencies", "structure" |56| Concept hierarchy, brainstorming | **Mind Map** | "mind map", "concepts", "ideas", "breakdown" |57| System design, components | **Architecture Diagram** | "architecture", "system", "components", "modules" |58| Data flow, transformation processes | **Data Flow Diagram (DFD)** | "data flow", "data processing", "data transformation" |59| Cross-functional processes, actor responsibilities | **Business Flow (Swimlane)** | "business process", "swimlane", "actors", "responsibilities" |60| Object-oriented design, class structures | **Class Diagram** | "class", "inheritance", "OOP", "object model" |61| Interaction sequences, message flows | **Sequence Diagram** | "sequence", "interaction", "messages", "timeline" |62| Database design, entity relationships | **ER Diagram** | "database", "entity", "relationship", "data model" |6364### Step 3: Extract Structured Information6566**For Flowcharts:**67- List of sequential steps68- Decision points (if any)69- Start and end points7071**For Relationship Diagrams:**72- Entities/nodes (name + optional description)73- Relationships between entities (from → to, with label)7475**For Mind Maps:**76- Central topic77- Main branches (3-6 recommended)78- Sub-topics for each branch (optional)7980**For Data Flow Diagrams (DFD):**81- Data sources and destinations (external entities)82- Processes (data transformations)83- Data stores (databases, files)84- Data flows (arrows showing data movement from left-to-right or from top-left to bottom-right)85- **Important**: Do not represent process order, only data flow8687**For Business Flow (Swimlane):**88- Actors/roles (departments, systems, people) - displayed as header columns89- Process lanes (vertical lanes under each actor)90- Process boxes (activities within each lane)91- Flow arrows (connecting process boxes, including cross-lane handoffs)9293**For Class Diagrams:**94- Classes with names95- Attributes with visibility (+, -, #)96- Methods with visibility and parameters97- Relationships: inheritance (solid line + white triangle), implementation (dashed line + white triangle), association (solid line), dependency (dashed line), aggregation (solid line + white diamond), composition (solid line + filled diamond)98- Multiplicity notations (1, 0..1, 1..*, *)99100**For Sequence Diagrams:**101- Objects/actors (arranged horizontally at top)102- Lifelines (vertical lines from each object)103- Messages (horizontal arrows between lifelines)104- Synchronous messages (solid arrow), asynchronous messages (dashed arrow)105- Return values (dashed arrows)106- Activation boxes (rectangles on lifelines during execution)107- Time flows from top to bottom108109**For ER Diagrams:**110- Entities (rectangles with entity names)111- Attributes (listed inside entities)112- Primary keys (underlined or marked with PK)113- Foreign keys (marked with FK)114- Relationships (lines connecting entities)115- Cardinality: 1:1 (one-to-one), 1:N (one-to-many), N:M (many-to-many)116- Junction/associative entities for many-to-many relationships (dashed rectangles)117118### Step 4: Generate the Excalidraw JSON119120Create the `.excalidraw` file with appropriate elements:121122**Available element types:**123- `rectangle`: Boxes for entities, steps, concepts124- `ellipse`: Alternative shapes for emphasis125- `diamond`: Decision points126- `arrow`: Directional connections127- `text`: Labels and annotations128129**Key properties to set:**130- **Position**: `x`, `y` coordinates131- **Size**: `width`, `height`132- **Style**: `strokeColor`, `backgroundColor`, `fillStyle`133- **Font**: `fontFamily: 5` (Excalifont - **required for all text elements**)134- **Text**: Embedded text for labels135- **Connections**: `points` array for arrows136137**Important**: All text elements must use `fontFamily: 5` (Excalifont) for consistent visual appearance.138139### Step 5: Format the Output140141Structure the complete Excalidraw file:142143```json144{145"type": "excalidraw",146"version": 2,147"source": "https://excalidraw.com",148"elements": [149// Array of diagram elements150],151"appState": {152"viewBackgroundColor": "#ffffff",153"gridSize": 20154},155"files": {}156}157```158159### Step 6: Save and Provide Instructions1601611. Save as `<descriptive-name>.excalidraw`1622. Inform user how to open:163- Visit https://excalidraw.com164- Click "Open" or drag-and-drop the file165- Or use Excalidraw VS Code extension166167## Best Practices168169### Element Count Guidelines170171| Diagram Type | Recommended Count | Maximum |172|--------------|-------------------|---------|173| Flowchart steps | 3-10 | 15 |174| Relationship entities | 3-8 | 12 |175| Mind map branches | 4-6 | 8 |176| Mind map sub-topics per branch | 2-4 | 6 |177178### Layout Tips1791801. **Start positions**: Center important elements, use consistent spacing1812. **Spacing**:182- Horizontal gap: 200-300px between elements183- Vertical gap: 100-150px between rows1843. **Colors**: Use consistent color scheme185- Primary elements: Light blue (`#a5d8ff`)186- Secondary elements: Light green (`#b2f2bb`)187- Important/Central: Yellow (`#ffd43b`)188- Alerts/Warnings: Light red (`#ffc9c9`)1894. **Text sizing**: 16-24px for readability1905. **Font**: Always use `fontFamily: 5` (Excalifont) for all text elements1916. **Arrow style**: Use straight arrows for simple flows, curved for complex relationships192193### Complexity Management194195**If user request has too many elements:**196- Suggest breaking into multiple diagrams197- Focus on main elements first198- Offer to create detailed sub-diagrams199200**Example response:**201```202"Your request includes 15 components. For clarity, I recommend:2031. High-level architecture diagram (6 main components)2042. Detailed diagram for each subsystem205206Would you like me to start with the high-level view?"207```208209## Example Prompts and Responses210211### Example 1: Simple Flowchart212213**User:** "Create a flowchart for user registration"214215**Agent generates:**2161. Extract steps: "Enter email" → "Verify email" → "Set password" → "Complete"2172. Create flowchart with 4 rectangles + 3 arrows2183. Save as `user-registration-flow.excalidraw`219220### Example 2: Relationship Diagram221222**User:** "Diagram the relationship between User, Post, and Comment entities"223224**Agent generates:**2251. Entities: User, Post, Comment2262. Relationships: User → Post ("creates"), User → Comment ("writes"), Post → Comment ("contains")2273. Save as `user-content-relationships.excalidraw`228229### Example 3: Mind Map230231**User:** "Mind map about machine learning concepts"232233**Agent generates:**2341. Center: "Machine Learning"2352. Branches: Supervised Learning, Unsupervised Learning, Reinforcement Learning, Deep Learning2363. Sub-topics under each branch2374. Save as `machine-learning-mindmap.excalidraw`238239## Troubleshooting240241| Issue | Solution |242|-------|----------|243| Elements overlap | Increase spacing between coordinates |244| Text doesn't fit in boxes | Increase box width or reduce font size |245| Too many elements | Break into multiple diagrams |246| Unclear layout | Use grid layout (rows/columns) or radial layout (mind maps) |247| Colors inconsistent | Define color palette upfront based on element types |248249## Advanced Techniques250251### Grid Layout (for Relationship Diagrams)252```javascript253const columns = Math.ceil(Math.sqrt(entityCount));254const x = startX + (index % columns) * horizontalGap;255const y = startY + Math.floor(index / columns) * verticalGap;256```257258### Radial Layout (for Mind Maps)259```javascript260const angle = (2 * Math.PI * index) / branchCount;261const x = centerX + radius * Math.cos(angle);262const y = centerY + radius * Math.sin(angle);263```264265### Auto-generated IDs266Use timestamp + random string for unique IDs:267```javascript268const id = Date.now().toString(36) + Math.random().toString(36).substr(2);269```270271## Output Format272273Always provide:2741. ✅ Complete `.excalidraw` JSON file2752. 📊 Summary of what was created2763. 📝 Element count2774. 💡 Instructions for opening/editing278279**Example summary:**280```281Created: user-workflow.excalidraw282Type: Flowchart283Elements: 7 rectangles, 6 arrows, 1 title text284Total: 14 elements285286To view:2871. Visit https://excalidraw.com2882. Drag and drop user-workflow.excalidraw2893. Or use File → Open in Excalidraw VS Code extension290```291292## Validation Checklist293294Before delivering the diagram:295- [ ] All elements have unique IDs296- [ ] Coordinates prevent overlapping297- [ ] Text is readable (font size 16+)298- [ ] **All text elements use `fontFamily: 5` (Excalifont)**299- [ ] Arrows connect logically300- [ ] Colors follow consistent scheme301- [ ] File is valid JSON302- [ ] Element count is reasonable (<20 for clarity)303304## Icon Libraries (Optional Enhancement)305306For specialized diagrams (e.g., AWS/GCP/Azure architecture diagrams), you can use pre-made icon libraries from Excalidraw. This provides professional, standardized icons instead of basic shapes.307308### When User Requests Icons309310**If user asks for AWS/cloud architecture diagrams or mentions wanting to use specific icons:**3113121. **Check if library exists**: Look for `libraries/<library-name>/reference.md`3132. **If library exists**: Proceed to use icons (see AI Assistant Workflow below)3143. **If library does NOT exist**: Respond with setup instructions:315316```317To use [AWS/GCP/Azure/etc.] architecture icons, please follow these steps:3183191. Visit https://libraries.excalidraw.com/3202. Search for "[AWS Architecture Icons/etc.]" and download the .excalidrawlib file3213. Create directory: skills/excalidraw-diagram-generator/libraries/[icon-set-name]/3224. Place the downloaded file in that directory3235. Run the splitter script:324python skills/excalidraw-diagram-generator/scripts/split-excalidraw-library.py skills/excalidraw-diagram-generator/libraries/[icon-set-name]/325326This will split the library into individual icon files for efficient use.327After setup is complete, I can create your diagram using the actual AWS/cloud icons.328329Alternatively, I can create the diagram now using simple shapes (rectangles, ellipses)330which you can later replace with icons manually in Excalidraw.331```332333### User Setup Instructions (Detailed)334335**Step 1: Create Library Directory**336```bash337mkdir -p skills/excalidraw-diagram-generator/libraries/aws-architecture-icons338```339340**Step 2: Download Library**341- Visit: https://libraries.excalidraw.com/342- Search for your desired icon set (e.g., "AWS Architecture Icons")343- Click download to get the `.excalidrawlib` file344- Example categories (availability varies; confirm on the site):345- Cloud service icons346- UI/Material icons347- Flowchart symbols348349**Step 3: Place Library File**350- Rename the downloaded file to match the directory name (e.g., `aws-architecture-icons.excalidrawlib`)351- Move it to the directory created in Step 1352353**Step 4: Run Splitter Script**354```bash355python skills/excalidraw-diagram-generator/scripts/split-excalidraw-library.py skills/excalidraw-diagram-generator/libraries/aws-architecture-icons/356```357358**Step 5: Verify Setup**359After running the script, verify the following structure exists:360```361skills/excalidraw-diagram-generator/libraries/aws-architecture-icons/362aws-architecture-icons.excalidrawlib (original)363reference.md (generated - icon lookup table)364icons/ (generated - individual icon files)365API-Gateway.json366CloudFront.json367EC2.json368Lambda.json369RDS.json370S3.json371...372```373374### AI Assistant Workflow375376**When icon libraries are available in `libraries/`:**377378**RECOMMENDED APPROACH: Use Python Scripts (Efficient & Reliable)**379380The repository includes Python scripts that handle icon integration automatically:3813821. **Create base diagram structure**:383- Create `.excalidraw` file with basic layout (title, boxes, regions)384- This establishes the canvas and overall structure3853862. **Add icons using Python script**:387```bash388python skills/excalidraw-diagram-generator/scripts/add-icon-to-diagram.py \389<diagram-path> <icon-name> <x> <y> [--label "Text"] [--library-path PATH]390```391- Edit via `.excalidraw.edit` is enabled by default to avoid overwrite issues; pass `--no-use-edit-suffix` to disable.392393**Examples**:394```bash395# Add EC2 icon at position (400, 300) with label396python scripts/add-icon-to-diagram.py diagram.excalidraw EC2 400 300 --label "Web Server"397398# Add VPC icon at position (200, 150)399python scripts/add-icon-to-diagram.py diagram.excalidraw VPC 200 150400401# Add icon from different library402python scripts/add-icon-to-diagram.py diagram.excalidraw Compute-Engine 500 200 \403--library-path libraries/gcp-icons --label "API Server"404```4054063. **Add connecting arrows**:407```bash408python skills/excalidraw-diagram-generator/scripts/add-arrow.py \409<diagram-path> <from-x> <from-y> <to-x> <to-y> [--label "Text"] [--style solid|dashed|dotted] [--color HEX]410```411- Edit via `.excalidraw.edit` is enabled by default to avoid overwrite issues; pass `--no-use-edit-suffix` to disable.412413**Examples**:414```bash415# Simple arrow from (300, 250) to (500, 300)416python scripts/add-arrow.py diagram.excalidraw 300 250 500 300417418# Arrow with label419python scripts/add-arrow.py diagram.excalidraw 300 250 500 300 --label "HTTPS"420421# Dashed arrow with custom color422python scripts/add-arrow.py diagram.excalidraw 400 350 600 400 --style dashed --color "#7950f2"423```4244254. **Workflow summary**:426```bash427# Step 1: Create base diagram with title and structure428# (Create .excalidraw file with initial elements)429430# Step 2: Add icons with labels431python scripts/add-icon-to-diagram.py my-diagram.excalidraw "Internet-gateway" 200 150 --label "Internet Gateway"432python scripts/add-icon-to-diagram.py my-diagram.excalidraw VPC 250 250433python scripts/add-icon-to-diagram.py my-diagram.excalidraw ELB 350 300 --label "Load Balancer"434python scripts/add-icon-to-diagram.py my-diagram.excalidraw EC2 450 350 --label "EC2 Instance"435python scripts/add-icon-to-diagram.py my-diagram.excalidraw RDS 550 400 --label "Database"436437# Step 3: Add connecting arrows438python scripts/add-arrow.py my-diagram.excalidraw 250 200 300 250 # Internet → VPC439python scripts/add-arrow.py my-diagram.excalidraw 300 300 400 300 # VPC → ELB440python scripts/add-arrow.py my-diagram.excalidraw 400 330 500 350 # ELB → EC2441python scripts/add-arrow.py my-diagram.excalidraw 500 380 600 400 # EC2 → RDS442```443444**Benefits of Python Script Approach**:445- ✅ **No token consumption**: Icon JSON data (200-1000 lines each) never enters AI context446- ✅ **Accurate transformations**: Coordinate calculations handled deterministically447- ✅ **ID management**: Automatic UUID generation prevents conflicts448- ✅ **Reliable**: No risk of coordinate miscalculation or ID collision449- ✅ **Fast**: Direct file manipulation, no parsing overhead450- ✅ **Reusable**: Works with any Excalidraw library you provide451452**ALTERNATIVE: Manual Icon Integration (Not Recommended)**453454Only use this if Python scripts are unavailable:4554561. **Check for libraries**:457```458List directory: skills/excalidraw-diagram-generator/libraries/459Look for subdirectories containing reference.md files460```4614622. **Read reference.md**:463```464Open: libraries/<library-name>/reference.md465This is lightweight (typically <300 lines) and lists all available icons466```4674683. **Find relevant icons**:469```470Search the reference.md table for icon names matching diagram needs471Example: For AWS diagram with EC2, S3, Lambda → Find "EC2", "S3", "Lambda" in table472```4734744. **Load specific icon data** (WARNING: Large files):475```476Read ONLY the needed icon files:477- libraries/aws-architecture-icons/icons/EC2.json (200-300 lines)478- libraries/aws-architecture-icons/icons/S3.json (200-300 lines)479- libraries/aws-architecture-icons/icons/Lambda.json (200-300 lines)480Note: Each icon file is 200-1000 lines - this consumes significant tokens481```4824835. **Extract and transform elements**:484```485Each icon JSON contains an "elements" array486Calculate bounding box (min_x, min_y, max_x, max_y)487Apply offset to all x/y coordinates488Generate new unique IDs for all elements489Update groupIds references490Copy transformed elements into your diagram491```4924936. **Position icons and add connections**:494```495Adjust x/y coordinates to position icons correctly in the diagram496Update IDs to ensure uniqueness across diagram497Add connecting arrows and labels as needed498```499500**Manual Integration Challenges**:501- ⚠️ High token consumption (200-1000 lines per icon × number of icons)502- ⚠️ Complex coordinate transformation calculations503- ⚠️ Risk of ID collision if not handled carefully504- ⚠️ Time-consuming for diagrams with many icons505506### Example: Creating AWS Diagram with Icons507508**Request**: "Create an AWS architecture diagram with Internet Gateway, VPC, ELB, EC2, and RDS"509510**Recommended Workflow (using Python scripts)**:511**Request**: "Create an AWS architecture diagram with Internet Gateway, VPC, ELB, EC2, and RDS"512513**Recommended Workflow (using Python scripts)**:514515```bash516# Step 1: Create base diagram file with title517# Create my-aws-diagram.excalidraw with basic structure (title, etc.)518519# Step 2: Check icon availability520# Read: libraries/aws-architecture-icons/reference.md521# Confirm icons exist: Internet-gateway, VPC, ELB, EC2, RDS522523# Step 3: Add icons with Python script524python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw "Internet-gateway" 150 100 --label "Internet Gateway"525python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw VPC 200 200526python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw ELB 350 250 --label "Load Balancer"527python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw EC2 500 300 --label "Web Server"528python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw RDS 650 350 --label "Database"529530# Step 4: Add connecting arrows531python scripts/add-arrow.py my-aws-diagram.excalidraw 200 150 250 200 # Internet → VPC532python scripts/add-arrow.py my-aws-diagram.excalidraw 265 230 350 250 # VPC → ELB533python scripts/add-arrow.py my-aws-diagram.excalidraw 415 280 500 300 # ELB → EC2534python scripts/add-arrow.py my-aws-diagram.excalidraw 565 330 650 350 --label "SQL" --style dashed535536# Result: Complete diagram with professional AWS icons, labels, and connections537```538539**Benefits**:540- No manual coordinate calculation541- No token consumption for icon data542- Deterministic, reliable results543- Easy to iterate and adjust positions544545**Alternative Workflow (manual, if scripts unavailable)**:5461. Check: `libraries/aws-architecture-icons/reference.md` exists → Yes5472. Read reference.md → Find entries for Internet-gateway, VPC, ELB, EC2, RDS5483. Load:549- `icons/Internet-gateway.json` (298 lines)550- `icons/VPC.json` (550 lines)551- `icons/ELB.json` (363 lines)552- `icons/EC2.json` (231 lines)553- `icons/RDS.json` (similar size)554**Total: ~2000+ lines of JSON to process**5554. Extract elements from each JSON5565. Calculate bounding boxes and offsets for each icon5576. Transform all coordinates (x, y) for positioning5587. Generate unique IDs for all elements5598. Add arrows showing data flow5609. Add text labels56110. Generate final `.excalidraw` file562563**Challenges with manual approach**:564- High token consumption (~2000-5000 lines)565- Complex coordinate math566- Risk of ID conflicts567568### Supported Icon Libraries (Examples — verify availability)569570- This workflow works with any valid `.excalidrawlib` file you provide.571- Examples of library categories you may find on https://libraries.excalidraw.com/:572- Cloud service icons573- Kubernetes / infrastructure icons574- UI / Material icons575- Flowchart / diagram symbols576- Network diagram icons577- Availability and naming can change; verify exact library names on the site before use.578579### Fallback: No Icons Available580581**If no icon libraries are set up:**582- Create diagrams using basic shapes (rectangles, ellipses, arrows)583- Use color coding and text labels to distinguish components584- Inform user they can add icons later or set up libraries for future diagrams585- The diagram will still be functional and clear, just less visually polished586587## References588589See bundled references for:590- `references/excalidraw-schema.md` - Complete Excalidraw JSON schema591- `references/element-types.md` - Detailed element type specifications592- `templates/flowchart-template.json` - Basic flowchart starter593- `templates/relationship-template.json` - Relationship diagram starter594- `templates/mindmap-template.json` - Mind map starter595- `scripts/split-excalidraw-library.py` - Tool to split `.excalidrawlib` files596- `scripts/README.md` - Documentation for library tools597- `scripts/.gitignore` - Prevents local Python artifacts from being committed598599## Limitations600601- Complex curves are simplified to straight/basic curved lines602- Hand-drawn roughness is set to default (1)603- No embedded images support in auto-generation604- Maximum recommended elements: 20 per diagram605- No automatic collision detection (use spacing guidelines)606607## Future Enhancements608609Potential improvements:610- Auto-layout optimization algorithms611- Import from Mermaid/PlantUML syntax612- Template library expansion613- Interactive editing after generation614