Excalidraw diagram generator

From mouadja02/skills · View interactive version

Excalidraw diagram generator is an AI agent skill from the GitHub repository mouadja02/skills. 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 arc

How to use this skill

Skill file

Attribution: Sourced from github/awesome-copilot by GitHub Community, licensed MIT. Modified for this collection.

Excalidraw Diagram Generator

A 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.

When to Use This Skill

Use this skill when users request:

Supported diagram types:

Prerequisites

Step-by-Step Workflow

Step 1: Understand the Request

Analyze the user's description to determine:

  1. Diagram type (flowchart, relationship, mind map, architecture)
  2. Key elements (entities, steps, concepts)
  3. Relationships (flow, connections, hierarchy)
  4. Complexity (number of elements)

Step 2: Choose the Appropriate Diagram Type

| User Intent | Diagram Type | Example Keywords |

|-------------|--------------|------------------|

| Process flow, steps, procedures | Flowchart | "workflow", "process", "steps", "procedure" |

| Connections, dependencies, associations | Relationship Diagram | "relationship", "connections", "dependencies", "structure" |

| Concept hierarchy, brainstorming | Mind Map | "mind map", "concepts", "ideas", "breakdown" |

| System design, components | Architecture Diagram | "architecture", "system", "components", "modules" |

| Data flow, transformation processes | Data Flow Diagram (DFD) | "data flow", "data processing", "data transformation" |

| Cross-functional processes, actor responsibilities | Business Flow (Swimlane) | "business process", "swimlane", "actors", "responsibilities" |

| Object-oriented design, class structures | Class Diagram | "class", "inheritance", "OOP", "object model" |

| Interaction sequences, message flows | Sequence Diagram | "sequence", "interaction", "messages", "timeline" |

| Database design, entity relationships | ER Diagram | "database", "entity", "relationship", "data model" |

Step 3: Extract Structured Information

For Flowcharts:

For Relationship Diagrams:

For Mind Maps:

For Data Flow Diagrams (DFD):

For Business Flow (Swimlane):

For Class Diagrams:

For Sequence Diagrams:

For ER Diagrams:

Step 4: Generate the Excalidraw JSON

Create the .excalidraw file with appropriate elements:

Available element types:

Key properties to set:

Important: All text elements must use fontFamily: 5 (Excalifont) for consistent visual appearance.

Step 5: Format the Output

Structure the complete Excalidraw file:

{
  "type": "excalidraw",
  "version": 2,
  "source": "https://excalidraw.com",
  "elements": [
    // Array of diagram elements
  ],
  "appState": {
    "viewBackgroundColor": "#ffffff",
    "gridSize": 20
  },
  "files": {}
}

Step 6: Save and Provide Instructions

  1. Save as <descriptive-name>.excalidraw
  2. Inform user how to open:

Best Practices

Element Count Guidelines

| Diagram Type | Recommended Count | Maximum |

|--------------|-------------------|---------|

| Flowchart steps | 3-10 | 15 |

| Relationship entities | 3-8 | 12 |

| Mind map branches | 4-6 | 8 |

| Mind map sub-topics per branch | 2-4 | 6 |

Layout Tips

  1. Start positions: Center important elements, use consistent spacing
  2. Spacing:
  1. Colors: Use consistent color scheme
  1. Text sizing: 16-24px for readability
  2. Font: Always use fontFamily: 5 (Excalifont) for all text elements
  3. Arrow style: Use straight arrows for simple flows, curved for complex relationships

Complexity Management

If user request has too many elements:

Example response:

"Your request includes 15 components. For clarity, I recommend:
1. High-level architecture diagram (6 main components)
2. Detailed diagram for each subsystem

Would you like me to start with the high-level view?"

Example Prompts and Responses

Example 1: Simple Flowchart

User: "Create a flowchart for user registration"

Agent generates:

  1. Extract steps: "Enter email" → "Verify email" → "Set password" → "Complete"
  2. Create flowchart with 4 rectangles + 3 arrows
  3. Save as user-registration-flow.excalidraw

Example 2: Relationship Diagram

User: "Diagram the relationship between User, Post, and Comment entities"

Agent generates:

  1. Entities: User, Post, Comment
  2. Relationships: User → Post ("creates"), User → Comment ("writes"), Post → Comment ("contains")
  3. Save as user-content-relationships.excalidraw

Example 3: Mind Map

User: "Mind map about machine learning concepts"

Agent generates:

  1. Center: "Machine Learning"
  2. Branches: Supervised Learning, Unsupervised Learning, Reinforcement Learning, Deep Learning
  3. Sub-topics under each branch
  4. Save as machine-learning-mindmap.excalidraw

Troubleshooting

| Issue | Solution |

|-------|----------|

| Elements overlap | Increase spacing between coordinates |

| Text doesn't fit in boxes | Increase box width or reduce font size |

| Too many elements | Break into multiple diagrams |

