“Everything is a graph”
The context-usage visual is a comparative quantitative infographic. It has no graph nodes, control-flow edges, or decision semantics.
The reliable path is natural-language intent → family-specific typed specification → deterministic SVG layout → geometry and visual validation → exported artifact.
Finding 01
The earlier analysis treated all examples as graph-based agent workflows. That was not supported by the referenced page.
The context-usage visual is a comparative quantitative infographic. It has no graph nodes, control-flow edges, or decision semantics.
An IR remains the right architecture. The correction is to use family-specific schemas instead of forcing every diagram into nodes and edges.
This remains the central design decision. Claude should identify meaning. Trusted code should own geometry, typography, and export.
A universal graph schema becomes an exception warehouse when it is asked to represent time, quantitative comparison, and architecture with the same primitives.
| Previous claim | Verdict | Correction |
|---|---|---|
| These are graph-based tool orchestration diagrams. | Mostly incorrect | One is a segmented comparison graphic. Another is a sequence diagram. |
| Nodes are tools or agents. | Incorrect | Sequence diagrams use participants, lifelines, activations, and ordered messages. |
| Edges distinguish control and data flow. | Unsupported | The arrows in the published sequence visual represent messages over time. |
| Mermaid should be the primary renderer. | Too broad | Use Mermaid as an adapter. Use deterministic SVG as the canonical output. |
| Use Neo4j for storage. | Premature | A graph database adds complexity without solving the core layout problem. |
Finding 02
The commonality is editorial design language, not diagram semantics. Select a family before generating a specification.
Design 01
The model converts intent into a constrained semantic specification. The application converts that specification into a visual artifact.
User intent, evidence, audience, and desired visual outcome.
Sequence, comparison, architecture, timeline, or another explicit family.
Schema-valid content without pixel positions or arbitrary SVG.
Family renderer owns geometry, typography, routing, and tokens.
Geometry checks, screenshots, accessibility, provenance, and file output.
Design 02
A discriminated union provides shared infrastructure while preserving each diagram family’s native grammar.
export interface SequenceDiagramSpec {
kind: "sequence";
title: string;
participants: Array<{
id: string;
label: string;
role?: "person" | "service" |
"model" | "tool";
}>;
events: Array<
| {
type: "message";
from: string;
to: string;
label: string;
}
| {
type: "activate" | "deactivate";
participant: string;
}
| {
type: "group-start" | "group-end";
label?: string;
}
>;
}
export interface ComparisonDiagramSpec {
kind: "segmented-comparison";
title: string;
capacityLabel?: string;
scenarios: Array<{
id: string;
label: string;
total: number;
segments: Array<{
id: string;
label: string;
value: number;
accent: "blue" | "mint" |
"coral" | "cream" |
"neutral";
}>;
}>;
}
export type DiagramSpec =
| SequenceDiagramSpec
| ComparisonDiagramSpec
| ArchitectureDiagramSpec;
Design 03
Each diagram family gets the simplest renderer capable of producing editorial-quality output.
Resolution-independent, browser-native, accessible, inspectable, and suitable as the source for PNG or PDF export.
Participant lanes, lifelines, event rows, activations, message arrows, and text wrapping are deterministic enough to own directly.
Use ELK-style layered layout for graph-shaped diagrams. Do not use it for segmented comparison or fixed-time sequence layouts.
Font metrics change geometry. Wrapped labels change heights. Headless rendering can use a fallback font and move every element.
The shared style comes from warm surfaces, restrained strokes, low-saturation accents, strong title hierarchy, direct labels, and generous whitespace.
Design 04
A successful render is not the same as a correct diagram. Validate content, geometry, accessibility, and visual stability.
| Dimension | Cases | Purpose |
|---|---|---|
| Text length | Short, wrapped, pathological | Validates measurement and container growth. |
| Scale | 4, 8, and maximum supported participants | Exposes density and routing limits. |
| Flow | Loops, parallel groups, empty optional fields | Exercises sequence semantics. |
| Viewport | Mobile, desktop, print export | Validates responsive presentation. |
| Theme | Light, dark, preferred font missing | Exposes contrast and metric drift. |
| Language | Long words, CJK, right-to-left | Tests internationalization assumptions. |
Design 05
The renderer processes model-generated and user-provided content. Treat every label and path as untrusted input.
Escape XML or use a DOM/JSX renderer. Block scripts, event attributes, external URLs, remote fonts, and uncontrolled embedded HTML.
Limit elements, label length, nested groups, canvas dimensions, render iterations, export resolution, and total execution time.
Generate filenames server-side, reject traversal, write only to approved directories, and avoid arbitrary command execution.
// Unsafe: model or user text is inserted directly into markup.
svg += `<text>${userLabel}</text>`;
// Safer: render text as a DOM/JSX text node and validate length.
return <text>{validatedLabel}</text>;
Integration
Start with a local CLI. Add a Claude Code skill for generation discipline. Add MCP when multiple clients or remote execution justify the boundary.
Render, validate, inspect, snapshot, and export.
Classification rules, schema examples, simplification guidance, CLI usage.
Expose safe render and validation tools to multiple clients.
Generate assets, run snapshots, publish diagnostics.
Version schemas, themes, and renderer behavior.
diagram validate diagram.json
diagram render diagram.json \
--format svg \
--output architecture.svg
diagram snapshot diagram.json \
--output architecture.png
const RenderDiagramInput = z.object({
spec: DiagramSpecSchema,
format: z.enum([
"svg", "png", "pdf", "html"
]).default("svg"),
theme: z.string().default(
"editorial-warm"
),
validate: z.boolean().default(true)
});
Execution
The smallest useful product should prove both behavioral diagrams and quantitative editorial graphics.
The first two renderers should force the architecture to support both behavior over time and quantitative comparison. That is the real design test.
Evidence
This document distinguishes direct observations, architectural recommendations, and explicit inference.
Primary reference for the visual examples and advanced tool-use concepts.
Canonical specification for scalable vector graphics and text measurement behavior.
Reference for Mermaid’s sequence-diagram feature set and interoperability role.
Reference for layered graph layout, routing, ports, and compound graph support.
Reference for programmatic browser screenshot generation and visual fixtures.
Reference for local and remote MCP server integration with Claude Code.
Reference for trust boundaries and security considerations around tools and extensions.