agentsclimarketplace

Diagram generator

Skill puretechnyc/purebrain-skills/skills/operations/diagram-generator

Production-tested Claude Code skills for marketing, operations, and business automation. Built by PureBrain.

Install
npx -y skills add puretechnyc/purebrain-skills --skill diagram-generator

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

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.

SKILL.md

5.0 KB, as published. Nobody here has run it

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

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.