| Unclear layout | Use grid layout (rows/columns) or radial layout (mind maps) |

| Colors inconsistent | Define color palette upfront based on element types |

Advanced Techniques

Grid Layout (for Relationship Diagrams)

const columns = Math.ceil(Math.sqrt(entityCount));
const x = startX + (index % columns) * horizontalGap;
const y = startY + Math.floor(index / columns) * verticalGap;

Radial Layout (for Mind Maps)

const angle = (2 * Math.PI * index) / branchCount;
const x = centerX + radius * Math.cos(angle);
const y = centerY + radius * Math.sin(angle);

Auto-generated IDs

Use timestamp + random string for unique IDs:

const id = Date.now().toString(36) + Math.random().toString(36).substr(2);

Output Format

Always provide:

  1. ✅ Complete .excalidraw JSON file
  2. 📊 Summary of what was created
  3. 📝 Element count
  4. 💡 Instructions for opening/editing

Example summary:

Created: user-workflow.excalidraw
Type: Flowchart
Elements: 7 rectangles, 6 arrows, 1 title text
Total: 14 elements

To view:
1. Visit https://excalidraw.com
2. Drag and drop user-workflow.excalidraw
3. Or use File → Open in Excalidraw VS Code extension

Validation Checklist

Before delivering the diagram:

Icon Libraries (Optional Enhancement)

For 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.

When User Requests Icons

If user asks for AWS/cloud architecture diagrams or mentions wanting to use specific icons:

  1. Check if library exists: Look for libraries/<library-name>/reference.md
  2. If library exists: Proceed to use icons (see AI Assistant Workflow below)
  3. If library does NOT exist: Respond with setup instructions:

```

To use [AWS/GCP/Azure/etc.] architecture icons, please follow these steps:

1. Visit https://libraries.excalidraw.com/

2. Search for "[AWS Architecture Icons/etc.]" and download the .excalidrawlib file

3. Create directory: skills/excalidraw-diagram-generator/libraries/[icon-set-name]/

4. Place the downloaded file in that directory

5. Run the splitter script:

python skills/excalidraw-diagram-generator/scripts/split-excalidraw-library.py skills/excalidraw-diagram-generator/libraries/[icon-set-name]/

This will split the library into individual icon files for efficient use.

After setup is complete, I can create your diagram using the actual AWS/cloud icons.

Alternatively, I can create the diagram now using simple shapes (rectangles, ellipses)

which you can later replace with icons manually in Excalidraw.

```

User Setup Instructions (Detailed)

Step 1: Create Library Directory

mkdir -p skills/excalidraw-diagram-generator/libraries/aws-architecture-icons

Step 2: Download Library

Step 3: Place Library File

Step 4: Run Splitter Script

python skills/excalidraw-diagram-generator/scripts/split-excalidraw-library.py skills/excalidraw-diagram-generator/libraries/aws-architecture-icons/

Step 5: Verify Setup

After running the script, verify the following structure exists:

skills/excalidraw-diagram-generator/libraries/aws-architecture-icons/
  aws-architecture-icons.excalidrawlib  (original)
  reference.md                          (generated - icon lookup table)
  icons/                                (generated - individual icon files)
    API-Gateway.json
    CloudFront.json
    EC2.json
    Lambda.json
    RDS.json
    S3.json
    ...

AI Assistant Workflow

When icon libraries are available in libraries/:

RECOMMENDED APPROACH: Use Python Scripts (Efficient & Reliable)

The repository includes Python scripts that handle icon integration automatically:

  1. Create base diagram structure:
  1. Add icons using Python script:

```bash

python skills/excalidraw-diagram-generator/scripts/add-icon-to-diagram.py \

<diagram-path> <icon-name> <x> <y> [--label "Text"] [--library-path PATH]

```

Examples:

```bash

# Add EC2 icon at position (400, 300) with label

python scripts/add-icon-to-diagram.py diagram.excalidraw EC2 400 300 --label "Web Server"

# Add VPC icon at position (200, 150)

python scripts/add-icon-to-diagram.py diagram.excalidraw VPC 200 150

# Add icon from different library

python scripts/add-icon-to-diagram.py diagram.excalidraw Compute-Engine 500 200 \

--library-path libraries/gcp-icons --label "API Server"

```

  1. Add connecting arrows:

```bash

python skills/excalidraw-diagram-generator/scripts/add-arrow.py \

<diagram-path> <from-x> <from-y> <to-x> <to-y> [--label "Text"] [--style solid|dashed|dotted] [--color HEX]

```

Examples:

```bash

# Simple arrow from (300, 250) to (500, 300)

python scripts/add-arrow.py diagram.excalidraw 300 250 500 300

# Arrow with label

python scripts/add-arrow.py diagram.excalidraw 300 250 500 300 --label "HTTPS"

# Dashed arrow with custom color

python scripts/add-arrow.py diagram.excalidraw 400 350 600 400 --style dashed --color "#7950f2"

```

  1. Workflow summary:

