Skip to main content
The @diagram tool renders architecture, dependency, flow and ER diagrams to PNG, SVG or JPG from Graphviz DOT β€” with crisp, exactly-correct text, because the labels come from the layout engine, not from pixels a vision model guesses. Graphviz is embedded: go-graphviz ships the upstream engine compiled to WebAssembly, run on the pure-Go wazero runtime. So there is no cgo, no dot binary to install and no network call β€” the same self-contained DNA as the embedded TTS/STT and the pure-Go voice notes.
For any node/edge diagram, prefer @diagram over @image. @image produces a raster image and mangles letters; @diagram is deterministic and the names come out 100% correct. SVG is infinitely scalable; PNG with dpi=300 is print-grade.

Usage

<tool_call name="@diagram" args='{"cmd":"render","dot":"digraph{rankdir=LR; cli->agent; cli->llm}","output":"/tmp/arch.png"}' />
<tool_call name="@diagram" args='{"file":"./arch.dot","format":"svg","output":"/tmp/arch.svg"}' />
<tool_call name="@diagram" args='{"cmd":"gomod","root":".","format":"svg","output":"/tmp/imports.svg"}' />
The LLM invokes @diagram automatically when you ask for an architecture/dependency diagram as an image β€” it writes the DOT (models are good at DOT) and renders it here. There are two subcommands: render (DOT β†’ image) and gomod (real import graph of a Go module β†’ image).

render subcommand

Renders DOT β€” inline (dot) or from a .dot file (file) β€” to an image.

Arguments

ArgumentDescriptionDefault
dotInline Graphviz DOT source. Exactly one of dot | file.(one of)
filePath to a .dot file to render. Exactly one of dot | file.(one of)
formatpng | svg | jpgpng
engineLayout: dot | neato | fdp | sfdp | circo | twopi | osage | patchworkdot
dpiRaster resolution for png/jpg (30–600, clamped)150
outputOutput file path. When omitted, a temp file is written and its path returned.(temp)

gomod subcommand

Builds the real import graph of a Go module (via go list -json ./...) and renders it, clustered by top-level directory β€” a 1:1, code-faithful dependency graph with no manual package enumeration.

Arguments

ArgumentDescriptionDefault
rootModule directory to analyze.
internalOnlyOnly edges between packages of this module (drop third-party deps)true
clusterGroup packages into clusters by top-level directorytrue
styledark | light | plaindark
dotOnlyReturn the generated DOT source instead of rendering an imagefalse
format / engine / dpi / outputSame as renderβ€”
Use dotOnly: true to get the generated DOT and edit it (colors, grouping, labels) before rendering with render. For focused diagrams, point root at a subdirectory (e.g. ./cli) β€” the whole-module graph can get very wide.

Output

For render and gomod (without dotOnly), the tool writes the file and returns a summary with path, format, size and β€” for raster β€” the dimensions:
Diagram rendered β†’ /tmp/arch.png (PNG, 245.1KB)
dimensions: 1200x800
With dotOnly: true, gomod returns the DOT source itself (text), ready to edit or version.

Notes

  • Not read-only and not concurrency-safe: the tool writes a file (and gomod shells out to go list), so it goes through the standard security confirmation and never joins a parallel read-only batch.
  • Truly embedded: Graphviz runs as WebAssembly via wazero β€” nothing to install, works offline on first use, on any OS/architecture.
  • Supported engines: dot (hierarchical, default), neato/fdp/sfdp (force-directed), circo (circular), twopi (radial), osage/patchwork (clusters/treemap).
Combine with @docs-flatten and @context: build a knowledge base of the project and ask for an architecture diagram β€” the AI uses what it learned to write the DOT and @diagram to render it faithfully.