pma-d2
Installation
SKILL.md
D2 Diagram Author
Generate idiomatic .d2 source files — diagrams encoded as declarative text, rendered by the official d2 CLI to SVG / PNG / PDF / GIF. The output is human-readable, diffable, and embeds anywhere D2 embeds (GitHub, Notion, VS Code, docs sites, Oxide's play.d2lang.com).
Keep this entry file small. Load only the reference packs that match the current diagram.
Always-On Rules
- Output is
.d2text, nothing else. The skill never invokes a renderer; the user runsd2 input.d2 out.svgor opens play.d2lang.com. Quality must be enforceable by reading the source. - Idiomatic D2 over clever D2. Prefer declarative node names (
api -> db) over IDs + labels when the name reads naturally. Reach forlabel:only when the natural name would be awkward or duplicated. - Shape type matches concept. A database is
shape: cylinder, a queue isshape: queue, an actor isshape: person. Never default everything torectangle. Full catalog inreferences/shapes.md. - Direction declared up front. Set
direction: down | right | up | lefton the root (and per container if needed). Layout direction is a communication choice, not an incidental default. - Semantic edge style, not ornamental.
stroke-dashfor async / weak dependency;animated: truefor streams;strokecolor to encode criticality / failure paths. Catalog inreferences/connections.md. - Group by container, not by proximity. If nodes belong to one domain (a subsystem, a cloud, a bounded context), nest them in a container map. Containers are D2's native grouping — use them instead of manual placement.
- One concept per diagram. If a diagram answers two questions, split into two
layers:or two files. Don't compress. - Classes for repetition. ≥ 2 nodes share styling → define a class in
classes: {}and apply with.class: nameor a glob. - No invented shapes. All
shape:values must come fromreferences/shapes.md. D2 silently falls back to rectangle on typos, which is the worst failure mode: it looks right but isn't. - Commit-ready source. File ends with a newline, uses 2-space indentation, no trailing whitespace, comments explain intent not mechanics. D2 is git-friendly — keep it that way.