--- name: plantuml-skill description: Use when user requests diagrams, flowcharts, sequence diagrams, class diagrams, component diagrams, ER diagrams, architecture charts, or visualizations β€” including generating a diagram from existing source code, or rendering/extracting PlantUML embedded in a Markdown file to images (e.g. preparing docs for Confluence/Notion). Also use proactively when explaining systems with 3+ components, APIs, data flows, or class hierarchies. Generates .puml files and exports to PNG/SVG via Kroki API (no local install required). license: MIT homepage: https://github.com/Agents365-ai/plantuml-skill compatibility: Requires curl on PATH (pre-installed on macOS/Linux/Windows Git Bash). Default renderer is the public Kroki API at https://kroki.io; can also point to a local Kroki Docker instance, or fall back to a local PlantUML jar + Java + Graphviz. platforms: [macos, linux, windows] metadata: {"openclaw":{"requires":{"bins":["curl"]},"emoji":"🧩","os":["darwin","linux","win32"]},"hermes":{"tags":["plantuml","diagram","flowchart","sequence","class","uml","architecture","kroki"],"category":"design","requires_tools":["curl"],"related_skills":["drawio","mermaid","excalidraw","tldraw"]},"author":"Agents365-ai","version":"1.5.0"} --- # PlantUML Diagram Skill ## Overview Generate `.puml` PlantUML diagram files and export to PNG/SVG using **Kroki** β€” a cloud rendering API that requires no local installation beyond `curl`. **Format:** `.puml` (PlantUML text) **Renderer:** Kroki API (`https://kroki.io`) β€” just `curl`, no Java needed **Output:** PNG, SVG **Diagram types:** sequence, component, class, ER, activity, use case, state, C4, and more ## When to Use **Explicit triggers:** - "plantuml diagram", "sequence diagram", "class diagram", "component diagram" - "UML", "activity diagram", "use case diagram", "state machine" - "visualize", "draw", "diagram", "flowchart", "architecture chart" **Proactive triggers:** - Explaining a system with 3+ interacting components - Describing API flows, authentication sequences, message passing - Showing class hierarchies, database schemas, or ER models - Illustrating state machines or lifecycle flows **When NOT to use it β€” route elsewhere:** - General, non-UML quick diagrams embedded in Markdown β†’ **mermaid**. - Freeform, heavily-styled, or branded diagrams needing pixel control β†’ **drawio**. - A hand-drawn / sketchy look β†’ **excalidraw** or **tldraw**. ## Modes Once triggered, route by what the user actually wants β€” then run the shared render loop (Steps 4–8): | Mode | The user wants… | Entry point | |---|---|---| | **Generate** (default) | a diagram from a text description | Steps 1–8 below | | **From code** | a diagram of existing source code | [`references/from-source-code.md`](references/from-source-code.md) β†’ Steps 4–8 | | **Embed** | the PlantUML inside a Markdown doc rendered to images | [`references/markdown-embed.md`](references/markdown-embed.md) | | **Refine** | to change an existing diagram | load its `.puml`, apply the minimal edit (Step 7), re-render (Steps 4–6) | | **Review** | to know whether an existing diagram is readable / correct | run the Step 6 vision self-check on the image | ## Prerequisites **Option A: Kroki API (recommended β€” no install)** ```bash # Just needs curl (pre-installed on macOS/Linux/Windows Git Bash) curl --version ``` **Option B: Local Kroki via Docker (for offline use)** ```bash docker run -d -p 8000:8000 yuzutech/kroki # Then replace https://kroki.io with http://localhost:8000 in commands ``` **Option C: Local PlantUML jar (traditional)** ```bash # Requires Java + Graphviz brew install graphviz # macOS sudo apt install graphviz # Ubuntu # Download plantuml.jar from https://plantuml.com/download java -jar plantuml.jar diagram.puml ``` ## Workflow ### Step 1: Check Dependencies ```bash curl --version ``` curl is available on all modern systems. If missing, install via package manager. ### Step 2: Pick Diagram Type Choose the most appropriate PlantUML diagram type (see reference below). ### Step 3: Generate .puml File Write the PlantUML source file with `@startuml` / `@enduml` markers. ### Step 4: Export via Kroki (capture the HTTP status) Pick the backend first. The default below (public Kroki) **uploads the `.puml` source to kroki.io** β€” for sensitive diagrams use a local backend instead, and never silently fall back. See [`references/rendering-backends.md`](references/rendering-backends.md). For local Kroki, swap `https://kroki.io` β†’ `http://localhost:8000`. ```bash # PNG (recommended) β€” keep the status code so Step 5 can verify it http=$(curl -s -w "%{http_code}" -o diagram.png \ -X POST https://kroki.io/plantuml/png \ -H "Content-Type: text/plain" \ --data-binary "@diagram.puml") echo "HTTP $http" # SVG http=$(curl -s -w "%{http_code}" -o diagram.svg \ -X POST https://kroki.io/plantuml/svg \ -H "Content-Type: text/plain" \ --data-binary "@diagram.puml") echo "HTTP $http" ``` ### Step 5: Validate & self-correct (loop β€” do NOT skip) Never report success on a blind `curl`. Verify the output first; treat the export as **failed** if any of these hold: - `$http` is not `200`. Kroki returns `400` on a syntax error and writes the error text into the output file, so a `.png` can exist yet be broken. - The file is empty: `[ -s diagram.png ]` fails. - The bytes aren't a real image: `file diagram.png` should report `PNG image data`; for SVG the file should start with `