UML Diagramming
Generate a single, correct Mermaid or PlantUML code block from a user's description. Output only the diagram script in one code block; no prose outside it.
When to Use
- User asks for a diagram (UML, architecture, flow, process, etc.)
- User specifies or implies Mermaid or PlantUML (or "diagram code")
- Task is to produce diagram script for documentation, design, or for the
generate_uml MCP tool
The generate_uml tool supports all Kroki diagram types via diagram_type (e.g. mermaid, plantuml, d2, graphviz, blockdiag, bpmn, vegalite, wavedrom, etc.). Use resource uml://types for the full list and uml://templates for starter code. For non-Mermaid/PlantUML types (D2, BlockDiag, BPMN, Bytefield, Vega, WaveDrom, etc.), see references/DIAGRAM-TYPES.md.
Output Rules
- Emit only one code block; no explanatory text outside the block.
- Code block language:
mermaid or plantuml.
- For PlantUML: script must start with
@startuml and end with @enduml.
- You may use brief comments inside the block (Mermaid
%% ... or PlantUML ' ...) to note assumptions.
Choosing Mermaid vs PlantUML
- If the user says Mermaid or PlantUML, use that.
- If unspecified:
- Prefer PlantUML for: Use Case, Deployment, Object, WBS, Gantt, Wireframe.
- Prefer Mermaid for: Markdown/GitHub-friendly docs, quick diagrams, and when there is no strong UML requirement.
Parsing the Request
From the user's message or context, identify:
- Diagram type: Sequence, Use Case, Class, Activity, Component, State, Object, Deployment, Timing, Network, Gantt, MindMap, WBS, etc.
- Purpose: Communication, Planning, Design, Analysis, Modeling, Documentation, Implementation, Testing, Debugging.
- Elements (optional): Actors, Messages, Objects, Classes, Interfaces, Components, States, Nodes, Edges, etc.
- Target language for labels (e.g. English) if obvious.
- Optional constraints if mentioned: direction (LR/TB), detail level, max nodes, naming style, group_by.
Mermaid Type Mapping
| Diagram Type |
Mermaid syntax |
| Sequence |
sequenceDiagram |
| Class |
classDiagram |
| State |
stateDiagram-v2 |
| Activity |
flowchart (TB) |
| Component, Deployment, Network |
flowchart + subgraphs |
| Gantt |
gantt |
| MindMap |
mindmap |
| Use Case |
flowchart (actors + use cases; no native use case in Mermaid) |
| Timing |
sequenceDiagram with timing notes |
| Object |
classDiagram (instances via notes) or flowchart |
| JSON/YAML |
flowchart representing the structure (not raw JSON/YAML inside the block) |
Default direction: TB. Use LR for architecture/component/deployment when it improves readability.
PlantUML Type Mapping
| Diagram Type |
PlantUML |
| Sequence |
sequence diagram syntax |
| Use Case |
usecase diagram syntax |
| Class |
class diagram syntax |
| Activity |
activity diagram syntax |
| Component |
component diagram syntax |
| State |
state diagram syntax |
| Object |
object diagram syntax |
| Deployment |
deployment diagram syntax |
| Timing |
timing or sequence |
| Network |
deployment/component (nodes + links) |
| Wireframe |
salt (simple UI wireframes) |
| Gantt |
gantt syntax |
| MindMap |
mindmap syntax |
| WBS |
wbs syntax |
| JSON/YAML |
class/object or mindmap representing structure |
Use left to right direction for architecture-heavy diagrams when it helps. Add a short title in the target language.
Quality Rules
- Choose the minimal diagram type that fits the purpose.
- Limit size: roughly <25 nodes for Mermaid, <30 for PlantUML.
- Naming: Consistent, short names; qualifiers in notes if needed.
- Grouping: Use subgraphs (Mermaid) or packages/frames (PlantUML): e.g. Client, API, Services, DB.
- Sequence: Show key messages only; use
alt/opt for branches.
- Class: Include main attributes/methods; show relationships with multiplicities where known.
- State: Clear start and end; label transitions with events/guards.
- Activity: One start, one end; decisions as diamonds; label yes/no paths.
- If the request is ambiguous, make reasonable assumptions and note them in comments inside the diagram.
Process
- Parse the prompt: extract entities, actions, relationships, lifelines, states, modules.
- Choose Mermaid or PlantUML (see "Choosing Mermaid vs PlantUML").
- Select the diagram form from the type mapping tables above.
- Apply direction: default TB; LR for architecture/component/deployment/network.
- Emit a single code block with the diagram script.
- If the MCP
generate_uml tool is available, call it with the produced diagram_type and code (e.g. diagram_type: "mermaid", "class", "sequence", "activity", "usecase" as appropriate).
Examples
Example 1 (Mermaid – login flow)
User request: "User login flow: enter credentials, API validates, DB check, return JWT or error."
sequenceDiagram
actor User
participant Client
participant API
participant DB
User->>Client: Enter credentials
Client->>API: Validate request
API->>DB: Check credentials
alt Valid
DB-->>API: OK
API-->>Client: JWT
Client-->>User: Logged in
else Invalid
DB-->>API: Fail
API-->>Client: Error
Client-->>User: Show error
end
Example 2 (PlantUML – login sequence)
User request: "Login: validate, DB check, JWT or error."
@startuml
title Login flow
actor User
participant "API" as API
database DB
User -> API : credentials
API -> DB : validate
alt valid
DB --> API : OK
API --> User : JWT
else invalid
DB --> API : fail
API --> User : error
end
@enduml
Example 3 (Mermaid – API call sequence)
User request: "Show me a Mermaid sequence diagram for an API call."
Use sequenceDiagram with participants such as Client, API, Auth, DB. Show request/response and optional alt for success/error. See resource uml://mermaid-examples (key sequence_api) or uml://examples (Mermaid) for examples. Then call generate_uml("mermaid", code).
Example 4 (Mermaid – Gantt)
User request: "Generate a Gantt chart using Mermaid syntax."
Use a Mermaid gantt block with title, dateFormat, section, and tasks (with ids and durations or after). See resource uml://mermaid-examples (key gantt). Then call generate_uml("mermaid", code).
Convert class diagram to Mermaid
When the user asks to convert a class diagram (PlantUML or prose) into Mermaid:
- Map each class to
classDiagram syntax: class name, then lines for attributes/methods with + - #.
- Map relationships: inheritance
--|>, composition *--, aggregation o--, association -- with : label, dependency ..>.
- Emit one Mermaid code block and call
generate_uml("mermaid", code).
BPMN process model
When the user asks how to draw a BPMN process model:
- Describe core BPMN 2.0.2 elements: Start/End events, Task, Gateways (Exclusive, Parallel, Inclusive), Sequence Flow, Lanes, Pools.
- Point to resource
uml://bpmn-guide for the structured guide and to generate_bpmn_diagram or generate_uml("bpmn", ...) for generating BPMN XML.
Additional Resources
For full diagram-type mappings and optional constraints (direction, detail_level, max_nodes, naming_style, group_by), see references/DIAGRAM-TYPES.md.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: uml-diagramming3description: Produces Mermaid or PlantUML diagram code from user specifications for UML, architecture, and flow diagrams. Use when the user asks for a diagram (sequence, class, activity, use case, component, state, deployment), diagram code, or when generating diagram script for documentation, design, or the generate_uml MCP tool. Supports Kroki-renderable output. Use when this capability is needed.4---56# UML Diagramming78Generate a single, correct Mermaid or PlantUML code block from a user's description. Output only the diagram script in one code block; no prose outside it.910## When to Use1112- User asks for a diagram (UML, architecture, flow, process, etc.)13- User specifies or implies Mermaid or PlantUML (or "diagram code")14- Task is to produce diagram script for documentation, design, or for the `generate_uml` MCP tool1516The `generate_uml` tool supports all Kroki diagram types via `diagram_type` (e.g. `mermaid`, `plantuml`, `d2`, `graphviz`, `blockdiag`, `bpmn`, `vegalite`, `wavedrom`, etc.). Use resource `uml://types` for the full list and `uml://templates` for starter code. For non-Mermaid/PlantUML types (D2, BlockDiag, BPMN, Bytefield, Vega, WaveDrom, etc.), see [references/DIAGRAM-TYPES.md](references/DIAGRAM-TYPES.md).1718## Output Rules1920- Emit **only one** code block; no explanatory text outside the block.21- Code block language: `mermaid` or `plantuml`.22- For PlantUML: script must start with `@startuml` and end with `@enduml`.23- You may use brief comments inside the block (Mermaid `%% ...` or PlantUML `' ...`) to note assumptions.2425## Choosing Mermaid vs PlantUML2627- If the user says **Mermaid** or **PlantUML**, use that.28- If unspecified:29 - Prefer **PlantUML** for: Use Case, Deployment, Object, WBS, Gantt, Wireframe.30 - Prefer **Mermaid** for: Markdown/GitHub-friendly docs, quick diagrams, and when there is no strong UML requirement.3132## Parsing the Request3334From the user's message or context, identify:3536- **Diagram type**: Sequence, Use Case, Class, Activity, Component, State, Object, Deployment, Timing, Network, Gantt, MindMap, WBS, etc.37- **Purpose**: Communication, Planning, Design, Analysis, Modeling, Documentation, Implementation, Testing, Debugging.38- **Elements** (optional): Actors, Messages, Objects, Classes, Interfaces, Components, States, Nodes, Edges, etc.39- **Target language** for labels (e.g. English) if obvious.40- **Optional constraints** if mentioned: direction (LR/TB), detail level, max nodes, naming style, group_by.4142## Mermaid Type Mapping4344| Diagram Type | Mermaid syntax |45|--------------|----------------|46| Sequence | `sequenceDiagram` |47| Class | `classDiagram` |48| State | `stateDiagram-v2` |49| Activity | `flowchart` (TB) |50| Component, Deployment, Network | `flowchart` + subgraphs |51| Gantt | `gantt` |52| MindMap | `mindmap` |53| Use Case | `flowchart` (actors + use cases; no native use case in Mermaid) |54| Timing | `sequenceDiagram` with timing notes |55| Object | `classDiagram` (instances via notes) or `flowchart` |56| JSON/YAML | `flowchart` representing the structure (not raw JSON/YAML inside the block) |5758Default direction: TB. Use LR for architecture/component/deployment when it improves readability.5960## PlantUML Type Mapping6162| Diagram Type | PlantUML |63|--------------|----------|64| Sequence | `sequence` diagram syntax |65| Use Case | `usecase` diagram syntax |66| Class | `class` diagram syntax |67| Activity | `activity` diagram syntax |68| Component | `component` diagram syntax |69| State | `state` diagram syntax |70| Object | `object` diagram syntax |71| Deployment | `deployment` diagram syntax |72| Timing | `timing` or sequence |73| Network | deployment/component (nodes + links) |74| Wireframe | `salt` (simple UI wireframes) |75| Gantt | `gantt` syntax |76| MindMap | `mindmap` syntax |77| WBS | `wbs` syntax |78| JSON/YAML | class/object or mindmap representing structure |7980Use `left to right direction` for architecture-heavy diagrams when it helps. Add a short `title` in the target language.8182## Quality Rules8384- Choose the **minimal** diagram type that fits the purpose.85- Limit size: roughly <25 nodes for Mermaid, <30 for PlantUML.86- **Naming**: Consistent, short names; qualifiers in notes if needed.87- **Grouping**: Use subgraphs (Mermaid) or packages/frames (PlantUML): e.g. Client, API, Services, DB.88- **Sequence**: Show key messages only; use `alt`/`opt` for branches.89- **Class**: Include main attributes/methods; show relationships with multiplicities where known.90- **State**: Clear start and end; label transitions with events/guards.91- **Activity**: One start, one end; decisions as diamonds; label yes/no paths.92- If the request is ambiguous, make reasonable assumptions and note them in comments inside the diagram.9394## Process95961. Parse the prompt: extract entities, actions, relationships, lifelines, states, modules.972. Choose Mermaid or PlantUML (see "Choosing Mermaid vs PlantUML").983. Select the diagram form from the type mapping tables above.994. Apply direction: default TB; LR for architecture/component/deployment/network.1005. Emit a single code block with the diagram script.1016. If the MCP `generate_uml` tool is available, call it with the produced `diagram_type` and `code` (e.g. `diagram_type`: "mermaid", "class", "sequence", "activity", "usecase" as appropriate).102103## Examples104105**Example 1 (Mermaid – login flow)**106107User request: "User login flow: enter credentials, API validates, DB check, return JWT or error."108109```mermaid110sequenceDiagram111 actor User112 participant Client113 participant API114 participant DB115 User->>Client: Enter credentials116 Client->>API: Validate request117 API->>DB: Check credentials118 alt Valid119 DB-->>API: OK120 API-->>Client: JWT121 Client-->>User: Logged in122 else Invalid123 DB-->>API: Fail124 API-->>Client: Error125 Client-->>User: Show error126 end127```128129**Example 2 (PlantUML – login sequence)**130131User request: "Login: validate, DB check, JWT or error."132133```plantuml134@startuml135title Login flow136actor User137participant "API" as API138database DB139User -> API : credentials140API -> DB : validate141alt valid142 DB --> API : OK143 API --> User : JWT144else invalid145 DB --> API : fail146 API --> User : error147end148@enduml149```150151**Example 3 (Mermaid – API call sequence)**152153User request: "Show me a Mermaid sequence diagram for an API call."154155Use `sequenceDiagram` with participants such as Client, API, Auth, DB. Show request/response and optional `alt` for success/error. See resource `uml://mermaid-examples` (key `sequence_api`) or `uml://examples` (Mermaid) for examples. Then call `generate_uml("mermaid", code)`.156157**Example 4 (Mermaid – Gantt)**158159User request: "Generate a Gantt chart using Mermaid syntax."160161Use a Mermaid `gantt` block with `title`, `dateFormat`, `section`, and tasks (with ids and durations or `after`). See resource `uml://mermaid-examples` (key `gantt`). Then call `generate_uml("mermaid", code)`.162163**Convert class diagram to Mermaid**164165When the user asks to convert a class diagram (PlantUML or prose) into Mermaid:1661. Map each class to `classDiagram` syntax: class name, then lines for attributes/methods with `+` `-` `#`.1672. Map relationships: inheritance `--|>`, composition `*--`, aggregation `o--`, association `--` with `: label`, dependency `..>`.1683. Emit one Mermaid code block and call `generate_uml("mermaid", code)`.169170**BPMN process model**171172When the user asks how to draw a BPMN process model:173- Describe core BPMN 2.0.2 elements: Start/End events, Task, Gateways (Exclusive, Parallel, Inclusive), Sequence Flow, Lanes, Pools.174- Point to resource `uml://bpmn-guide` for the structured guide and to `generate_bpmn_diagram` or `generate_uml("bpmn", ...)` for generating BPMN XML.175176## Additional Resources177178For full diagram-type mappings and optional constraints (direction, detail_level, max_nodes, naming_style, group_by), see [references/DIAGRAM-TYPES.md](references/DIAGRAM-TYPES.md).179180---181> Converted and distributed by [TomeVault](https://tomevault.io/claim/antoinebou12) — claim your Tome and manage your conversions.182<!-- tomevault:4.0:skill_md:2026-04-11 -->