mcpField
U
uml-modeling

uml-modeling

github.com/melodic-software開発2887 回インストール今日更新
リポジトリ

uml-modeling について

uml-modelingは、ソフトウェア設計文書向けのUML図を作成するスキルです。要件分析、システム設計、アーキテクチャ記録に携わる開発者を対象に、PlantUMLとMermaidの例を示し、文書確認、構文検証、UML 2.5への準拠を求めます。

主な機能

  1. 01構造図と振る舞い図を幅広く扱う
  2. 02PlantUMLとMermaidの例を掲載
  3. 03設計目的に応じた図の選択を案内
  4. 04文書確認を優先し構文検証を要求
  5. 05作図とレビューのワークフローを提示

活用シーン

  1. 01クラス図やコンポーネント図によるシステム構造の記録
  2. 02シーケンス図によるAPIやプロトコルの流れの説明
  3. 03アクティビティ図やユースケース図によるプロセスと要件の表現
  4. 04状態機械図によるライフサイクル遷移の記録

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/melodic-software/claude-code-plugins --skill uml-modeling

インストール後、Claude Code で/uml-modelingを入力して読み込まれたか確認します。

詳細

UML モデリングスキル

このスキルを使用する場面

以下の場合にこのスキルを使用します。

  • UML モデリングタスク - クラス図、シーケンス図、アクティビティ図、ユースケース図、状態図などの UML 図の生成に取り組む場合
  • 計画や設計 - UML モデリングの手法についてガイダンスが必要な場合
  • ベストプラクティス - 確立されたパターンや標準に従いたい場合

概要

ソフトウェア設計ドキュメント用に、PlantUML および Mermaid の記法を使って UML 図を作成します。

必須:ドキュメントを最優先するアプローチ

UML 図を作成する前に、以下を行います。

  1. UML 標準に関するガイダンスを得るため、docs-management スキルを呼び出します
  2. 適切な記法(PlantUML/Mermaid)を使って図の構文を検証します
  3. すべてのガイダンスを UML 2.5 仕様に基づかせます

UML 図の種類

構造図
図目的使用場面
クラス図クラス、属性、メソッド、関係を示すドメインモデリング、設計
コンポーネント図コンポーネントと依存関係を示すアーキテクチャのドキュメント作成
配置図物理的な配置を示すインフラストラクチャの計画
オブジェクト図オブジェクトのインスタンスを示す特定のシナリオ
パッケージ図名前空間/モジュールを示すコードの整理
振る舞い図
図目的使用場面
ユースケース図アクターとシステムのやり取りを示す要件
シーケンス図時間の経過に沿ったメッセージの流れを示すAPI 設計、プロトコル
アクティビティ図ワークフローとプロセスを示すビジネスプロセス
ステートマシン図状態遷移を示すライフサイクルのモデリング
コミュニケーション図オブジェクト間のやり取りを示すデザインパターン

クラス図

PlantUML の構文
@startuml
skinparam classAttributeIconSize 0

abstract class Entity {
  +Id: Guid
  +CreatedAt: DateTimeOffset
  +UpdatedAt: DateTimeOffset
}

class Order extends Entity {
  -_lineItems: List<LineItem>
  +CustomerId: Guid
  +Status: OrderStatus
  +Total: Money
  --
  +AddItem(product: Product, quantity: int): Result<LineItem>
  +RemoveItem(lineItemId: Guid): Result
  +Submit(): Result
  +Cancel(): Result
}

class LineItem extends Entity {
  +ProductId: Guid
  +ProductName: string
  +Quantity: int
  +UnitPrice: Money
  +LineTotal: Money
}

enum OrderStatus {
  Draft
  Submitted
  Paid
  Shipped
  Delivered
  Cancelled
}

class Money <<value object>> {
  +Amount: decimal
  +Currency: string
  +{static} Zero: Money
  +Add(other: Money): Money
  +Multiply(factor: decimal): Money
}

Order "1" *-- "0..*" LineItem : contains
Order --> OrderStatus
Order --> Money
LineItem --> Money

