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
- Extract or derive diagrammable data from the current context.
- If the Emacs foreground color and background mode are not already known from a previous diagram in this session, query them:
The first returns a hex color likeemacsclient --eval '(face-foreground (quote default))' emacsclient --eval '(frame-parameter nil (quote background-mode))'"#eeffff". The second returnsdarkorlight. Reuse both for all subsequent diagrams. - Write a D2 file to a temporary file using the foreground color.
- Run D2 with
--theme 200if background mode isdark, or--theme 0iflight. - Output the result as a markdown image on its own line:
