Diagram — Visual Rendering via Snip
Generate a visual diagram or HTML preview from the current conversation context and render it with Snip.
Step 1: Analyze context and choose format
Review the conversation to determine what to visualize.
Choose Mermaid for: architecture diagrams, sequence diagrams, flowcharts, ER diagrams, class diagrams, state diagrams, Gantt charts, git graphs, mind maps, timelines, or any structural/relational/flow visualization.
Choose HTML for: UI mockups, component previews, landing pages, dashboards, styled cards, data tables, or anything where visual design (colors, typography, layout) is the point.
Step 2: Pick the right Mermaid diagram type
When using Mermaid, select the most appropriate type:
| Context |
Diagram Type |
| Request/response flows, API calls, service interactions |
sequenceDiagram |
| Decision trees, workflows, processes |
flowchart TD or flowchart LR |
| Database schemas, data models |
erDiagram |
| Code structure, inheritance, interfaces |
classDiagram |
| Lifecycle, transitions, modes |
stateDiagram-v2 |
| System components, services, layers |
flowchart TD with subgraphs |
| Project timelines, sprints |
gantt |
| Proportions, distributions |
pie |
| Concept relationships |
mindmap |
Step 3: Write to a file
Use the Write tool to create the file — not Bash.
Write to ~/.snip/tmp/ — not the project directory.
For Mermaid diagrams:
- Write to a
.mmd file: ~/.snip/tmp/architecture.mmd, ~/.snip/tmp/auth-flow.mmd
For HTML previews:
- Write to a
.html file: ~/.snip/tmp/preview.html, ~/.snip/tmp/dashboard-mockup.html
Step 4: Render with Snip
Then use Bash to render:
# Mermaid
snip render --format mermaid < ~/.snip/tmp/architecture.mmd
# HTML
snip render --format html < ~/.snip/tmp/preview.html
Step 5: Handle the response
The render command returns JSON: {"status": "approved", "edited": false, "path": "/path/to/rendered.png"}
- If
status is "approved" and edited is false — the user accepted the diagram. Done.
- If
edited is true — the user annotated the image with corrections. Use the Read tool to view the image at path, then update the source file and re-render.
- If
status is "changes_requested" — read the text field for written feedback. Update the source file and re-render.
Tips
- For large diagrams, use subgraphs to organize related nodes
- Keep node labels concise; use notes for details
- For HTML, use inline
<style> tags (external stylesheets won't load)
- HTML is sandboxed: no
<script> or <canvas> JS will execute
- For fixed-size HTML designs, set explicit body dimensions:
body { width: 800px; height: 600px; }
1---2name: diagram3description: Render a visual diagram or HTML preview using Snip. Use when the user wants to visualize architecture, flows, schemas, state machines, UI mockups, or any structural concept.4---56# Diagram — Visual Rendering via Snip78<!-- snip-rules-v9 -->910Generate a visual diagram or HTML preview from the current conversation context and render it with Snip.1112## Step 1: Analyze context and choose format1314Review the conversation to determine what to visualize.1516**Choose Mermaid** for: architecture diagrams, sequence diagrams, flowcharts, ER diagrams, class diagrams, state diagrams, Gantt charts, git graphs, mind maps, timelines, or any structural/relational/flow visualization.1718**Choose HTML** for: UI mockups, component previews, landing pages, dashboards, styled cards, data tables, or anything where visual design (colors, typography, layout) is the point.1920## Step 2: Pick the right Mermaid diagram type2122When using Mermaid, select the most appropriate type:2324| Context | Diagram Type |25|---------|-------------|26| Request/response flows, API calls, service interactions | `sequenceDiagram` |27| Decision trees, workflows, processes | `flowchart TD` or `flowchart LR` |28| Database schemas, data models | `erDiagram` |29| Code structure, inheritance, interfaces | `classDiagram` |30| Lifecycle, transitions, modes | `stateDiagram-v2` |31| System components, services, layers | `flowchart TD` with subgraphs |32| Project timelines, sprints | `gantt` |33| Proportions, distributions | `pie` |34| Concept relationships | `mindmap` |3536## Step 3: Write to a file3738Use the **Write tool** to create the file — not Bash.39Write to `~/.snip/tmp/` — not the project directory.4041For Mermaid diagrams:42- Write to a `.mmd` file: `~/.snip/tmp/architecture.mmd`, `~/.snip/tmp/auth-flow.mmd`4344For HTML previews:45- Write to a `.html` file: `~/.snip/tmp/preview.html`, `~/.snip/tmp/dashboard-mockup.html`4647## Step 4: Render with Snip4849Then use Bash to render:50```bash51# Mermaid52snip render --format mermaid < ~/.snip/tmp/architecture.mmd5354# HTML55snip render --format html < ~/.snip/tmp/preview.html56```5758## Step 5: Handle the response5960The render command returns JSON: `{"status": "approved", "edited": false, "path": "/path/to/rendered.png"}`6162- If `status` is `"approved"` and `edited` is `false` — the user accepted the diagram. Done.63- If `edited` is `true` — the user annotated the image with corrections. Use the Read tool to view the image at `path`, then update the source file and re-render.64- If `status` is `"changes_requested"` — read the `text` field for written feedback. Update the source file and re-render.6566## Tips6768- For large diagrams, use subgraphs to organize related nodes69- Keep node labels concise; use notes for details70- For HTML, use inline `<style>` tags (external stylesheets won't load)71- HTML is sandboxed: no `<script>` or `<canvas>` JS will execute72- For fixed-size HTML designs, set explicit body dimensions: `body { width: 800px; height: 600px; }`