# Diagram

Create a color picture from Mermaid text to visualize flow, structure, or plan in the desktop app or terminal.

**Canonical URL:** https://skillshunter.net/skills/discovered-2446f9b3e99901bb5c5735861047b789a31ddbf43da20211

**JSON URL:** https://skillshunter.net/api/public/v1/skills/discovered-2446f9b3e99901bb5c5735861047b789a31ddbf43da20211

**Markdown URL:** https://skillshunter.net/skills/discovered-2446f9b3e99901bb5c5735861047b789a31ddbf43da20211.md

**Instructions download URL:** https://skillshunter.net/skills/discovered-2446f9b3e99901bb5c5735861047b789a31ddbf43da20211/download

**Category:** Software & Development

**Source URL:** https://github.com/jueyi6/empstack/blob/74181e31d2f00313f8683ba157966efcabbe109e/skills/diagram/SKILL.md

**Source commit:** 74181e31d2f00313f8683ba157966efcabbe109e

**Listing approved at:** 2026-12-02

**Created at:** 2026-11-30T08:55:35.000000Z

**Updated at:** 2026-12-02T09:15:13.000000Z

## Catalog information

The following descriptions are catalog information. Listing approval does not mean the skill has been tested or is safe for every environment.

### Editor's note

Write Mermaid text in `<name>.mmd` inside `.empstack/diagrams/` unless the diagram belongs in the repo's docs. Use `flowchart TB` for most diagrams, and color nodes with `class` lines using up to three colors from the specified palette.

### When to use it

- Visualizing software architecture using Mermaid text
- Creating flowcharts for documentation
- Designing project plans with color-coded elements

## Skill instructions

---
name: diagram
description: Draw a flow, structure or plan as a color picture from Mermaid text, in the desktop app or a terminal.
---

# Diagram

1. Write the Mermaid text to `<name>.mmd`, in `.empstack/diagrams/` unless the diagram belongs in the repo's docs. Start with `flowchart TB` unless the picture is short and wide.
2. Color nodes by kind with `class` lines, such as `class A,B teal`. The colors are gray, purple, teal, coral, pink, blue, green, amber and red. Use gray for start and end, and at most three colors. Write no `classDef` or `style` line, since those fix one color for both light and dark.
3. Keep a picture to about 12 nodes. Split a bigger one into an overview and one picture per part. A subgraph whose nodes have edges to the outside ignores its `direction` line and runs those edges through its boxes, so put the group's name in each node's label instead.
4. Run `node <skill dir>/scripts/diagram.mjs <name>.mmd --png`. It writes `<name>.svg` and `<name>.png` and prints the size.
   - Exit 3 means Pele, the renderer, is not installed. Tell the user in one line that empstack installs `pele@1.9.0` from npm (2.3 MB, no dependencies) into `~/.claude/empstack/diagram`. Run the `--install` command the script printed, then step 4 again. If the install fails, give the user the error and the command, and show the Mermaid text in a ```` ```mermaid ```` block until then.
   - Exit 1 names the Mermaid line to fix.
   - Wider than 1200 shrinks in a narrow pane. Turn the flow or split it.
5. Read the PNG. Redraw while a label is cut off, an edge runs through a box or a label, or an edge seems to start at the wrong box. Without Chrome or Edge there is no PNG, so say the picture is unchecked.
6. Show the SVG. In the desktop app, where `CLAUDE_CODE_ENTRYPOINT` is `claude-desktop`, send it with `SendUserFile`, display `render`. In a terminal, open it in the browser (`start "" <file>` on Windows, `open` on macOS, `xdg-open` on Linux) and give its path. Never send the `.mmd` file as the picture. The desktop app shows it as plain text.

In a Markdown doc or PR body, use a ```` ```mermaid ```` block. GitHub draws it.

