diagrams-as-code

diagrams-as-code is a skill for Claude Code from sammcj/agentic-coding. It costs 27 tokens per session (1,033 once invoked), scanned A, original, Apache-2.0.

A Python-based way to create architecture and infrastructure diagrams as image files. It uses the diagrams library and Graphviz, a tool that lays out graph-based drawings.

In plain words
What is it for?
Creating architecture or infrastructure diagrams from Python scripts, then rendering them as PNG, JPG, SVG, PDF, or Graphviz files.
Why use it?
It turns a written Python description into a repeatable diagram, avoiding manual drawing and making diagram changes easier to reproduce.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Creating architecture or infrastructure diagrams from Python scripts, then rendering them as PNG, JPG, SVG, PDF, or Graphviz files.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sammcj/agentic-coding/diagrams-as-code
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add sammcj/agentic-coding --skill diagrams-as-code
Clone the repo
git clone --depth 1 https://github.com/sammcj/agentic-coding

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for diagrams-as-code

README.md
[![agentmods](https://agentmods.dev/badge/skills/sammcj/agentic-coding/diagrams-as-code/github.svg)](https://agentmods.dev/skills/sammcj/agentic-coding/diagrams-as-code)
Your own site
<a href="https://agentmods.dev/skills/sammcj/agentic-coding/diagrams-as-code"><img src="https://agentmods.dev/badge/skills/sammcj/agentic-coding/diagrams-as-code/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for diagrams-as-code

Your own site · 80×15
<a href="https://agentmods.dev/skills/sammcj/agentic-coding/diagrams-as-code"><img src="https://agentmods.dev/badge/skills/sammcj/agentic-coding/diagrams-as-code.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 27 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,033 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00027 $0.01033
Opus 5.5 $0.00011 $0.00413
Sonnet 5.5 $0.00005 $0.00207
Haiku 4.5 $0.00003 $0.00103

Measured 1mo ago against content hash fea5affb0098, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

diagrams-as-code scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Skills_disabled/diagrams-as-code/SKILL.md · 121 lines

How it starts

The opening of the file, as written. The whole thing — 121 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

  1. Check prerequisites - verify graphviz and diagrams are installed
  2. Write the diagram script to a .py file in the user's working directory
  3. Run it with python3 <file>.py
  4. 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",           # 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.

Nodes

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.

Read the full file on GitHub · 121 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 121 lines · 27 tokens per session scan A fea5affb0098

Subscribe to this mod's changes

diagrams-as-code is a skill published in the GitHub repository sammcj/agentic-coding (167 stars, last pushed today), licensed Apache-2.0. It adds 27 tokens to every session and 1,033 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.