/diagrams:diagramsfrom diagrams
Create technical architecture diagrams using Python's diagrams library (mingrammer/diagrams) or raw Graphviz dot. Use when users need to create cloud architecture diagrams with provider icons (Azure, GCP, AWS, Kubernetes, on-prem), system design diagrams, infrastructure visualizations, data flow diagrams, dependency graphs, org or process trees, or any structural diagram showing relationships between components. Also the hub for choosing the right diagram tool (Python diagrams vs Mermaid vs draw.io vs Excalidraw) and for the SVG plus PNG output pipeline that feeds GitHub markdown, PowerPoint decks and exec briefings, and standalone architecture docs. Includes iterative review loop and custom Graphviz attributes for professional formatting. Self-improving - accumulates learnings in memory file to avoid repeating mistakes. Structural diagrams only - data charts and plots belong to the dataviz skill, deck theming to presentations.
Ships in diagrams. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Create architecture diagrams programmatically using the diagrams Python library or raw Graphviz dot. This skill is also the hub of the diagrams plugin: it owns tool selection, the raw-Graphviz workflow, and the output pipelines shared by every sibling skill.
One owner per fact — these boundaries keep skills from fighting over triggers:
dataviz skill. If the visual encodes a dataset, it is not this plugin's job.presentations. This plugin renders diagram files; how a deck styles and lays out slides around them is owned there.| Need | Tool | Skill |
|---|---|---|
| GitHub-rendered repo docs, architecture flowcharts, auth sequence diagrams, ERDs, state diagrams | Mermaid | mermaid |
| Cloud architecture with provider icons — Azure first (primary platform), GCP (legacy product line), AWS/K8s/on-prem | Python diagrams | this skill |
| Dependency graphs, org/process trees, anything graph-shaped without provider icons | Raw Graphviz dot | this skill |
Reading/converting legacy .drawio files, headless export of draw.io to PNG/SVG | draw.io | drawio |
| Sketch-style, hand-drawn-look architecture diagrams | Excalidraw | excalidraw |
Default for repo docs is Mermaid (renders in place on GitHub, diffable). Reach for Python diagrams when provider iconography earns its keep — exec briefings and architecture docs where an Azure Function icon reads faster than a labeled box.
Self-improving workflow: plan → code → render → review → adjust → record learnings
This skill reads bundled guidance from memory/MEMORY.md and saves new learnings in the
consumer project, so plugin refreshes cannot erase them. Each diagram session:
Key capability: Diagrams supports custom Graphviz dot attributes for professional formatting via graph_attr, node_attr, and edge_attr parameters. See references/graphviz-attrs.md for comprehensive formatting options.
# In a project venv (preferred): uv add diagrams — or: pip install diagrams
uv pip install diagrams
# Graphviz is required for rendering — install per platform:
brew install graphviz # macOS
# apt-get install -y graphviz # Debian/Ubuntu
Confirm both landed before the first render: python3 "<skill-dir>/scripts/diagram_helper.py" validate
reports Graphviz and the diagrams library and exits non-zero if either is missing.
This skill is self-improving. Always check the memory file before starting, and record learnings after completing diagrams.
Resolve <skill-dir> from this loaded skill's absolute location. Run helpers by that
absolute path while keeping the working directory in the consumer project. First read the
bundled seed and the project's accumulated learnings:
cat "<skill-dir>/memory/MEMORY.md"
python3 "<skill-dir>/scripts/memory_manager.py" view
The learned-memory file is .claude/memory/diagrams.md when that memory directory exists,
otherwise .claude/diagrams-memory.md. A memory-path: key in the frontmatter of
.claude/diagrams.local.md overrides it with a project-relative file. Blank, malformed, or
out-of-project overrides fall back to the detected default. The .claude location is a
shared project convention and requires no Claude runtime. memory_manager.py path prints
the resolved destination. Never write learnings into the installed package.
Review relevant sections based on your task:
Apply any relevant learnings to your plan before coding.
Before writing code, explicitly plan the diagram structure:
Output a structured plan before coding:
DIAGRAM PLAN:
- Title: [diagram name]
- Direction: [TB/LR/etc]
- Style: [corporate/presentation/technical/compact]
- Components:
- [component1]: [provider.category.Node]
- [component2]: [provider.category.Node]
- Clusters:
- [cluster_name]: [component1, component2]
- Flows:
- [source] >> [target] (label: [description])
from diagrams import Diagram, Cluster, Edge
with Diagram("Name", show=False, filename="output", direction="TB"):
# nodes and connections
| Parameter | Values | Purpose |
|---|---|---|
show | False | Disable auto-open (required for headless) |
filename | string | Output path without extension |
outformat | "png", "svg", "pdf", "jpg" | Output format |
direction | "TB", "BT", "LR", "RL" | Layout direction |
graph_attr | dict | Graph-level Graphviz attributes |
node_attr | dict | Default node Graphviz attributes |
edge_attr | dict | Default edge Graphviz attributes |
# AWS
from diagrams.aws.compute import EC2, Lambda, ECS, EKS
from diagrams.aws.database import RDS, DynamoDB, ElastiCache, Redshift
from diagrams.aws.network import ELB, Route53, VPC, CloudFront
from diagrams.aws.storage import S3
from diagrams.aws.integration import SQS, SNS, StepFunctions
from diagrams.aws.analytics import Kinesis, Athena, Glue
# Azure
from diagrams.azure.compute import FunctionApps, VM, AKS
from diagrams.azure.database import SQLDatabases, CosmosDb
from diagrams.azure.network import LoadBalancers, ApplicationGateway
from diagrams.azure.storage import BlobStorage
# GCP
from diagrams.gcp.compute import GCE, GKE, Functions, AppEngine
from diagrams.gcp.database import BigQuery, SQL, Spanner
from diagrams.gcp.network import LoadBalancing
from diagrams.gcp.storage import GCS
from diagrams.gcp.analytics import PubSub, Dataflow
# Kubernetes
from diagrams.k8s.compute import Pod, Deployment, StatefulSet, ReplicaSet
from diagrams.k8s.network import Service, Ingress
from diagrams.k8s.storage import PV, PVC, StorageClass
from diagrams.k8s.clusterconfig import HPA
# On-Premises / Generic
from diagrams.onprem.compute import Server
from diagrams.onprem.database import PostgreSQL, MySQL, MongoDB, Redis
from diagrams.onprem.network import Nginx, HAProxy
from diagrams.onprem.queue import Kafka, RabbitMQ
from diagrams.onprem.monitoring import Prometheus, Grafana
from diagrams.onprem.container import Docker
from diagrams.onprem.client import Users, Client
# Generic (provider-agnostic)
from diagrams.generic.compute import Rack
from diagrams.generic.database import SQL as GenericSQL
from diagrams.generic.network import Firewall
from diagrams.generic.storage import Storage
# Custom icons
from diagrams.custom import Custom
# Flow operators
node1 >> node2 # left to right
node1 << node2 # right to left
node1 - node2 # bidirectional (no arrow)
# Multiple targets
source >> [target1, target2, target3]
# Labeled/styled edges
node1 >> Edge(label="API call", color="blue", style="dashed") >> node2
with Diagram("Clustered", show=False):
with Cluster("VPC"):
with Cluster("Public Subnet"):
lb = ELB("load balancer")
with Cluster("Private Subnet"):
web = [EC2("web1"), EC2("web2")]
lb >> web
graph_attr = {
"fontsize": "20",
"bgcolor": "white", # or "transparent"
"splines": "ortho", # "spline", "line", "ortho", "curved"
"nodesep": "0.8",
"ranksep": "1.0",
}
with Diagram("Name", show=False, graph_attr=graph_attr):
...
Diagrams supports custom Graphviz dot attributes for professional output. Pass dictionaries to graph_attr, node_attr, and edge_attr. For complete reference, see references/graphviz-attrs.md.
Full Graphviz docs: https://www.graphviz.org/doc/info/attrs.html
graph_attr = {
"fontsize": "16",
"fontname": "Helvetica",
"bgcolor": "white",
"pad": "0.5",
"nodesep": "0.8",
"ranksep": "1.0",
"splines": "ortho",
}
node_attr = {
"fontsize": "12",
"fontname": "Helvetica",
}
edge_attr = {
"fontsize": "10",
"fontname": "Helvetica",
}
with Diagram("Architecture", show=False, graph_attr=graph_attr,
node_attr=node_attr, edge_attr=edge_attr):
...
graph_attr = {
"fontsize": "24",
"fontname": "Arial",
"bgcolor": "transparent",
"pad": "1.0",
"nodesep": "1.2",
"ranksep": "1.5",
"dpi": "150",
}
node_attr = {
"fontsize": "18",
"penwidth": "2.0",
}
edge_attr = {
"penwidth": "2.0",
"arrowsize": "1.5",
}
graph_attr = {
"fontsize": "10",
"nodesep": "0.3",
"ranksep": "0.4",
"concentrate": "true",
}
node_attr = {
"fontsize": "9",
"width": "0.5",
"height": "0.5",
}
| Attribute | Scope | Values | Purpose |
|---|---|---|---|
nodesep | graph | 0.25-1.5 | Horizontal spacing between nodes (inches) |
ranksep | graph | 0.5-2.0 | Vertical spacing between ranks (inches) |
splines | graph | ortho, spline, line, curved, polyline | Edge routing style |
bgcolor | graph | color/transparent | Background color |
pad | graph | 0.1-1.0 | Padding around diagram (inches) |
dpi | graph | 72-300 | Resolution for bitmap output |
fontsize | all | 8-48 | Text size in points |
fontname | all | font name | Font family (Helvetica, Arial, Courier) |
fontcolor | all | color | Text color |
penwidth | node/edge | 0.5-3.0 | Line thickness |
style | node/cluster | filled, rounded, dashed, bold | Visual style |
fillcolor | node/cluster | color | Fill color (requires style=filled) |
color | all | color | Border/line color |
arrowsize | edge | 0.5-2.0 | Arrow scale factor |
minlen | edge | 1-5 | Minimum edge length (ranks) |
weight | edge | 1-10 | Edge importance for layout |
constraint | edge | true/false | Include edge in ranking |
compound | graph | true/false | Allow edges between clusters |
concentrate | graph | true/false | Merge parallel edges |
with Cluster("VPC", graph_attr={
"style": "rounded,filled",
"fillcolor": "#e8f4f8",
"color": "#1976d2",
"fontsize": "14",
"fontcolor": "#1976d2",
"labeljust": "l", # left-align label
"labelloc": "t", # label at top
}):
...
from diagrams import Edge
# Styled connections
node1 >> Edge(
label="API",
color="blue",
style="dashed", # solid, dashed, dotted, bold
penwidth="2.0",
fontsize="10",
fontcolor="gray",
minlen="2", # minimum length in ranks
arrowhead="vee", # normal, inv, dot, none, vee, diamond
arrowsize="1.5",
) >> node2
Execute the Python script to generate the image:
python diagram_script.py
Output file appears in working directory with specified filename.
After rendering, load and examine the image:
Common fixes:
| Problem | Solution |
|---|---|
| Overlapping nodes | Add nodesep/ranksep to graph_attr |
| Wrong flow direction | Change direction parameter |
| Cluttered connections | Use clusters to group related nodes |
| Missing icons | Use Custom() with downloaded icon |
| Edge labels overlap | Adjust minlen in Edge() |
| Nodes in wrong order | Reverse declaration order (rendered in reverse) |
Iterate phases 2-5 until output meets requirements.
After completing a diagram, reflect on the process:
If you learned something new, use memory_manager.py add to append it to the consumer
project's learned-memory file. Entries use this format:
### [Date] - [Brief Title]
**Problem**: [What went wrong]
**Solution**: [What fixed it]
**Example**:
```python
# Code snippet if applicable
#### What to Record
**DO record:**
- Import path corrections (e.g., "Use `diagrams.aws.network` not `diagrams.aws.networking`")
- Attribute values that fixed layout issues (e.g., "`nodesep=1.2` needed for 10+ nodes")
- Provider-specific quirks discovered
- Styling combinations that worked well
- Edge cases and their solutions
**DON'T record:**
- User-specific requirements
- One-off diagram structures
- Obvious errors (typos, missing imports)
#### Memory File Structure
Append learnings to the appropriate section:
```markdown
## Import Errors
### 2025-01-15 - Azure SQL Import
**Problem**: `from diagrams.azure.database import SQL` failed
**Solution**: Use `SQLDatabases` instead of `SQL`
**Example**:
```python
from diagrams.azure.database import SQLDatabases # NOT SQL
Problem: Pod nodes overlapped when using 5+ replicas Solution: Increase nodesep and use vertical layout Example:
graph_attr = {"nodesep": "1.0", "ranksep": "0.8"}
with Diagram("K8s", direction="TB", graph_attr=graph_attr):
...
This creates a growing knowledge base that improves diagram quality over time.
## Patterns
### Data Pipeline
```python
from diagrams import Diagram, Cluster
from diagrams.aws.analytics import Kinesis, Glue, Athena
from diagrams.aws.storage import S3
from diagrams.aws.database import Redshift
with Diagram("Data Pipeline", show=False, direction="LR"):
source = Kinesis("stream")
with Cluster("Processing"):
raw = S3("raw")
transform = Glue("ETL")
processed = S3("processed")
with Cluster("Analytics"):
warehouse = Redshift("DW")
query = Athena("query")
source >> raw >> transform >> processed
processed >> warehouse
processed >> query
from diagrams import Diagram, Cluster, Edge
from diagrams.aws.compute import ECS
from diagrams.aws.database import RDS, ElastiCache
from diagrams.aws.network import ELB, Route53
from diagrams.aws.integration import SQS
with Diagram("Microservices", show=False):
dns = Route53("DNS")
lb = ELB("ALB")
with Cluster("Services"):
api = ECS("API Gateway")
users = ECS("Users")
orders = ECS("Orders")
notify = ECS("Notifications")
with Cluster("Data"):
db = RDS("PostgreSQL")
cache = ElastiCache("Redis")
queue = SQS("Queue")
dns >> lb >> api
api >> users >> db
api >> orders >> db
orders >> queue >> notify
users >> cache
from diagrams import Diagram, Cluster
from diagrams.k8s.compute import Pod, Deployment
from diagrams.k8s.network import Service, Ingress
from diagrams.k8s.storage import PVC
with Diagram("K8s App", show=False, direction="TB"):
ingress = Ingress("ingress")
with Cluster("Namespace"):
svc = Service("service")
with Cluster("Deployment"):
pods = [Pod("pod-1"), Pod("pod-2"), Pod("pod-3")]
storage = PVC("data")
ingress >> svc >> pods
pods >> storage
from diagrams import Diagram
from diagrams.custom import Custom
from urllib.request import urlretrieve
# Download icon
icon_url = "https://example.com/icon.png"
icon_path = "custom_icon.png"
urlretrieve(icon_url, icon_path)
with Diagram("Custom", show=False):
custom_node = Custom("My Service", icon_path)
When no provider icon is needed — dependency graphs, org charts, process trees — skip the Python wrapper and write dot directly. Same install (graphviz), same attribute vocabulary (references/graphviz-attrs.md applies verbatim).
// deps.dot — module dependency graph
digraph deps {
rankdir=LR;
node [shape=box, style="rounded,filled", fillcolor="#eef4fb", fontname="Helvetica"];
edge [color="#555555"];
api -> service -> repo -> db;
api -> auth;
service -> queue;
}
dot -Tsvg deps.dot -o deps.svg
dot -Tpng -Gdpi=150 deps.dot -o deps.png
dot engine, rankdir=TB. Large undirected graphs: try neato or fdp; circular: circo.strict digraph deduplicates parallel edges automatically.cluster_ name prefix (subgraph cluster_platform { ... }) to draw a border.Every diagram ships as SVG + PNG side by side — SVG for crisp embedding and diffs, PNG for surfaces that can't take SVG (PowerPoint compatibility, chat, thumbnails). Three consumption surfaces:
mermaid skill) — it renders natively and diffs cleanly..2026-07-04-status-update/diagrams/01-data-storage-isolation.png + .svg. Numbering fixes narrative order; the deck embeds the PNGs, the SVGs are the editable/scalable masters.dpi="150" minimum (200 for full-slide diagrams) so projection doesn't blur.presentations owns palettes — don't bake a deck palette into the diagram).# Python diagrams: render both formats in one run
with Diagram("Auth Architecture", show=False, filename="diagrams/04-auth-db-logins",
outformat=["png", "svg"], graph_attr={"dpi": "150", "bgcolor": "white"}):
...
# Graphviz / dot equivalent
dot -Tsvg arch.dot -o diagrams/03-deploy-process.svg
dot -Tpng -Gdpi=150 arch.dot -o diagrams/03-deploy-process.png
.py / .dot) next to the outputs so the diagram is regenerable, never hand-edited.bgcolor="transparent" only when the destination background is known and controlled (a deck slide); on dark-mode pages transparent + black text becomes unreadable.#1f1f1f-ish on light fills; avoid pure-saturated fills that fight both themes. Mermaid has genuinely theme-aware options — see the mermaid skill.| Issue | Cause | Fix |
|---|---|---|
graphviz not found | Graphviz not installed | brew install graphviz (macOS) / apt-get install graphviz (Debian) |
| File not created | Exception in code | Check for import/syntax errors |
| Image opens unexpectedly | show=True (default) | Set show=False |
| Nodes too close | Default spacing | Add nodesep/ranksep to graph_attr |
| Edges overlap nodes | Default routing | Set splines="ortho" or "spline" |
| Labels overlap | Crowded layout | Increase pad, nodesep, ranksep |
| Wrong import | Node not in expected module | Check docs |
| Blurry output | Low resolution | Set dpi="150" or higher |
| Transparent bg needed | White default | Set bgcolor="transparent" |
| Edges cross clusters | Default behavior | Set compound="true", use lhead/ltail |
| Nodes in wrong order | Declaration order | Reverse order or use invisible edges |
memory/MEMORY.md — read-only guidance; also check the consumer memory
returned by scripts/memory_manager.py pathreferences/nodes.md - Complete import paths by providerreferences/patterns.md - Ready-to-use architecture templatesreferences/graphviz-attrs.md - Professional formatting attributesscripts/memory_manager.py - CLI for viewing/adding memory entries# View all memory
python3 "<skill-dir>/scripts/memory_manager.py" view
# View specific section
python3 "<skill-dir>/scripts/memory_manager.py" view --section "Import Errors"
# Search memory
python3 "<skill-dir>/scripts/memory_manager.py" search "spacing"
# Add new entry
python3 "<skill-dir>/scripts/memory_manager.py" add \
--section "Layout Issues" \
--title "Wide diagrams need LR direction" \
--problem "Diagram too tall and narrow" \
--solution "Use direction=LR for wide layouts" \
--example 'with Diagram("Wide", direction="LR"): ...'
# List sections
python3 "<skill-dir>/scripts/memory_manager.py" sections
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub hsb3/dotfiles-agents --plugin diagrams4 skills in this plugin
/drawioRead, convert, and export draw.io / diagrams.net files. Use when the user has legacy .drawio or .drawio.png/.drawio.svg files to inspect, extract content from, convert to Mermaid or another format, or export headlessly to PNG/SVG from the command line - or asks about drawio, diagrams.net, or mxGraph XML. Covers the compressed and uncompressed XML formats, a Python decompression recipe, and the desktop app's CLI export flags./excalidrawCreate sketch-style, hand-drawn-look architecture diagrams as Excalidraw files. Use when the user asks for an excalidraw diagram, a whiteboard-style or sketchy diagram, or wants a .excalidraw file created or edited. Works with or without the Excalidraw MCP tools - when the MCP tools are unavailable, author the .excalidraw JSON scene directly. Covers the scene JSON schema, element and arrow-binding essentials, an offline headless render-and-lint loop that screenshots a scene and names its defects, and export to SVG/PNG./mermaidAuthor Mermaid diagrams for GitHub-rendered markdown and technical docs - architecture flowcharts, sequence diagrams for auth and API flows, entity-relationship diagrams for database design, state diagrams, and class diagrams. Use whenever adding a diagram to a README, repo doc, PR description, or any markdown that GitHub renders, or when the user says mermaid, flowchart, sequence diagram, ERD, or state diagram. Enforces the house rule that node labels must contain no parentheses or special characters, and covers light/dark theming and local rendering to SVG/PNG via mermaid-cli.Other plugins' skills for the same job