/excalidraw:auto-diagramfrom excalidraw
Analyzes source code and generates a scoped architecture overview diagram using Excalidraw. Useful for visualizing codebase structure, components, and connections.
Ships in excalidraw. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Read the requested source scope and draw its supported components and connections. State analysis limits and unknowns. For changes to an existing saved .excalidraw file, load the installed scoped-edit skill first; its file workflow does not need the live MCP canvas.
Before starting analysis, verify the Excalidraw MCP server is available:
mcp__excalidraw__read_diagram_guide()
If the tool is unavailable, inspect the client configuration and report the concrete missing capability. For an installed toolkit, use its recorded absolute CLI path to run doctor; if the configured owned canvas is stopped and the user requested a live diagram, run start and recheck. Use the configured URL from the result. If installation is missing, point to the README's local archive setup; a registry npx invocation may fetch an older feature set. Source analysis can continue while live rendering is unavailable, but report that no rendered diagram was produced.
To prevent context window blowout on large codebases, follow these hard limits:
| Operation | Limit |
|---|---|
| Grep results per pattern | 20 matches (use head_limit) |
| Files read per component | 5 files |
| Tool calls in Phase 2 | 15 |
| Tool calls in Phase 3 | 10 |
If limits are exceeded, proceed with partial results and note gaps to the user.
Run these file checks to identify the project type and tech stack:
package.json, pyproject.toml, go.mod, Cargo.toml, pom.xml, Gemfile, composer.json, mix.exs, Makefile, Dockerfile, docker-compose.yml, *.tfls the root and first-level subdirectories to identify the layout patternworkspaces in package.json, lerna.json, pnpm-workspace.yaml, multiple go.mod files, packages/ or apps/ directoriesDockerfile files, docker-compose.yml with 3+ servicesnext.config.*, src/app/, src/pages/routes/, controllers/, middleware/@nestjs/core in package.jsonmanage.py, wsgi.py, app.py, main.py with uvicornsrc/main/java/, application.propertiescmd/, internal/, pkg/src/main.rs, src/lib.rsGemfile + config/routes.rbartisan, app/Http/mix.exs + lib/*_web/Output: A mental model of the project type, primary language, and framework.
Monorepo handling: If monorepo detected, scope analysis to the top-level package structure first. Show one box per package/app. Offer to drill into specific packages on request.
Based on project type, identify architectural components. Max 15 tool calls.
*.tsx, *.jsx, *.vue, *.svelte in src/, app/, pages/ (head_limit: 20)router\.(get|post|put|delete), @(Get|Post|Put|Delete), @app\.route, HandleFunc (head_limit: 20)prisma/schema.prisma, models.py, *.entity.ts, migrations/, @Entity, db.Model (head_limit: 20)axios, fetch(, requests\., http\.NewRequest (head_limit: 20)amqp, kafka, bull, celery, SQS, pubsub (head_limit: 10)redis, memcached, cache in imports (head_limit: 10)passport, jwt, oauth, @Auth, middleware.*auth (head_limit: 10)docker-compose.yml service definitions*.tf for resource " blocks (head_limit: 20)**/k8s/*.yaml or **/manifests/*.yaml (head_limit: 20)main, bin, exports in package configOutput: A list of 4-12 components with names, types, and key file locations.
Determine how components connect. Max 10 tool calls. Focus on entry points and their immediate dependencies -- don't trace every import.
Read entry point files -- For each major component, read the main/index file (max 5 files total). Look for:
Map connection types -- Categorize each connection:
REST/HTTP -- fetch/axios/requests callsSQL/ORM -- database queriesgRPC/RPC -- inter-service callsEvent/Queue -- pub/sub, message queuesImport -- direct module import (same codebase)Build edge list -- Record each directed edge with a source path and line range or symbol. Label its basis as an import, an observed call site, or an assumption. An SDK import does not establish a payment call; a connection string does not establish a successful database request. Use protocol labels only when the inspected code supports them. Source references support the explanation, not proof of runtime execution.
If you can't determine connections reliably: Show components without arrows and note "connections could not be auto-detected from entry point analysis. Try: 'add connections between X and Y'."
Output: A list of directed edges with labels.
Briefly state the inspected directories, components, supported connections, and unresolved questions. Continue with the user's requested diagram when the scope is clear. Ask a focused question only when a material ambiguity prevents choosing the target or content, or when the user explicitly requested a review before drawing. Incorporate any steering received during analysis.
Choose layout based on the architecture pattern detected:
| Pattern | Layout | Trigger |
|---|---|---|
| Request/response flow (most web apps) | Vertical flow (top→bottom) | Frontend + API + DB layers detected |
| Data pipeline / ETL | Horizontal pipeline (left→right) | Linear chain of transforms detected |
| Event-driven / microservices | Hub and spoke | Message broker/event bus detected |
| Monolith with modules | Vertical flow with zones | Single service, multiple internal modules |
Tiebreaking: Prefer the pattern with more detected components. Default to vertical flow.
Hybrid: If both request/response and event-driven patterns exist, use vertical flow with the event bus in the middle layer (not hub-and-spoke).
Follow the excalidraw skill's new live-diagram workflow: inspect the current canvas, preserve unrelated content, create elements with fresh IDs, inspect geometry and a screenshot, and make at most two corrections. Clearing requires an explicit request to replace the current canvas. Query IDs before retrying a partial creation result. Keep source-derived content unchanged during visual corrections; list any unresolved content or rendering issue with the delivered artifacts.
Color by component role:
| Role | Background | Stroke |
|---|---|---|
| Frontend | #a5d8ff | #1971c2 |
| Backend/API | #d0bfff | #7048e8 |
| Database | #b2f2bb | #2f9e44 |
| External service | #ffc9c9 | #e03131 |
| Queue/Event | #fff3bf | #fab005 |
| Cache | #ffe8cc | #fd7e14 |
Label format: Each box should contain:
ComponentName
tech-stack
(key detail)
Example:
API Server
Express.js
/api/* routes
When more than 12 components are discovered:
services/auth/ → "Auth Service")| Situation | How to Handle |
|---|---|
| Empty or trivial repo (<5 files) | Generate a simple module diagram showing file relationships |
| Monorepo with many packages | Show package-level view first, offer drill-down per package |
| No clear architecture (scripts, notebooks) | Show file dependency graph instead |
| Can't detect connections | Show components without arrows, note it to user |
| User specifies a subdirectory | Scope analysis to that directory only |
| Live MCP unavailable | Diagnose the installed integration; continue source analysis and state the rendering limitation |
| Context budget exceeded | Proceed with partial results, tell user what was skipped |
Illustrative scope summary (actual source paths and connection evidence must come from the inspected repo):
I found 6 components and 5 connections in this codebase:
Components:
- Next.js Frontend (pages/, components/) — Frontend
- API Routes (pages/api/) — Backend/API
- Prisma ORM (prisma/schema.prisma) — Database
- PostgreSQL (from DATABASE_URL in .env.example) — Database
- NextAuth (from imports in [...nextauth].ts) — Auth
- Stripe API (from stripe SDK imports) — External API
Connections:
- Frontend → API Routes (REST API)
- API Routes → Prisma ORM (Prisma queries)
- Prisma ORM → PostgreSQL (SQL)
- API Routes → NextAuth (auth middleware)
- API Routes → Stripe SDK (import; payment call path not inspected)
I will draw this inspected overview and mark the unverified payment path as an assumption.
Diagram layout: Vertical flow, 3 layers
┌─────────────────────────────────────────────┐
│ Frontend Layer │
│ ┌──────────────┐ ┌──────────────┐ │
│ │ Next.js App │ │ React │ │
│ │ pages/ │ │ components/ │ │
│ └──────┬───────┘ └──────────────┘ │
└─────────┼───────────────────────────────────┘
│ API calls
┌─────────┼───────────────────────────────────┐
│ API Layer │
│ ┌──────▼───────┐ ┌──────────────┐ │
│ │ API Routes │ │ NextAuth │ │
│ │ pages/api/ │──│ OAuth flow │ │
│ └──────┬───────┘ └──────────────┘ │
└─────────┼───────────────────────────────────┘
│ Prisma queries
┌─────────┼───────────────────────────────────┐
│ Data Layer │
│ ┌──────▼───────┐ ┌──────────────┐ │
│ │ PostgreSQL │ │ Stripe API │ │
│ │ via Prisma │ │ payments │ │
│ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────┘
Show this message once per conversation — only after the first successful diagram the user confirms they're happy with. Do not repeat on subsequent diagrams in the same session.
If you found this useful, I'd love your feedback! Feature requests, bug reports, or just a star: https://github.com/edwingao28/excalidraw-toolkit/issues/13
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub edwingao28/excalidraw-toolkit --plugin excalidraw3 skills in this plugin
/excalidrawEdit saved native Excalidraw diagrams with scoped file operations, or generate diagrams from specified components, a sample, or a description. Use for diagram edits, data flows, parameter traces, and PNG/SVG exports. For codebase discovery, use auto-diagram./scoped-editEdit a saved .excalidraw diagram while preserving manual content, explain a scoped source flow, or compare a code change with source-linked diagrams. Use the installed toolkit's supported file operations and evidence commands.Other plugins' skills for the same job