@enduml
Mermaid クラス図
classDiagram
    class Entity {
        <<abstract>>
        +Guid Id
        +DateTimeOffset CreatedAt
        +DateTimeOffset UpdatedAt
    }

    class Order {
        -List~LineItem~ _lineItems
        +Guid CustomerId
        +OrderStatus Status
        +Money Total
        +AddItem(Product, int) Result~LineItem~
        +RemoveItem(Guid) Result
        +Submit() Result
        +Cancel() Result
    }

    class LineItem {
        +Guid ProductId
        +string ProductName
        +int Quantity
        +Money UnitPrice
        +Money LineTotal
    }

    class OrderStatus {
        <<enumeration>>
        Draft
        Submitted
        Paid
        Shipped
        Delivered
        Cancelled
    }

    Entity <|-- Order
    Entity <|-- LineItem
    Order "1" *-- "0..*" LineItem : contains
    Order --> OrderStatus
関係の種類
// UML Relationship Reference
public static class UMLRelationships
{
    // Association: uses, knows about
    // Customer --> Order (Customer uses Order)

    // Aggregation: has-a (shared ownership)
    // Team o-- Player (Team has Players, Players can exist independently)

    // Composition: contains (exclusive ownership)
    // Order *-- LineItem (Order contains LineItems, LineItems cannot exist without Order)

    // Inheritance: is-a
    // Dog --|> Animal (Dog extends Animal)

    // Implementation: implements
    // UserService ..|> IUserService (UserService implements IUserService)

    // Dependency: depends on
    // Controller ..> Service (Controller depends on Service)
}

シーケンス図

PlantUML の構文
@startuml
title Order Submission Flow

actor Customer
participant "API Gateway" as API
participant "Order Service" as Orders
participant "Payment Service" as Payment
participant "Notification Service" as Notify
database "Order DB" as DB
queue "Message Bus" as Bus

Customer -> API: POST /orders/{id}/submit
activate API

API -> Orders: SubmitOrder(orderId)
activate Orders

Orders -> DB: GetOrder(orderId)
activate DB
DB --> Orders: Order
deactivate DB

alt Order is valid
    Orders -> Payment: ProcessPayment(order)
    activate Payment

    Payment --> Orders: PaymentResult
    deactivate Payment

    alt Payment successful
        Orders -> DB: UpdateStatus(Paid)
        Orders -> Bus: Publish(OrderSubmitted)
        Bus -> Notify: OrderSubmitted
        activate Notify
        Notify -> Notify: SendConfirmation()
        deactivate Notify

        Orders --> API: Success
        API --> Customer: 200 OK
    else Payment failed
        Orders --> API: PaymentFailed
        API --> Customer: 402 Payment Required
    end
else Order invalid
    Orders --> API: ValidationError
    API --> Customer: 400 Bad Request
end

deactivate Orders
deactivate API

@enduml
Mermaid シーケンス図
sequenceDiagram
    participant C as Customer
    participant A as API Gateway
    participant O as Order Service
    participant P as Payment Service
    participant D as Database

    C->>A: POST /orders/{id}/submit
    activate A
    A->>O: SubmitOrder(orderId)
    activate O
    O->>D: GetOrder(orderId)
    D-->>O: Order

    alt Order valid
        O->>P: ProcessPayment(order)
        P-->>O: PaymentResult

        alt Payment successful
            O->>D: UpdateStatus(Paid)
            O-->>A: Success
            A-->>C: 200 OK
        else Payment failed
            O-->>A: PaymentFailed
            A-->>C: 402 Payment Required
        end
    else Order invalid
        O-->>A: ValidationError
        A-->>C: 400 Bad Request
    end

    deactivate O
    deactivate A

アクティビティ図

PlantUML の構文
@startuml
title Order Processing Workflow

start

:Customer submits order;

:Validate order;

if (Order valid?) then (yes)
  :Calculate totals;
  :Reserve inventory;

  fork
    :Process payment;
  fork again
    :Send confirmation email;
  end fork

  if (Payment successful?) then (yes)
    :Confirm inventory;
    :Create shipment;
    :Update order status;
    stop
  else (no)
    :Release inventory;
    :Notify customer;
    stop
  endif
else (no)
  :Return validation errors;
  stop
endif

@enduml

ユースケース図

PlantUML の構文
@startuml
left to right direction

actor Customer
actor "Warehouse Staff" as Warehouse
actor Admin

