| name | diagrams-as-code |
| description | Use only when creating architecture diagrams with Python's `diagrams` library (mingrammer/diagrams). |
| allowed-tools | Bash(python3 *) Bash(uv *) Bash(pip install *) Bash(command -v *) Bash(brew install *) Read Write Edit Glob Grep |
Diagrams as Code
Generate architecture and infrastructure diagrams using the Python diagrams library. Diagrams are Python scripts that render to image files via Graphviz.
Workflow
- Check prerequisites - verify graphviz and diagrams are installed
- Write the diagram script to a
.py file in the user's working directory
- Run it with
python3 <file>.py
- Report the output path to the user (image appears in working directory)
Prerequisites check
command -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.
Core API
Diagram context manager
from diagrams import Diagram
with Diagram(
name="Title",
filename="output",
direction=,
curvestyle=,
outformat=,
show=,
strict=,
autolabel=,
graph_attr={},
node_attr={},
edge_attr={},
):
...