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 namediagram
Version1.1.0
Default activeYes — always injected, no /skill load needed
Output formatsInline SVG, Mermaid code blocks, diagram-html widgets
TriggersAny request that benefits from visual explanation: flowcharts, comparisons, timelines, charts, maps, simulations, mockups
Reference modulessvg-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:

Complexity Budget

Hard limits enforced on every diagram to prevent visual noise:

ConstraintLimitOverflow strategy
Box subtitles5 words maxMove detail to sendPrompt() or prose
Color ramps per diagram2 ramps maxConsolidate categories
Horizontal row (680px)4 boxes maxShrink or wrap to 2 rows
Nodes per diagram6 maxSplit into overview + detail diagrams
Consecutive visual blocksNeverAlways 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 intentTypeOutput
"how does X work"Illustrative SVGSpatial metaphor, cross-section, physical layout
"architecture of X" (system context)Structural SVGContainers, regions, nesting
"steps of X" (generic process)Flowchart SVG or Mermaid flowchartTop-down boxes + arrows
"compare A vs B"Comparison SVGSide-by-side columns

Mermaid types

User intentMermaid syntaxStatus
DB schema / entity relationshiperDiagramStable
Class diagram / OOP structureclassDiagramStable
State machine / lifecyclestateDiagram-v2Stable
Sequence / call order / API flowsequenceDiagramStable
Timeline / roadmap / historytimelineStable
Mind map / brainstormmindmapStable
Git branching / release historygitGraphStable
Priority quadrant / 2x2 matrixquadrantChartStable
Gantt / project scheduleganttStable
User journey mapjourneyStable
Pie breakdownpieStable
Radar / spider / skill profileradar-betaBeta (v11.6+)
Kanban boardkanbanBeta (v11.12+)
Cloud / infra architecturearchitecture-betaBeta
Hierarchy / proportional sizetreemap-betaBeta
Free-form block layoutblock-betaBeta

Interactive HTML widget types

User intentOutputLibraries
"show data / chart"diagram-html widgetChart.js, D3, ECharts
"simulate / interactive"diagram-html widgetMatter.js, Canvas, sliders
"interactive map"diagram-html widgetLeaflet + OpenStreetMap
"static choropleth"diagram-html widgetD3 + TopoJSON
Default behavior: "how does X work?" defaults to illustrative SVG, not a flowchart. When the diagram type is in the Mermaid table above, Mermaid is used — the skill does not hand-roll SVG when classDiagram/sequenceDiagram/stateDiagram already exists.

Mermaid Gotchas

Important caveats when working with Mermaid diagram types:

Do NOT use C4 diagrams (C4Context, C4Container, etc.) — theme tokens are not applied in dark mode, making text unreadable. Use the substitution table below instead.
C4 typeSubstitute
C4 System ContextStructural SVG (custom) or Mermaid flowchart with subgraphs
C4 ContainerMermaid architecture-beta
C4 ComponentMermaid flowchart with subgraph grouping
C4 DynamicMermaid sequenceDiagram
C4 DeploymentMermaid architecture-beta

