Skills/diagrams-as-code/SKILL.md
Use only when creating architecture diagrams with Python's `diagrams` library (mingrammer/diagrams).
npx skillsauth add sammcj/agentic-coding diagrams-as-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate architecture and infrastructure diagrams using the Python diagrams library. Diagrams are Python scripts that render to image files via Graphviz.
.py file in the user's working directorypython3 <file>.pycommand -v dot >/dev/null || brew install graphviz
uv pip install --system diagrams 2>/dev/null || pip install diagrams
Without graphviz, the script fails with a cryptic error. Always verify first.
from diagrams import Diagram
with Diagram(
name="Title", # used as default filename (slugified)
filename="output", # override filename (no extension)
direction="LR", # LR | RL | TB | BT
curvestyle="spline", # spline | ortho | curved | polyline
outformat="png", # png | jpg | svg | pdf | dot (or list)
show=False, # ALWAYS False - prevents auto-opening
strict=False, # merge duplicate edges
autolabel=False, # prefix labels with provider/type
graph_attr={}, # graphviz graph attributes
node_attr={}, # graphviz node attributes
edge_attr={}, # graphviz edge attributes
):
...
Always set show=False so the script runs non-interactively.
Import from diagrams.<provider>.<category>:
from diagrams.aws.compute import EC2, Lambda, ECS
from diagrams.aws.database import RDS, Aurora
from diagrams.aws.network import ELB, Route53, CloudFront
from diagrams.k8s.compute import Pod, Deployment
from diagrams.onprem.database import PostgreSQL, MySQL
from diagrams.onprem.network import Nginx
See references/providers.md for the full provider and category listing with common node names.
ELB("lb") >> EC2("web") >> RDS("db") # left to right
RDS("db") << EC2("web") # right to left
RDS("primary") - RDS("replica") # undirected
ELB("lb") >> [EC2("w1"), EC2("w2")] # fan-out to list
Operator precedence matters: - (subtraction) binds more tightly than >> / << (bitshift) in Python, so A >> B - C parses as A >> (B - C). Wrap in parentheses when mixing: (A >> B) - C.
from diagrams import Cluster
with Cluster("VPC"):
with Cluster("Private Subnet"):
svc = [ECS("svc1"), ECS("svc2")]
Unlimited nesting depth. Clusters accept graph_attr for styling (e.g. background colour).
from diagrams import Edge
node_a >> Edge(label="HTTPS", color="darkgreen", style="dashed") >> node_b
Attributes: label (text on the edge), color (X11 name or hex), style (solid | dashed | dotted | bold).
from diagrams.custom import Custom
svc = Custom("My Service", "./icon.png") # local PNG, ideally 256x256
TB for layered/hierarchical diagrams, LR for pipelines and flowsgraph_attr={"bgcolor": "transparent"}outformat=["png", "svg"]Node from diagrams and create blank junctions with Node("", shape="plaintext", width="0", height="0"), or merge overlapping edges with graph_attr={"concentrate": "true", "splines": "spline"}uv run handles the dependency automatically:
# /// script
# dependencies = ["diagrams"]
# ///
development
Use when answering questions from this machine-learning knowledge base. Triggers: questions about transformers, attention cost and efficiency, and long-context scaling; 'what do we know about attention', 'check the ML wiki'. Read-only querying of compiled knowledge; to add, update, supersede, lint, or audit, use the llm-wiki skill instead.
development
Use when building or maintaining a self-contained personal knowledge base (an LLM wiki) as plain markdown, optionally opened as an Obsidian vault. Triggers: ingesting sources into a wiki, querying wiki knowledge, linting wiki health, auditing article claims against their sources, superseding stale knowledge, 'add to wiki', or any mention of 'LLM wiki' or 'Karpathy wiki'.
tools
Provides guidance and tools for hardware design. Activate when using KiCAD, looking up electronic parts or designing PCBs.
testing
Grilling session that challenges your plan against the existing domain model, sharpens terminology, and updates documentation (CONTEXT.md, ADRs) inline as decisions crystallise.