diagram/SKILL.md
SVG diagrams, charts, and interactive visualizations for chat UI
npx skillsauth add lidge-jun/cli-jaw-skills diagramInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
window.__jawTokens for canvas/JS.sendPrompt() or prose — not the box.Route on the verb, not the noun. Same subject gets different diagrams. Prefer Mermaid when the diagram type maps cleanly to a native Mermaid syntax — it's cheaper than hand-rolling SVG.
| User says / 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 |
| "DB schema / entity relationship" | Mermaid | ```mermaid erDiagram |
| "class diagram / OOP structure" | Mermaid | ```mermaid classDiagram |
| "state machine / lifecycle" | Mermaid | ```mermaid stateDiagram-v2 |
| "sequence / call order / API flow" | Mermaid | ```mermaid sequenceDiagram |
| "timeline / roadmap / history" | Mermaid | ```mermaid timeline |
| "mind map / brainstorm / outline" | Mermaid | ```mermaid mindmap |
| "git branching / release history" | Mermaid | ```mermaid gitGraph |
| "2×2 matrix / priority quadrant" | Mermaid | ```mermaid quadrantChart |
| "radar / spider / skill profile" | Mermaid v11.6+ (beta) | ```mermaid radar-beta |
| "gantt / project schedule" | Mermaid | ```mermaid gantt |
| "user journey map" | Mermaid | ```mermaid journey |
| "pie breakdown (simple)" | Mermaid | ```mermaid pie |
| "kanban board" | Mermaid v11.12+ (beta, test before use) | ```mermaid kanban |
| "cloud/infra architecture" | Mermaid (beta) | ```mermaid architecture-beta |
| "hierarchy / proportional size" | Mermaid (beta) | ```mermaid treemap-beta |
| "free-form block layout" | Mermaid (beta) | ```mermaid block-beta |
| "show data / chart" | diagram-html | Chart.js / D3 / ECharts iframe widget |
| "simulate / interactive" | diagram-html | Matter.js / Canvas / sliders |
| "interactive map (with pan/zoom/markers)" | diagram-html | Leaflet iframe widget — see reference/module-map.md |
| "static country/state choropleth" | diagram-html | D3 + TopoJSON — see reference/module-chart.md |
Default to illustrative SVG for "how does X work?" — don't default to flowchart. Default to Mermaid when the type is in the table above — don't hand-roll an SVG when classDiagram/sequenceDiagram/stateDiagram already exists.
C4Context, C4Container, etc.) — theme tokens are not applied in dark mode, text becomes unreadable (mermaid #4906). Substitute routing:
flowchart with subgraphsarchitecture-beta (cloud/infra layout)flowchart with subgraph groupingsequenceDiagramarchitecture-betasankey-beta / xychart-beta — known to break scale-down at narrow chat widths. Prefer diagram-html + ECharts sankey for flow diagrams, Chart.js for simple XY.radar-beta is the keyword as of Mermaid v11.6+ (not bare radar — the beta suffix is still required at the time of writing per mermaid/syntax/radar). treemap-beta, block-beta, architecture-beta, packet-beta, kanban are still beta but functional — test each in cli-jaw Web UI before finalizing. If the installed Mermaid version drops the -beta suffix, update the routing table accordingly.sandbox securityLevel iframe background bug (mermaid #5034) — affects host rendering, not your output. No action needed from the agent.themeVariables. Do NOT set explicit colors in %%{init: ...}%% unless overriding for semantic reasons.Produce a diagram when the user's question benefits from visual explanation: flowcharts, comparisons, timelines, org charts, data charts, maps, UI mockups, physics simulations, interactive demos.
All three formats — inline SVG, ```mermaid, ```diagram-html — are rendered inline in the chat response. The jaw frontend parses your reply text and mounts them automatically. diagram-html goes into a sandboxed <iframe> that the host creates; you do not create the iframe.
| ❌ Don't | ✅ Do |
|---|---|
| Save to .svg / .html / .png file (Write tool, cat >, fs.writeFile) | Paste raw block directly into your reply |
| Wrap diagram-html in your own <iframe> / <html> / <body> / <head> | Start at <div> / <canvas> / <style> — host injects the shell |
| Send via /api/channel/send or Telegram/Discord — it is 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 |
If the user says "save this diagram" or "download it", still output it inline first so they see it rendered; only write a file if they explicitly ask for a file on disk (and even then, the inline version is the canonical delivery).
Output raw <svg> markup 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>
Rules:
role="img" + <title> + <desc>.node, .connector, .label, .label-start, etc.) — .label forces text-anchor: middle (centered text only); for left-aligned text use .label-start or just the color classfont-family inherited from host (do NOT set explicit fonts)Use standard ```mermaid code blocks. The existing renderer handles these.
Wrap in ```diagram-html code block. Rendered inside a sandboxed iframe.
` ` `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>
` ` `
These are design quality rules (separate from security restrictions below):
These are stripped by DOMPurify — NEVER use in inline <svg>:
<foreignObject> — embeds HTML in SVG (XSS vector)<animate>, <set>, <animateTransform>, <animateMotion> — animation XSS vectors<svg> — use <g> groups insteadxlink:href — use href="#fragment" on <use> only (no external URLs)on* event handlers (onclick, onerror, etc.) — stripped by DOMPurifyNote:
diagram-htmlcontent 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.
Each ramp has 3 shades: fill (bg), stroke (border), text (label).
Use CSS class names — see reference/color-palette.md:
| Ramp | Class 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 when meaning is "info") |
| green | .c-green | Success, positive (semantic) |
| amber | .c-amber | Warning, attention (semantic) |
| red | .c-red | Error, negative (semantic) |
Color assignment: color encodes meaning, not sequence. Don't 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.
reference/svg-components.md for templates and detailed SVG rules.For diagram-html widgets:
<style> and <link> tags first<script> tags lastThis ensures visual content appears before scripts execute (important during streaming).
| 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 |
window.__jawTheme.isDark (boolean) for JS-side theme detectionwindow.__jawTokens['--bg'] etc. for computed host CSS valuesmatchMedia('prefers-color-scheme') — the host controls themeFor detailed patterns, see:
reference/svg-components.md — SVG primitives, viewBox checklist, layout templatesreference/color-palette.md — Full color values (light + dark), assignment rulesreference/module-chart.md — Chart.js + D3 + ECharts 6 integration (bar/line/pie/choropleth + heatmap/sankey/radar/treemap/gauge/funnel/candlestick/chord)reference/module-widget.md — Physics (Matter.js), math graphs (Math.js), 3D (Three.js), creative coding (p5.js), audio (Tone.js), mini-gamesreference/module-interactive.md — Sliders, selects, segmented buttons, toggles, play/pause/reset, debouncing, sendPrompt, keyboard accessibility, control layout patternreference/module-map.md — Leaflet interactive maps (OpenStreetMap tiles, markers, popups, dark mode)reference/module-mockup.md — UI mockup patternsreference/module-art.md — Decorative SVG patternsdevelopment
Goal execution guidelines with PABCD integration, verification tiers, documentation workflow, and AI-driven planning
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
development
Use this skill any time a spreadsheet file is the primary input or output (.xlsx, .xlsm, .csv, .tsv). This includes: creating, reading, editing, analyzing, or formatting spreadsheets; cleaning messy tabular data; converting between formats; and data visualization with charts. Also use for pandas-based data analysis when the deliverable is a spreadsheet. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration.
tools
Use this skill when the user wants to build a financial model, 3-statement model, DCF valuation, cap table, scenario analysis, or financial projections in Excel. Trigger on: 'financial model', '3-statement model', 'DCF', 'cap table', 'pro forma', 'projections', 'sensitivity analysis', 'waterfall', 'debt schedule', 'break-even', 'discounted cash flow', 'capitalization table', 'fundraising model', 'WACC calculation', 'scenario analysis model'. Input is a text prompt with assumptions. Output is a single .xlsx file with formula-driven, interconnected statement sheets.