Mermaid to SVG
This skill should be used when the user asks to "convert mermaid to SVG", "render this mermaid diagram", "create an SVG from mermaid", "draw this diagram as SVG", "generate SVG from mermaid", "make an SVG diagram", "turn this mermaid into an image", "layout this diagram", or any task involving converting Mermaid diagram syntax into hand-crafted SVG markup. Produces clean, professionally styled SVGs with logical layout, efficient edge routing, and consistent visual design.
What this skill does
# Mermaid to SVG
Convert Mermaid diagram definitions into hand-crafted SVG markup with professional layout and consistent styling. This skill produces standalone SVG files — no rendering engine or JavaScript required.
## Supported Diagram Types
| Mermaid Type | Layout Direction | Primary Shape |
|---|---|---|
| `flowchart` / `graph` | TD (top-down) or LR (left-right) | Rounded rectangles, diamonds, circles |
| `sequenceDiagram` | Left-to-right actors, top-down messages | Rectangles for actors, arrows for messages |
| `classDiagram` | Grid or hierarchical | Three-section rectangles |
| `stateDiagram-v2` | Hierarchical | Rounded rectangles, filled circles for start/end |
| `erDiagram` | Grid | Rectangles with attribute lists |
| `mindmap` | Radial from center | Rounded rectangles, varying sizes by depth |
## Conversion Workflow
### 1. Parse the Mermaid Source
Extract the structural elements from the Mermaid definition:
- **Nodes** — identifier, display label, shape hint (`[]`, `{}`, `()`, `(())`, `[[]]`, `>]`, `[/\]`)
- **Edges** — source, target, label, line style (`-->`, `---`, `-.->`, `==>`)
- **Subgraphs** — grouping containers with optional titles
- **Directives** — `direction`, `classDef`, `style`, `click` (ignore click)
- **Diagram-specific** — actors, messages, states, entities, relationships
### 2. Compute Layout
Apply layout rules from `references/layout-patterns.md`. The core principles:
**Grid system.** Place nodes on a virtual grid. Cell size adapts to the largest node plus gutter. Default gutter: 40px horizontal, 50px vertical. Minimum node-to-node distance: 120px.
**Node sizing.** Measure text length (approximate 8px per character at 14px font, 6.5px per character at 12px font). Add horizontal padding of 24px per side, vertical padding of 14px per side. Minimum node width: 80px. Minimum node height: 40px.
**Rank assignment.** For directed graphs, assign ranks (layers) using longest-path from sources. Nodes with no predecessors start at rank 0. Within each rank, order nodes to minimize edge crossings — place nodes adjacent to their most-connected neighbor in the previous rank.
**Edge routing.** Use orthogonal (right-angle) paths routed through inter-node channels. Edges leave from the nearest side of the source node and enter the nearest side of the target. When multiple edges share a channel, offset them by 6px to prevent overlap. Consult `references/layout-patterns.md` for routing algorithms per diagram type.
**Subgraph containers.** Compute the bounding box of all contained nodes, then add 20px internal padding and a 30px top margin for the title. Nest subgraphs before placing top-level nodes.
### 3. Generate SVG
Build the SVG document following these conventions:
**Document structure:**
```xml
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {W} {H}"
font-family="Inter, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif">
<defs>
<!-- arrowheads, filters, gradients -->
</defs>
<g class="edges">...</g>
<g class="nodes">...</g>
<g class="labels">...</g>
</svg>
```
**Sizing.** Set viewBox to the computed layout bounds plus 30px margin on all sides. Omit explicit `width`/`height` to allow responsive scaling, or set them to match viewBox if fixed dimensions are preferred.
**Rendering order.** Draw edges first (behind), then nodes, then labels. This prevents edges from overlapping node fills.
**Apply the style system** from `references/style-guide.md`:
- Node fills use muted cool palette colors with 2px borders in a slightly darker shade of the same hue
- Text is `#334155` (slate-700) at 14px for node labels, 12px for edge labels, 18px for titles
- Edges are `#94a3b8` (slate-400) with 1.5px stroke, arrow markers in matching color
- Subgraph containers use `#f8fafc` fill with `#cbd5e1` dashed border
- Use warm accent (`#f59e0b` / `#d97706`) sparingly for decision nodes, error states, or key highlights
**Text layout.** Center text horizontally and vertically within nodes using `text-anchor="middle"` and `dominant-baseline="central"`. For multi-line text, use multiple `<tspan>` elements with `dy="1.3em"` line spacing. Wrap text that exceeds node width minus padding.
### 4. Refine and Validate
- Verify no overlapping nodes or edges
- Confirm all edge endpoints connect to correct node boundaries
- Check text fits within nodes (resize nodes if needed)
- Ensure arrowheads render at correct positions and orientations
- Validate SVG is well-formed XML
## Shape Mapping
Map Mermaid shape syntax to SVG elements:
| Mermaid Syntax | Shape | SVG Element |
|---|---|---|
| `[text]` | Rectangle | `<rect rx="6">` |
| `(text)` | Rounded rectangle | `<rect rx="16">` |
| `([text])` | Stadium/pill | `<rect rx="{h/2}">` |
| `{text}` | Diamond | `<polygon>` rotated square |
| `((text))` | Circle | `<circle>` |
| `[[text]]` | Subroutine | Double-bordered `<rect>` |
| `[/text/]` | Parallelogram | `<polygon>` with skewed sides |
| `>text]` | Asymmetric | `<polygon>` flag shape |
| `[(text)]` | Cylinder | `<path>` with elliptical top/bottom |
## Edge Styles
| Mermaid Syntax | Style | SVG Attributes |
|---|---|---|
| `-->` | Solid with arrow | `stroke-dasharray: none`, marker-end |
| `---` | Solid no arrow | `stroke-dasharray: none` |
| `-.->` | Dashed with arrow | `stroke-dasharray: 6 4` |
| `==>` | Thick with arrow | `stroke-width: 3` |
| `~~~` | Invisible | `stroke: none` (layout only) |
| `--text-->` | Labeled | Add `<text>` at edge midpoint |
## Key Conventions
- Always include `xmlns` on the root `<svg>` element for standalone files
- Use `id` attributes on nodes matching their Mermaid identifiers for traceability
- Define arrowhead markers in `<defs>` and reference via `marker-end="url(#arrow)"`
- For sequence diagrams, use lifeline `<line>` elements with `stroke-dasharray: 4 4`
- For class diagrams, partition the node rectangle into three sections with horizontal `<line>` dividers
- For ER diagrams, render crow's foot notation with custom marker paths
## Additional Resources
### Reference Files
For detailed patterns and specifications, consult:
- **`references/layout-patterns.md`** — Layout algorithms per diagram type: rank assignment, edge routing, crossing minimization, subgraph nesting, sequence diagram column allocation, and grid placement strategies
- **`references/style-guide.md`** — Complete color palette, typography scale, node styling rules, edge styling, shadow/filter definitions, and accessibility considerations
- **`references/svg-elements.md`** — Copy-ready SVG snippets for every node shape, edge style, arrowhead marker, text layout pattern, and diagram-specific elements (lifelines, crow's feet, state indicators)
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.