An opinionated starter repo for generating, editing, and exporting Excalidraw diagrams for many different projects.
繁體中文README.zh-TW.md
- A vendored Excalidraw renderer under
.claude/skills/excalidraw-diagram/references/(also projected for agents under.agents/skills/excalidraw-diagram) - A generic sample renderer in
generate_diagram.js - A reusable render script in
render_excalidraw.sh - A pre-render structural validator in
validate_excalidraw.sh(text overflow + arrow-binding consistency) - Generated diagram files in
output/
Recommended editor: VS Code with the pomdtr.excalidraw-editor extension for directly editing .excalidraw files inside the workspace.
- Generate or update a diagram JSON file:
node generate_diagram.js /absolute/path/to/my-diagram.jsonWhen a spec path is given, the output .excalidraw file is written next to the spec automatically. Without a spec path, examples/channel-map.example.json is used as the default spec and the diagram JSON is written to stdout. Use --dark for the dark theme.
- Validate structure before rendering (catches text-overflowing-its-box and broken arrow bindings):
./validate_excalidraw.sh # batch over output/ + temp/
./validate_excalidraw.sh /absolute/path/to/file.excalidraw
./validate_excalidraw.sh /absolute/path/to/file.excalidraw --fix # auto-fix safe binding issues- Render the
.excalidrawfile to PNG:
./render_excalidraw.sh- Render a different
.excalidrawfile when needed:
./render_excalidraw.sh /absolute/path/to/your-diagram.excalidraw- Keep rendering logic in
generate_diagram.js, and keep diagram content in JSON spec files. - Edit
.excalidrawfiles directly in Excalidraw, or replace the sample renderer with your own generator. - Run
./validate_excalidraw.shfirst — text overflow and binding issues are cheap to catch before any PNG is rendered. - Run
./render_excalidraw.sh <file>to render to PNG. - Add more generators or templates as your diagram library grows.
.
├── .claude/
│ └── skills/
│ └── excalidraw-diagram/
│ └── references/
├── .agents/
│ └── skills/
│ └── excalidraw-diagram/
├── examples/
│ └── channel-map.example.json
├── generate_diagram.js
├── lib/
├── output/
├── render_excalidraw.sh
└── validate_excalidraw.sh
- This repo recommends VS Code and includes
.vscode/extensions.jsonwithpomdtr.excalidraw-editor. - The render script prefers the vendored renderer under
.claude/skills/excalidraw-diagram/references/, so the project is portable across machines. - The vendored renderer loads Excalidraw from a pinned jsdelivr ESM build first, then falls back to the unpkg UMD build. If both fail, it prints browser request/page errors instead of hanging on a generic Playwright timeout.
- The validator measures text width with the same canvas + Excalidraw font stacks the renderer uses, so detected overflows match what would actually appear in the PNG (no character-count estimation).
.claude/is the source of truth..agents/skills/excalidraw-diagramis generated from it bynode ~/.claude/scripts/sync-to-agents.mjs.generate_diagram.jsis a reusable sample renderer. The repo stays generic by moving concrete diagram content into spec files instead of hardcoding it in the JS source.