/diagramming:architecture-diagram-reactfrom diagramming
Generates inline SVG architecture diagrams as fenced markdown blocks for embedding in React/Vite sites, with lucide-icon placeholders and no external scripts.
Ships in diagramming. 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.
This is the embedded counterpart to the architecture-diagram skill. The parent skill ships a self-contained .html file with its own toolbar, html2canvas/jsPDF CDN scripts, summary cards, and footer. This skill produces a leaner artifact suited for direct embedding inside a React-rendered markdown page: a fenced markdown block whose body is inline <svg> augmented with <lucide-icon> placeholders.
The runtime renderer lives in the consumer repo (see "Consumer contract" below). The React component provides the chrome (frame, FIG label, copy/save toolbar, slate-950 grid background, JetBrains Mono surface) — so the SVG you emit must contain only the diagram itself, not the chrome.
arch-diagram block"architecture-diagram skill when the user says "now put this on the site"If the user wants a shareable standalone artifact (Slack, PDF, slides), use the parent architecture-diagram skill instead.
design-system.md and label-placement.md. Every rule there still applies: semantic colors, JetBrains Mono sizes, halos, label-placement priority, 40 px minimum gaps, 100–200 px between bands. None of those rules are duplicated here.viewBox, component rects, arrows, halos, leader lines.<!-- fig: ... | title: ... | label: ... --> as the first line inside the fence.<lucide-icon> placeholders wherever a component box would benefit from a recognisable glyph (see "Lucide icon promotion" below).audit-labels.py works on raw SVG too; pipe the fenced-block body to it.arch-diagram.```arch-diagram
<!-- fig: 2.1 | title: REQUEST FLOW | label: SYSTEM -->
<svg viewBox="0 0 1000 400" xmlns="http://www.w3.org/2000/svg">
...everything from <defs> through every <rect>, <path>, <text>, <lucide-icon>...
</svg>
```
arch-diagram — the React renderer keys off this exact tag.key: value. Recognised keys:
fig — appears as FIG {fig} in the chrome (e.g., 2.1, A, 3)title — uppercase title shown after FIG x //label — small right-aligned tag (e.g., SYSTEM, CONTROL_PLANE, AUTH)A / ARCHITECTURE / ARCH_V2.<svg> (after the metadata comment). The renderer's auto-detection looks for <svg after the comment. If the body doesn't begin with <svg, the renderer treats it as ordinary code.When converting output of the parent skill to embedded form, remove:
| Strip | Why |
|---|---|
<!DOCTYPE html>, <html>, <head>, <body> | Renderer is inside a React tree |
Google Fonts <link> | Surface already loads JetBrains Mono via font-family |
html2canvas + jspdf <script> tags | Renderer provides Copy/Save via React |
.toolbar, .toolbar-toggle, .toolbar-actions markup + CSS | Chrome is the React component's job |
.container, .header, .header-row, .pulse-dot, .subtitle | Chrome — frame + FIG label come from React |
.summary-cards, .card, footer divs | Embedded diagrams have no info-cards / footer |
copyAsImage(), downloadPNG(), downloadPDF() scripts | Replaced by React Copy/Save |
@media print { ... } | Not applicable inside an SPA page |
Page-level body { padding: 2rem; ... } styles | Renderer controls outer padding |
Keep:
<svg> block: <defs>, <pattern>, <marker>, all <rect>/<path>/<line>/<polyline>/<text> elements, arrow leader lines, halo styles inlined as SVG attributes.svg text { paint-order: stroke fill; ... } selector. Each <text> that needs a halo must carry its own paint-order="stroke fill", stroke="rgba(2, 6, 23, 0.75)", stroke-width="1". The renderer adds nothing to text — what you emit is what renders.Per the parent skill's rule #3, every floating <text> (one that does not live inside a coloured component box — titles, edge labels, cluster names, annotations) needs a backing chip rect drawn immediately before the text:
<rect x="..." y="..." width="..." height="..." rx="3"
fill="rgba(15,23,42,0.92)" stroke="rgba(148,163,184,0.75)" stroke-width="1"/>
<text x="..." y="..." font-size="..." ...
paint-order="stroke fill" stroke="rgba(2,6,23,0.65)" stroke-width="3">
LABEL
</text>
Exactly one chip per label. Do not nest chips. Do not draw a slightly-larger outer chip around the canonical one — the result is a double-bordered pill that reads as a bug.
Two patterns produce the double-border bug:
add_chip_rects.py) re-runs and adds another because its idempotency check missed yours. Mitigation: the post-pass now scans the 240 characters before each <text> for fill="rgba(15,23,42,0.92)" and skips if found. Authors must use the canonical fill value verbatim — no alpha variants, no off-by-one rgba.font-size and font-weight="700", not a second border.The chip is for floating labels only. Text already living inside a coloured component box (e.g. a service name inside a cyan-stroked rect) inherits the box as its background — no chip needed and adding one looks doubly busy.
Replace bespoke icon <path> blocks with <lucide-icon> tags. The React renderer expands these at runtime via lucide-react, so authoring stays compact and icons match the rest of the site.
Syntax:
<lucide-icon name="database" x="56" y="56" size="20" color="#a78bfa" stroke-width="2"/>
name — required; one of the supported names below. Unknown names are silently stripped at render time, so prefer the parent skill's bespoke SVG over an unsupported guess.x, y — top-left of the icon's 24×24 box in SVG user units (default 0).size — pixel size of the bounding box (default 24; expansion scales by size/24).color — stroke color (default currentColor); use the stroke colour of the surrounding component box from the semantic palette.stroke-width — default 2. Use 1.5 when the icon sits inside a small (≤60 px) component box; default for ≥80 px.Supported names (32 total, from client/src/components/markdown/archDiagramIcons.ts in the consumer repo):
activity, bell, box, boxes, cloud, code, cog, container, cpu, database, file-code, git-branch, globe, hard-drive, key, key-round, layers, lock, mail, message-square, monitor, network, search, server, shield, smartphone, terminal, user, users, webhook, workflow, zap.
Recommended mapping (extend the parent skill's semantic colors with semantic glyphs):
| Component type | Stroke color | Recommended icon |
|---|---|---|
| Frontend / web client | #22d3ee cyan | monitor, smartphone, globe |
| Backend / service | #34d399 emerald | server, cog, workflow, box, container |
| Database / store | #a78bfa violet | database, hard-drive, layers |
| Cloud edge / LB / CDN | #fbbf24 amber | cloud, network, globe |
| Security / IDP / KMS | #fb7185 rose | shield, lock, key, key-round |
| Message bus / events | #fb923c orange | zap, webhook, activity |
| External / generic | #94a3b8 slate | box, boxes, mail, bell |
| Compute / worker | #34d399 emerald | cpu, terminal, code, file-code |
| Search / index | #a78bfa violet | search |
| Identity / user | #94a3b8 slate | user, users |
| VCS / pipeline | #34d399 emerald | git-branch, workflow |
If no listed icon fits, don't invent one — author the path inline as the parent skill does. Adding a name to the consumer requires editing archDiagramIcons.ts (the icon must be imported from lucide-react).
When an icon sits in a box's left padding, the label inside that box must not centre on the full box width — the text glyphs will slide under the icon and intersect it. This bug is visually obvious and unprofessional; it has been reported on shipped diagrams more than once.
Mandatory formulas — compute every time, do not eyeball coordinates:
icon_left = box_x + 16 # 16 px left padding
icon_right = icon_left + size # size is the <lucide-icon> `size` attr
box_right = box_x + box_w
Pattern A — right-shifted centre (use for short labels):
text_anchor = "middle"
text_x = (icon_right + 8 + box_right) / 2 # midpoint of space RIGHT of icon
Pattern B — left-aligned (use for long or multi-line labels):
text_anchor = "start"
text_x = icon_right + 8 # 8 px gap between icon and first glyph
The wrong pattern that produces visible icon/text intersection — DO NOT EMIT:
text_x = box_cx # centres across whole box, overlays the icon
text_anchor = "middle"
Minimum reserved space on the icon side: size + 16 px. For a 20 px icon that's a 36 px guard. Mirror for right-side icons. Vertical guard for top-positioned icons is size + 8 px.
Placement example — correct math applied (180×80 box, 20 px icon):
<!-- Box: x=40, w=180 → box_right=220. Icon: x=56..76.
text_x = (76 + 8 + 220) / 2 = 152 (not 130 = box_cx) -->
<rect x="40" y="40" width="180" height="80" rx="6"
fill="rgba(6,78,59,0.4)" stroke="#34d399" stroke-width="1.5"/>
<lucide-icon name="server" x="56" y="56" size="20" color="#34d399"/>
<text x="152" y="76" fill="white" font-size="12" font-weight="600"
text-anchor="middle">API GATEWAY</text>
<text x="152" y="92" fill="#94a3b8" font-size="9" text-anchor="middle">
AUTHN / RATE-LIMIT
</text>
For small (≤80 px wide) boxes the right-of-icon space is too narrow for any label — drop the icon or stack vertically: icon at (box_cx − size/2, box_y + 10), label at (box_cx, box_y + size + 22) with text-anchor="middle".
The renderer in the consumer repo (this site) lives at:
client/src/components/markdown/ArchDiagram.tsx — frame, toolbar, sanitization, render.client/src/components/markdown/archDiagramIcons.ts — <lucide-icon> expansion + supported-name allowlist.client/src/components/markdown/CodeBlock.tsx — trigger: language-arch-diagram className or auto-detected leading <svg> (after optional metadata comment).The renderer:
<!-- ... --> metadata comment off the front.expandLucideIcons() over the body, replacing <lucide-icon ... /> with positioned/scaled <g> groups containing real Lucide paths.ZOOM / COPY_SVG / SAVE toolbar.Every rendered diagram has a ZOOM button in its toolbar. Clicking it opens a fullscreen modal overlay:
width: 100%; height: auto, so authors can rely on the intrinsic viewBox aspect ratio — no special "zoom mode" markup needed in the SVG itself.COPY_SVG and SAVE controls plus an explicit CLOSE button. ESC and clicking the backdrop also dismiss.Authoring implications:
viewBox aspect ratio you actually want. The zoom layer scales the SVG to fill width while preserving aspect; ultra-tall or ultra-wide viewBoxes will read poorly at zoom too.<text> that overlaps anything must carry its own paint-order="stroke fill", stroke="rgba(2,6,23,0.65)", stroke-width="3".What this means for what you emit:
<script> — sanitizer strips it.<foreignObject> — both unsupported in html2canvas (parent skill rule) and stripped by the SVG profile.style="...".<defs>, <pattern>, <marker>, <linearGradient>, <radialGradient>, <clipPath>, <mask> — all in the SVG profile allowlist.Run the parent skill's audit script on the fenced-block body. Extract everything from <svg to </svg> and feed it in:
sed -n '/^<svg/,/<\/svg>/p' diagram-body.txt > /tmp/diagram.svg
python3 ${CLAUDE_PLUGIN_ROOT}/skills/architecture-diagram/resources/audit-labels.py /tmp/diagram.svg
If the audit flags labels for being far from the arrow midpoint without a leader line, fix them per the parent skill's algorithm.
<html> document — only the fenced block.<script>, <link>, <style> outside <defs> — sanitizer strips them anyway.<text> must carry its own halo attrs where needed.<lucide-icon> names — they silently disappear.<foreignObject> for rich labels — text + halo is the supported path.```arch-diagram
<!-- fig: 1 | title: HELLO WORLD | label: DEMO -->
<svg viewBox="0 0 600 200" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="ah" markerWidth="10" markerHeight="7" refX="9" refY="3.5" orient="auto">
<polygon points="0 0, 10 3.5, 0 7" fill="#64748b"/>
</marker>
</defs>
<!-- Box 1: x=40..220, icon 56..76 → text_x = (76+8+220)/2 = 152 -->
<rect x="40" y="60" width="180" height="80" rx="6"
fill="rgba(8,51,68,0.4)" stroke="#22d3ee" stroke-width="1.5"/>
<lucide-icon name="monitor" x="56" y="76" size="20" color="#22d3ee"/>
<text x="152" y="96" fill="white" font-size="12" font-weight="600"
text-anchor="middle"
paint-order="stroke fill" stroke="rgba(2, 6, 23, 0.75)" stroke-width="1">CLIENT</text>
<line x1="220" y1="100" x2="380" y2="100"
stroke="#64748b" stroke-width="1.5" marker-end="url(#ah)"/>
<text x="300" y="92" fill="#cbd5e1" font-size="9" text-anchor="middle"
paint-order="stroke fill" stroke="rgba(2, 6, 23, 0.75)" stroke-width="1">HTTPS</text>
<!-- Box 2: x=380..560, icon 396..416 → text_x = (416+8+560)/2 = 492 -->
<rect x="380" y="60" width="180" height="80" rx="6"
fill="rgba(6,78,59,0.4)" stroke="#34d399" stroke-width="1.5"/>
<lucide-icon name="server" x="396" y="76" size="20" color="#34d399"/>
<text x="492" y="96" fill="white" font-size="12" font-weight="600"
text-anchor="middle"
paint-order="stroke fill" stroke="rgba(2, 6, 23, 0.75)" stroke-width="1">API</text>
</svg>
```
This skill is the React/inline-SVG embedding companion to the architecture-diagram skill. All design-system rules — colors, fonts, halos, label placement, spacing — come from the parent skill; this skill only documents the format conversion and consumer contract.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub sergio-bershadsky/ai --plugin diagramming4 skills in this plugin
/architecture-diagramUse when the user asks for a system, infrastructure, cloud, security, network topology, or architecture diagram. Produces polished dark-themed self-contained HTML+SVG files with mathematically-correct label placement, clean-background priority, text halos, and leader lines./mindmapUse when the user asks for a mindmap, mind-map, concept map, idea tree, brainstorm diagram, or any radial topic explosion ("draw a mindmap of X", "map out the themes around Y", "mindmap the differentiators of Z"). Produces dark-themed self-contained HTML+SVG with a central root, branches radiating in all directions, halo text, Q-curved Bezier connectors, and geometry-audit gating./sequence-diagramUse when the user asks for a sequence diagram, ladder diagram, message-exchange diagram, or any temporal flow showing who talks to whom in order ("draw the OAuth flow", "show the request lifecycle", "diagram the protocol over time", "sequence diagram for X"). Produces dark-themed self-contained SVG with actor lifelines, sync/async/return messages, self-loops, halo text, and a geometry-audit gate that knows about lifelines.Other plugins' skills for the same job