/aeo-docs:d2from aeo-docs
Creates, edits, and renders diagrams using the D2 text-to-diagram language. Supports architecture, flowchart, sequence, ER/SQL schema, UML class, network topology, mind map, deployment, org chart, state machine, and grid layouts.
Ships in aeo-docs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
D2 is a declarative text-to-diagram language. You write a .d2 file; the d2 CLI compiles it to SVG/PNG/PDF/PPTX/GIF. Most files are short — five to fifty lines — and lean on layout engines (dagre/elk/tala) to position things automatically.
This skill is your reference for writing D2 well. The body below is the working overview; the detailed grammar and per-diagram-type references are in references/. Hand-edit examples are in assets/examples/.
Pick the shape that actually matches the data, not the one that's flashy. D2 has eight specialized diagram modes plus the general-purpose flowchart mode that does everything else.
shape: sequence_diagram (alice → bob → carol with messages).shape: sql_table per table + crow's-foot connections (cf-many / cf-one).shape: class (fields + methods with visibility prefixes).grid-rows: N / grid-columns: N on the container.shape: hierarchy.shape: image.shape: text, shape: code, or a |md ... | / |tex ... | block.If the user asks for a "Mermaid flowchart" or "Graphviz dot" or "PlantUML sequence diagram", D2 can produce the same diagram — just tell them you'll use D2's equivalent.
# Comments start with '#'
direction: right # up | down | left | right (default: down)
# Shapes are declared by mentioning them, optionally with a label
api: API Gateway # `api` is the key, "API Gateway" is the label
db: { shape: cylinder } # set shape via attributes
worker.shape: queue # dot syntax also works
# Connections — these IMPLICITLY create the shapes if not already declared
api -> db: writes # directed edge with label
worker <- queue # reverse direction
client <-> server # bidirectional
metric -- log # undirected
# Chained connections
client -> api -> worker -> db
# Containers (nesting)
prod: {
api -> db
worker -> db
}
prod.api -> staging.api: replicate # cross-container reference
# Styling — quote hex colors (unquoted '#' starts a comment!)
api.style.fill: "#4baae5"
api.style.stroke-width: 2
(api -> db)[0].style.stroke: red # style a specific connection
That's enough to draft most diagrams. The rest is refinement.
web server.shape: hexagon — web server is one identifier.aws.vpc.subnet.ec2 creates a 4-deep hierarchy.. in them, single quotes to bypass ${var} substitution and special meanings: 'literal text'. Backticks are not used.\n (api: my\nmulti-line\nlabel) or a |md ... | block.desc: |md\n # Title\n - bullet 1\n - bullet 2\n|.label, shape, icon, near, top, left, width, height, style, class, classes, vars, layers, scenarios, steps, direction, link, tooltip, constraint, source-arrowhead, target-arrowhead, grid-rows, grid-columns, grid-gap, vertical-gap, horizontal-gap. To use one literally as a shape name, escape with a leading \ or quote it.shape: values that change layout/parsing rulesThese have special handling. The rest (rectangle, square, page, parallelogram, document, cylinder, queue, package, step, callout, stored_data, person, diamond, oval, circle, hexagon, cloud, c4-person) only change appearance.
| Shape | What changes |
|---|---|
sequence_diagram | Whole container is laid out as actor lanes + time arrows. See references/sequence-diagrams.md. |
sql_table | Children become rows (column-name: type with optional {constraint: primary_key}). See references/sql-and-er-diagrams.md. |
class | Children become UML fields/methods. Visibility via + - # prefix. See references/class-diagrams.md. |
hierarchy | Tree layout from connections. Position keywords forbidden. See references/grid-diagrams.md. |
image | Borderless icon-only node. Pair with icon: <url>. |
text | Plain text node, no surrounding box. |
code | Code block (use style.font: mono and ` |
grid-rows: N / grid-columns: N | Children flow into a grid in declaration order. See references/grid-diagrams.md. |
direction: if the auto-layout direction is wrong. Default is top-to-bottom; direction: right is the most common override (good for sequence/process flows).dagre (default) for plain hierarchical flowcharts.elk for SQL/UML/anything with deep nesting and cross-container edges, and for crisp orthogonal routing.tala (paid) only when the user explicitly asks or the diagram needs near: <other-shape> or per-container direction:.vars.d2-config rather than scattered style.* overrides. Use semantic theme color codes (B1–B6, AA2/4/5, AB4/5, N1–N7) so themes still work.https://icons.terrastruct.com for AWS/GCP/Azure/dev/tech categories — they elevate architecture diagrams.classes: if you find yourself repeating styles more than twice. Don't preemptively define classes.D2 errors loudly when syntax is wrong, but stays silent when the diagram is visually broken. The compiler will happily produce a diagram with overlapping text, truncated labels, mis-aligned cards, orphaned containers, illegible contrast, or comic spacing — and report success. So you have to look.
Workflow:
d2 input.d2 input.png. PNG renders through headless Chromium so it requires Playwright/Chromium to be installed; SVG is a fallback that works without.Visual-quality checklist — scan the image for each of these and fix what's broken:
width: on the class, or shorten the label.height: on the class to force uniform.|md blocks especially can render text outside the box bounds. Use a fixed width: and height: to constrain, or shrink font-size.shape: text with style.opacity: 0).--layout=elk (orthogonal) instead of dagre. For complex architecture, ELK is almost always better. If edges still cut diagonally across content under ELK, the cause is usually a grid-rows: / grid-columns: container — see pitfall 15 and references/edge-routing.md.font-size: 8 is the floor; below that, increase the box size or split content.stroke-width: 1 on a light-on-light combo disappears; bump to 2–4.B1 darkest → B6 lightest) are designed to pair text/fill correctly.If you're tempted to skip the render step because "the syntax is correct": don't. That's the failure mode this section exists to prevent. The user will be looking at the image, not at the source.
vars.d2-config blockWhen you produce a polished diagram, put this near the top — it sets sensible defaults and makes the output theme-aware:
vars: {
d2-config: {
layout-engine: elk # crisp orthogonal routing, good for most cases
theme-id: 0 # Neutral default; see references/styling-and-themes.md for the full list
pad: 40 # tighter than the 100px default
sketch: false # set true for hand-drawn whiteboard look
}
}
CLI flags (--theme=N, --sketch, --layout=elk) override these. Don't set sketch: true by default — the user usually wants the polished version.
If d2 is available on the user's machine (or in this sandbox), render directly:
d2 input.d2 output.svg # SVG (default, best)
d2 input.d2 output.png # PNG (raster; needs Playwright/Chromium)
d2 input.d2 output.pdf # PDF (multi-board → multi-page)
d2 --layout=elk --theme=101 input.d2 # output defaults to input.svg
d2 --animate-interval=1500 in.d2 out.svg # animate through layers/scenarios/steps
d2 --watch in.d2 # live-reload server; opens a browser
d2 fmt in.d2 # autoformat in place
d2 validate in.d2 # parse-only check
If d2 is not installed, do NOT pip install/brew install it without the user's blessing. Either:
.d2 file and tell them to render it (or paste at https://play.d2lang.com).brew install d2 (mac) / curl -fsSL https://d2lang.com/install.sh | sh -s -- (linux/mac) / Windows MSI.When you do produce a rendered file, prefer SVG unless the user explicitly needs PNG/PDF/PPTX. SVG keeps tooltips, links, animations, and infinite zoom; PNG strips all of that and needs a headless Chromium.
The full list is in references/full-grammar-cheatsheet.md. The top hits:
# is a comment. style.fill: #4baae5 is broken. Use style.fill: "#4baae5".-> not --> for connections (no Mermaid-style double-dash).alt/opt/loop/par keyword in sequence diagrams — those are just nested groups whose key happens to be named alt etc. See references/sequence-diagrams.md.# (protected) visibility collides with comments — escape as \# or use the # prefix without alphanumerics on the next char.fill is not allowed on connections. Use stroke for connection color.shape: hierarchy forbids top:/left: keywords — it'll error.sequence_diagram, all actors must be predeclared at the top of the container if you want to reference them in nested groups.${var} substitution. Double quotes / unquoted text expand it. Surprising if you're escaping for shell reasons.(a -> b)[0] indexes the first edge between a and b. Multiple a -> b lines create distinct edges, not overrides — use the index syntax to restyle one of them.near: <shape-id> is TALA-only. Cardinal near: top-center works in any engine.|md blocks ignore card box styling in practice. Even though |md is documented as defaulting to a rectangle, applying style.fill / style.stroke / style.border-radius / style.shadow via a class on a |md shape often does nothing visible — the box is invisible behind the markdown rendering. For boxed content with bullets, use shape: rectangle with a \n-separated label (e.g. iam: "Identity & Access\n\n• Authentication\n• SSO\n• User management" { class: card }). Save |md for situations where you actually want rendered Markdown text without a surrounding box.height: on the class so every card in the row is the same size.grid-columns: 1 (or grid-rows: N). Otherwise dagre/elk treats each grid as a peer and lines them up sideways.label: "" when you're using nested grids structurally. Otherwise the row containers' names ("domains", "concerns") show up as visible labels in the rendered diagram.grid-rows: / grid-columns: on a connected container breaks ELK's orthogonal routing. When grid children connect to shapes outside the grid, ELK silently falls back to diagonal/polyline routes for those cross-grid edges, producing the spaghetti-line look the engine is supposed to prevent. Drop the grid (let ELK arrange siblings itself) or connect to the parent container instead of individual children. See references/edge-routing.md.style.border-radius is the curve lever, and it scales past the documented max. Docs say 0–20, but values up to ~100 work and progressively soften corners. border-radius: 20 is the architectural-soft sweet spot; border-radius: 50–100 reads as a Bezier curve while keeping ELK's clean orthogonal routing. Per-edge AND per-class. See references/edge-routing.md for the full picture, including why true Bezier curves require switching engines.The body above is enough for ~70% of cases. For the rest, read the relevant reference file:
references/edge-routing.md — connection styling, curves vs. orthogonal, corner softening, multi-bend workarounds, the grid-vs-ELK pitfall in depth.references/shapes-and-connections.md — every shape value, every connection operator, arrowheads, labels, the full styling menu.references/layouts.md — engine selection (dagre/elk/tala), direction:, near:, top:/left:, width:/height: per engine.references/styling-and-themes.md — theme IDs, palette codes (B1–B6, AA2/AA4/AA5, AB4/AB5, N1–N7), sketch mode, custom theme overrides.references/containers-classes-vars.md — nesting, classes:, vars: substitution, inheritance.references/grid-diagrams.md — grid-rows: / grid-columns:, gap controls, layout caveats.references/sequence-diagrams.md — actor lanes, time arrows, nested groups (alt/opt/loop/par).references/sql-and-er-diagrams.md — shape: sql_table, crow's-foot cardinalities, ELK's exact-column routing.references/class-diagrams.md — shape: class, visibility prefixes, fields/methods.references/markdown-and-text.md — |md / |tex / |<lang> blocks, multi-line labels, the |md styling caveat.references/icons-and-images.md — icon:, shape: image, the icons.terrastruct.com catalog.references/boards.md — layers: / scenarios: / steps: for multi-board diagrams (multi-page PDFs, multi-slide PPTX, animated SVG).references/globs-and-filters.md — * wildcard, & filters, ** deep glob.references/imports.md — @import and ...@import, partial vs. spread imports.references/cli-and-tooling.md — every d2 CLI flag, env vars, watch mode, d2 fmt and d2 validate.references/full-grammar-cheatsheet.md — the long-tail grammar quirks not covered above.assets/examples/architecture.d2 (opens in a new tab)assets/examples/c4.d2 (opens in a new tab)assets/examples/class-diagram.d2 (opens in a new tab)assets/examples/deployment.d2 (opens in a new tab)assets/examples/er-diagram.d2 (opens in a new tab)assets/examples/flowchart.d2 (opens in a new tab)assets/examples/grid.d2 (opens in a new tab)assets/examples/mindmap.d2 (opens in a new tab)assets/examples/multilayer.d2 (opens in a new tab)assets/examples/network.d2 (opens in a new tab)assets/examples/sequence.d2 (opens in a new tab)assets/examples/state-machine.d2 (opens in a new tab)assets/examples/timeline.d2 (opens in a new tab)references/boards.md (opens in a new tab)references/class-diagrams.md (opens in a new tab)references/cli-and-tooling.md (opens in a new tab)references/containers-classes-vars.md (opens in a new tab)references/edge-routing.md (opens in a new tab)references/full-grammar-cheatsheet.md (opens in a new tab)references/globs-and-filters.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
d2, diagramming, text-to-diagram, architecture-diagrams, flowcharts
Other plugins' skills for the same job
npx claudepluginhub aeyeops/aeo-skill-marketplace --plugin aeo-docs4 skills in this plugin
/architecture-docsUse when someone asks to document system architecture for a technical audience — write an ADR, capture an
architectural decision, generate C4 diagrams (Context / Container / Component / Code), produce an OpenAPI spec
for an HTTP API, draft a system or component design document, or document how services integrate. Covers the
C4 model, Architectural Decision Records, OpenAPI specifications, and design documents for engineers who need
to build against or reason about the architecture. Not for: end-user-facing docs (use the `aeo-docs:diataxis`
skill instead — tutorials, how-tos, references, explanations live there), README content, or code-level inline
documentation.
/diataxisUse whenever someone asks to document something for users — write a getting-started guide, generate an API,
config, or CLI reference, write a deployment, migration, or troubleshooting guide, explain a design decision,
or produce any docs that will live in `docs/`. Authors user-facing technical documentation following the
Diataxis framework: tutorials, how-to guides, reference material, and conceptual explanations, each with its
own structural template and no cross-mode bleed. Not for: README content, code comments, architecture / C4 /
ADR / OpenAPI work (use `aeo-docs:architecture-docs` instead), or internal design docs that aren't
user-facing.