Skip to content

Commit 55247cb

Browse files
committed
feat: v0.4.1 — Mermaid TD vs LR guidance, README simplification
Mermaid layout direction: - New 'Layout Direction: TD vs LR' section in libraries.md - Prefer flowchart TD over LR for complex diagrams (5+ nodes) - Updated all diagram type sections to recommend TD first Documentation: - Simplified README: consolidated Install, added Slide Deck Mode section - Added /generate-visual-plan to command table
1 parent 8e25581 commit 55247cb

File tree

6 files changed

+77
-74
lines changed

6 files changed

+77
-74
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Changelog
22

3+
## [0.4.1] - 2026-03-01
4+
5+
### Mermaid Layout Direction
6+
- New "Layout Direction: TD vs LR" section in `libraries.md`
7+
- Prefer `flowchart TD` (top-down) over `flowchart LR` (left-to-right) for complex diagrams
8+
- LR spreads horizontally and makes labels unreadable with many nodes
9+
- Rule: use TD for 5+ nodes or any branching; LR only for simple 3-4 node linear flows
10+
11+
### Documentation
12+
- Simplified README: trimmed Usage section, consolidated Install, added Slide Deck Mode section
13+
- Added `/generate-visual-plan` to command table
14+
315
## [0.4.0] - 2026-02-28
416

517
### New Prompt Template

README.md

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -8,130 +8,94 @@
88

99
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](LICENSE)
1010

11-
Ask your agent to explain a system architecture, review a diff, or compare requirements against a plan. Instead of ASCII art and box-drawing tables, it generates a self-contained HTML page and opens it in your browser:
11+
Ask your agent to explain a system architecture, review a diff, or compare requirements against a plan. Instead of ASCII art and box-drawing tables, it generates a self-contained HTML page and opens it in your browser.
1212

1313
```
1414
> draw a diagram of our authentication flow
1515
> /diff-review
1616
> /plan-review ~/docs/refactor-plan.md
1717
```
1818

19-
Each one produces a single `.html` file with real typography, dark/light theme support, and interactive Mermaid diagrams with zoom and pan. No build step, no dependencies beyond a browser.
20-
2119
https://github.com/user-attachments/assets/55ebc81b-8732-40f6-a4b1-7c3781aa96ec
2220

2321
## Why
2422

25-
Every coding agent defaults to ASCII art when you ask for a diagram. Box-drawing characters, monospace alignment hacks, text arrows. It works for trivial cases, but anything beyond a 3-box flowchart turns into an unreadable mess that nobody would put in a presentation or share with a team.
23+
Every coding agent defaults to ASCII art when you ask for a diagram. Box-drawing characters, monospace alignment hacks, text arrows. It works for trivial cases, but anything beyond a 3-box flowchart turns into an unreadable mess.
2624

2725
Tables are worse. Ask the agent to compare 15 requirements against a plan and you get a wall of pipes and dashes that wraps and breaks in the terminal. The data is there but it's painful to read.
2826

29-
## Install
27+
This skill fixes that. Real typography, dark/light themes, interactive Mermaid diagrams with zoom and pan. No build step, no dependencies beyond a browser.
3028

31-
### Pi
29+
## Install
3230

31+
**Pi:**
3332
```bash
34-
# Installs the skill and all slash commands in one step
3533
pi install https://github.com/nicobailon/visual-explainer
3634
```
3735

38-
If you prefer a manual install, clone the repo and copy the prompts:
39-
40-
```bash
41-
git clone https://github.com/nicobailon/visual-explainer.git ~/.pi/agent/skills/visual-explainer
42-
mkdir -p ~/.pi/agent/prompts
43-
cp ~/.pi/agent/skills/visual-explainer/prompts/*.md ~/.pi/agent/prompts/
44-
```
45-
46-
### Claude Code
47-
48-
Clone the skill, then copy the prompt templates so they register as slash commands:
49-
36+
**Claude Code:**
5037
```bash
5138
git clone https://github.com/nicobailon/visual-explainer.git ~/.claude/skills/visual-explainer
5239
mkdir -p ~/.claude/commands
5340
cp ~/.claude/skills/visual-explainer/prompts/*.md ~/.claude/commands/
5441
```
5542

