Create professional diagrams for documentation using the D2 language.
Install
mkdir -p .claude/skills/d2 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13465" && unzip -o skill.zip -d .claude/skills/d2 && rm skill.zipInstalls to .claude/skills/d2
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.
D2 diagramming language reference for architecture diagrams, sequence diagrams, grid layouts, SQL tables, and class diagrams. Produces .d2 files rendered via CLI or playground.Key capabilities
- →Create architecture diagrams with shapes and connections
- →Draw sequence diagrams for API interactions
- →Build data model diagrams using SQL table shapes
- →Lay out grid-based comparison diagrams
- →Visualize deployment topologies or flowcharts
- →Style diagram elements with fill colors, stroke patterns, and icons
How it works
The skill processes text-based `.d2` files to define and render diagrams with specified shapes, connections, and styling.
Inputs & outputs
When to use d2
- →Creating system architecture diagrams
- →Drawing API sequence flows
- →Modeling SQL database structures
- →Visualizing deployment topologies
About this skill
D2 Diagramming Language
D2 is a text-to-diagram language. Write .d2 files and render them to SVG/PNG via the d2 CLI or https://play.d2lang.com.
When to Use
- Creating architecture or system diagrams for plans and documentation
- Drawing sequence diagrams for API or workflow interactions
- Building data model diagrams with SQL table shapes
- Laying out grid-based comparison or dashboard diagrams
- Visualizing deployment topologies, state machines, or flowcharts
Quick Reference
| Concept | Syntax |
|---|---|
| Shape | name or name: Label |
| Connection | a -> b or a -> b: label |
| Reverse / bidirectional | a <- b / a <-> b |
| Line (no arrow) | a -- b |
| Container | parent: { child1; child2 } |
| Dot nesting | parent.child.grandchild |
| Set shape type | name.shape: oval |
| Style | name.style.fill: "#ff0000" |
| Icon | name.icon: https://url/icon.svg |
| Tooltip | name.tooltip: hover text |
| Link | name.link: https://example.com |
| Class | classes: { c: { style: {...} } } then name.class: c |
| Variable | vars: { k: v } then ${k} |
| Direction | direction: right |
| Comment | # single line comment |
| SQL table | name.shape: sql_table then col: type {constraint: pk} |
| Sequence diagram | name.shape: sequence_diagram |
| Grid | name.grid-rows: 3 or name.grid-columns: 3 |
| Layers | layers: { name: { ... } } |
| Scenarios | scenarios: { name: { ... } } (inherits parent) |
| Steps | steps: { 1: { ... } 2: { ... } } (each inherits previous) |
| Import | a: @file or ...@file (spread) |
| Glob | *.style.fill: red / **.style.fill: red |
| Null (delete) | x: null / (a -> b)[0]: null |
Core Syntax
Shapes
Any identifier becomes a shape. The default shape is rectangle.
server
database: My Database
api: API Gateway {
shape: hexagon
}
All shape types: rectangle, square, page, parallelogram, document, cylinder, queue, package, step, callout, stored_data, person, diamond, oval, circle, hexagon, cloud, text, code, class, sql_table, image, sequence_diagram, c4-person.
Connections
a -> b: request
b -> a: response
a <-> b: bidirectional
a -- b: line (no arrowhead)
# Multiple connections between same shapes are indexed
a -> b: first # (a -> b)[0]
a -> b: second # (a -> b)[1]
Connection References
Style existing connections by referencing them:
a -> b: request
(a -> b)[0].style.stroke: red
(a -> b)[0].style.stroke-dash: 5
Arrowheads
a -> b: {
source-arrowhead: 1 {
shape: diamond
}
target-arrowhead: * {
shape: cf-many
}
}
Arrowhead shapes: triangle (default), arrow, diamond, circle, cf-one, cf-many, cf-one-required, cf-many-required.
Containers (Nesting)
cloud: AWS {
vpc: VPC {
subnet: Private Subnet {
ec2: Web Server
db: Database {
shape: cylinder
}
}
}
}
# Dot notation shorthand
cloud.vpc.subnet.ec2 -> cloud.vpc.subnet.db: query
Labels and Text
# Markdown labels
explanation: |md
# Architecture Overview
This system uses **microservices**.
|
# Code blocks
snippet: |go
func main() {
fmt.Println("hello")
}
|
# LaTeX
formula: |latex
\\frac{n!}{k!(n-k)!}
|
Direction
Controls layout flow. Values: up, down (default), left, right.
direction: right
a -> b -> c
Null (Deletion)
Remove shapes, connections, or attributes:
x: {style.fill: red}
x.style.fill: null # remove fill
x: null # remove shape entirely
(a -> b)[0]: null # remove connection
Comments
# This is a comment
server # Inline comment
"""
This is a block comment
spanning multiple lines
"""
Positions (near)
Position items at fixed points around the diagram:
title: Architecture Overview {
shape: text
near: top-center
style.font-size: 28
}
legend: {
near: bottom-right
}
Values: top-left, top-center, top-right, center-left, center-right, bottom-left, bottom-center, bottom-right.
Label/icon positioning (additional values):
node: {
label.near: outside-top-center
icon: https://icons.terrastruct.com/aws/Compute/Amazon-EC2.svg
icon.near: outside-left-center
}
Extra values for label/icon: outside-top-left, outside-top-center, outside-top-right, outside-left-center, outside-right-center, outside-bottom-left, outside-bottom-center, outside-bottom-right.
Dimensions
node: {
width: 200
height: 100
}
Cannot be set on containers (they resize to fit children).
Configuration via Vars
vars: {
d2-config: {
theme-id: 4
dark-theme-id: 200
pad: 50
center: true
sketch: true
layout-engine: elk
}
}
Layout engines: dagre (default, free), elk (free, more features), tala (premium).
Resource Files
For detailed guidance, read these on-demand:
- shapes-and-connections.md — Complete shape catalog, connection types, arrowheads
- styling-and-layout.md — All style properties, classes, themes, layout engines
- special-diagrams.md — Sequence diagrams, grid layouts, SQL tables, class diagrams
- composition-and-advanced.md — Vars, globs, imports, layers, scenarios, steps
Input / Output
This skill defines no input parameters or structured output.
When not to use it
- →The user needs to render diagrams without the `d2` CLI or play.d2lang.com
Limitations
- →It requires external tools (`d2` CLI or play.d2lang.com) for rendering
- →It does not support direct image output without rendering
How it compares
This approach uses a text-to-diagram language for diagram creation, allowing version control and programmatic generation, unlike manual drawing tools.
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 | No flags | Beginner |
| c4 | 0 | 1mo | Review | Intermediate |
| draw-io | 41 | 6mo | Review | Intermediate |
| mermaid-expert | 27 | 4mo | No flags | Beginner |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
c4
me2resh
Generate C4 L1 (Context) + L2 (Container) Mermaid diagrams from a project's codebase. Structurizr DSL escape hatch (--dsl) for L3+ component precision.
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.
excalidraw-diagram-generator
github
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.
scientific-schematics
davila7
Create publication-quality scientific diagrams using Nano Banana Pro AI with smart iterative refinement. Uses Gemini 3 Pro for quality review. Only regenerates if quality is below threshold for your document type. Specialized in neural network architectures, system diagrams, flowcharts, biological pathways, and complex scientific visualizations.
mermaid-diagrams
davila7
Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts, gantt charts, or any other diagram type. Triggers include requests to "diagram", "visualize", "model", "map out", "show the flow", or when explaining system architecture, database design, code structure, or user/application flows.