A tool that takes context and converts it into rendered D2 diagrams, ideal for visualizing system architecture.
Install
mkdir -p .claude/skills/d2-xenodium && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15407" && unzip -o skill.zip -d .claude/skills/d2-xenodium && rm skill.zipInstalls to .claude/skills/d2-xenodium
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
This skill should be used when the user invokes "/d2" to create a diagram from the current context using D2 and output the resulting image path.Key capabilities
- →Extract diagrammable data from context
- →Query Emacs foreground color and background mode
- →Write D2 files to temporary locations
- →Run D2 with theme based on background mode
- →Output rendered diagrams as markdown images
- →Apply foreground color to D2 node and edge styles
How it works
The skill extracts data from the current context, queries Emacs for theme information, generates a D2 file, and then renders it to a PNG image with D2.
Inputs & outputs
When to use d2
- →Visualize system architecture
- →Create flowcharts from project code
- →Generate dependency diagrams
- →Document process flows
About this skill
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:

# Use --theme 200 for dark, --theme 0 for light
d2 --theme 200 --pad 40 /tmp/agent-diagram-XXXX.d2 /tmp/agent-diagram-XXXX.png
D2 template
Use --theme 200 for dark or --theme 0 for light, based on the Emacs background mode. Apply the queried foreground color to style.font-color and style.stroke on nodes and edges.
direction: right
node1: Label {
style.font-color: "#eeffff"
style.fill: "#2d3748"
style.stroke: "#eeffff"
}
node2: Label {
style.font-color: "#eeffff"
style.fill: "#2d3748"
style.stroke: "#eeffff"
}
node1 -> node2: label {style.stroke: "#eeffff"; style.font-color: "#eeffff"}
Rules
- Query the Emacs foreground color once per session and reuse it for all subsequent diagrams. Only query again if the color is not already known.
- Query the Emacs background mode once per session via
(frame-parameter nil 'background-mode). Use--theme 200fordarkor--theme 0forlight. Always use--pad 40. - Always use a timestamp in the filename (e.g.,
/tmp/agent-diagram-$(date +%s).png). Never use descriptive names. - Set the queried foreground color on
style.font-colorandstyle.strokefor all nodes and edges so the diagram is readable on the user's Emacs background. - Use meaningful fill colors to distinguish different types of elements.
- After D2 runs successfully, output a markdown image (
) on its own line. - Choose an appropriate layout direction and structure for the data.
- Include labels on edges when they add clarity.
- If no diagrammable data exists in the recent context, inform the user.
When not to use it
- →If no diagrammable data exists in the recent context
- →When the user does not explicitly invoke '/d2'
- →When a diagram is not required from the current context
Limitations
- →Requires Emacs foreground color and background mode for theming
- →Diagrams are rendered as PNG images
- →Filenames must include a timestamp and not be descriptive
How it compares
This skill automates the creation of D2 diagrams from context, including theme adaptation, rather than requiring manual D2 file creation and rendering.
Compared to similar skills
d2 side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| d2 (this skill) | 0 | 5mo | Review | Intermediate |
| plantuml-ascii | 8 | 6mo | Review | Beginner |
| mermaidjs-v11 | 4 | 7mo | Review | Beginner |
| mermaid-visualizer | 6 | 6mo | No flags | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
plantuml-ascii
github
Generate ASCII art diagrams using PlantUML text mode. Use when user asks to create ASCII diagrams, text-based diagrams, terminal-friendly diagrams, or mentions plantuml ascii, text diagram, ascii art diagram. Supports: Converting PlantUML diagrams to ASCII art, Creating sequence diagrams, class diagrams, flowcharts in ASCII format, Generating Unicode-enhanced ASCII art with -utxt flag
mermaidjs-v11
mrgoonie
Create diagrams and visualizations using Mermaid.js v11 syntax. Use when generating flowcharts, sequence diagrams, class diagrams, state diagrams, ER diagrams, Gantt charts, user journeys, timelines, architecture diagrams, or any of 24+ diagram types. Supports JavaScript API integration, CLI rendering to SVG/PNG/PDF, theming, configuration, and accessibility features. Essential for documentation, technical diagrams, project planning, system architecture, and visual communication.
mermaid-visualizer
axtonliu
Transform text content into professional Mermaid diagrams for presentations and documentation. Use when users ask to visualize concepts, create flowcharts, or make diagrams from text. Supports process flows, system architectures, comparisons, mindmaps, and more with built-in syntax error prevention.
wiki-page-writer
microsoft
Generates rich technical documentation pages with dark-mode Mermaid diagrams, source code citations, and first-principles depth. Use when writing documentation, generating wiki pages, creating technical deep-dives, or documenting specific components or systems.
draw-io
davila7
draw.io diagram creation, editing, and review. Use for .drawio XML editing, PNG conversion, layout adjustment, and AWS icon usage.
mermaid-expert
sickn33
Create Mermaid diagrams for flowcharts, sequences, ERDs, and architectures. Masters syntax for all diagram types and styling. Use PROACTIVELY for visual documentation, system diagrams, or process flows.