Diagrams Default Active v1.1.0
SVG diagrams, Mermaid charts, and interactive visualizations — rendered inline in the chat UI. From architecture overviews to interactive data dashboards, this skill turns any visual request into a rendered output directly in the conversation.
| Skill name | diagram |
| Version | 1.1.0 |
| Default active | Yes — always injected, no /skill load needed |
| Output formats | Inline SVG, Mermaid code blocks, diagram-html widgets |
| Triggers | Any request that benefits from visual explanation: flowcharts, comparisons, timelines, charts, maps, simulations, mockups |
| Reference modules | svg-components, color-palette, module-chart, module-widget, module-interactive, module-map, module-mockup, module-art |
Design Principles
Every diagram produced by this skill follows four core principles:
- Flat — No gradients, shadows, blur, glow, or decorative effects. Clean flat surfaces only.
- Compact — Show the essential inline. Explain the rest in response text.
- Theme-aware — Every color works in both light and dark mode. CSS classes for SVG,
window.__jawTokensfor canvas/JS. - Text in response, visuals in tool — All explanatory prose goes outside the diagram. Never put paragraphs of explanation inside the SVG or widget HTML.
Complexity Budget
Hard limits enforced on every diagram to prevent visual noise:
| Constraint | Limit | Overflow strategy |
|---|---|---|
| Box subtitles | 5 words max | Move detail to sendPrompt() or prose |
| Color ramps per diagram | 2 ramps max | Consolidate categories |
| Horizontal row (680px) | 4 boxes max | Shrink or wrap to 2 rows |
| Nodes per diagram | 6 max | Split into overview + detail diagrams |
| Consecutive visual blocks | Never | Always add prose between SVG/widget blocks |
Diagram Type Selection
The skill routes on the verb, not the noun. The same subject can produce different diagram types depending on what the user asks. When a type maps cleanly to native Mermaid syntax, Mermaid is preferred over hand-rolled SVG.
SVG types
| User intent | Type | Output |
|---|---|---|
| "how does X work" | Illustrative SVG | Spatial metaphor, cross-section, physical layout |
| "architecture of X" (system context) | Structural SVG | Containers, regions, nesting |
| "steps of X" (generic process) | Flowchart SVG or Mermaid flowchart | Top-down boxes + arrows |
| "compare A vs B" | Comparison SVG | Side-by-side columns |
Mermaid types
| User intent | Mermaid syntax | Status |
|---|---|---|
| DB schema / entity relationship | erDiagram | Stable |
| Class diagram / OOP structure | classDiagram | Stable |
| State machine / lifecycle | stateDiagram-v2 | Stable |
| Sequence / call order / API flow | sequenceDiagram | Stable |
| Timeline / roadmap / history | timeline | Stable |
| Mind map / brainstorm | mindmap | Stable |
| Git branching / release history | gitGraph | Stable |
| Priority quadrant / 2x2 matrix | quadrantChart | Stable |
| Gantt / project schedule | gantt | Stable |
| User journey map | journey | Stable |
| Pie breakdown | pie | Stable |
| Radar / spider / skill profile | radar-beta | Beta (v11.6+) |
| Kanban board | kanban | Beta (v11.12+) |
| Cloud / infra architecture | architecture-beta | Beta |
| Hierarchy / proportional size | treemap-beta | Beta |
| Free-form block layout | block-beta | Beta |
Interactive HTML widget types
| User intent | Output | Libraries |
|---|---|---|
| "show data / chart" | diagram-html widget | Chart.js, D3, ECharts |
| "simulate / interactive" | diagram-html widget | Matter.js, Canvas, sliders |
| "interactive map" | diagram-html widget | Leaflet + OpenStreetMap |
| "static choropleth" | diagram-html widget | D3 + TopoJSON |
classDiagram/sequenceDiagram/stateDiagram already exists.Mermaid Gotchas
Important caveats when working with Mermaid diagram types:
C4Context, C4Container, etc.) — theme tokens are not applied in dark mode, making text unreadable. Use the substitution table below instead.| C4 type | Substitute |
|---|---|
| C4 System Context | Structural SVG (custom) or Mermaid flowchart with subgraphs |
| C4 Container | Mermaid architecture-beta |
| C4 Component | Mermaid flowchart with subgraph grouping |
| C4 Dynamic | Mermaid sequenceDiagram |
| C4 Deployment | Mermaid architecture-beta |
Additional notes:
sankey-beta/xychart-betabreak at narrow chat widths. Preferdiagram-html+ ECharts sankey or Chart.js for XY charts.radar-betarequires the-betasuffix (Mermaid v11.6+). Other beta types:treemap-beta,block-beta,architecture-beta,packet-beta,kanban.- All stable Mermaid types inherit the host dark/light theme automatically. Do NOT set explicit colors in
%%{init: ...}%%unless overriding for semantic reasons.
Output Formats
1. Inline SVG (static diagrams)
Raw <svg> markup output directly in the response. The chat UI renders it inline.
<svg viewBox="0 0 680 {height}" xmlns="http://www.w3.org/2000/svg"
role="img" aria-labelledby="title-id desc-id">
<title id="title-id">Diagram Title</title>
<desc id="desc-id">Brief description for screen readers</desc>
<!-- shapes, text, paths -->
</svg>
Inline SVG rules
- viewBox width MUST be 680 (matches container width — never change this)
- Height varies by content: last element bottom + 40px padding
- Every SVG MUST have
role="img"+<title>+<desc> - Use CSS classes from the design system (
.node,.connector,.label,.label-start) .labelforcestext-anchor: middle(centered only); use.label-startfor left-aligned text- Colors: use CSS classes, not inline
fill/stroke - Font-family inherited from host — do NOT set explicit fonts
2. Mermaid (structured diagrams)
Standard ```mermaid code blocks. The existing renderer handles these automatically.
```mermaid
sequenceDiagram
participant A as Client
participant B as Server
A->>B: GET /api/data
B-->>A: 200 OK (JSON)
```
3. Interactive HTML widget (charts, controls, simulations)
Wrapped in ```diagram-html code blocks. Rendered inside a sandboxed iframe created by the host.
```diagram-html
<div id="chart-wrapper" style="position: relative; width: 100%; height: 300px;">
<canvas id="myChart" role="img" aria-label="Chart description">
Fallback text
</canvas>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.js"
onerror="document.body.innerHTML='<p>Chart library failed to load.</p>'">
</script>
<script>
const isDark = window.__jawTheme?.isDark ?? true;
// ... Chart.js code
</script>
```
diagram-html widgets, always put <style> and <link> tags first, then HTML structure, then <script> tags last. This ensures visual content appears before scripts execute during streaming.Delivery Mechanism
All three formats — inline SVG, ```mermaid, ```diagram-html — are rendered inline in the chat response. The jaw frontend parses the reply text and mounts them automatically. diagram-html goes into a sandboxed <iframe> that the host creates; the skill does not create the iframe.
Save to .svg / .html / .png file (Write tool, cat >, fs.writeFile)
Paste raw block directly into the reply text
Wrap diagram-html in <iframe> / <html> / <body> / <head>
Start at <div> / <canvas> / <style> — host injects the shell
Send via /api/channel/send or Telegram/Discord (not an attachment)
Let the renderer handle it; diagrams are response text
Reference an external image URL and call it a diagram
Output the SVG/widget code itself
SVG Design System
Design forbidden list
Quality rules enforced on all SVG output (separate from the security restrictions below):
- No gradients, drop shadows, blur, glow, or neon effects
- No emoji — use CSS shapes or SVG paths
- No decorative step numbers or oversized headings
- No icons or illustrations inside flowchart boxes — text only
- No rotated text
- No dark/colored backgrounds on outer containers (transparent only — host provides bg)
- Stroke width: 0.5px for borders and edges (not 1px or 2px)
- Font weights: 400 (regular) and 500 (bold) only — never 600 or 700
- Font sizes: 14px (node labels) and 12px (subtitles/arrow labels) only
- Sentence case always — never Title Case or ALL CAPS
Security restrictions (inline SVG)
These elements and attributes are stripped by DOMPurify. Never use them in inline <svg>:
| Forbidden element / attribute | Reason | Alternative |
|---|---|---|
<foreignObject> | Embeds HTML in SVG (XSS vector) | Use native SVG elements |
<animate>, <set>, <animateTransform>, <animateMotion> | Animation XSS vectors | Static SVG only |
Nested <svg> | Parsing issues | Use <g> groups |
xlink:href | External URL injection | Use href="#fragment" on <use> only |
All on* event handlers | Stripped by DOMPurify | Not available in inline SVG |
diagram-html content runs inside a sandboxed iframe where <script>, on* handlers, and CDN imports ARE allowed. The restrictions above apply only to inline SVG rendered in the main document.Color ramps (9 semantic colors)
Each ramp has 3 shades: fill (background), stroke (border), and text (label). Always use CSS class names, not inline colors.
| Ramp | CSS prefix | Preferred use |
|---|---|---|
| Cyan | .c-cyan | General categories (preferred for neutral info) |
| Pink | .c-pink | General categories, highlights |
| Purple | .c-purple | General categories, grouping |
| Orange | .c-orange | General categories, accent |
| Slate | .c-slate | Neutral, disabled, structural (start/end nodes) |
| Blue | .c-blue | Informational (semantic — use only for "info") |
| Green | .c-green | Success, positive (semantic) |
| Amber | .c-amber | Warning, attention (semantic) |
| Red | .c-red | Error, negative (semantic) |
Layout patterns
| Pattern | Layout | Size |
|---|---|---|
| Flowchart | Top-to-bottom | 680 x auto |
| Comparison | Side-by-side columns | 680 x auto |
| Timeline | Horizontal with markers | 680 x auto |
| Org chart | Hierarchical tree | 680 x auto |
Theme Integration
CSS variable mapping
The cli-jaw host exposes these CSS variables for diagram theming:
| Variable | Use |
|---|---|
--bg | Page background |
--surface | Card/surface background |
--text | Primary text |
--text-dim | Muted/secondary text |
--border | Default border |
--accent | Accent color |
--font-ui | UI font family |
--font-mono | Code font family |
--radius-md | 8px border radius |
--radius-lg | 12px border radius |
Theme detection by format
| Format | Theme method |
|---|---|
| Inline SVG | CSS classes adapt to host theme automatically |
diagram-html iframe (JS) | window.__jawTheme.isDark (boolean) |
diagram-html iframe (CSS values) | window.__jawTokens['--bg'], ['--text'], etc. |
| Mermaid | Automatic via cli-jaw themeVariables |
matchMedia('prefers-color-scheme') in diagrams. The host controls the theme, not the OS setting.Reference Modules
The diagram skill loads additional reference files for specialized diagram types. These provide detailed patterns, library integration guides, and templates:
| Module | File | Coverage |
|---|---|---|
| SVG components | reference/svg-components.md | SVG primitives, viewBox checklist, layout templates |
| Color palette | reference/color-palette.md | Full color values (light + dark), assignment rules |
| Charts | reference/module-chart.md | Chart.js + D3 + ECharts 6 — bar, line, pie, choropleth, heatmap, sankey, radar, treemap, gauge, funnel, candlestick, chord |
| Widgets | reference/module-widget.md | Physics (Matter.js), math graphs (Math.js), 3D (Three.js), creative coding (p5.js), audio (Tone.js), mini-games |
| Interactive | reference/module-interactive.md | Sliders, selects, segmented buttons, toggles, play/pause/reset, debouncing, sendPrompt, keyboard accessibility |
| Maps | reference/module-map.md | Leaflet interactive maps — OpenStreetMap tiles, markers, popups, dark mode |
| UI Mockups | reference/module-mockup.md | UI mockup patterns |
| Art | reference/module-art.md | Decorative SVG patterns |
Usage Examples
"마이크로서비스 아키텍처 그려줄" # Triggers: Structural SVG — containers, regions, nesting
# The skill produces an inline SVG with service boxes, arrows, and grouping regions.
# No Mermaid C4 (dark mode issue) — uses custom structural SVG instead.
"이 DB 스키마 ER 다이어그램으로 보여주" # Triggers: Mermaid erDiagram
# Outputs a ```mermaid block with erDiagram syntax.
# Theme adapts automatically — no manual color config needed.
"월별 매출 데이터 차트로 그려주" # Triggers: diagram-html + Chart.js
# Produces a ```diagram-html block with Chart.js bar/line chart.
# Uses window.__jawTheme.isDark for dark mode colors.
"로그인 API 흐름 시켐스 다이어그램으로 그려주" # Triggers: Mermaid sequenceDiagram
# Client → Auth Server → API → DB — full request/response flow.
# Mermaid chosen over SVG because sequenceDiagram natively supports this.
"React vs Vue vs Svelte 비교해주" # Triggers: Comparison SVG (side-by-side columns)
# Produces an inline SVG with 3 columns, key attributes compared visually.
# Max 2 color ramps — one for category headers, one for highlights.
Quick Reference
Decision tree for choosing the right output format:
| Question | Answer | Format |
|---|---|---|
| Does Mermaid have a native syntax for this? | Yes | Use ```mermaid |
| Is it a static layout/architecture/comparison? | Yes | Use inline <svg> |
| Does it need interactivity, data viz, or JS libs? | Yes | Use ```diagram-html |
| Is it a C4 diagram? | Yes | Substitute per C4 mapping table above |
| Is it a "how does X work" question? | Yes | Illustrative SVG (not flowchart) |