Additional notes:

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

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>
```
Style-first, script-last: For 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.

Do NOT

Save to .svg / .html / .png file (Write tool, cat >, fs.writeFile)

Do

Paste raw block directly into the reply text

Do NOT

Wrap diagram-html in <iframe> / <html> / <body> / <head>

Do

Start at <div> / <canvas> / <style> — host injects the shell

Do NOT

Send via /api/channel/send or Telegram/Discord (not an attachment)

Do

Let the renderer handle it; diagrams are response text

Do NOT

Reference an external image URL and call it a diagram

Do

Output the SVG/widget code itself

File saves: If the user says "save this diagram" or "download it", still output it inline first so they see it rendered. Only write a file to disk if they explicitly request a file — and even then, the inline version is the canonical delivery.

SVG Design System

Design forbidden list

Quality rules enforced on all SVG output (separate from the security restrictions below):

Security restrictions (inline SVG)

These elements and attributes are stripped by DOMPurify. Never use them in inline <svg>:

Forbidden element / attributeReasonAlternative
<foreignObject>Embeds HTML in SVG (XSS vector)Use native SVG elements
<animate>, <set>, <animateTransform>, <animateMotion>Animation XSS vectorsStatic SVG only
Nested <svg>Parsing issuesUse <g> groups
xlink:hrefExternal URL injectionUse href="#fragment" on <use> only
All on* event handlersStripped by DOMPurifyNot available in inline SVG
Note: 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.

RampCSS prefixPreferred use
Cyan.c-cyanGeneral categories (preferred for neutral info)
Pink.c-pinkGeneral categories, highlights
Purple.c-purpleGeneral categories, grouping
Orange.c-orangeGeneral categories, accent
Slate.c-slateNeutral, disabled, structural (start/end nodes)
Blue.c-blueInformational (semantic — use only for "info")
Green.c-greenSuccess, positive (semantic)
Amber.c-amberWarning, attention (semantic)
Red.c-redError, negative (semantic)
Color assignment rule: Color encodes meaning, not sequence. Do not cycle through colors like a rainbow. Group by category — all nodes of the same type share one color. Prefer cyan/pink/purple/orange for general categories. Reserve blue/green/amber/red for genuinely semantic concepts.

Layout patterns

PatternLayoutSize
FlowchartTop-to-bottom680 x auto
ComparisonSide-by-side columns680 x auto
TimelineHorizontal with markers680 x auto
Org chartHierarchical tree680 x auto

Theme Integration

CSS variable mapping

The cli-jaw host exposes these CSS variables for diagram theming:

VariableUse
--bgPage background
--surfaceCard/surface background
--textPrimary text
--text-dimMuted/secondary text
--borderDefault border
--accentAccent color
--font-uiUI font family
--font-monoCode font family
--radius-md8px border radius
--radius-lg12px border radius

Theme detection by format

FormatTheme method
Inline SVGCSS classes adapt to host theme automatically
diagram-html iframe (JS)window.__jawTheme.isDark (boolean)
diagram-html iframe (CSS values)window.__jawTokens['--bg'], ['--text'], etc.
MermaidAutomatic via cli-jaw themeVariables
Never use 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:

ModuleFileCoverage
SVG componentsreference/svg-components.mdSVG primitives, viewBox checklist, layout templates
Color palettereference/color-palette.mdFull color values (light + dark), assignment rules
Chartsreference/module-chart.mdChart.js + D3 + ECharts 6 — bar, line, pie, choropleth, heatmap, sankey, radar, treemap, gauge, funnel, candlestick, chord
Widgetsreference/module-widget.mdPhysics (Matter.js), math graphs (Math.js), 3D (Three.js), creative coding (p5.js), audio (Tone.js), mini-games
Interactivereference/module-interactive.mdSliders, selects, segmented buttons, toggles, play/pause/reset, debouncing, sendPrompt, keyboard accessibility
Mapsreference/module-map.mdLeaflet interactive maps — OpenStreetMap tiles, markers, popups, dark mode
UI Mockupsreference/module-mockup.mdUI mockup patterns
Artreference/module-art.mdDecorative SVG patterns

Usage Examples

~해주 example 1 — Architecture diagram
"마이크로서비스 아키텍처 그려줄" # 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.
~해주 example 2 — Database ER diagram
"이 DB 스키마 ER 다이어그램으로 보여주" # Triggers: Mermaid erDiagram # Outputs a ```mermaid block with erDiagram syntax. # Theme adapts automatically — no manual color config needed.
~해주 example 3 — Interactive data chart
"월별 매출 데이터 차트로 그려주" # Triggers: diagram-html + Chart.js # Produces a ```diagram-html block with Chart.js bar/line chart. # Uses window.__jawTheme.isDark for dark mode colors.
~해주 example 4 — API sequence flow
"로그인 API 흐름 시켐스 다이어그램으로 그려주" # Triggers: Mermaid sequenceDiagram # Client → Auth Server → API → DB — full request/response flow. # Mermaid chosen over SVG because sequenceDiagram natively supports this.
~해주 example 5 — Comparison diagram
"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:

QuestionAnswerFormat
Does Mermaid have a native syntax for this?YesUse ```mermaid
Is it a static layout/architecture/comparison?YesUse inline <svg>
Does it need interactivity, data viz, or JS libs?YesUse ```diagram-html
Is it a C4 diagram?YesSubstitute per C4 mapping table above
Is it a "how does X work" question?YesIllustrative SVG (not flowchart)