d2

Installation
SKILL.md

Create diagrams with D2

Create a diagram from the most recent interaction context using D2. Generate a PNG image and output it as a markdown image so it renders inline.

How to create a diagram

  1. Extract or derive diagrammable data from the current context.
  2. If the Emacs foreground color and background mode are not already known from a previous diagram in this session, query them:
    emacsclient --eval '(face-foreground (quote default))'
    emacsclient --eval '(frame-parameter nil (quote background-mode))'
    
    The first returns a hex color like "#eeffff". The second returns dark or light. Reuse both for all subsequent diagrams.
  3. Write a D2 file to a temporary file using the foreground color.
  4. Run D2 with --theme 200 if background mode is dark, or --theme 0 if light.
  5. Output the result as a markdown image on its own line:
    ![description](/tmp/agent-diagram-XXXX.png)
    
Related skills
Installs
17
GitHub Stars
97
First Seen
Mar 12, 2026