Index of every page on this site: llms.txt
All skills
Run it yourself

Make box-and-arrow diagrams as images with the D2 CLI, including Oxide-styled ones for slides, docs, or notes. Use when the user asks for a diagram as a PNG/SVG, wants an existing mermaid diagram rendered nicely, or mentions d2. Covers the render-and-look loop, the Oxide style import, and layout gotchas.

  • 2 files
  • 5.7 KB
  • Updated last month
  • GitHub
Use this Skill: https://skilld.dev/gh/david-crespo/dotfiles/d2

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈77 tokens for metadata: the name and description. ≈1.1k when used: this file.

Description uses 3.9% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈310 characters, or 3.9%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

D2 diagrams

d2 is installed (brew install d2). It renders .d2 source to SVG or PNG with dagre or ELK layout built in. No browser needed, renders in tens of ms.

Loop

  1. Write the source to the scratchpad (or wherever the user wants it kept).
  2. d2 file.d2 file.png
  3. Look at the PNG with the Read tool. Fix. Repeat.

For the user to iterate alongside: d2 --watch file.d2 file.svg serves a live-reloading preview in the browser.

Oxide style

Import the shared style at the top of the file:

...@/Users/david/repos/dotfiles/d2/oxide.d2

direction: right
a: Some artifact { class: thing }
b: Another { class: thing }
g: A group {
  class: group
  c: Inside { class: thing }
}
a -> b { class: edge }
b -> g.c: uses { class: dashed }

Classes: thing (green box, the nouns), group (gray box, for containers and verb labels), edge (solid), dashed (secondary relationship, takes a label). The import sets ELK layout, padding, and the background. Colors are design-system dark-theme tokens; the file comments name each one. Font is D2's default; changing it needs TTF files via --font-* flags, not worth it.

See examples/pipeline.d2 for a full diagram using a container, multi-line labels, and edge ordering.

Layout control (ELK)

  • Vertical order within a column follows node declaration order. To move a node to the bottom, declare it last.
  • Port order on a fan-out node follows edge declaration order. If two edges cross on the way to their targets, reorder the edge lines.
  • Nested direction inside a container is ignored under ELK.
  • Container padding is fixed and generous. A grid container (grid-rows: 2, grid-gap: 12) packs children tightly, but only works when edges connect to the container itself, not to its children: edges into grid children route badly and can drag the container out of its column. For two small things that travel together, a single box with a two-line label ("TypeScript client\n+ mock API server") usually reads better than any container. A container with transparent fill and stroke looks broken; avoid it.
  • Tall fan-out nodes: a node with many outgoing edges grows to fit its ports. Pin it with height: 70 (or whatever matches the other boxes).
  • Invisible edges are not a tool here. There is no ~~~. Use ordering.
  • Edges that flow against direction get routed around the outside, even when a short straight path exists: ELK treats them as feedback edges. Declare every edge in the layout direction and flip the arrowhead with <- where the flow runs back: server.thread <- you: comment lays out like server.thread -> you but points at server.thread. A diagram of a round trip (request out, reply back) needs this on every return edge.
  • Kinks on edges into a column of nodes: when the box at the other end is much shorter than the column, its ports bunch up and each edge jogs. Set that box's height to about the column's so its ports sit level with their targets. Try two or three heights; the straight one is obvious.
  • ELK's crossing minimization can override declaration order for a node with edges on both sides. When reordering doesn't move it, merging or dropping a node usually helps more.

Syntax gotchas

  • Maps must be multi-line or use ; separators. vars: { d2-config: { layout-engine: elk, theme-id: 200 } } fails with a confusing "layout not found" error. Write it over several lines.
  • Newlines in labels: impl: "API implementation\n(Rust)".
  • Edge attributes go in braces after the optional label: a -> b: label { class: dashed }.
  • Source arrowheads (source-arrowhead) only draw on bidirectional edges (a <-> b). On a -> b they are silently dropped. Arrowhead size cannot be changed.
  • Import paths (...@path) are cut at the first ., so a path through .config or .claude fails with "failed to import /path/up/to/dot.d2". That is why the style lives at ~/repos/dotfiles/d2/oxide.d2.
  • Top-level background: style.fill: "#..." at file root. theme-id alone does not set it.

When not to use D2

If the diagram needs to live as text inside an RFD, GitHub markdown, or an Obsidian note, write mermaid instead: those render mermaid natively and D2 only as an image. Mermaid can be rendered to PNG with mmdc (mermaid-cli, installed) but needs a theme JSON and a CSS file to look like anything.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at d229350. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last week.

Activeupdated last month

README badge

README badge for david-crespo/dotfiles/d2