D2 Diagram Generator

VerifiedSafe

Generates diagrams using the D2 diagramming language. Supports various diagram types including UML class diagrams, SQL tables, containers, and custom shapes. Useful when users need to create technical diagrams programmatically, especially for architecture, database schemas, or flowcharts.

Sby Skills Guide Bot
DocumentationIntermediate
6/2/2026
Claude Code
#d2#diagramming#visualization#architecture

Recommended for

Automated summary

Generates diagrams using the D2 language, supporting various shapes, containers, UML class diagrams, and SQL tables.

Strengths

  • Supports a wide range of shapes and containers
  • Integrates UML and SQL table diagrams
  • Allows markdown and code blocks
  • Multiple rendering options (SVG, PNG) with layout and theme control

Limitations

  • Requires the D2 CLI to be installed
  • Complex diagrams may need non-default layout engine
  • Limited to D2's syntax and capabilities
When to use it

Use this skill when you need to create clear, structured diagrams for architecture, data models, or documentation.

When not to use it

Avoid when you need highly customized or interactive diagrams, or if D2 is not available in the environment.

Security analysis

Safe
Quality score90/100

The skill only describes writing .d2 files and running the d2 CLI with rendering options. There are no destructive commands, network calls, or handling of sensitive data. The CLI execution is benign and typical for diagram generation.

No concerns found

How this analysis is made

Examples

System architecture diagram
Create a system architecture diagram showing a web server, database, and client with D2.
UML class diagram
Generate a UML class diagram for a User and Organization model with D2.
ER diagram
Create an entity-relationship diagram using D2's sql_table shape for users and orders.

name: d2-diagram description: Generate diagrams using the D2 diagramming language. Use when the user requests diagrams.

D2 Diagram

Instructions

Generate D2 code following these guidelines.

Basic Syntax

# Nodes and labels
node1
node2: Custom Label

# Connections
a -> b: label     # directed arrow (left to right)
a <- b: label     # directed arrow (right to left)
a <-> b: label    # bidirectional arrow
a -- b: label     # line (no arrows)

# Chained connections
a -> b -> c -> d

Containers

# Dot notation (quick)
aws.ec2.instance

# Map syntax (structured)
aws: {
  ec2: {
    instance
  }
}

# Reference children with full path
aws.ec2.instance -> database

Shapes

Available shapes: rectangle, square, circle, oval, diamond, hexagon, parallelogram, cylinder, queue, package, step, page, document, callout, stored_data, person, cloud

server: Web Server {shape: cylinder}
user: {shape: person}
cdn: {shape: cloud}

UML Class Diagrams

MyClass: {
  shape: class
  +publicField: string
  -privateField: int
  #protectedField: bool
  +publicMethod(): void
  -privateMethod(arg: string): int
}

SQL Tables

users: {
  shape: sql_table
  id: int {constraint: primary_key}
  email: varchar {constraint: unique}
  org_id: int {constraint: foreign_key}
}

orgs: {
  shape: sql_table
  id: int {constraint: primary_key}
  name: varchar
}

users.org_id -> orgs.id

Markdown and Code Blocks

# Markdown content
readme: |`
# Title
- List item
- Another item
`|

# Code block with syntax highlighting
snippet: |`go
func main() {
    fmt.Println("Hello")
}
`|

Guidelines

  1. Write D2 code to .d2 files
  2. Use descriptive node IDs (e.g., web_server not ws)
  3. Group related nodes in containers
  4. Add labels to connections when they clarify relationships
  5. Choose appropriate shapes for the domain (e.g., cylinder for databases, cloud for external services, person for users)
  6. Render to PNG by default unless vector format is specifically requested

Rendering

Render diagrams using the d2 CLI. The output format is determined by the file extension.

# Render to SVG (vector)
d2 input.d2 output.svg

# Render to PNG (raster)
d2 input.d2 output.png

# Set layout engine (dagre is default, elk for complex diagrams)
d2 --layout=elk input.d2 output.png

# Set theme (0-8, or use theme name)
d2 --theme=3 input.d2 output.png

# Set padding around diagram
d2 --pad=50 input.d2 output.png

# Sketch mode (hand-drawn look)
d2 --sketch input.d2 output.png

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/d2-diagram-generator-mm5t8bip/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/d2-diagram-generator-mm5t8bip' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/d2-diagram-generator-mm5t8bip/download' --output '.skill-downloads/d2-diagram-generator-mm5t8bip/SKILL.md.part' && mv '.skill-downloads/d2-diagram-generator-mm5t8bip/SKILL.md.part' '.skill-downloads/d2-diagram-generator-mm5t8bip/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/d2-diagram-generator-mm5t8bip/SKILL.md' && test -s '.skill-downloads/d2-diagram-generator-mm5t8bip/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/d2-diagram' && cp -R '.skill-downloads/d2-diagram-generator-mm5t8bip' '.claude/skills/d2-diagram'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/d2-diagram-generator-mm5t8bip'

openskills read 'd2-diagram-generator-mm5t8bip'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/d2-diagram-generator-mm5t8bip/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills