Skip to content
Back to skills

Mermaid Terminal

ASecurity

Render Mermaid source locally and preview it in Ghostty, Kitty, or another Kitty-graphics-compatible terminal. Use when a user wants to see a Mermaid diagram without opening a browser; do not use for general image viewing or non-Mermaid diagrams.

  • 8 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 12, 2026
toolspythonrustshellbash

Works with

  • terminal
  • cli

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned September 12, 2026

npx -y skills add stanfish06/skillquarium --skill mermaid-terminal --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Mermaid Terminal?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Mermaid Terminal
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/stanfish06-mermaid-terminal/badge)](https://www.skillsdirectory.com/skills/stanfish06-mermaid-terminal)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: mermaid-terminal
description: Render Mermaid source locally and preview it in Ghostty, Kitty, or another Kitty-graphics-compatible terminal. Use when a user wants to see a Mermaid diagram without opening a browser; do not use for general image viewing or non-Mermaid diagrams.
---

# Mermaid Terminal

Use the bundled renderer to turn Mermaid source into a PNG and send it to the
current terminal with the Kitty graphics protocol.

## Preview a diagram

Locate this skill directory, then run:

```bash
python3 <skill-dir>/scripts/mermaid_terminal.py diagram.mmd
```

The script also accepts Mermaid source on standard input:

```bash
printf '%s\n' 'flowchart LR' '  A --> B' \
  | python3 <skill-dir>/scripts/mermaid_terminal.py -
```

It accepts a Markdown file or stdin containing a fenced `mermaid` block and
renders the first block. Use `--output diagram.png --no-display` when the caller
needs a persistent file instead of an inline terminal preview.

## Workflow

1. Preserve or create editable Mermaid source before rendering.
2. Use a temporary `.mmd` file unless the user asked to keep the source.
3. Run the bundled script. It prefers `mmdc` on `PATH`; otherwise it uses a
   pinned Mermaid CLI through Bun or npm. The fallback downloads into the
   package-manager cache on first use but never sends diagram source to a
   rendering service.
   When an agent shell captures stdout, the script finds the nearest parent
   terminal device, reads geometry with an ioctl (never a terminal query — the
   agent host owns the terminal's input and would swallow the reply), and shows
   the diagram on the alternate screen. By default it holds until interrupted:
   the user dismisses it with Esc or Ctrl-C (which makes the host kill the
   command; SIGTERM/SIGINT handlers restore the screen), and the Bash timeout
   is the backstop. Tell the user how to dismiss it. Pass `--hold-seconds N`
   for a timed preview that restores by itself when you need the shell back
   without user action.
4. Report Mermaid syntax errors with the source path and keep the editable
   source available for correction.
5. If inline display is unavailable, rerun with `--output` and return the PNG
   path. Do not claim the diagram appeared in the user's terminal when the
   command was run without a TTY or with `--no-display`.

Use `--theme neutral` for a light terminal and `--theme dark` for a dark
terminal when automatic selection is wrong. Pass `--help` for the complete
script interface.

## Neovim and Snacks

Snacks can render fenced Mermaid blocks inside Neovim when its `image` module
is enabled, the Markdown Tree-sitter parser is installed, and `mmdc` is on
`PATH`. Do not edit the user's Neovim configuration unless they explicitly ask.
The bundled script is the default path because it works independently of editor
configuration and uses the same Kitty graphics capability exposed by Ghostty.

## Constraints

- Keep rendering local; do not upload diagram source to Kroki or another remote
  service without explicit permission.
- Display through `kitten icat` using streamed image data so the terminal does
  not need to read the renderer's temporary file.
- In a captured shell, never let `kitten icat` query the terminal or wait for a
  keypress: pass `--use-window-size` from the ioctl geometry and use the timed
  hold. Both reads race against the agent host's own terminal reader.
- Treat Mermaid source as untrusted input to the renderer. Do not interpolate it
  into a shell command.

Files in this skill

  • .gitignore46 B
  • README.md175 B
  • SKILL.md3.4 KB
  • agents/openai.yaml217 B
  • scripts/mermaid_terminal.py11.7 KB
  • tests/test_mermaid_terminal.py6.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.