/architecture-diagram:architecture-diagramfrom architecture-diagram
Builds interactive, click-through architecture diagrams as self-contained HTML files with animated step-by-step flows, mode toggles, and a side panel. Use for visualizing system designs, service maps, data flows, or pipelines.
Ships in architecture-diagram. 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.
Read when SKILL.md points to them.
Build single-file, drop-in HTML pages that let workshop attendees, clients, or new team members click through how a system works — step by step, with animated data packets flowing between nodes, payload details on a side panel, and toggleable modes (offline/online, dev/prod, v1/v2). The aesthetic is dark and didactic-first: bounded nodes, gentle quadratic wires, packets that glow only on the active step — no rainbow gradients. Rebrand via the CSS tokens in assets/css-tokens.css.
| Situation | Use this skill? |
|---|---|
| "Show me how the auth flow works" (interactive, for a workshop) | Yes |
| "Design the RAG pipeline before we build it" (planning new service) | Yes |
| "Map our microservices and how they communicate" | Yes |
| "Visualize the CI/CD pipeline for onboarding docs" | Yes |
| "Show the data flow through our ETL pipeline" | Yes |
| "Draw an agentic multi-agent system with tool calls" | Yes |
| "Build me an architecture mockup we can iterate on with the team" | Yes |
| "Draw a sequence diagram for the PR" (static, goes in markdown) | No — a Mermaid sequence diagram inline is simpler |
| "Add a diagram to a slide deck or PDF" (static, not interactive) | No — this produces interactive HTML, not images or slides |
| "I just need a static boxes-and-arrows topology" (no flows/steps) | No — a Mermaid flowchart is enough |
The differentiator is interactivity + sequenced data flow: if the value is "click through it and watch what happens", use this skill; if you need a static image, a slide, or an inline diagram, use Mermaid instead. (Already have an interactive diagram and also want it static? references/spec.js export turns it into Mermaid or draw.io — see Step 5.)
Scope. The skill writes two files (architecture.html, architecture.md) and reads only what you point it at. The bundled Node tools need no npm install, read only the file they are given and send nothing anywhere: references/spec.js and mcp/server.js parse a diagram without executing it; references/screenshot.js opens it in headless Chrome for a preview, and the MCP view runs it in the chat host's sandboxed frame. The generated page makes one network request, to Google Fonts (optional; it renders without them), and a Content Security Policy blocks everything else.
Every diagram has four things:
RAG Query, Direct Query, Ingest, Auth). Each flow is an ordered list of steps.{from, to, color, title, route, payload, desc, chips}. Each step lights up one wire and one target node. (color and title are required — color must be a CSS variable name like --c-orch, anything else falls back to the brand accent; a missing title shows "—". Color it by the non-orchestrator endpoint: flow-design-patterns.md → "Wire color logic".) A step with from === to renders as a loop on that node — above it, or below for a top-row node (internal work such as "CI → CI: build").Modes are NOT alternative flows. Flows describe scenarios ("user asks a question"); modes describe deployment shape ("on Docker" vs "on Cloud Run").
If the user has uploaded a SOLUTION.md, README, OpenAPI spec, or any architecture description — or described the system in their message — read it first. Extract:
Then ask ONLY the gaps that can't be reasonably defaulted. If the system, its main flows and its modes (or lack of them) are known — or the user said not to ask — proceed, and list your assumptions in architecture.md. Defaults: audience = engineers, language = the request's.
Only for a vague request ("diagram our backend") ask briefly: what system, which main flows, any mode toggles (offline/online, dev/prod, v1/v2), who the audience is.
Grounding protocol — when the system exists in a repo you can read. A diagram that shows one invented component loses the viewer's trust in all of it, so draw only what you can point at:
data-assumed="why" / assumed:"why" — an assumed node renders dashed with an "assumed" label, an assumed step's wire stays dashed and its number gets a ?, and the side panel shows the reason. Something you cannot find at all stays out, unless the user asked for it.SOURCE.commit (git rev-parse --short HEAD) and SOURCE.repo (the https URL of git remote get-url origin — convert [email protected]:org/repo.git to https://github.com/org/repo); cite data-src="path:start-end" on nodes and src:"path:start-end" on steps. Paths are relative to the repo root — not the absolute paths your file tools show. Line numbers must come from that commit: if the working tree has uncommitted changes, say so in architecture.md (links only resolve once the commit is pushed). The side panel then shows clickable evidence and the lint flags anything uncited.For a design (the system doesn't exist yet) or a description pasted into chat, leave SOURCE.commit empty and say in architecture.md that it is a proposal / based on the given doc.
Updating an existing diagram. Read the old architecture.html first (node <skill-dir>/references/spec.js extract architecture.html prints its nodes and flows as JSON) and keep every data-id, flow key, tab order and node position that still applies — the same system must come out the same way, so a reviewer sees only real changes. After regenerating, run spec.js diff --level=3 on the old and new file and put its output in architecture.md under "Changes" (and in the PR description).
Before writing code, sketch on paper (literally in your head or a scratch file) WHICH services exist, WHERE they sit relative to each other, and WHICH flows connect WHICH nodes. Avoid wire crossings — this is the single biggest readability win. See references/flow-design-patterns.md for layout heuristics.
Quick rules:
Copy assets/template.html to the working directory. It's a fully working drop-in: dark theme, side panel, player controls (play/pause/step), keyboard shortcuts, animated SVG packets, mode toggle. Edit only these regions (the template's top EDIT THESE THINGS comment is the authoritative list):
<title> + <h1> — replace {{SYSTEM_NAME}} and the header text. For a Polish (or other non-English) diagram also set <html lang="pl">..modepick buttons — mode toggle labels (or remove the whole .modepick if single-mode; the panel badge and O key adapt). Three or more modes are fine — O cycles through them..flowtabs — one .flowtab per scenario; data-flow must match a flows key. Tab order = keyboard digits 1–9; nothing else to keep in sync..node divs in .stage — one per service: data-id, data-role, style="left/top", label, tech, port. Place them on the grid in references/flow-design-patterns.md (left 2/26/52/78%, top 8/38/70%, ≥ 24% apart in a row) — fixed 150px tiles overlap or clip otherwise.flows object in JS — one entry per scenario, each with an ordered steps[] array. Keep it plain data (no variables, function calls or regexes — spec.js reads it without running it). Set state.mode / state.flow to the keys you want shown first (an unknown key falls back to the first button and logs a warning).SOURCE + evidence (grounded diagrams, see Step 1) — SOURCE.repo/commit below flows, data-src/data-assumed on nodes, src/assumed on steps. Refs are path, path:line or path:start-end; several → ;-separated in the attribute, an array in a step.Always edit the .legend: one item per role you use, labelled with what that color means in your system (e.g. compute → "Worker"); delete the rest. Recolor :root CSS variables only for a restyle. After editing, search the file for {{[A-Z] (regex) — a correctly filled file has zero matches.
Don't reinvent the CSS, the player, the SVG wire renderer, or the side panel — they all work.
After generating, do this self-check:
to of two consecutive steps? That's fine if it's a loop, but check the description explains why.architecture.md? (Required — see Step 5.)Then run every check in references/validation.md the environment allows. First the static lint (needs only node):
node <skill-dir>/references/spec.js lint architecture.html # add --json for machine-readable findings
Exit 1 = errors (the page is broken or wrong — fix every one), 2 = warnings (fix them, or say in architecture.md why one stays — e.g. an unavoidable crossing), 0 = clean. Each finding has a rule code (AD0xx) and a fix hint; re-run until it passes. Then, with puppeteer-core + Chrome, node <skill-dir>/references/screenshot.js architecture.html /tmp/arch-preview from the user's project (<skill-dir> = this SKILL.md's folder; exit 1 = page error, 2 = lint warnings — non-zero means fix the HTML) and read the canvas PNGs for overlapping or cut-off tiles; without either, window.archValidate() in the browser console ([] = clean).
Always two files:
architecture.html — the interactive diagramarchitecture.md — text description (components, flows step-by-step, mode differences, scenarios for the workshop). For a grounded diagram add an Evidence table (component → file:lines, at commit X) and an Assumptions list (everything marked assumed, and why). For an update, add Changes (the spec.js diff output).Save to the current working directory. Platform-specific overrides:
/mnt/user-data/outputs/ insteadBoth should be self-sufficient — someone can read the markdown without opening the HTML, and vice versa.
Static fallbacks (optional). When the .md will be read on GitHub, in a wiki or a PR, append a Flows (static) section generated from the finished HTML — every flow as a Mermaid sequence diagram, which those sites render inline:
node <skill-dir>/references/spec.js export architecture.html --mermaid --level=3 >> architecture.md
When the user asks for draw.io / diagrams.net (to edit by hand, or for Confluence), write architecture.drawio with export architecture.html --drawio [--mode=prod] > architecture.drawio. Both are generated from the HTML — never hand-write them, and regenerate them after every change to the diagram.
Tell the user where the files were saved and how to open them (open architecture.html on macOS, xdg-open architecture.html on Linux, or just open in browser). If present_files is available (Claude.ai), call it to display the HTML first, then the markdown. If the show_architecture_diagram tool is available (this skill's MCP server, mcp/server.js), call it with the file's path — in hosts that support MCP Apps (Claude Desktop, VS Code Copilot, ChatGPT, Goose, Cursor) the diagram opens interactively inside the conversation; pass flow, mode and step to open on the step you are talking about.
| File | When to read |
|---|---|
assets/template.html | Always. This is the starting point you copy and modify. |
assets/css-tokens.css | If user asks to restyle (e.g. light theme, different brand colors). Standalone tokens you can splice into existing CSS. |
references/flow-design-patterns.md | When planning a new system from scratch. Heuristics for node placement, naming flows, sequencing steps, choosing modes. |
references/component-library.md | When building the nodes list. Copy-paste node snippets for User/API/Service/DB/Queue/Cache/LLM/Cron/External/etc. with proper roles and icons. |
references/spec.js | Step 4 (lint), when updating a diagram (extract, diff), and for static copies (export --mermaid / --drawio, Step 5). Zero-dependency Node tool. |
mcp/server.js, mcp/viewer.html | Not read during generation. An optional MCP server (zero dependencies) that shows a finished diagram inline in MCP Apps hosts and lints it; setup in the repo README. |
references/validation.md | Step 4. spec.js rule codes and diffing, how to run references/screenshot.js (headless-Chrome previews + lint) and its exit codes, browser-console fallback. |
examples/rag-eskadra-bielik.json | Reference example: a real RAG system with 5 flows and offline/online modes. Read for topology layout, offline/online mode design (per-node tech/port swapping), and flow decomposition via step_outline. Payload/chip conventions are in the sections below, not the examples. |
examples/auth-oauth2.json | Reference example: an OAuth2 + session flow with dev/prod modes. Shows redirect flows and external IdP nodes. |
examples/event-driven.json | Reference example: event-driven microservices with Kafka, showing async fan-out flows. |
examples/cicd-pipeline.json | Reference example: CI/CD pipeline with GitHub Actions, staging/prod modes, rollback flow. |
examples/agentic-tool-calling.json | Reference example: agentic AI system with tool calling, single-agent vs multi-agent modes. |
The examples/*.json files are planning specs, not drop-in code — JSON outlines you translate into the template's HTML nodes + inline JS flows object. See references/flow-design-patterns.md → "Example JSON → template mapping" for the field-by-field translation.
Hardcoded in CSS variables in template.html. Pick one per node:
| Role | Color | Use for |
|---|---|---|
user | mint #46f9b8 | Browser, mobile client, end user, CLI user |
orch | sky #6aa9ff | API / Service: gateway, orchestrator, BFF, ordinary internal services |
compute | magenta #ff6b8a | LLM, ML model, worker, expensive compute |
embed | amber #ffc14d | Embedding service, transformer, preprocessor |
vector | violet #b388ff | Database (any), vector store, cache, queue, blob storage |
seed | orange #ff9457 | Cron, one-shot job, migration, seed, scheduled task |
ext | slate #94a3b8 | External: 3rd-party / SaaS (Stripe, Twilio, Confluence, hosted IdP) |
Roles are color groups, not literal meanings; the legend labels say what each color means in your diagram. Don't invent more (Postgres + Redis are both vector, told apart by icon and label) — past seven the legend becomes a colorblind nightmare. An 8th role needs a --c-<role> in the dark :root and body.light blocks, a .node[data-role] rule, an ahMap entry + <marker>, and a legend item.
This is the most important didactic mechanic in the diagram. Understand it before modifying the JS or CSS, or you'll break the "click a flow tab, see the whole path" intuition.
When a user picks a flow tab and lands on step N, every node and wire is classified into one of these states:
| Element | State | Looks like | When |
|---|---|---|---|
| Node | active | Full ring + glow + step-number badge | Target of current step (e.g. LLM when step says "Orch → LLM") |
| Node | active-from | Soft ring, no badge | Source of current step |
| Node | participant | Near-full opacity, slightly desaturated | Appears anywhere else in this flow, just not in this step |
| Node | dimmed | 25% opacity, washed out | Not in this flow at all (e.g. seed during a login flow) |
| Node | hidden | Invisible | Mode-excluded entirely (e.g. seed node in online mode) |
| Wire | active | Bright role color, glow, packet animating | The wire of the current step |
| Wire | preview | Role color at 50% opacity, dashed | Belongs to this flow but not the active step — shows the full path ahead |
| Wire | muted | ~8% opacity | Doesn't belong to this flow |
Why participant matters (and the JS/CSS implementation gotchas) is detailed in references/flow-design-patterns.md → "The participant state". Short version: it lets a viewer see the whole path on the first click, instead of stepping through to discover which nodes a flow uses — that's the entire point of the diagram. If you add node states, keep applyStep and the CSS (.node.participant, .wire.preview) consistent.
The diagram supports six ways to interact, in increasing order of viewer expertise:
| Interaction | What happens | Who uses it |
|---|---|---|
| Click flow tab | Jump to the first playable step of that flow, side panel updates | Everyone |
| Click Next/Prev (or →/←, Space) | Advance/rewind one step; Play at the end restarts the flow | Workshop attendees walking through |
| Click a node | Jump to the first step where this node appears | Curious viewers exploring |
| Drag a node (mouse/pen) or Shift+Arrows on a focused node | Reposition the node on the canvas; wires redraw live; layout saved per browser | Layout tweakers / presenters |
| Share a view | The URL hash tracks flow, mode and step (#flow=ask&mode=online&step=3); copy the address bar to send someone that exact step | Reviewers, async walkthroughs |
| Fullscreen (F) | Canvas fills the screen with the controls bar on top, flow tabs at the bottom, and the side panel as an overlay; Escape or the same button exits | Workshop presenters |
Node click vs drag. A 5px movement threshold distinguishes a click (jump to step) from a drag (reposition). On touch screens nodes are tap-to-jump only, so swiping over a node still scrolls the page.
Node click is the easiest to miss when modifying the skill. Three things must be in place:
cursor: pointer on .node (visual affordance — "this is clickable"):hover state that reveals the role color (confirms interactivity)findIndex on the current flow's steps and jumps thereIf a node isn't part of the current flow (.dimmed state), clicking it shakes the node instead of doing nothing. Silent ignore is bad UX — the viewer thinks the page is broken.
Keyboard accessibility: nodes have tabIndex=0, Enter/Space triggers the same action as click, Shift+Arrows moves the node one grid cell. Step changes are announced through a live region. Single-key shortcuts can be switched off via the "shortcuts on" link under the tabs (WCAG 2.1.4).
Don't break this when adding features. It's the only way for a viewer to think "wait, where is the LLM used?" and find out instantly. Without it, they'd have to step through all 8 steps just to discover one node's role.
Payloads in the side panel are monospace + minimal syntax highlight. Keep them realistic but trimmed — show the shape, omit boring fields:
{
payloadOffline:
`POST /ask
{
"query": "Ile kosztuje parking?",
"limit": 3,
"temperature": 0.7
}`
// avoid: full HTTP headers, User-Agent, 50-line bodies — show only the shape
}
Use 4-space indent, no tabs. Use // comments for inline annotations.
If a step is the same in both modes, use payload (single key). If they differ, use payloadOffline + payloadOnline (or whatever the mode names are: payload + capitalized mode key, so mode prod → payloadProd). The mode-specific key wins when both are present — handy for "generic payload, one mode overrides it". Same rule for chips / chipsOffline. An object instead of a string is pretty-printed as JSON.
desc accepts inline HTML only: <em>, <strong>, <code>, <kbd>, <br>, <a href="https://…">. Everything else is stripped at render time (block tags unwrap, scripts/iframes are dropped) — keep descriptions to a sentence or three.
Chips below the payload are short metadata labels. Two semantic types auto-style themselves:
/\d+\s*(?:ms|s|min)\b/) — gets a stopwatch icon, e.g. "~150ms", "5-30s", "timeout 120s"/dim|×|loaded|rules|count/) — gets a database icon, e.g. "768 dim", "38 loaded", "×N""COSINE", "baseline", "idempotent", "UUID5"Maximum 3 chips per step. They're hints, not specifications.
| Thing | Convention | Example |
|---|---|---|
| Flow key in JS | snake_case | ask, ask_direct, ingest_text |
| Flow display name | "Title Case (METHOD /route)" | "RAG Query (POST /ask)" |
Node data-id | snake_case, short | orch, vector, embed |
| Mode key | snake_case, descriptive | offline/online, dev/prod, v1/v2 |
| Step title | Polish or English, depending on workshop language. Consistent within one file. | "Pytanie z UI" or "Question from UI" |
Three strings kill the whole diagram. Everything in flows lives inside one <script> block, so in any desc, title, payload or chip:
</script> closes the block early — write <\/script> (</script> works only in desc; elsewhere it shows literally).<!-- with a <script anywhere after it keeps the real </script> from closing the block — write <\!--.${…} in a backtick payload runs as JavaScript (crash, or silently wrong text). Write \${ (e.g. \${{ secrets.TOKEN }}) and \` for a backtick.The page lints itself (browser console, window.archValidate(), or screenshot.js): unknown node ids, tab/flow mismatches, unknown onlyMode / data-modes values, missing title/color, leftover placeholders, and — in a grounded diagram — uncited nodes and steps. spec.js lint checks the same without a browser, plus layout (same-row spacing, wire crossings, node budget). A clean lint is part of "done".
Content Security Policy. The template ships a CSP <meta> that allows only inline script/style and Google Fonts. If a user asks for an external image, script, or font, extend the matching directive (or they'll see a blocked request in the console).
Source node looks dead. If a step's source node renders dimmed instead of active-from, you regressed the participant logic — see "Visual states".
Wire crossings. Caused by node placement, not code — swap node positions to fix. (Wires bend to the right of their direction of travel, so a request and its response sit on opposite sides; repeats between one pair get wider lanes. That helps but won't fix a bad layout.)
Too many flows. More than 6 flows clutters the tab bar. If you have 8+, group them: one diagram per group (e.g. "read flows" vs "write flows" as two separate HTML files).
Modes that aren't really modes. If the toggle changes the entire topology (different services, different protocols), it's not a mode — it's a second system. Build two HTML files.
Static screenshots beat live diagrams sometimes. If the diagram will end up in a PDF report, a slide deck, or a printed handout, this skill is the wrong choice — produce a static diagram instead. This skill is for interactive consumption in a browser.
Forgetting the .md. The HTML is the showpiece, but the .md is what people read on GitHub, paste into Slack, and grep for endpoint names. Always generate both.
Polish vs English. Match the workshop language. Bilingual settings typically use Polish for internal workshops and English for client deliverables. Default to the language of the request; ask only if it's genuinely ambiguous.
If a user asks for something the template doesn't support, here's the difficulty ranking:
| Request | Difficulty | Where to edit |
|---|---|---|
| New node | trivial | Add .node div, position via left/top % |
| New flow | trivial | Add entry to flows object |
| Different brand colors | small | Edit CSS variables in :root (see assets/css-tokens.css) |
| Light theme | built-in | Click the moon/sun button or press T. To make light the default, add class="light" to <body>. |
| Drag-and-drop nodes | built-in | Already supported — drag any node (mouse/pen) or Shift+Arrow a focused one; positions snap to a 48px lattice; only moved nodes are saved in localStorage (keyed by page title + node-id set — give each diagram a unique title). |
| Fullscreen mode | built-in | Press F or click the expand icon. Controls bar and flow tabs stay reachable, the side panel too above ~1140px (narrower: a one-line step summary); Escape or the button exits. |
| Self-step (internal work) | built-in | A step with from === to draws a loop on the node (above it; below it on the top row). |
| Three or more modes | small | Add a button to .modepick; add payload<Mode> / chips<Mode> / data-*-<mode> fields. O cycles through all modes automatically. Mode colors follow button order, not keys: 1st blue, 2nd violet, 3rd+ accent. |
| Layout reset | built-in | Press R or click the ↻ button (appears after any drag). |
| Progress bar | built-in | Thin bar below player shows step position in current flow. |
| Flow note line | built-in | Set note on a flow (and onlineNote on an onlyMode flow); it renders under the player. |
| Reduced motion | built-in | Honors prefers-reduced-motion: the flying packet is hidden and transitions collapse. |
| Shareable link to a step | built-in | The URL hash keeps flow, mode, step (1-based); invalid values are ignored. |
| Evidence / provenance | built-in | SOURCE + data-src / src (Step 1 → grounding protocol). Assumed parts render dashed. |
| Parallel steps (two simultaneous wires) | not yet | Not supported by the player (the lint rejects parallel). Write consecutive steps and say "in parallel" in desc. |
| Branching flows (if-then-else) | hard | Currently linear. Fork into separate flows (e.g. "cache hit" / "cache miss"). |
Don't promise features the template doesn't support without flagging the work involved.
When the user gives feedback like "the diagram is too cramped" or "step 5 is confusing":
tech/port text; never below 24% between nodes in a row. More than ~12 nodes → split the diagram..legend font-size and gap.assets/css-tokens.css (opens in a new tab)assets/template.html (opens in a new tab)examples/agentic-tool-calling.json (opens in a new tab)examples/auth-oauth2.json (opens in a new tab)examples/cicd-pipeline.json (opens in a new tab)examples/event-driven.json (opens in a new tab)examples/rag-eskadra-bielik.json (opens in a new tab)mcp/server.js (opens in a new tab)mcp/viewer.html (opens in a new tab)references/component-library.md (opens in a new tab)references/flow-design-patterns.md (opens in a new tab)references/screenshot.js (opens in a new tab)references/spec.js (opens in a new tab)references/validation.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub konraddzbik/architecture-diagram-skill --plugin architecture-diagramOther plugins' skills for the same job