figures

Reviewed at commit f9e1cd2 New version, not yet reviewed

Draw diagrams, LaTeX math, and tool-result images inline in kitty-graphics terminals

Made by
natsukium
What we checked

Draws mermaid, Graphviz, d2 and SVG blocks and LaTeX display math from Claude's replies as pictures under the reply, plus images that tools return or send, in kitty-graphics terminals. It runs the diagram programs you have installed (mmdr, mmdc, dot, d2, resvg, ImageMagick) and caches the PNGs in your temp folder for seven days; /figures opens a gallery pane. It makes no network calls of its own.

Review details

Static review of the source at the pinned commit; not run. The whole plugin was reviewed again because the diff since 7ea0b51 is too large for a delta review (it adds the bundled pele mermaid renderer, an SVG CSS resolver and rebuilt vendor files). Hooks: session.start (expires cached PNGs older than 7 days with find -name '*.png' -mtime +7 -delete in $TMPDIR/claude-figures, registers the /figures command, toasts unknown renderer ids), command.run for /figures (reads $.ui.selection, opens a pane), prompt.submit (only closes the pane when you type a prompt; the prompt is passed on unchanged and not read), and ui.render for Pane, AssistantMessage, ToolResult (SendUserFile only), ToolUse and ToolGroup on the terminal surface, which add Image elements under the row and never change or block the row itself. Runtime calls: $.process.run, $.fs.read/exists/write, $.env.get (TMPDIR, COLORFGBG), $.config.list (only the theme value is used), $.session.messages (to rebuild the gallery from assistant replies and tool results), $.ui.toast/open/close/selection/resolve, $.command.register and two plugin state atoms. Code blocks are detected in assistant text; source goes on stdin to mmdr, mmdc (60 s timeout, headless browser), dot or d2, SVG output is rasterized by resvg (fc-match picks the sans-serif font), math is typeset in-process by bundled MathJax 4.1.3 (glyph ranges read from the plugin's own hooks/vendor/mathjax-fonts JSON), and mermaid can also be laid out in-process by bundled pele 1.12.0 whose CSS is resolved by the plugin's own XML/CSS code. Images in tool results (Read, MCP screenshots, at most 4 per call) and files sent with SendUserFile are written to $TMPDIR/claude-figures as PNG through sh -c 'base64 -d > "$1"' with a hash-derived path, non-PNG input is converted by magick or sips and the intermediate file removed with rm -f; PNG size is read with head -c 24 | base64. Mermaid background config JSON files are also written there. The pane's o key opens the current PNG with open or xdg-open only when you press it. All argv are arrays (no shell interpolation of content); missing programs are skipped and the block stays as code. The diagrams skill only explains which fences render and has no allowed-tools. Read fully: manifests, register.tsx and every TypeScript module, vendor/mathjax.ts and vendor/pele.ts sources and vite.config.ts in the clone. Covered by targeted search only: the minified vendor bundles hooks/vendor/mathjax.js, pele.js, the three mathjax glyph chunks and hash.js (noble-hashes sha256), checked for fetch, XMLHttpRequest, WebSocket, eval, new Function, require, dynamic import, child_process and process.env with no hits beyond MathJax's platform sniffing and W3C namespace strings; the base64 string in mathjax.js is MathJax's embedded zero-width font. Not reviewed: the external renderer programs, which may resolve resources a diagram references (for example remote icons in d2).

What it uses
  • Reads your prompts: no
  • Sees tool calls: yes
  • Blocks or changes tool calls: no
  • Reads or writes files: yes
  • Runs programs on your machine: yes
  • Calls the model (uses tokens): no
  • Sends data over the network: no
  • Stores data: yes
  • Shows something on screen: yes
Hooked events
Screenshot of figures
Made this mod? Add a badge to your README

modsforClaude badge for figures

Paste this into your README. The badge says reviewed once the current version has been reviewed, and links readers to this page.

[![Listed on modsforClaude](https://modsforclaude.com/badge/figures.svg)](https://modsforclaude.com/mods/figures/)

← All mods