agentleFS
jonathan-vellajonathan-vella/apex/.github/skills/apex-python-diagrams/SKILL.md

apex-python-diagrams

Skill220 starsChanged 2 months agoMITView on GitHub

**UTILITY SKILL** — Python diagram generation for Azure architectures, WAF/cost/compliance charts, ERDs, swimlanes, timelines, and wireframes. WHEN: 'architecture diagram', 'WAF bar chart', 'cost chart', 'ERD', 'swimlane', 'timeline', 'wireframe'. DO NOT USE FOR: inline Mermaid diagrams (apex-mermaid).

  • Installs packages

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every diagram generator emits both .svg and .png siblings — the .svg is the editable vector master (selectable text, embedded official …

    line 30
  2. Distinctive:

    Inspect scope & choose pattern: Read the architecture/plan specification for exact titles, resource names, CIDRs, boundaries, and …

    line 76
  3. Very specific:

    Keep service cards compact (1–2 lines, h=44..84) with concise titles ("Blob Storage", "Azure OpenAI", "snet-pe / Private endpoints").

    line 120
  4. Very specific:

    Keep a 20px+ gap between sibling boxes, leave dedicated routing corridors for orthogonal connectors (M...H...V...), and use Unicode → …

    line 123
  5. Very specific:

    Non-Azure shapes: No official Azure icon exists for a generic browser, laptop, folder, or Microsoft Graph — use clean labelled box()/card() …

    line 131
  6. Very specific:

    DON'T: Call plt.savefig(...), Diagram(..., outformat=...), or dot.render(...) directly · Shrink font sizes below 12px to cram text · Route …

    line 141
  7. Very specific:

    Does NOT: produce inline Mermaid diagrams (apex-mermaid) · generate Bicep/Terraform · create ADRs (apex-azure-adr) · deploy resources.

    line 145

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Diagrams & Charts (dlib SVG/PNG + matplotlib)

Skill for authoring faithful, brand-consistent Azure architecture diagrams as editable 1920×1080 SVG masters plus 3840×2160 (4K) PNG renders using scripts/dlib.py and the bundled official Microsoft Azure Public Service Icons v23 (assets/), alongside matplotlib for quantitative WAF/cost/compliance charts via scripts/diagram_io.py.

Prerequisites

pip install cairosvg matplotlib pillow diagrams graphviz && apt-get install -y graphviz

Routing Guide

Every diagram generator emits both .svg and .png siblings — the .svg is the editable vector master (selectable text, embedded official Azure SVG <symbol> icons) and the .png is the 3840×2160 raster render.

Diagram typeEngineHelper / APIOutput
Azure architecture, hub-spoke routing, private DNSdlib (scripts/dlib.py)from dlib import *; reset(); add(...); finish(...).py + .svg + .png (4K)
Identity, RBAC, Key Vault & telemetry flowsdlib (scripts/dlib.py)from dlib import *; reset(); add(...); finish(...).py + .svg + .png (4K)
Subscription vending, cutover & pipeline swimlanesdlib (scripts/dlib.py)from dlib import *; reset(); add(...); finish(...).py + .svg + .png (4K)
WAF bar chartsmatplotlibsave_figure from scripts/diagram_io.py.py + .png + .svg
Cost donut / projection chartsmatplotlibsave_figure from scripts/diagram_io.py.py + .png + .svg
Compliance gap & Gantt timeline chartsmatplotlibsave_figure from scripts/diagram_io.py.py + .png + .svg
Entity-relationship diagrams (ERD)dlib or graphvizdlib.finish or render_graphviz (diagram_io.py).py + .png + .svg
UI wireframesSVG / graphvizcreate_wireframe_svg (multi_diagram_generator.py).py + .svg (+ .png via CairoSVG)

Required Outputs (Workflow Integration)

For the standalone assessment profile, assets/03-des-diagram.{py,png,svg} is mandatory before final bundle acceptance. Diagram generation uses authorized evidence and validated analysis, not an intermediate Architecture approval. Render all observed resource families inside their Subscription/RG/VNet containers, encode observed versus declared/unverified edges visually via the compact legend (capping caveat boxes at <= 10% of canvas height), and never portray a recommendation or unverified control as deployed. For assessment-bundle-v3 (visual_charts: true), 03-Architect also runs python3 tools/scripts/render-assessment-charts.py --project-dir agent-output/{project} during analysis to produce assets/02-waf-posture.{png,svg}, assets/03-cost-trends.{png,svg}, and assets/03-cost-drivers.{png,svg} from _meta/waf-scores.json and contracts/03-cost-management.json, embedding the SVGs inline in 02-architecture-assessment.md and 03-cost-management-report.md.

StepPython diagram & chart files
202-waf-scores.py/.png/.svg (matplotlib via save_figure)
303-des-diagram.py/.png/.svg (dlib), 03-des-cost-distribution.py/.png/.svg, 03-des-cost-projection.py/.png/.svg
404-dependency-diagram.py/.png/.svg (dlib), 04-runtime-diagram.py/.png/.svg (dlib)
707-ab-diagram.py/.png/.svg (dlib), 07-ab-cost-*.py/.png/.svg, 07-ab-compliance-gaps.py/.png/.svg

Suffix rules: -des for design (Step 3), -ab for as-built (Step 7).

Architecture Diagram Workflow (dlib.py)

Draw the approved specification faithfully; never redesign or invent unapproved services.

Choosing the Right Style: AAC Technical Architecture vs. Executive Overview Slide

  • AAC Technical Architecture (default for 03-des-diagram, 04-runtime-diagram, 07-ab-diagram): Use bare official Azure icons (tile()), neutral containment boundaries (zone() for region, sub, rg, vnet, subnet, onprem), thin dark orthogonal connectors with numbered flow badges (flow()), and a matching dataflow_key(). This aligns with Microsoft Azure Architecture Center (AAC) and Well-Architected Framework diagramming standards.
  • Executive / Bid Overview Slide (for RFI/RFP briefings and capability overviews): Use horizontal card() tiles, semantic tinted sub() / rg() frames, arr() connectors, and a bottom 5-stage chevron() summary bar (gen02 pattern).
  1. Inspect scope & choose pattern: Read the architecture/plan specification for exact titles, resource names, CIDRs, boundaries, and connectors. Consult references/common-patterns.md for the closest template (AAC hub-spoke + observability with numbered dataflows, executive overview, private DNS, identities/telemetry, or swimlanes).
  2. Author .py using AAC primitives (or semantic topology spec):
    import sys
    from pathlib import Path
    sys.path.insert(0, str(Path(".github/skills/apex-python-diagrams/scripts").resolve()))
    from dlib import *  # noqa: F403
    
    reset()
    add(zone(40, 80, 1840, 820, "Azure Region: Sweden Central", kind="region", zone_id="reg-swc"))
    add(zone(70, 130, 520, 740, "Hub VNet", kind="vnet", subtitle="10.0.0.0/16", zone_id="vnet-hub", parent_id="reg-swc"))
    add(tile(200, 260, "fw", "Azure Firewall", node_id="fw-hub", parent_id="vnet-hub"))
    add(tile(440, 260, "dnsresolver", "DNS Private Resolver", node_id="dns-hub", parent_id="vnet-hub"))
    add(flow([(260, 260), (380, 260)], step=1, style="private", source_id="fw-hub", target_id="dns-hub"))
    add(dataflow_key(40, 920, 1840, [(1, "Hub firewall proxies private DNS resolution.")]))
    finish("agent-output/{project}/04-runtime-diagram", "Runtime Architecture & Private Connectivity", style="aac")
  3. Run & check overflow warnings: Execute python3 agent-output/{project}/<name>.py. dlib.t() prints WARN overflow: lines whenever estimated text width exceeds mw. Fix every warning by wrapping text or widening the container — never shrink text below 12px. tile() and zone() enforce strict=True exact icon matching so invalid icon keys fail immediately with suggestions.
  4. Inspect the rendered PNG & SVG: View the rendered .png to verify zero overlapping labels, uncrossed arrows, and clean visual hierarchy. Note: if the view tool caches by path, copy the PNG to a unique preview filename, inspect it, and remove the temporary preview afterward.

Canvas, Palette & Boundary Rules (dlib.py)

  • Canvas: SVG width="3840" height="2160" viewBox="0 0 1920 1080", explicit white background (#FFFFFF), font Segoe UI, Arial, sans-serif. Title top-centre at (960, 56) (40px bold navy #0B1F3A); footer bottom-centre at (960, 1058) (18px #4A5A6A, defaults to "APEX").
  • Semantic Colours:
    • Shared platform (BL / BLF): Stroke #0078D4, fills #E6F1FB / #F5FAFF
    • Workload (TL / TLF): Stroke #008272, fills #E3F4F1 / #F2FAF8
    • Legacy / management (SL / GRF): Stroke #5B6B7B, fill #EEF2F6
    • Migration / notes / policy / exceptions (AM / AMB / AMF): Stroke #D18B00 / #F2A900 on fill #FFF6DD
    • Identity (PU / PUF): Stroke #7B3FA0, fill #F3ECF8
  • Distinct Boundaries (containment = boundary, relationship = arrow):
    • Tenant: tenant(x=30, y=80, w=1860, h=940, name="Microsoft Entra tenant") — heavy navy solid border (NAVY, sw=3, rx=14) + ten icon
    • Management group: Filled rounded box with mg icon
    • Subscription: sub(x, y, w, h, name, col, fill, badgetxt, bw) — solid 2.5px border + sub icon + top-right scope badge
    • Resource group: rg(x, y, w, h, name, col) — dashed 1.8px border (stroke-dasharray="7 4") + rg icon
    • VNet / Subnet: Solid box inside RG with vnet / subnet icon and CIDR block in the header
  • Semantic Connectors (arr(d, kind=...), vbracket(...), legend(...), chevron(...)):
    • net (solid blue #0078D4): network/request traffic
    • id (dashed purple #7B3FA0): identity, RBAC, token/secret authorization
    • dns (dotted teal #008272): private DNS resolution
    • tel (dashed slate #5B6B7B): diagnostics and OpenTelemetry/Log Analytics
    • mig (solid amber #D18B00): replication / migration cutover path
    • off (dashed grey #8A98A8): disabled / decommissioned path
  • Typography & Anti-Crowding (gen02 / gen08 / gen09 Visual Standard):
    • Body 16–22px, headers 20–26px, badges 15px bold, nothing below ~12px.
    • Keep service cards compact (1–2 lines, h=44..84) with concise titles ("Blob Storage", "Azure OpenAI", "snet-pe / Private endpoints"). Never pack 3–4 lines of spec-sheet prose into wide full-width text blocks.
    • Group stacked Private Endpoint or VNet-integrated targets with vbracket(x, y1, y2) and label connectors directly with inline chip() / chip2() pills.
    • Anchor end-to-end overview diagrams with an outer tenant() frame, a top-left visual legend(60, 172, ...) listing only used connector kinds, and a bottom 5-stage chevron() bar + summary chip().
    • Keep a 20px+ gap between sibling boxes, leave dedicated routing corridors for orthogonal connectors (M...H...V...), and use Unicode → (\u2192) rather than ASCII -> in text labels.

Official Azure SVG Icons (assets/)

All 705 official Microsoft Azure Public Service Icons (v23) plus assets/github.svg (gh) are vendored offline under assets/.

  • Curated short keys (dlib.P): ten, mg, sub, rg, pol, bud, arc, rsv, bvault, vnet, subnet, fw, fwp, waf, dns, bas, nat, peer, rt, pe, pip, nsg, afd, agw, lb, vpngw, er, vm, disk, app, asp, func, swa, aks, acr, aci, aca, signalr, sqlmi, sqls, sqldb, arcsql, cosmos, postgres, mysql, redis, blob, st, cont, queue, apim, sb, evg, evh, logic, adf, databricks, kv, mi, user, entra, appreg, entapp, mon, law, ai, openai, foundry, search, cog, ml, code, cli, dev, plus gh (GitHub).
  • Full v23 auto-lookup: Any of the 705 v23 icons can also be referenced by service slug (e.g., "event-hubs", "front-door-and-cdn-profiles") via dlib.resolve_icon_path(k).
  • Gradient ID Namespacing: Azure SVG icons share internal gradient/clip IDs (id="a", url(#a)). dlib.symbols() embeds only used icons as <symbol id="ic-{k}"> and prefixes every internal id, url(#...), and href="#..." with {k}-. Never inline raw SVG icon files without this prefixing.
  • Non-Azure shapes: No official Azure icon exists for a generic browser, laptop, folder, or Microsoft Graph — use clean labelled box()/card() containers or the folder() glyph; never invent lookalike icons.

Quantitative Charts & Legacy Helpers (diagram_io.py)

For quantitative charts (matplotlib), import save_figure from scripts/diagram_io.py so every chart emits .png + .svg siblings (DPI 150). See references/python-charts.md and references/waf-cost-charts.md. Legacy diagrams (diagram_kwargs + embed_svg_images) and graphviz (render_graphviz) helpers remain in diagram_io.py for backward compatibility.

Rules

DO: Use scripts/dlib.py (finish or diagram_io.render_dlib) for architecture, network, DNS, identity, cutover, and swimlane diagrams · Use save_figure from scripts/diagram_io.py for WAF/cost/compliance matplotlib charts · Fix all WARN overflow: hints before finishing · Keep orthogonal connectors (M...H...V...) in routing corridors · Escape &lt;, &gt;, &amp; in SVG text · Verify both .svg and .png outputs exist and are non-empty.

DON'T: Call plt.savefig(...), Diagram(..., outformat=...), or dot.render(...) directly · Shrink font sizes below 12px to cram text · Route arrows across unrelated cards or text labels · Include real tenant/subscription/object IDs or credentials · Use Mermaid for rendered PNG/SVG deliverables.

Scope Exclusions

Does NOT: produce inline Mermaid diagrams (apex-mermaid) · generate Bicep/Terraform · create ADRs (apex-azure-adr) · deploy resources.

Scripts

scripts/dlib.py (primary AAC + overview SVG & 4K PNG Azure diagram engine) · scripts/topology_render.py (semantic *.topology.json → ELK auto-layout → AAC SVG + PNG; invoked via diagram_io.render_topology() inside the standard .py wrapper) · scripts/diagram_io.py (shared PNG+SVG output helper: render_dlib, render_topology, save_figure, diagram_kwargs, render_graphviz, embed_svg_images) · scripts/generate_diagram.py (interactive template generator) · scripts/multi_diagram_generator.py (ERD, swimlane, timeline, wireframe helpers) · scripts/ascii_to_diagram.py (ASCII art → diagram conversion) · scripts/verify_installation.py (prerequisites & dlib/v23 icon check)

Reference Index

FileContent
references/common-patterns.mdReady-to-use dlib.py Azure architecture templates (hub-spoke, vending, DNS, identity, cutover, swimlanes)
references/azure-components.mdCurated dlib.P icon keys and full 705-icon Azure v23 component catalog
references/python-charts.mdChart execution, dlib & matplotlib design tokens, output standards
references/waf-cost-charts.mdWAF pillar bar, cost donut & projection matplotlib chart implementations
references/business-process-flows.mdWorkflow and swimlane diagram patterns
references/entity-relationship-diagrams.mdDatabase ERD patterns
references/integration-services.mdIntegration service diagram patterns
references/migration-patterns.mdMigration and cutover architecture patterns
references/sequence-auth-flows.mdAuthentication and identity flow patterns
references/timeline-gantt-diagrams.mdProject timeline and Gantt diagrams
references/ui-wireframe-diagrams.mdUI mockup and wireframe patterns
references/iac-to-diagram.mdGenerate diagrams from Bicep/Terraform/ARM templates

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.