Agent skill

Diagrams As Code

by sammcj in sammcj/agentic-coding

Use only when creating architecture diagrams with Python's diagrams library (mingrammer/diagrams).

Apache-2.0Auto-check passedDevelopment

Install Diagrams As Code

skills CLI
$ npx skills add sammcj/agentic-coding --skill diagrams-as-code -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install sammcj/agentic-coding diagrams-as-code --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/sammcj/agentic-coding.git skills-src && mkdir -p .claude/skills && cp -r skills-src/Skills_disabled/diagrams-as-code .claude/skills/diagrams-as-code && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
diagrams-as-code
GitHub stars
162
Token cost
~1k tokens
SKILL.md length
242 words
Files
2 (incl. references)
Skills in repo
64
Repo updated
First seen
Licence
Apache-2.0

At a glance

Use only when creating architecture diagrams with Python's diagrams library (mingrammer/diagrams).

  • Works in 4 steps: Check prerequisites - verify graphviz… → Write the diagram script to a .py file… → Run it with python3 .py → …
  • Tasks that involve Diagrams
  • SKILL.md covers Workflow, Core API and Key Techniques
  • Calls uv, brew and pip

What it does

Diagrams As Code is an agent skill from sammcj/agentic-coding. Use only when creating architecture diagrams with Python's diagrams library (mingrammer/diagrams).

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/providers.md`).

It sits in Development, covering Diagrams. It works with Python. The repository describes itself as: Agentic Coding Rules, Templates etc... The licence is Apache-2.0.

When your agent uses it

  • Tasks that involve Diagrams

Example prompts

  • “/diagrams-as-code”

Requirements

  • Python 3
  • Pre-approved tools (allowed-tools): Bash(python3 *), Bash(uv *), Bash(pip install *), Bash(command -v *), Bash(brew install *), Read, Write, Edit, Glob, Grep

Workflow steps

4 steps, taken from the first numbered list in SKILL.md.

  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 .py
  4. Report the output path to the user (image appears in working directory)

What it can do on your machine

Read from SKILL.md and the folder at commit 2f25ced. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Bash(python3 *)
    • Bash(uv *)
    • Bash(pip install *)
    • Bash(command -v *)
    • Bash(brew install *)
    • Read
    • Write
    • Edit
    • Glob
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • uv
    • brew
    • pip
    • python3

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use uv and pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Diagrams As Code loads about 1k tokens when it runs, and up to ~2.3k if it reads all its reference files. Until then it costs about 29 tokens; SKILL.md has 242 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~29
When it runs · the whole SKILL.md, loaded when a task matches
~1k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from sammcj/agentic-coding at commit 2f25ced, republished under its Apache-2.0 licence (© sammcj). 242 words, ~1,016 tokens.

Download SKILL.mdSave it as .claude/skills/diagrams-as-code/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
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

  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
bash
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
python
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>:

python
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.

Data flow operators
python
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.

Clusters
python
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).

Edges
python
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).

Custom nodes
python
from diagrams.custom import Custom

svc = Custom("My Service", "./icon.png")  # local PNG, ideally 256x256

Key Techniques

  • Direction: use TB for layered/hierarchical diagrams, LR for pipelines and flows
  • Transparent background: graph_attr={"bgcolor": "transparent"}
  • Multiple outputs: outformat=["png", "svg"]
  • Reduce edge noise: import 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"}
  • Assign nodes to variables when they connect to multiple other nodes
  • PEP 723 for standalone scripts so uv run handles the dependency automatically:
    python
    # /// script
    # dependencies = ["diagrams"]
    # ///

© sammcj, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in Skills_disabled/diagrams-as-code of sammcj/agentic-coding.

  • SKILL.md
  • references/providers.md

Open the folder on GitHubat commit 2f25ced

Compare with similar skills

Diagrams As Code next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Diagrams As Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Diagrams As Code this skillsammcj/agentic-coding162—~1kAutomated safety check: PassApache-2.0
Senior Architect Toolkitmaslennikov-ig/claude-code-orchestrator-kit2608 repos~1.2kAutomated safety check: NotesCustom licence
Code Graph Mermaid Diagramstrailofbits/skills7.4k—~1.7kAutomated safety check: PassCC-BY-SA-4.0
Design Doc MermaidSpillwaveSolutions/design-doc-mermaid1761 repos~5.6kAutomated safety check: PassNone
VisiomasterRss3208/Visiomaster821—~15kAutomated safety check: PassMIT
Archscribelazypay/Archscribe359—~1.9kAutomated safety check: PassMIT

Similar skills

  • Senior Architect Toolkit

    maslennikov-ig/claude-code-orchestrator-kit

    Comprehensive software architecture skill for designing scalable, maintainable systems using ReactJS, NextJS, NodeJS, Express, React Native, Swift, Kotlin…

    260 GitHub starsUsed in 8 repos~1.2k tokens
    DevelopmentAuto-check: notes
  • Code Graph Mermaid Diagrams

    trailofbits/skills

    Official

    Generates Mermaid diagrams from Trailmark code graphs, including call graphs, class hierarchies, module dependency maps, complexity heatmaps and attack surface data flows.

    7.4k GitHub stars~1.7k tokensUpdated 2 days ago
    DevelopmentAuto-check passed
  • Design Doc Mermaid

    SpillwaveSolutions/design-doc-mermaid

    Create Mermaid diagrams (flowchart, sequence, class, ER, state, C4, architecture) from text or source code.

    176 GitHub starsUsed in 1 repo~5.6k tokens
    DevelopmentAuto-check passed
  • Visiomaster

    Rss3208/Visiomaster

    Windows-first Visio diagram reconstruction workflow for flowcharts, architecture diagrams, and paper-style module figures.

    821 GitHub stars~15k tokensUpdated 25 days ago
    DevelopmentAuto-check passed
  • Archscribe

    lazypay/Archscribe

    Create premium hand-drawn architecture, workflow, and swimlane diagrams in a dark neon or light paper style, with editable Excalidraw sources, PNG/SVG previews, animated GIF/MP4 output, and…

    359 GitHub stars~1.9k tokensUpdated 2 mo ago
    DevelopmentAuto-check passed
  • Drawio Diagram Builder

    Will-hxw/drawio-diagram-builder

    Create, edit, replicate, and iteratively refine editable research and technical diagrams in diagrams.net/draw.io (.drawio XML) from prompts, papers, repositories, screenshots, or existing diagrams.

    413 GitHub stars~5.9k tokensUpdated 3 mo ago
    DevelopmentAuto-check passed

More from sammcj/agentic-coding

All 64 skills in this repo
  • Yue2 Music

    sammcj/agentic-coding

    A skill your agent uses when generating songs with YuE2, covering a recording via SheetSage2 audio-to-ABC, editing a score or lyrics with melody preservation, or building a reproducible listening…

    162 GitHub stars~2.3k tokensUpdated today
    Auto-check passed
  • Bento Slides

    sammcj/agentic-coding

    A skill your agent uses when creating or editing Bento (.bento.html) slide decks, including any request for a single-file HTML slide deck.

    162 GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Idrive Backup

    sammcj/agentic-coding

    A skill your agent uses whenever the user wants you to manage, discuss or diagnose iDrive Backup configuration on macOS

    162 GitHub stars~1.7k tokensUpdated today
    Auto-check: notes
  • Piper Tts Training

    sammcj/agentic-coding

    Train custom TTS voices for Piper (ONNX format) using fine-tuning or from-scratch approaches.

    162 GitHub stars~1.4k tokensUpdated today
    Auto-check passed
  • PPTX To Md

    sammcj/agentic-coding

    Convert a PPTX slide deck into per-slide markdown that preserves both the verbatim text and the meaning of embedded screenshots, diagrams and charts in their original layout positions.

    162 GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Skill Creator Primer

    sammcj/agentic-coding

    You MUST load this skill before the skill-creator skill AND before making ANY change to, or conducting a review of ANY Agent Skill.

    162 GitHub stars~9.8k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Diagrams As Code

What does Diagrams As Code do?

Use only when creating architecture diagrams with Python's diagrams library (mingrammer/diagrams). Diagrams As Code is an agent skill from sammcj/agentic-coding. Use only when creating architecture diagrams with Python's diagrams library (mingrammer/diagrams).

When should I use Diagrams As Code?

Diagrams As Code fits situations like: tasks that involve Diagrams.

How do I install Diagrams As Code in Claude Code?

Run `npx skills add sammcj/agentic-coding --skill diagrams-as-code -a claude-code`. Or copy the skill folder (Skills_disabled/diagrams-as-code in sammcj/agentic-coding) into .claude/skills/diagrams-as-code in your project. Claude Code loads it when a task matches its description.

How do I install Diagrams As Code in Codex?

Run `npx skills add sammcj/agentic-coding --skill diagrams-as-code -a codex`. Or copy the skill folder (Skills_disabled/diagrams-as-code in sammcj/agentic-coding) into .agents/skills/diagrams-as-code in your project. Codex loads it when a task matches its description.

Can I use Diagrams As Code in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add sammcj/agentic-coding --skill diagrams-as-code -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/diagrams-as-code, .gemini/skills/diagrams-as-code, .github/skills/diagrams-as-code and .opencode/skills/diagrams-as-code in your project.

What does Diagrams As Code need to run?

Going by SKILL.md and its folder, Diagrams As Code needs the command-line tools its instructions call (uv, brew, pip and python3). Our summary lists: Python 3. Its frontmatter pre-approves these tools: Bash(python3 *), Bash(uv *), Bash(pip install *), Bash(command -v *), Bash(brew install *), Read, Write, Edit, Glob, Grep.

Does Diagrams As Code access the network?

SKILL.md contains no URLs. Its commands use uv and pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Diagrams As Code safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Diagrams As Code use?

Diagrams As Code is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Diagrams As Code use?

About 1k tokens (SKILL.md is roughly 4.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.3k tokens, read only when the agent opens those files.

What are the alternatives to Diagrams As Code?

Skills that share tags, products or a category with Diagrams As Code: Senior Architect Toolkit (maslennikov-ig/claude-code-orchestrator-kit, 260 stars), Code Graph Mermaid Diagrams (trailofbits/skills, 7.4k stars), Design Doc Mermaid (SpillwaveSolutions/design-doc-mermaid, 176 stars) and Visiomaster (Rss3208/Visiomaster, 821 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Diagrams As Code?

sammcj (a GitHub user) maintains it in sammcj/agentic-coding, which has 162 GitHub stars. The repository holds 64 skills in this directory. The repository was last updated on October 9, 2026.

Source: sammcj/agentic-coding on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.