Excalidraw

From tinh2/skills-hub-registry · View interactive version

Excalidraw is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Generate Excalidraw architecture diagrams (.excalidraw JSON files) from your codebase. Triggers: you need whiteboard-style sketches that read as a thinking artifact rather than a polished spec — ideal for design.

How to use this skill

Skill file

You are in AUTONOMOUS MODE. Do NOT ask questions. Analyze the project codebase and generate Excalidraw architecture diagrams as .excalidraw JSON files.

INPUT:

$ARGUMENTS

Accepted arguments:

============================================================

PHASE 1: CODEBASE ANALYSIS

============================================================

Step 1.1 — Tech Stack and Architecture Detection

Scan config files to determine: project type (web app, API, mobile, CLI, library, monorepo), primary language/framework, database(s), external services (auth, payment, email, storage), message queues, caching layers, and API gateway config.

Step 1.2 — Service and Module Mapping

For monorepos/microservices: read docker-compose.yml or K8s manifests for service definitions, map inter-service communication, identify external deps per service.

For monoliths: read directory structure to identify modules/domains, trace import statements to map module dependencies, identify layer boundaries.

Step 1.3 — Database Schema Extraction

Scan for schema definitions in: schema.prisma, *.entity.ts (TypeORM/MikroORM), models/*.js (Sequelize), models.py (Django), db/schema.rb (Rails), models/*.py (SQLAlchemy), schema.ts (Drizzle), migrations/*.sql, *.model.ts (Mongoose).

Extract: table/collection names, columns with types, primary/foreign keys, relationships (1:1, 1:N, M:N), indexes, and enums.

Step 1.4 — Key Flow Identification

Identify the most important flows to diagram:

For each flow, trace: entry point, middleware, service layer, data access, external calls, and response construction.

============================================================

PHASE 2: EXCALIDRAW FILE FORMAT

============================================================

Each .excalidraw file is a single JSON document with this top-level shape:

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

Every element MUST include: id (random nanoid-like string), type, x, y, width, height, angle (default 0), strokeColor, backgroundColor, fillStyle (hachure | cross-hatch | solid), strokeWidth (1 thin, 2 bold, 4 extra-bold), strokeStyle (solid | dashed | dotted), roughness (0 smooth, 1 normal, 2 cartoonist), opacity (0–100), groupIds ([]), frameId (null), roundness (null or { "type": 3 } for rounded rectangles), seed (random int), version (1), versionNonce (random int), isDeleted (false), boundElements (null or array), updated (epoch ms), link (null), locked (false).

Type-specific extras:

Color palette — use the Excalidraw default-ish set so files open cleanly:

Layout rules (avoid overlap and produce a readable canvas):

============================================================

PHASE 3: DIAGRAM GENERATION

============================================================

Step 3.1 — C4 Context Diagram (docs/diagrams/excalidraw/c4-context.excalidraw)

Center the System under test as a rounded rectangle with a bold label. Place users/actors as ellipses on the left, external systems as rectangles with strokeStyle: "dashed" on the right. Arrows labeled with the relationship verb ("uses", "sends events to"). Keep it under 12 shapes.

Step 3.2 — C4 Container Diagram (docs/diagrams/excalidraw/c4-container.excalidraw)

Inside a large dashed rectangle representing the system boundary, draw each container (web app, API, worker, db, cache, queue) as a labeled rounded rectangle. Use the color palette above. Annotate arrows with protocol (HTTPS, SQL, AMQP, gRPC).

Step 3.3 — Sequence Diagrams (docs/diagrams/excalidraw/sequence-<flow>.excalidraw)

Lay participants out as labeled rectangles along the top edge (x stepped by 200, y = 40). Drop a vertical dashed line beneath each as the lifeline. Messages are horizontal arrows between lifelines, stepping y by 80 per message. Always generate the auth flow if auth exists, plus the primary business flow.

Step 3.4 — ER Diagram (docs/diagrams/excalidraw/er-diagram.excalidraw)

Each table is a rounded rectangle with two text rows: bold table name (fontSize 20) on top, then a multi-line column list (fontSize 16) listing name: type with (PK) / (FK) markers. Relationships are arrows with cardinality labels (1, 0..1, *).

Step 3.5 — Module Dependency Graph (docs/diagrams/excalidraw/dependency-graph.excalidraw)

Top-down layout: entry points (routes/controllers) at the top, data stores at the bottom, external systems on the sides. Use background-fill color to encode the layer (api / domain / data / external). Highlight circular dependencies with red dashed arrows.

============================================================

PHASE 4: OUTPUT AND ORGANIZATION

============================================================

Create docs/diagrams/excalidraw/ if it does not exist. Skip diagram types with no underlying data (no ER if no database).

For every .excalidraw file, also write a sibling .md file with the same stem containing: heading, brief explanation of the diagram, and a fenced link [Open in Excalidraw](./<file>.excalidraw). The .excalidraw file can be opened directly at https://excalidraw.com (File → Open) or via the VS Code Excalidraw extension.

Generate docs/diagrams/excalidraw/README.md listing every diagram with a one-line description and a link to both the JSON file and the explanation.

============================================================

SELF-HEALING VALIDATION (max 2 iterations)

============================================================

After producing each .excalidraw file, validate:

  1. The file is valid JSON (jq empty <file> exits 0). If jq is unavailable, parse with node -e "JSON.parse(require('fs').readFileSync('<file>','utf8'))".
  2. type === "excalidraw", version === 2, elements is a non-empty array.
  3. Every element has all required base fields listed in Phase 2.
  4. Every arrow's startBinding.elementId and endBinding.elementId resolve to an existing element id.
  5. No two non-arrow shapes overlap by more than 50% of either's bounding box.
  6. No element has x or y greater than 4000 or less than -2000 (keeps the canvas reasonable).

If validation fails, regenerate only the offending file and re-validate. Stop after 2 iterations and report which file is still failing.

============================================================

OUTPUT

============================================================

Excalidraw Diagrams Generated

System Profile

Diagrams Created

| Diagram | File | Elements |

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

| C4 Context | docs/diagrams/excalidraw/c4-context.excalidraw | N |

| C4 Container | docs/diagrams/excalidraw/c4-container.excalidraw | N |

| Sequence: Auth | docs/diagrams/excalidraw/sequence-auth.excalidraw | N |

| ER Diagram | docs/diagrams/excalidraw/er-diagram.excalidraw | N |

| Dependencies | docs/diagrams/excalidraw/dependency-graph.excalidraw | N |

How to View

Observations

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists at ~/.claude/projects/<project>/. If found, append to skill-telemetry.md:

### /excalidraw — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / 2 max
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Skip silently if the memory directory does not exist.

============================================================

DO NOT

============================================================

NEXT STEPS:

After generating diagrams:

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.