```bash

# Step 1: Create base diagram with title and structure

# (Create .excalidraw file with initial elements)

# Step 2: Add icons with labels

python scripts/add-icon-to-diagram.py my-diagram.excalidraw "Internet-gateway" 200 150 --label "Internet Gateway"

python scripts/add-icon-to-diagram.py my-diagram.excalidraw VPC 250 250

python scripts/add-icon-to-diagram.py my-diagram.excalidraw ELB 350 300 --label "Load Balancer"

python scripts/add-icon-to-diagram.py my-diagram.excalidraw EC2 450 350 --label "EC2 Instance"

python scripts/add-icon-to-diagram.py my-diagram.excalidraw RDS 550 400 --label "Database"

# Step 3: Add connecting arrows

python scripts/add-arrow.py my-diagram.excalidraw 250 200 300 250 # Internet → VPC

python scripts/add-arrow.py my-diagram.excalidraw 300 300 400 300 # VPC → ELB

python scripts/add-arrow.py my-diagram.excalidraw 400 330 500 350 # ELB → EC2

python scripts/add-arrow.py my-diagram.excalidraw 500 380 600 400 # EC2 → RDS

```

Benefits of Python Script Approach:

ALTERNATIVE: Manual Icon Integration (Not Recommended)

Only use this if Python scripts are unavailable:

  1. Check for libraries:

```

List directory: skills/excalidraw-diagram-generator/libraries/

Look for subdirectories containing reference.md files

```

  1. Read reference.md:

```

Open: libraries/<library-name>/reference.md

This is lightweight (typically <300 lines) and lists all available icons

```

  1. Find relevant icons:

```

Search the reference.md table for icon names matching diagram needs

Example: For AWS diagram with EC2, S3, Lambda → Find "EC2", "S3", "Lambda" in table

```

  1. Load specific icon data (WARNING: Large files):

```

Read ONLY the needed icon files:

Note: Each icon file is 200-1000 lines - this consumes significant tokens

```

  1. Extract and transform elements:

```

Each icon JSON contains an "elements" array

Calculate bounding box (min_x, min_y, max_x, max_y)

Apply offset to all x/y coordinates

Generate new unique IDs for all elements

Update groupIds references

Copy transformed elements into your diagram

```

  1. Position icons and add connections:

```

Adjust x/y coordinates to position icons correctly in the diagram

Update IDs to ensure uniqueness across diagram

Add connecting arrows and labels as needed

```

Manual Integration Challenges:

Example: Creating AWS Diagram with Icons

Request: "Create an AWS architecture diagram with Internet Gateway, VPC, ELB, EC2, and RDS"

Recommended Workflow (using Python scripts):

Request: "Create an AWS architecture diagram with Internet Gateway, VPC, ELB, EC2, and RDS"

Recommended Workflow (using Python scripts):

# Step 1: Create base diagram file with title
# Create my-aws-diagram.excalidraw with basic structure (title, etc.)

# Step 2: Check icon availability
# Read: libraries/aws-architecture-icons/reference.md
# Confirm icons exist: Internet-gateway, VPC, ELB, EC2, RDS

# Step 3: Add icons with Python script
python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw "Internet-gateway" 150 100 --label "Internet Gateway"
python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw VPC 200 200
python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw ELB 350 250 --label "Load Balancer"
python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw EC2 500 300 --label "Web Server"
python scripts/add-icon-to-diagram.py my-aws-diagram.excalidraw RDS 650 350 --label "Database"

# Step 4: Add connecting arrows
python scripts/add-arrow.py my-aws-diagram.excalidraw 200 150 250 200  # Internet → VPC
python scripts/add-arrow.py my-aws-diagram.excalidraw 265 230 350 250  # VPC → ELB
python scripts/add-arrow.py my-aws-diagram.excalidraw 415 280 500 300  # ELB → EC2
python scripts/add-arrow.py my-aws-diagram.excalidraw 565 330 650 350 --label "SQL" --style dashed

# Result: Complete diagram with professional AWS icons, labels, and connections

Benefits:

Alternative Workflow (manual, if scripts unavailable):

  1. Check: libraries/aws-architecture-icons/reference.md exists → Yes
  2. Read reference.md → Find entries for Internet-gateway, VPC, ELB, EC2, RDS
  3. Load:

Total: ~2000+ lines of JSON to process

  1. Extract elements from each JSON
  2. Calculate bounding boxes and offsets for each icon
  3. Transform all coordinates (x, y) for positioning
  4. Generate unique IDs for all elements
  5. Add arrows showing data flow
  6. Add text labels
  7. Generate final .excalidraw file

Challenges with manual approach:

Supported Icon Libraries (Examples — verify availability)

Fallback: No Icons Available

If no icon libraries are set up:

References

See bundled references for:

Limitations

Future Enhancements

Potential improvements:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.