d2
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:

More from xenodium/emacs-skills
emacsclient
Always use emacsclient instead of emacs. This applies to all Emacs operations: user requests, byte compilation, check-parens, running ERT tests, and any other elisp evaluation.
59describe
This skill should be used when the user invokes "/describe" to look up Emacs documentation via emacsclient.
43dired
This skill should be used when the user invokes "/dired" to open files from the latest interaction in an Emacs dired buffer via emacsclient.
42open
This skill should be used when the user invokes "/open" to open files from the latest interaction in Emacs buffers via emacsclient.
40select
This skill should be used when the user invokes "/select" to open one or more files in Emacs and select a region relevant to the current discussion via emacsclient.
39highlight
This skill should be used when the user invokes "/highlight" to highlight relevant regions in one or more files in Emacs via emacsclient.
39