56-
If you have [surf-cli](https://github.com/nicobailon/surf-cli) installed, the skill can also generate illustrations via Gemini and embed them in pages. The agent detects surf automatically and skips image generation if it's not there.
57-
58-
## Usage
59-
60-
The agent loads the skill when you mention diagrams, architecture, flowcharts, schemas, or visualizations. It also kicks in automatically when it's about to dump a complex table in the terminal (4+ rows or 3+ columns) — it renders HTML instead and opens it in the browser. Output goes to `~/.agent/diagrams/`.
61-
62-
The skill ships with seven prompt templates:
43+
## Commands
6344

6445
| Command | What it does |
6546
|---------|-------------|
6647
| `/generate-web-diagram` | Generate an HTML diagram for any topic |
6748
| `/generate-visual-plan` | Generate a visual implementation plan for a feature or extension |
68-
| `/generate-slides` | Generate a magazine-quality slide deck for any topic |
69-
| `/diff-review` | Visual diff review with architecture comparison, code review, decision log |
49+
| `/generate-slides` | Generate a magazine-quality slide deck |
50+
| `/diff-review` | Visual diff review with architecture comparison and code review |
7051
| `/plan-review` | Compare a plan against the codebase with risk assessment |
7152
| `/project-recap` | Mental model snapshot for context-switching back to a project |
72-
| `/fact-check` | Verify accuracy of a review page or plan doc against actual code |
53+
| `/fact-check` | Verify accuracy of a document against actual code |
7354

74-
https://github.com/user-attachments/assets/342d3558-5fcf-4fb2-bc03-f0dd5b9e35dc
75-
76-
Any prompt that produces a scrollable page also supports a `--slides` flag to generate a slide deck instead:
55+
The agent also kicks in automatically when it's about to dump a complex table in the terminal (4+ rows or 3+ columns) — it renders HTML instead.
7756

78-
```
79-
/diff-review --slides # slide deck version of a diff review
80-
/project-recap --slides 2w # slide deck recap of last 2 weeks
81-
```
57+
## Slide Deck Mode
8258

83-
`/diff-review` is probably the most useful. Run it with no arguments to diff against `main`, or pass any git ref:
59+
Any command that produces a scrollable page supports `--slides` to generate a slide deck instead:
8460

8561
```
86-
/diff-review # feature branch vs main (default)
87-
/diff-review abc123 # single commit
88-
/diff-review main..HEAD # committed changes only
89-
/diff-review #42 # pull request
62+
/diff-review --slides
63+
/project-recap --slides 2w
9064
```
9165

92-
It generates a full page with before/after architecture diagrams, KPI dashboard, structured Good/Bad/Ugly code review, decision log with confidence indicators, and re-entry context for your future self.
93-
94-
`/plan-review` does something similar but for implementation plans — pass it a plan file and it cross-references every claim against the actual codebase, produces current vs. planned architecture diagrams, and flags risks and gaps:
95-
96-
```
97-
/plan-review ~/docs/refactor-plan.md
98-
```
99-
100-
`/project-recap` is designed for context-switching back to a project after days away. It scans recent git activity and produces an architecture snapshot, decision log, and cognitive debt hotspots. `/fact-check` takes any document that makes claims about code and verifies every one of them.
66+
https://github.com/user-attachments/assets/342d3558-5fcf-4fb2-bc03-f0dd5b9e35dc
10167

10268
## How It Works
10369

10470
```
10571
SKILL.md (workflow + design principles)
10672
107-
references/ ← agent reads before each generation
108-
├── css-patterns.md (layouts, animations, theming, depth tiers)
109-
├── libraries.md (Mermaid theming, Chart.js, anime.js, font pairings)
110-
├── responsive-nav.md (sticky sidebar TOC for multi-section pages)
111-
└── slide-patterns.md (slide engine, 10 slide types, transitions, presets)
73+
references/ ← agent reads before generating
74+
├── css-patterns.md (layouts, animations, theming)
75+
├── libraries.md (Mermaid, Chart.js, fonts)
76+
├── responsive-nav.md (sticky TOC for multi-section pages)
77+
└── slide-patterns.md (slide engine, transitions, presets)
11278
113-
templates/ ← agent reads the matching reference template
114-
├── architecture.html (CSS Grid cards — terracotta/sage palette)
115-
├── mermaid-flowchart.html (Mermaid + ELK — teal/cyan palette)
116-
├── data-table.html (tables with KPIs and badges — rose/cranberry palette)
117-
└── slide-deck.html (viewport-fit slides — midnight editorial palette)
79+
templates/ ← reference templates with different palettes
80+
├── architecture.html
81+
├── mermaid-flowchart.html
82+
├── data-table.html
83+
└── slide-deck.html
11884
11985
~/.agent/diagrams/filename.html → opens in browser
12086
```
12187

122-
The agent picks an aesthetic direction, reads the right reference template, generates a self-contained HTML file with both light and dark themes, and opens it. The four templates use deliberately different palettes so the agent learns variety rather than defaulting to one look. The skill handles 11 diagram types — Mermaid for anything with connections (flowcharts, sequences, ER, state machines, mind maps), CSS Grid for text-heavy architecture overviews, HTML tables for data, Chart.js for dashboards — and routes to the right approach automatically.
123-
124-
To customize the output directory, browser command, or add your own diagram types and CSS patterns, edit the files directly. The agent reads them fresh each time.
88+
The skill routes to the right approach automatically: Mermaid for flowcharts and diagrams, CSS Grid for architecture overviews, HTML tables for data, Chart.js for dashboards.
12589

12690
## Limitations
12791

128-
- Requires a browser to view — no inline terminal rendering
129-
- Switching OS theme requires a page refresh for Mermaid SVGs (CSS-styled elements respond instantly)
130-
- Results vary by model capability — the skill provides design guidance, not pixel-perfect specs
92+
- Requires a browser to view
93+
- Switching OS theme requires a page refresh for Mermaid SVGs
94+
- Results vary by model capability
13195

13296
## Credits
13397

134-
Borrows ideas from [Anthropic's frontend-design skill](https://github.com/anthropics/skills) and [interface-design](https://github.com/Dammyjay93/interface-design), adapted for one-shot diagram generation.
98+
Borrows ideas from [Anthropic's frontend-design skill](https://github.com/anthropics/skills) and [interface-design](https://github.com/Dammyjay93/interface-design).
13599

136100
## License
137101

SKILL.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ license: MIT
55
compatibility: Requires a browser to view generated HTML files. Optional surf-cli for AI image generation.
66
metadata:
77
author: nicobailon
8-
version: "0.4.0"
8+
version: "0.4.1"
99
---
1010

1111
# Visual Explainer
@@ -84,6 +84,8 @@ Vary the choice each time. If the last diagram was dark and technical, make the
8484

8585
**Mermaid scaling:** Complex diagrams with 10+ nodes render too small by default. Increase `fontSize` in themeVariables to 18-20px (default is 16px), or apply a CSS `transform: scale(1.3)` on the SVG. Don't let diagrams float in oversized containers with unreadable text. See `./references/css-patterns.md` "Scaling Small Diagrams".
8686

87+
**Mermaid layout direction:** Prefer `flowchart TD` (top-down) over `flowchart LR` (left-to-right) for complex diagrams. LR spreads horizontally and makes labels unreadable when there are many nodes. Use LR only for simple 3-4 node linear flows. See `./references/libraries.md` "Layout Direction: TD vs LR".
88+
8789
**Mermaid CSS class collision constraint:** Never define `.node` as a page-level CSS class. Mermaid.js uses `.node` internally on SVG `<g>` elements with `transform: translate(x, y)` for positioning. Page-level `.node` styles (hover transforms, box-shadows) leak into diagrams and break layout. Use the namespaced `.ve-card` class for card components instead. The only safe way to style Mermaid's `.node` is scoped under `.mermaid` (e.g., `.mermaid .node rect`).
8890

8991
**AI-generated illustrations (optional).** If [surf-cli](https://github.com/nicobailon/surf-cli) is available, you can generate images via Gemini and embed them in the page for creative, illustrative, explanatory, educational, or decorative purposes. Check availability with `which surf`. If available:
@@ -183,24 +185,24 @@ Two approaches depending on what matters more:
183185

184186
**Text-heavy overviews** (card content matters more than connections): CSS Grid with explicit row/column placement. Sections as rounded cards with colored borders and monospace labels. Vertical flow arrows between sections. Nested grids for subsystems. The reference template at `./templates/architecture.html` demonstrates this pattern. Use when cards need descriptions, code references, tool lists, or other rich content that Mermaid nodes can't hold.
185187

186-
**Topology-focused diagrams** (connections matter more than card content): **Use Mermaid.** A `graph TD` or `graph LR` with custom `themeVariables` produces proper diagrams with automatic edge routing. Use when the point is showing how components connect rather than describing what each component does in detail.
188+
**Topology-focused diagrams** (connections matter more than card content): **Use Mermaid.** A `graph TD` (or `graph LR` for simple linear flows) with custom `themeVariables` produces proper diagrams with automatic edge routing. Use when the point is showing how components connect rather than describing what each component does in detail.
187189

188190
### Flowcharts / Pipelines
189-
**Use Mermaid.** Automatic node positioning and edge routing produces proper diagrams with connecting lines, decision diamonds, and parallel branches — dramatically better than CSS flexbox with arrow characters. Use `graph TD` for top-down or `graph LR` for left-right. Color-code node types with Mermaid's `classDef` or rely on `themeVariables` for automatic styling.
191+
**Use Mermaid.** Automatic node positioning and edge routing produces proper diagrams with connecting lines, decision diamonds, and parallel branches — dramatically better than CSS flexbox with arrow characters. Prefer `graph TD` (top-down); use `graph LR` only for simple 3-4 node linear flows. Color-code node types with Mermaid's `classDef` or rely on `themeVariables` for automatic styling.
190192

191193
### Sequence Diagrams
192194
**Use Mermaid.** Lifelines, messages, activation boxes, notes, and loops all need automatic layout. Use Mermaid's `sequenceDiagram` syntax. Style actors and messages via CSS overrides on `.actor`, `.messageText`, `.activation` classes.
193195

194196
### Data Flow Diagrams
195-
**Use Mermaid.** Data flow diagrams emphasize connections over boxes — exactly what Mermaid excels at. Use `graph LR` or `graph TD` with edge labels for data descriptions. Thicker, colored edges for primary flows. Source/sink nodes styled differently from transform nodes via Mermaid's `classDef`.
197+
**Use Mermaid.** Data flow diagrams emphasize connections over boxes — exactly what Mermaid excels at. Use `graph TD` (or `graph LR` for simple linear flows) with edge labels for data descriptions. Thicker, colored edges for primary flows. Source/sink nodes styled differently from transform nodes via Mermaid's `classDef`.
196198

197199
### Schema / ER Diagrams
198200
**Use Mermaid.** Relationship lines between entities need automatic routing. Use Mermaid's `erDiagram` syntax with entity attributes. Style via `themeVariables` and CSS overrides on `.er.entityBox` and `.er.relationshipLine`.
199201

200202
### State Machines / Decision Trees
201203
**Use Mermaid.** Use `stateDiagram-v2` for states with labeled transitions. Supports nested states, forks, joins, and notes. Decision trees can use `graph TD` with diamond decision nodes.
202204

203-
**`stateDiagram-v2` label caveat:** Transition labels have a strict parser — colons, parentheses, `<br/>`, HTML entities, and most special characters cause silent parse failures ("Syntax error in text"). If your labels need any of these (e.g., `cancel()`, `curate: true`, multi-line labels), use `flowchart LR` instead with rounded nodes and quoted edge labels (`|"label text"|`). Flowcharts handle all special characters and support `<br/>` for line breaks. Reserve `stateDiagram-v2` for simple single-word or plain-text labels.
205+
**`stateDiagram-v2` label caveat:** Transition labels have a strict parser — colons, parentheses, `<br/>`, HTML entities, and most special characters cause silent parse failures ("Syntax error in text"). If your labels need any of these (e.g., `cancel()`, `curate: true`, multi-line labels), use `flowchart TD` instead with rounded nodes and quoted edge labels (`|"label text"|`). Flowcharts handle all special characters and support `<br/>` for line breaks. Reserve `stateDiagram-v2` for simple single-word or plain-text labels.
204206

205207
### Mind Maps / Hierarchical Breakdowns
206208
**Use Mermaid.** Use `mindmap` syntax for hierarchical branching from a root node. Mermaid handles the radial layout automatically. Style with `themeVariables` to control node colors at each depth level.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "visual-explainer",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Agent skill that generates beautiful HTML pages for diagrams, diff reviews, plan reviews, and data tables",
55
"keywords": ["pi-package"],
66
"license": "MIT",

prompts/generate-visual-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Verify each against the code. If something cannot be verified, mark it as uncert
5454

5555
2. **The Problem** — side-by-side comparison panels showing current behavior vs. desired behavior. Use concrete examples, not abstract descriptions. Show what the user experiences or what the code does, step by step. *Visual treatment: two-column grid with rose-tinted "Before" header and sage-tinted "After" header. Numbered flow steps with arrows between them.*
5656

57-
3. **State Machine** — Mermaid flowchart or stateDiagram showing the states and transitions. Label edges with the triggers (commands, events, conditions). *Wrap in `.mermaid-wrap` with zoom controls. Use `flowchart LR` instead of `stateDiagram-v2` if labels need special characters like colons or parentheses. Add explanatory caption below the diagram.*
57+
3. **State Machine** — Mermaid flowchart or stateDiagram showing the states and transitions. Label edges with the triggers (commands, events, conditions). *Wrap in `.mermaid-wrap` with zoom controls. Use `flowchart TD` instead of `stateDiagram-v2` if labels need special characters like colons or parentheses. Add explanatory caption below the diagram.*
5858

5959
4. **State Variables** — card grid showing new state and existing state (if modified). Use code blocks with proper `white-space: pre-wrap`. *Visual treatment: two cards side-by-side, elevated depth, monospace labels.*
6060

references/libraries.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,31 @@ B->>S: POST /submit with selected indices
256256

257257
**Don't mix diagram syntax.** Each diagram type has its own syntax. `-->` works in flowcharts but not in sequence diagrams (`->>` instead). `:::className` works in flowcharts but not in ER diagrams. When in doubt, check the examples below for correct syntax per type.
258258

259+
### Layout Direction: TD vs LR
260+
261+
`flowchart LR` (left-to-right) spreads horizontally. With many nodes, Mermaid scales everything down to fit the width, making text unreadable. `flowchart TD` (top-down) is almost always better.
262+
263+
**When to use each:**
264+
265+
| Direction | Use when | Avoid when |
266+
|-----------|----------|------------|
267+
| `TD` (top-down) | Complex diagrams, 5+ nodes, hierarchies, architecture | Simple A→B→C linear flows |
268+
| `LR` (left-to-right) | Simple linear flows, 3-4 nodes, pipelines | Complex graphs, many branches |
269+
270+
**Rule of thumb:** If the diagram has more than one row of nodes or any branching, use `TD`. The extra vertical space makes labels readable.
271+
272+
```
273+
%% WRONG — LR with many nodes produces wide, short, unreadable diagram
274+
flowchart LR
275+
A --> B --> C --> D --> E
276+
A --> F --> G --> H
277+
278+
%% RIGHT — TD uses vertical space, labels stay readable
279+
flowchart TD
280+
A --> B --> C --> D --> E
281+
A --> F --> G --> H
282+
```
283+
259284
### Diagram Type Examples
260285

261286
**Flowchart with decisions:**

0 commit comments

Comments
 (0)