ec-draw: Excalidraw Diagram Generator
Generate themed .excalidraw files by filling a template's content slots and calling renderFromRecipe.
Workflow
Pick a template — Read the matching template from templates/ for the diagram type the user wants:
Recipe-ready (YAML frontmatter, use with renderFromRecipe):
templates/narrative-framework.md — concept diagrams, frameworks, mental models
Informational (use as pattern references with Diagram API or JSON descriptors):
templates/flowchart.md — decision trees, process flows
templates/architecture.md — system topology, service diagrams
templates/sequence.md — API flows, message passing
templates/er.md — entity-relationship, class diagrams
templates/comparison.md — A vs B, side-by-side comparisons
templates/before-after-gap.md — problem → gap → solution narratives
templates/layered-explainer.md — what → how → why depth layers
templates/whiteboard.md — freeform sketches, brainstorming
Fill the slots — Each template defines a ## Slots section. Fill in the content (headings, items, icons, labels) based on what the user asked for. Templates define grid, colors, and layout — do NOT include coordinates or hex colors in your slots.
Call renderFromRecipe — Pass the template ID, your filled slots, and the theme:
import { renderFromRecipe } from "ec-draw";
import { writeFileSync } from "fs";
const doc = renderFromRecipe("narrative-framework", {
title: "Diagram Title",
sections: [
{
heading: "Section 1",
role: "primary",
items: [{ title: "Card A", subtitle: "description", icon: "cloud" }],
},
// ... more sections
],
transitions: [
{ from: 0, to: 1, label: "describes the relationship" },
],
callout: { text: "Key insight message", icon: "fire" },
}, "sketchy");
writeFileSync("output.excalidraw", JSON.stringify(doc, null, 2), "utf-8");
- Save — Write to
.excalidraw file.
Themes
| Theme |
Best for |
sketchy |
Brainstorming, early ideas (default) |
professional |
Architecture docs, formal presentations |
dark |
Dark-mode contexts |
colorful |
Slides, teaching, demos |
Built-in Icons
database, server, cloud, user, gear, document, globe, mobile, lock, fire, brain, code.
Tips
- Read the template before writing slots — each template defines its own roles, grid, and rules
- Transitions must have labels — never create silent arrows between sections
- Use roles from the template's table — don't invent new role names
- Match icons to semantic meaning —
cloud for external services, lock for security, gear for processing
1---2name: ec-draw3description: Generate hand-drawn Excalidraw diagrams. Use when the user asks to draw, sketch, or create a diagram, flowchart, architecture diagram, concept diagram, or any visual diagram. Trigger on "draw", "sketch", "diagram", "flowchart", "visualize", "excalidraw".4---56# ec-draw: Excalidraw Diagram Generator78Generate themed `.excalidraw` files by filling a template's content slots and calling `renderFromRecipe`.910## Workflow11121. **Pick a template** — Read the matching template from `templates/` for the diagram type the user wants:1314 **Recipe-ready (YAML frontmatter, use with `renderFromRecipe`):**15 - `templates/narrative-framework.md` — concept diagrams, frameworks, mental models1617 **Informational (use as pattern references with Diagram API or JSON descriptors):**18 - `templates/flowchart.md` — decision trees, process flows19 - `templates/architecture.md` — system topology, service diagrams20 - `templates/sequence.md` — API flows, message passing21 - `templates/er.md` — entity-relationship, class diagrams22 - `templates/comparison.md` — A vs B, side-by-side comparisons23 - `templates/before-after-gap.md` — problem → gap → solution narratives24 - `templates/layered-explainer.md` — what → how → why depth layers25 - `templates/whiteboard.md` — freeform sketches, brainstorming26272. **Fill the slots** — Each template defines a `## Slots` section. Fill in the content (headings, items, icons, labels) based on what the user asked for. Templates define grid, colors, and layout — do NOT include coordinates or hex colors in your slots.28293. **Call `renderFromRecipe`** — Pass the template ID, your filled slots, and the theme:3031```ts32import { renderFromRecipe } from "ec-draw";33import { writeFileSync } from "fs";3435const doc = renderFromRecipe("narrative-framework", {36 title: "Diagram Title",37 sections: [38 {39 heading: "Section 1",40 role: "primary",41 items: [{ title: "Card A", subtitle: "description", icon: "cloud" }],42 },43 // ... more sections44 ],45 transitions: [46 { from: 0, to: 1, label: "describes the relationship" },47 ],48 callout: { text: "Key insight message", icon: "fire" },49}, "sketchy");5051writeFileSync("output.excalidraw", JSON.stringify(doc, null, 2), "utf-8");52```53544. **Save** — Write to `.excalidraw` file.5556## Themes5758| Theme | Best for |59|-------|----------|60| `sketchy` | Brainstorming, early ideas (default) |61| `professional` | Architecture docs, formal presentations |62| `dark` | Dark-mode contexts |63| `colorful` | Slides, teaching, demos |6465## Built-in Icons6667`database`, `server`, `cloud`, `user`, `gear`, `document`, `globe`, `mobile`, `lock`, `fire`, `brain`, `code`.6869## Tips7071- **Read the template before writing slots** — each template defines its own roles, grid, and rules72- **Transitions must have labels** — never create silent arrows between sections73- **Use roles from the template's table** — don't invent new role names74- **Match icons to semantic meaning** — `cloud` for external services, `lock` for security, `gear` for processing