mcpField
P
plantuml-diagramming

plantuml-diagramming

github.com/beecode-rsDevelopment049 installsUpdated 1w ago
Repository

About plantuml-diagramming

A skill for Agents creating PlantUML diagrams from text requirements. It covers diagram selection, syntax, styling, readability, and output conventions for UML and non-UML diagrams.

Key features

  1. 01Choose diagram types by intent
  2. 02Generate and validate PlantUML syntax
  3. 03Guide layout, aliases, and styling
  4. 04Require puml code block output
  5. 05Diagnose common rendering errors

Use cases

  1. 01Diagram API calls as a sequence
  2. 02Map business steps to an activity diagram
  3. 03Show class structures, states, or components
  4. 04Create UI wireframes from text

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/beecode-rs/claude-skills --skill plantuml-diagramming

After installing, type/plantuml-diagrammingin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

activity-diagram.md
class-diagram.md
component-diagram.md
flowchart.md
LICENSE.txt
object-diagram.md
sequence-diagram.md
state-diagram.md
use-case-diagram.md

Details

From the project README

PlantUML Diagramming Expert

Purpose

Expert in the PlantUML diagramming language for creating UML and non-UML diagrams. Translates textual descriptions into visual representations using PlantUML syntax. Understands structure, syntax, styling, and best practices for creating various types of diagrams.

When to Use

Auto-invoke when users mention:

  • PlantUML - "plantuml", "plantuml diagram", "plantuml code"
  • UML diagrams - "uml diagram", "use case diagram", "sequence diagram", "class diagram"
  • Flowcharts - "flowchart", "flow chart", "activity diagram", "workflow diagram"
  • State/Process - "state diagram", "state machine", "process flow", "component diagram"
  • Visual from text - "create diagram from text", "visualize this", "draw a diagram", "make a uml"
  • Wireframes - "wireframe", "ui mockup", "screen mockup"

Process

1. Analyze the Request

Determine the best diagram type based on user intent:

User asks aboutUse this diagram
Time flow, API calls, chronological eventsSequence Diagram
Data structure, inheritance, relationshipsClass Diagram
Business steps, workflow, decisionsActivity Diagram
System functionality, user interactionsUse Case Diagram
Object lifecycle, states, transitionsState Diagram
System components, dependenciesComponent Diagram
Instances, snapshotsObject Diagram
Simple process, non-UML flowFlowchart
2. Gather Context

Use tools to collect information:

  • Read existing documentation or requirements
  • Search for related diagrams in the codebase
  • Find data structures or API definitions if needed
3. Generate PlantUML Code

Always follow these core directives:

  1. Encapsulation: Wrap PlantUML code in @startuml and @enduml tags
  2. Syntax Validity: Ensure correct bracket closing, arrow types, and end keywords (end, endif, endwhile)
  3. Readability: Use aliases (alias X as Name) for long class or participant names
  4. Layout: Use directional hints (left to right direction, top to bottom direction) if default causes clutter
4. Provide Output

MANDATORY: Code Block Format for PlantUML

ALL PlantUML code MUST be wrapped in markdown code blocks using puml as the language identifier:

@startuml
' your diagram code here
@enduml

