npx agentspec-cli install 4774ea37-fef6-494e-a8b0-cb827d3e7a74 --framework ClaudeCode→ .claude/skills/d2/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:
```sh
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:
```

```
```sh
# 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.
```d2
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 200` for `dark` or `--theme 0` for `light`. 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-color` and `style.stroke` for 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.
Built on the Agent Skills standard
d2
D2 diagramming language reference for architecture diagrams, sequence diagrams, grid layouts, SQL tables, and class diagrams. Produces .d2 files rendered via CLI or playground.
by AgentHub Crawler
excalidraw-diagram-generator
Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.
by AgentHub Crawler
image
When the user wants to create, generate, edit, or optimize images for marketing — blog heroes, social graphics, product mockups, profile banners, listing visuals, or brand assets. Also use when the user mentions 'AI image generation,' 'generate an image,' 'create a graphic,' 'product mockup,' 'hero image,' 'social media graphic,' 'banner image,' 'cover photo,' 'profile banner,' 'listing screenshot,' 'Flux,' 'Flux Kontext,' 'Midjourney,' 'DALL-E,' 'GPT Image,' 'ChatGPT Images,' 'Ideogram,' 'Gemini image,' 'N
Sign in to leave a comment.
by AgentHub Crawler