d2

d2 is a skill for Claude Code, Codex from fmind/dot. It costs 31 tokens per session (725 once invoked), scanned A, original, MIT.

A workflow for creating and exporting D2 diagrams, a text-based diagram format, when the layout needs more control than a basic flowchart tool provides.

In plain words
What is it for?
Design diagrams with nested containers, layers, scenarios, boards, or process steps, then format, validate, render, and inspect the export.
Why use it?
It gives structured diagrams a repeatable path from source to validated SVG, PNG, PDF, presentation, animation, or text output.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/fmind/dot/d2
Any agent
npx skills add fmind/dot --skill d2
Clone the repo
git clone --depth 1 https://github.com/fmind/dot

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for d2

README.md
[![agentmods](https://agentmods.dev/badge/skills/fmind/dot/d2.svg)](https://agentmods.dev/skills/fmind/dot/d2)
Your own site
<a href="https://agentmods.dev/skills/fmind/dot/d2"><img src="https://agentmods.dev/badge/skills/fmind/dot/d2.svg" alt="Measured on agentmods" height="20"></a>
Per session 31 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 725 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.00725
Opus 5 $0.00015 $0.00362
Sonnet 5 $0.00006 $0.00145
Haiku 4.5 $0.00003 $0.00072

Measured yesterday against content hash c99e57b00fbb, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

d2 scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/d2/SKILL.md · 44 lines

How it starts

The opening of the file, as written. The whole thing — 44 lines — stays where its author put it; the contents beside it link to each section on GitHub.

D2 Diagram Standard

D2 is the specialist diagram tool: use it when the repository already owns .d2 sources, the diagram needs bespoke composition (nested containers, boards, scenarios, layers, steps), a standalone SVG, PNG, PDF, PPTX, GIF, or ASCII export is the deliverable, or Mermaid cannot express the visual cleanly. Tool choice lives in fmind-visuals.

Workflow

  1. State the thesis: the visual claim, target medium, and expected reading size.

  2. Write the smallest readable source: prefer containers, explicit directions, and short labels over manual coordinates.

  3. Choose the layout: start with dagre; try elk only when it produces a materially clearer topology (d2 layout lists the engines).

  4. Apply the palette: an Fmind article diagram imports diagram.d2 and uses its classes on a light surface; elsewhere start from a built-in theme (d2 themes) and apply the Fmind tokens through theme-overrides as in fmind-theme.

  5. Format, validate, and render, trusting the exit status rather than the presence of an output file:

    d2 fmt diagram.d2
    d2 validate diagram.d2
    d2 diagram.d2 diagram.svg
    
  6. Inspect the export: clipping, crossings, font fallback, contrast, appendix behavior, and whether links or tooltips survive the target embedding.

Gotchas

  • Raster by default: prefer SVG for web pages and documentation; use PNG only for raster-only destinations.
  • Partial font sets: supply all eight --font-* flags together with custom TTF files so missing weights do not silently fall back.
  • PNG and PDF need a browser: D2 rasterizes through a bundled Playwright download; when it is unavailable, keep the SVG and rasterize it with playwright instead of pinning an obsolete browser.
  • Exported image as source: keep .d2 beside every generated artifact; the export is never the editable source.
  • Native rendering: switch to mermaid when the source must render inside GitHub or Slidev Markdown.

Read the full file on GitHub · 44 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 44 lines · 31 tokens per session scan A c99e57b00fbb

Subscribe to this mod's changes

d2 is a skill published in the GitHub repository fmind/dot (4 stars, last pushed today), licensed MIT. It adds 31 tokens to every session and 725 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.