Required Format Rules:

  1. ALWAYS start code blocks with ```puml (NOT just ``` without a language identifier)
  2. NEVER use bare ``` for PlantUML code - always specify puml
  3. NEVER output raw @startuml/@enduml without code block wrapping
  4. Include a brief explanation of the diagram structure
  5. Suggest rendering options (PlantUML server, VS Code extension, etc.)

Diagram Types Reference

DiagramPurposeReference
Use Case DiagramSystem functionality and actors, interactions between users and featuresuse-case-diagram.md
Sequence DiagramInteractions between objects over time, message flow in chronological ordersequence-diagram.md
Class DiagramStatic structure of a system, classes, interfaces, and relationshipsclass-diagram.md
Activity DiagramWorkflows or business processes, flow of control through actions and decisionsactivity-diagram.md
Component DiagramOrganization and dependencies among components, interfaces, and nodescomponent-diagram.md
State DiagramLifecycle of an object, states and transitions triggered by eventsstate-diagram.md
Object DiagramInstances of classes and their relationships at a specific point in timeobject-diagram.md
FlowchartSimple process flows, non-UML alternative to activity diagramsflowchart.md

Choosing Between Diagram Types

When a request could fit multiple diagram types, use this decision guide:

ScenarioPreferWhy
API calls, message flowSequenceShows message order and participants clearly
Business process with decisionsActivityBetter for branching logic and workflows
Object changes states over timeStateFocus on lifecycle and transitions
Static data structureClassShows types, fields, and relationships
Specific instance snapshotObjectWhen you need to show actual values
System components & deploymentComponentInfrastructure and dependencies
User interactions with systemUse CaseFunctional requirements from user perspective
Simple step-by-step processFlowchartLightweight, non-UML option
Complex workflow with swimlanesActivitySupports partitions/roles
Common Ambiguities Resolved

"Show me how the login process works"

  • With API calls between services → Sequence Diagram
  • With business logic and decisions → Activity Diagram

"Diagram the Order entity"

  • Showing class structure → Class Diagram
  • Showing a specific order instance → Object Diagram
  • Showing order lifecycle (created → paid → shipped) → State Diagram

"Visualize our microservices"

  • Showing runtime dependencies → Component Diagram
  • Showing communication patterns → Sequence Diagram

Examples

Example 1: Basic Sequence Diagram

User request: "Show the login flow between user, frontend, and backend"

Process: Identify participants (User, Frontend, Backend) and message flow (request → validate → authenticate → response)

Output:

@startuml
actor User
participant Frontend
participant Backend

User -> Frontend : Enter credentials
Frontend -> Backend : POST /login
Backend -> Backend : Validate credentials
Backend --> Frontend : JWT token
Frontend --> User : Redirect to dashboard
@enduml
Example 2: Class Diagram with Relationships

User request: "Create a class diagram for an e-commerce system with User, Order, and Product"

Process: Identify classes and their relationships (User places Orders, Orders contain Products)

Output:

@startuml
class User {
  - id: UUID
  - name: String
  - email: String
  + login()
  + logout()
}

class Order {
  - id: UUID
  - status: OrderStatus
  - total: Decimal
  + addItem()
  + checkout()
}

class Product {
  - id: UUID
  - name: String
  - price: Decimal
  + updateStock()
}

User "1" --> "*" Order : places
Order "*" --> "*" Product : contains
@enduml
Example 3: Activity Diagram for Workflow

User request: "Draw an approval workflow for document review"

Process: Map decision points and actions

Output:

@startuml
start
:Submit Document;

if (Manager Approved?) then (yes)
  :Forward to Director;
  if (Director Approved?) then (yes)
    :Document Finalized;
    stop
  else (no)
    :Return with Comments;
    :Revise Document;
  endif
else (no)
  :Return with Feedback;
  :Revise Document;
endif

:Resubmit;
@enduml

Styling and Theming

Skinparam

Customize the look and feel globally:

skinparam monochrome true
skinparam style strictuml
skinparam classAttributeIconSize 0
skinparam backgroundColor #EEEBDC
Themes

Apply built-in themes instantly:

!theme spacelab
!theme cerulean
!theme superhero
!theme minty
Colors and Fonts
A --> B : Label #FF0000
skinparam defaultFontName Courier
skinparam defaultFontSize 12

Advanced Features

Procedures (Macros)

Reuse code blocks:

!procedure $draw_connection($from, $to)
$from -> $to
!endprocedure

Alice -> Bob : $draw_connection(Alice, Bob)
Includes

Include external files and libraries:

!include <archimate/Archimate>
!include stdlib/common
Salt (Wireframe)

UI Mockups:

@startsalt
{+
  Login | {username: "_______" }
        | {password: "_______" }
        | [OK]
}
@endsalt

Best Practices

DO:
  • MANDATORY: Always start code blocks with ```puml - NEVER use bare ``` without the language identifier
  • Use left to right direction for wide sequence diagrams
  • Group related participants with box "Group Name" { ... }
  • Add notes for context using note left of, note right of
  • Use aliases to keep diagrams readable
  • Split complex diagrams into multiple focused diagrams
  • Apply themes for consistent visual style
DON'T:
  • NEVER use bare ``` for PlantUML code - always use ```puml
  • NEVER output raw PlantUML code without markdown code block wrapping
  • Create diagrams with 20+ participants (consider splitting)
  • Use overly long labels (create notes instead)
  • Forget to close brackets, arrows, or blocks
  • Mix too many arrow types in one diagram
  • Include implementation details in high-level diagrams

Common Pitfalls

  • Pitfall: Using bare ``` without language identifier for PlantUML code

    • Instead: ALWAYS use ```puml as the code block opener - this enables proper syntax highlighting and tool recognition
  • Pitfall: Missing @startuml/@enduml tags

    • Instead: Always wrap code in these tags
  • Pitfall: Outputting raw PlantUML code without markdown code blocks

    • Instead: ALWAYS wrap in triple backticks with puml language identifier:
      @startuml
      ...
      @enduml
      
  • Pitfall: Using reserved words as identifiers

    • Instead: Quote identifiers or use aliases
  • Pitfall: Forgetting to escape special characters in labels

    • Instead: Use quotes or escape syntax
  • Pitfall: Creating unreadable diagrams due to size

    • Instead: Split into multiple diagrams or use left to right direction
  • Pitfall: Wrong arrow type for the relationship

    • Instead: Use -> (synchronous), --> (async), ->> (return) appropriately

Debugging Common Errors

When PlantUML fails to render, check these common issues:

ErrorCauseFix
Some diagram description contains errorsBracket/brace mismatchCount opening/closing brackets, ensure endif, endwhile, end are present
Preprocessor failedBad !include pathCheck file path, use !include <stdlib/common> for built-ins
Cannot find symbolUndefined participant/classDefine all elements before referencing them
Graphviz neededMissing Graphviz installationUser needs to install Graphviz for local rendering
Syntax ErrorReserved word as identifierQuote the identifier: "class" or use alias
Quick Debug Checklist
  1. Tags present? Every diagram needs @startuml and @enduml
  2. Brackets balanced? Every { needs }, every if needs endif
  3. Participants defined? Reference files before using them in arrows
  4. Reserved words escaped? Quote identifiers that match keywords
  5. Arrow syntax correct? Check ->, -->, ->>, <-- are used properly

Resources

Comments

Markdown supported