d2-diagram

Generate D2 diagram files for flowcharts, architecture, and sequence diagrams.

Updated Feb 9, 2026
One-click install
npx skills add https://github.com/RandyHaylor/enhanceclaude --skill d2-diagram-randyhaylor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: d2-diagram
Source: https://github.com/RandyHaylor/enhanceclaude/tree/main/ai-tools/d2-diagram
Command: npx skills add https://github.com/RandyHaylor/enhanceclaude --skill d2-diagram-randyhaylor

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill automates the creation of complex technical diagrams (flowcharts, architecture, sequence, etc.) using the D2 language, eliminating the need for manual drawing and ensuring consistency.

Core Features & Use Cases

  • Diagram Generation: Creates .d2 files for various diagram types including flowcharts, architecture, sequence, state machines, SQL schemas, and class diagrams.
  • Template Library: Offers pre-defined templates for common diagram needs.
  • Syntax Reference: Provides comprehensive guides on D2 syntax for customization.
  • Use Case: Document your microservices architecture with a clear, renderable D2 diagram, or visualize a complex API request flow.

Quick Start

Use the d2-diagram skill to create a D2 architecture diagram for a system with a web server, API gateway, and a PostgreSQL database.

Frequently Asked Questions about d2-diagram

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate a D2 diagram for a microservices architecture?

To generate a D2 diagram for microservices architecture, you define the system components and connections in a .d2 file. This Skill automates creating that text-based D2 syntax, providing templates and syntax references for clear, renderable architecture visualization.

Can I create sequence diagrams and database schemas using D2 syntax?

Yes, you can create sequence diagrams and database schemas using D2 syntax. This Skill generates .d2 files for various technical visualizations, including state machines, SQL schemas, and class diagrams, automating the syntax creation process.

Do I need the D2 CLI and VS Code extension to preview D2 diagrams?

Yes, you need the D2 CLI and the VS Code D2 extension to validate and preview D2 diagrams. This Skill generates the raw .d2 text files, but relies on these external tools to render the visual output and check syntax accuracy.

What is the best way to document an API request flow as code?

The best way to document an API request flow as code is using the D2 language to generate text-based diagram files. This Skill automates creating the .d2 syntax for visualizing complex API flows, ensuring consistency without manual drawing.

Does D2 support generating state machines and class diagrams?

Yes, D2 supports generating state machines and class diagrams. This Skill creates .d2 files for these specific diagram types, offering guided workflows and an extensive syntax reference to accurately map out system states and class structures.

Why use D2 for technical visualization instead of manual diagramming tools?

You use D2 for technical visualization to eliminate manual drawing and ensure consistency across documentation. This Skill automates the creation of complex D2 diagram files, making it easier to maintain and version-control architecture and flowchart designs.