creating-mermaid-diagrams
3つ以上の要素を含むシステム、APIフロー、認証シーケンス、データベース構造などを説明する際に、Mermaid記法で図を作成し、PNG/SVG/PDF形式でエクスポートして視覚的に分かりやすく表現するSkill。
📜 元の英語説明(参考)
Generate Mermaid diagrams (.mmd) and export to PNG/SVG/PDF using mmdc CLI or Kroki API. USE THIS SKILL when user mentions diagram, flowchart, sequence diagram, class diagram, ER diagram, state machine, architecture, visualize, git graph, 画图, 架构图, 流程图, 时序图. PROACTIVELY USE when explaining ANY system with 3+ components, API flows, authentication sequences, class hierarchies, database schemas, or state machines. Supports 11+ diagram types with fully automatic layout.
🇯🇵 日本人クリエイター向け解説
3つ以上の要素を含むシステム、APIフロー、認証シーケンス、データベース構造などを説明する際に、Mermaid記法で図を作成し、PNG/SVG/PDF形式でエクスポートして視覚的に分かりやすく表現するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o creating-mermaid-diagrams.zip https://jpskill.com/download/10332.zip && unzip -o creating-mermaid-diagrams.zip && rm creating-mermaid-diagrams.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/10332.zip -OutFile "$d\creating-mermaid-diagrams.zip"; Expand-Archive "$d\creating-mermaid-diagrams.zip" -DestinationPath $d -Force; ri "$d\creating-mermaid-diagrams.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
creating-mermaid-diagrams.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
creating-mermaid-diagramsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Mermaid ダイアグラム
.mmd テキストファイルを生成し、mmdc (ローカル) または Kroki API (インストール不要) を使用して PNG/SVG/PDF にエクスポートします。
主な利点: 完全に自動化されたレイアウトによるテキストベースの構文 — x/y 座標は不要です。
前提条件
オプション A: ローカル (mmdc)
npm install -g @mermaid-js/mermaid-cli
mmdc --version
オプション B: Kroki API (インストール不要)
curl --version # curl が必要です
ワークフロー
-
更新チェック (通知のみで pull しない) — 会話ごとに最初に実行します。
<this-skill-dir>/.last_updateを介して 24 時間に 1 回に制限します。ユーザーの明示的な同意なしにスキルディレクトリを変更しないでください。-
.last_updateが存在し、24 時間未満の場合は、このステップを完全にスキップします。 -
それ以外の場合は、アップストリームから最新のタグを取得します。
git -C <this-skill-dir> ls-remote --tags origin 'v*' 2>/dev/null \ | awk '{print $2}' | sed 's|refs/tags/||' | sort -V | tail -1 -
フロントマターのこのスキルの
metadata.versionと比較します。アップストリームタグが厳密に新しい (semver) 場合は、ユーザーに 1 行で伝え、次のように尋ねます。"このスキルの新しいバージョンが利用可能です: vX.Y.Z → vA.B.C.
git pullしますか?"はいと答えた場合は、
git -C <this-skill-dir> pull --ff-onlyを実行します。いずれにせよ.last_updateを更新して、プロンプトが 24 時間繰り返されないようにします。 -
アップストリームが同じか古い場合は、
.last_updateをサイレントに更新して続行します。 -
失敗した場合 (オフライン、git チェックアウトではない — 例: ClawHub でインストールされたコピー、読み取り専用パス、権限がない)、エラーをサイレントに無視して、ユーザーのタスクを続行します。失敗については言及しないでください。
-
-
依存関係の確認 —
mmdc --versionを試行し、利用できない場合は Kroki にフォールバックします -
ダイアグラムタイプの選択 — 下の表から選択します
-
生成 —
.mmdファイルをディスクに書き込みます -
検証 — 検証を実行します (エクスポート前に必須)
-
エクスポート —
mmdcまたは Kroki API を使用して PNG/SVG/PDF を生成します -
レポート — 出力ファイルのパスをユーザーに伝えます
検証 (必須)
最初に検証せずにダイアグラムをエクスポートしないでください。
# mmdc (ローカル) で検証
mmdc -i diagram.mmd -o /tmp/test.png 2>&1
# Kroki (mmdc が利用できない場合) で検証
curl -s -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/svg -o /tmp/test.svg && echo "Valid" || echo "Invalid"
# エラーが発生した場合は、.mmd ファイルを修正して再度検証します
# 検証が成功した後でのみエクスポートに進みます
一般的な検証エラー:
- 特殊文字を含むラベルを引用符で囲んでいない
- 間違った矢印構文 (シーケンスには
->>、フローチャートには-->を使用) - シーケンス図で宣言されていない参加者
ダイアグラムタイプ
| タイプ | キーワード | 用途 |
|---|---|---|
| フローチャート | flowchart TD/LR |
プロセス、パイプライン、決定 |
| シーケンス | sequenceDiagram |
API 呼び出し、メッセージパッシング |
| クラス | classDiagram |
OOP モデル、データ構造 |
| ER | erDiagram |
データベーススキーマ |
| ステート | stateDiagram-v2 |
ステートマシン、ライフサイクル |
| ガント | gantt |
プロジェクトタイムライン |
| パイ | pie |
割合 |
| Git グラフ | gitGraph |
ブランチ戦略 |
| C4 コンテキスト | C4Context |
高レベルアーキテクチャ |
| マインドマップ | mindmap |
トピックの内訳 |
構文リファレンス
フローチャート: reference/FLOWCHART.md を参照してください シーケンス: reference/SEQUENCE.md を参照してください クラス & ER: reference/CLASS-ER.md を参照してください その他のタイプ: reference/OTHER-TYPES.md を参照してください
例
例 1: API 認証フロー
ユーザープロンプト:
JWT 認証のシーケンス図を作成する
生成された .mmd:
sequenceDiagram
participant C as Client
participant G as API Gateway
participant A as Auth Service
participant D as Database
C->>G: POST /login {email, password}
G->>A: validate(credentials)
A->>D: SELECT user WHERE email=?
D-->>A: user record
A-->>A: verify password hash
A-->>G: 200 OK + JWT token
G-->>C: {token: "eyJhbG..."}
出力ファイル: auth-flow.mmd + auth-flow.png
例 2: マイクロサービスアーキテクチャ
ユーザープロンプト:
e コマースマイクロサービスアーキテクチャを描画する
生成された .mmd:
flowchart TD
subgraph Clients
M[Mobile App]
W[Web App]
end
GW[API Gateway]
subgraph Services
US[User Service]
OS[Order Service]
PS[Product Service]
PAY[Payment Service]
end
subgraph Data
UDB[(User DB)]
ODB[(Order DB)]
PDB[(Product DB)]
REDIS[(Redis Cache)]
end
M & W --> GW
GW --> US & OS & PS & PAY
US --> UDB
OS --> ODB
PS --> PDB
PAY --> REDIS
出力ファイル: ecommerce-arch.mmd + ecommerce-arch.png
例 3: 注文ステートマシン
ユーザープロンプト:
注文ライフサイクル状態を表示する
生成された .mmd:
stateDiagram-v2
[*] --> Pending : order created
Pending --> Confirmed : payment success
Pending --> Cancelled : timeout/cancel
Confirmed --> Shipped : dispatched
Shipped --> Delivered : received
Delivered --> [*]
Cancelled --> [*]
出力ファイル: order-states.mmd + order-states.png
エクスポートコマンド
オプション 1: ローカルエクスポート (mmdc)
ローカルに mmdc がインストールされている必要があります。オフラインでの使用に最適です。
# PNG (推奨: 幅 2048px、背景白)
mmdc -i diagram.mmd -o diagram.png -w 2048 --backgroundColor white
# テーマ付き PNG (default | dark | neutral | forest | base)
mmdc -i diagram.mmd -o diagram.png -w 2048 --backgroundColor white --theme neutral
# SVG
mmdc -i diagram.mmd -o diagram.svg
# PDF
mmdc -i diagram.mmd -o diagram.pdf
オプション 2: Kroki API (インストール不要)
mmdc が利用できない場合は、Kroki を使用します。ローカルの依存関係は必要ありません。
# Kroki 経由の SVG
curl -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/svg -o diagram.svg
# Kroki 経由の PNG
curl -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/png -o diagram.png
# Kroki 経由の PDF
curl -X POS 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Mermaid Diagrams
Generate .mmd text files and export to PNG/SVG/PDF using mmdc (local) or Kroki API (no install).
Key advantage: Text-based syntax with fully automatic layout — no x/y coordinates needed.
Prerequisites
Option A: Local (mmdc)
npm install -g @mermaid-js/mermaid-cli
mmdc --version
Option B: Kroki API (no install)
curl --version # Just need curl
Workflow
-
Update check (notify, don't pull) — first use per conversation. Throttle to once per 24 h via
<this-skill-dir>/.last_update; never mutate the skill directory without explicit user consent.-
If
.last_updateexists and is <24 h old, skip this step entirely. -
Otherwise, fetch the latest tag from upstream:
git -C <this-skill-dir> ls-remote --tags origin 'v*' 2>/dev/null \ | awk '{print $2}' | sed 's|refs/tags/||' | sort -V | tail -1 -
Compare with this skill's
metadata.versionfrom the frontmatter. If the upstream tag is strictly newer (semver), tell the user one line and ask:"A newer version of this skill is available: vX.Y.Z → vA.B.C. Want me to
git pull?"If they say yes, run
git -C <this-skill-dir> pull --ff-only. Refresh.last_updateeither way so the prompt doesn't repeat for 24 hours. -
If upstream is the same or older, refresh
.last_updatesilently and continue. -
On any failure (offline, not a git checkout — e.g. ClawHub-installed copy, read-only path, no permission), swallow the error silently and continue with the user's task. Do not mention the failure.
-
-
Check deps — try
mmdc --version, fallback to Kroki if unavailable -
Pick diagram type — choose from table below
-
Generate — write
.mmdfile to disk -
Validate — run validation (REQUIRED before export)
-
Export — use
mmdcor Kroki API to produce PNG/SVG/PDF -
Report — tell user the output file paths
Validation (Required)
NEVER export a diagram without validating first.
# Validate with mmdc (local)
mmdc -i diagram.mmd -o /tmp/test.png 2>&1
# Validate with Kroki (if mmdc unavailable)
curl -s -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/svg -o /tmp/test.svg && echo "Valid" || echo "Invalid"
# If error, fix the .mmd file and validate again
# Only proceed to export after validation passes
Common validation errors:
- Missing quotes around labels with special characters
- Wrong arrow syntax (use
->>for sequence,-->for flowchart) - Undeclared participants in sequence diagrams
Diagram Types
| Type | Keyword | Use for |
|---|---|---|
| Flowchart | flowchart TD/LR |
processes, pipelines, decisions |
| Sequence | sequenceDiagram |
API calls, message passing |
| Class | classDiagram |
OOP models, data structures |
| ER | erDiagram |
database schemas |
| State | stateDiagram-v2 |
state machines, lifecycle |
| Gantt | gantt |
project timelines |
| Pie | pie |
proportions |
| Git Graph | gitGraph |
branch strategies |
| C4 Context | C4Context |
high-level architecture |
| Mind Map | mindmap |
topic breakdowns |
Syntax Reference
Flowchart: See reference/FLOWCHART.md Sequence: See reference/SEQUENCE.md Class & ER: See reference/CLASS-ER.md Other types: See reference/OTHER-TYPES.md
Examples
Example 1: API Authentication Flow
User prompt:
Create a sequence diagram for JWT authentication
Generated .mmd:
sequenceDiagram
participant C as Client
participant G as API Gateway
participant A as Auth Service
participant D as Database
C->>G: POST /login {email, password}
G->>A: validate(credentials)
A->>D: SELECT user WHERE email=?
D-->>A: user record
A-->>A: verify password hash
A-->>G: 200 OK + JWT token
G-->>C: {token: "eyJhbG..."}
Output files: auth-flow.mmd + auth-flow.png
Example 2: Microservices Architecture
User prompt:
Draw an e-commerce microservices architecture
Generated .mmd:
flowchart TD
subgraph Clients
M[Mobile App]
W[Web App]
end
GW[API Gateway]
subgraph Services
US[User Service]
OS[Order Service]
PS[Product Service]
PAY[Payment Service]
end
subgraph Data
UDB[(User DB)]
ODB[(Order DB)]
PDB[(Product DB)]
REDIS[(Redis Cache)]
end
M & W --> GW
GW --> US & OS & PS & PAY
US --> UDB
OS --> ODB
PS --> PDB
PAY --> REDIS
Output files: ecommerce-arch.mmd + ecommerce-arch.png
Example 3: Order State Machine
User prompt:
Show order lifecycle states
Generated .mmd:
stateDiagram-v2
[*] --> Pending : order created
Pending --> Confirmed : payment success
Pending --> Cancelled : timeout/cancel
Confirmed --> Shipped : dispatched
Shipped --> Delivered : received
Delivered --> [*]
Cancelled --> [*]
Output files: order-states.mmd + order-states.png
Export Commands
Option 1: Local Export (mmdc)
Requires mmdc installed locally. Best for offline use.
# PNG (recommended: 2048px wide, white background)
mmdc -i diagram.mmd -o diagram.png -w 2048 --backgroundColor white
# PNG with theme (default | dark | neutral | forest | base)
mmdc -i diagram.mmd -o diagram.png -w 2048 --backgroundColor white --theme neutral
# SVG
mmdc -i diagram.mmd -o diagram.svg
# PDF
mmdc -i diagram.mmd -o diagram.pdf
Option 2: Kroki API (No Install Required)
Use Kroki when mmdc is not available. No local dependencies needed.
# SVG via Kroki
curl -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/svg -o diagram.svg
# PNG via Kroki
curl -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/png -o diagram.png
# PDF via Kroki
curl -X POST -H "Content-Type: text/plain" --data-binary @diagram.mmd https://kroki.io/mermaid/pdf -o diagram.pdf
Kroki advantages:
- No local installation required
- Works on any system with
curl - Supports 20+ diagram types (PlantUML, GraphViz, D2, etc.)
When to use Kroki:
mmdcinstallation fails- Quick one-off diagrams
- CI/CD pipelines without Node.js
Common Mistakes
| Mistake | Fix |
|---|---|
mmdc not found |
npm install -g @mermaid-js/mermaid-cli |
| Wrong arrow in sequence | Use ->> for request, -->> for response |
| Special chars in label | Wrap in quotes: A["Label: value"] |
| Blank/small output | Add -w 2048 flag |
| Participant order wrong | Declare participant explicitly at top |
| Subgraph name with spaces | Wrap in quotes: subgraph "My Layer" |