agentleFS
puretechnycpuretechnyc/purebrain-skills/skills/operations/diagram-generator/SKILL.md

diagram-generator

Skill0 starsChanged 6 months agoMITView on GitHub

Generate diagrams from Mermaid code using the free Kroki API. No authentication required. Flowcharts, sequence diagrams, class diagrams, ERDs, and more. Returns local PNG/SVG files.

11 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use pentest-tools, attack-chain and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • xAmirHamza77Skill

    pentest-tools

    Active penetration testing toolchain. Covers reconnaissance, port scanning, vulnerability scanning, web exploitation, SQL injection, directory brute-forcing, password cracking, and more. Exposes 20+ security tools to the AI agent via MCP servers (pentestMCP / mcp-security-hub). Trigger keywords: penetration testing, port scan, Nmap, vulnerability scan, Nuclei, SQL injection, SQLMap, directory brute-force, FFUF, password cracking, Hashcat, reconnaissance, subdomain, web exploitation, ZAP, Burp.

    Also in 5 projects that use this

  • xAmirHamza77Skill

    attack-chain

    Use for authorized multi-stage attack-path planning and orchestration when a task spans reconnaissance, initial access, privilege escalation, lateral movement, or impact assessment. Route single-stage tasks directly to their specialist skill.

    Also in 4 projects that use this

  • +10 more from xAmirHamza77

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Create professional diagrams programmatically from Mermaid syntax, saving PNG files locally for use in documentation, blogs, and …

    line 15

“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “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

Diagram Generator Skill

Generate diagrams from Mermaid code using free Kroki API -- no authentication required.

Purpose

Create professional diagrams programmatically from Mermaid syntax, saving PNG files locally for use in documentation, blogs, and architectural records.


Quick Start

import base64
import zlib
from pathlib import Path
import urllib.request

def generate_diagram(
    diagram_code: str,
    output_path: str,
    diagram_type: str = "mermaid",
    output_format: str = "png"
) -> str:
    """Generate a diagram using Kroki API (free, no auth required)."""
    compressed = zlib.compress(diagram_code.encode('utf-8'), 9)
    encoded = base64.urlsafe_b64encode(compressed).decode('ascii')
    url = f"https://kroki.io/{diagram_type}/{output_format}/{encoded}"

    with urllib.request.urlopen(url, timeout=30) as response:
        content = response.read()

    output = Path(output_path)
    output.parent.mkdir(parents=True, exist_ok=True)
    output.write_bytes(content)

    return str(output.absolute())

# Example: Generate a flowchart
mermaid_code = """
flowchart TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Action 1]
    B -->|No| D[Action 2]
    C --> E[End]
    D --> E
"""

output_path = generate_diagram(mermaid_code, "flowchart.png")
print(f"Diagram saved to: {output_path}")

Kroki API Details

Endpoint: https://kroki.io/{diagram_type}/{output_format}/{encoded_payload}

Cost: FREE -- No API key required!

Supported Diagram Types:

TypeKeywordBest ForFormats
MermaidmermaidFlowcharts, sequences, class diagramspng, svg
PlantUMLplantumlUML diagrams, complex sequencespng, svg, pdf
GraphVizgraphvizNetwork graphs, dependenciespng, svg, pdf
D2d2Modern diagrams with iconssvg only
StructurizrstructurizrC4 architecture diagramssvg only
DitaaditaaASCII art to diagramspng, svg
ERDerdEntity-relationship diagramspng, svg
NomnomlnomnomlUML class diagramssvg only

Encoding Method:

  1. Compress with zlib (level 9)
  2. Base64 URL-safe encode
  3. Append to URL

Mermaid Syntax Reference

Flowchart

flowchart TD
    A[Rectangle] --> B(Rounded)
    B --> C{Diamond}
    C -->|One| D[Result 1]
    C -->|Two| E[Result 2]

Sequence Diagram

sequenceDiagram
    participant A as Client
    participant B as Server
    A->>B: Request
    B-->>A: Response
    A->>A: Process
    A-->>B: Confirm

Class Diagram

classDiagram
    class Agent {
        +String id
        +String role
        +execute()
    }
    Agent <|-- Coder
    Agent <|-- Tester

Entity-Relationship

erDiagram
    USER ||--o{ ORDER : places
    ORDER }|--|| PRODUCT : contains
    USER ||--|{ SESSION : has

Usage Examples

Architecture Diagram

arch_diagram = """
flowchart TB
    subgraph Frontend
        W[Web App]
    end
    subgraph Backend
        A[API Server]
        D[(Database)]
    end
    subgraph Workers
        Q[Queue]
        P[Processor]
    end
    W --> A
    A --> D
    A --> Q
    Q --> P
    P --> D
"""

generate_diagram(arch_diagram, "architecture.png")

Process Flow

process_flow = """
sequenceDiagram
    actor User
    participant App
    participant API
    participant DB

    User->>App: Submit form
    App->>API: POST /data
    API->>DB: INSERT
    DB-->>API: Success
    API-->>App: 201 Created
    App-->>User: Confirmation
"""

generate_diagram(process_flow, "process-flow.png")

Error Handling

try:
    path = generate_diagram(code, output)
    print(f"Success: {path}")
except Exception as e:
    if "syntax" in str(e).lower():
        print("Invalid diagram syntax -- check Mermaid code")
    else:
        print(f"Kroki API error: {e}")

Anti-Patterns

Anti-PatternCorrect Approach
Using raw API without compressionAlways compress + base64 encode
Hardcoding output pathsUse organized output directories
Not handling API errorsWrap in try/except with specific handling
Generating without verificationVerify the output file exists and has reasonable size (>1KB)

Related Resources


Built by PureBrain -- AI-powered marketing operations.

Want the full suite of 183+ production-tested skills? Start your trial ->

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.