rectangle "E-Commerce System" {
  usecase "Browse Products" as UC1
  usecase "Add to Cart" as UC2
  usecase "Checkout" as UC3
  usecase "Track Order" as UC4
  usecase "Process Refund" as UC5
  usecase "Manage Inventory" as UC6
  usecase "Fulfill Order" as UC7
  usecase "Generate Reports" as UC8

  Customer --> UC1
  Customer --> UC2
  Customer --> UC3
  Customer --> UC4
  Customer --> UC5

  Warehouse --> UC6
  Warehouse --> UC7

  Admin --> UC6
  Admin --> UC8

  UC3 ..> UC2 : <<include>>
  UC5 ..> UC4 : <<extend>>
}

@enduml

ステートマシン図

PlantUML の構文
@startuml
title Order State Machine

[*] --> Draft : Create

Draft --> Submitted : Submit
Draft --> Cancelled : Cancel

Submitted --> Paid : PaymentReceived
Submitted --> Cancelled : Cancel
Submitted --> Draft : RequiresChanges

Paid --> Shipped : Ship
Paid --> Refunded : Refund

Shipped --> Delivered : Deliver
Shipped --> Returned : Return

Delivered --> Completed : Finalize
Delivered --> Returned : Return

Returned --> Refunded : ProcessReturn

Completed --> [*]
Refunded --> [*]
Cancelled --> [*]

@enduml
Mermaid ステート図
stateDiagram-v2
    [*] --> Draft : Create

    Draft --> Submitted : Submit
    Draft --> Cancelled : Cancel

    Submitted --> Paid : PaymentReceived
    Submitted --> Cancelled : Cancel
    Submitted --> Draft : RequiresChanges

    Paid --> Shipped : Ship
    Paid --> Refunded : Refund

    Shipped --> Delivered : Deliver
    Shipped --> Returned : Return

    Delivered --> Completed : Finalize
    Delivered --> Returned : Return

    Returned --> Refunded : ProcessReturn

    Completed --> [*]
    Refunded --> [*]
    Cancelled --> [*]

コンポーネント図

PlantUML の構文
@startuml
title System Components

package "Presentation Layer" {
  [Web Application] as Web
  [Mobile App] as Mobile
}

package "API Layer" {
  [API Gateway] as Gateway
  [GraphQL Server] as GraphQL
}

package "Business Layer" {
  [Order Service] as Orders
  [Payment Service] as Payment
  [Notification Service] as Notify
  [User Service] as Users
}

package "Data Layer" {
  database "Order DB" as OrderDB
  database "User DB" as UserDB
  queue "Message Bus" as Bus
}

package "External" {
  [Payment Provider] as PaymentExt
  [Email Service] as EmailExt
}

Web --> Gateway
Mobile --> Gateway
Gateway --> GraphQL
Gateway --> Orders
Gateway --> Users

Orders --> OrderDB
Orders --> Bus
Users --> UserDB

Payment --> PaymentExt
Notify --> EmailExt
Notify --> Bus

@enduml

ベストプラクティス

一般的なガイドライン
  1. 図の焦点を絞る:1 つの図につき 1 つの概念を扱います
  2. 一貫した記法を使う:プロジェクトごとに PlantUML または Mermaid を選びます
  3. 意味のある名前を付ける:明確で説明的なラベルを付けます
  4. 凡例を含める:複雑な図には凡例を付けます
  5. バージョン管理する:コードとともにリポジトリに保存します
図の選択ガイド
必要なもの図の種類
データ構造、ドメインモデルクラス図
API のフロー、プロトコルシーケンス図
ビジネスプロセスアクティビティ図
アクター間のやり取りユースケース図
ライフサイクル、状態遷移ステートマシン図
システム構造コンポーネント図
インフラストラクチャ配置図

ワークフロー

UML 図を作成する際は、以下の手順に従います。

  1. 目的を特定する:その図はどのような問いに答えるものですか?
  2. 図の種類を選択する:最も適切な種類を選びます
  3. テキストで下書きする:PlantUML または Mermaid の記法を使います
  4. 正確性を確認する:コードや要件と照らし合わせて検証します
  5. コンテキストを追加する:必要に応じてタイトル、注記、凡例を加えます
  6. レンダリングして検証する:図が正しくレンダリングされることを確認します

参考資料

詳しい記法ガイドについては、以下を参照してください。


最終更新日: 2025-12-26

コメント