Automated summary
A syntax reference for the D2 diagramming language, used to write .d2 files (architecture, sequence, SQL table and grid diagrams) that render to SVG/PNG via the d2 CLI or playground.
Strengths
- Compact quick-reference table for shapes, connections, containers, styles, icons and direction
- Covers varied diagram types: sql_table, sequence_diagram, grids, layers, scenarios and steps
- Explains reuse mechanics: classes, variables, imports and globs
- Points to both rendering paths (d2 CLI or play.d2lang.com)
Limitations
- It is a cheat sheet rather than a tutorial; the comments section is cut off mid-sentence
- No CLI installation steps or export flag details
- Advanced features (layers, scenarios, steps) are only listed, without full worked examples
Use it to quickly draft syntactically correct .d2 files for architecture, sequence or data-model diagrams.
Skip it if you need step-by-step CLI installation guidance or diagram types D2 does not support.
Security analysis
SafeThis skill is a documentation/reference for the D2 diagramming language. It declares no tools, contains no executable commands, scripts, network calls, secret handling, or destructive instructions, and only describes syntax and CLI/playground rendering conceptually.
No concerns found
How this analysis is madeExamples
Write a D2 file for our AWS architecture: an API gateway calling two Lambda services, each with its own Postgres database, plus a shared S3 bucket. Use nested containers and give the databases a cylinder shape.Create a D2 sequence diagram for an OAuth login flow between the browser, the auth service and the user database.Generate a D2 data model using sql_table shapes for users, orders and order_items, marking primary and foreign keys, with direction right.name: d2 description: "D2 diagramming language reference for architecture diagrams, sequence diagrams, grid layouts, SQL tables, and class diagrams. Produces .d2 files rendered via CLI or playground."
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.
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 filesThis 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.mdFrom the root of a test project, save the file as .skill-downloads/d2-diagramming-language-mrwak8xo/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-diagramming-language-mrwak8xo' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/d2-diagramming-language-mrwak8xo/download' --output '.skill-downloads/d2-diagramming-language-mrwak8xo/SKILL.md.part' && mv '.skill-downloads/d2-diagramming-language-mrwak8xo/SKILL.md.part' '.skill-downloads/d2-diagramming-language-mrwak8xo/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.
Original excerpt: 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 |
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-diagramming-language-mrwak8xo/SKILL.md' && test -s '.skill-downloads/d2-diagramming-language-mrwak8xo/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/d2' && cp -R '.skill-downloads/d2-diagramming-language-mrwak8xo' '.claude/skills/d2'Cursor
test -f '.skill-downloads/d2-diagramming-language-mrwak8xo/SKILL.md' && test -s '.skill-downloads/d2-diagramming-language-mrwak8xo/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/d2' && cp -R '.skill-downloads/d2-diagramming-language-mrwak8xo' '.cursor/skills/d2'Codex
test -f '.skill-downloads/d2-diagramming-language-mrwak8xo/SKILL.md' && test -s '.skill-downloads/d2-diagramming-language-mrwak8xo/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/d2' && cp -R '.skill-downloads/d2-diagramming-language-mrwak8xo' '.agents/skills/d2'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 installationopenskills install './.skill-downloads/d2-diagramming-language-mrwak8xo'openskills read 'd2-diagramming-language-mrwak8xo'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 syncManual 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-diagramming-language-mrwak8xo/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.
Supabase Docs Authoring
Documentation
Write, edit, and review Supabase documentation content including guides, tutorials, reference docs, and partials. Follow style guides and MDX/TOML validation rules.
Create Architecture Decision Record
Documentation
Create a new Architecture Decision Record with sequential numbering, register it in the AgentDB graph, and link related ADRs.
Plan update with deep research
Documentation
Updates a plan document by launching parallel subagents to analyze a topic across all compiler passes, then consolidates findings into the plan doc.