mermaid-diagram
できること
このスキルは、フローチャート、シーケンス図、クラス図などのMermaidの図のコードを書き、それを確認します。書かれた説明からきれいな図が必要な人向けです。
使う場面
- ✓説明から、フローチャート、シーケンス図、クラス図が必要なとき。
- ✓ドキュメント用にMermaidのファイルをfiguresフォルダーに保存したいとき。
- ✓数式を含む図を、正しく描画させる必要があるとき。
スキルのリンク
https://github.com/wanshuiyin/Auto-claude-code-research-in-sleep/blob/main/skills/skills-codex/mermaid-diagram/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のAPI呼び出しのMermaidシーケンス図を作り、構文を確認したうえでfiguresフォルダーに保存してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは図の種類を選び、コードを書いて、.mmdと.mdのファイルをfiguresフォルダーに保存します。構文を確認し、必要に応じて数ラウンドにわたってレイアウトを洗練させます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Mermaid Diagram Generator
Generate high-quality Mermaid diagram code based on user requirements, with file output and verification.
Constants
- OUTPUT_DIR =
figures/— Output directory for generated files - MAX_ITERATIONS = 3 — Maximum refinement rounds for syntax or layout issues
Workflow: MUST EXECUTE ALL STEPS
Step 0: Pre-flight Check
Create output directory
mkdir -p figures
Step 1: Understand Requirements & Select Diagram Type
Parse the input: $ARGUMENTS
- Analyze the request and choose the most suitable diagram type
- Read the corresponding Mermaid syntax reference below
- If the diagram involves mathematical notation, apply the math syntax rules from the Math Formulas in Diagrams section
- Identify all components, connections, and data flow
- Plan the diagram structure before writing code
Step 2: Read Documentation
Select the appropriate diagram type. Use built-in Mermaid knowledge first; if external documentation is needed and your environment provides it, fetch the up-to-date syntax reference.
Configuration & Themes
Choose theme, colors, and layout before writing code. For academic diagrams, prefer clean white backgrounds, restrained colors, and readable labels over decorative styling.
| Type | Use Cases |
|---|---|
| Flowchart | Processes, decisions, steps |
| Sequence Diagram | Interactions, messaging, API calls |
| Class Diagram | Class structure, inheritance, associations |
| State Diagram | State machines, state transitions |
| ER Diagram | Database design, entity relationships |
| Gantt Chart | Project planning, timelines |
| Pie Chart | Proportions, distributions |
| Mindmap | Hierarchical structures, knowledge graphs |
| Timeline | Historical events, milestones |
| Git Graph | Branches, merges, versions |
| Quadrant Chart | Four-quadrant analysis |
| Requirement Diagram | Requirements traceability |
| C4 Diagram | System architecture |
| Sankey Diagram | Flow, conversions |
| XY Chart | Line charts, bar charts |
| Block Diagram | System components, modules |
| Packet Diagram | Network protocols, data structures |
| Kanban | Task management, workflows |
| Architecture Diagram | System architecture |
| Radar Chart | Multi-dimensional comparison |
| Treemap | Hierarchical data visualization |
| User Journey | User experience flows |
| ZenUML | Sequence diagrams (code style) |
Step 3: Generate Mermaid Code & Save Files
Generate the Mermaid code and save two files:
File 1: figures/<diagram-name>.mmd — Raw Mermaid source
The .mmd file contains only raw Mermaid code, no markdown fences.
File 2: figures/<diagram-name>.md — Markdown with embedded Mermaid
The .md file wraps the same Mermaid code in a mermaid code block for preview rendering, plus a short title and description.
Diagram Title
Use a concise title in the .md wrapper that matches the generated diagram name.
Naming convention: use a descriptive kebab-case name derived from the request, such as auth-flow, system-architecture, or database-er.
Step 4: Verify Mermaid Syntax (MANDATORY)
Codex MUST verify the generated Mermaid code by running the Mermaid CLI (mmdc).
Check if mermaid-cli is available
if command -v mmdc >/dev/null 2>&1; then
mmdc -i figures/<diagram-name>.mmd -o figures/<diagram-name>.png -b transparent \
&& echo "Syntax valid — PNG rendered to figures/<diagram-name>.png"
else
npx -y @mermaid-js/mermaid-cli@latest -i figures/<diagram-name>.mmd -o figures/<diagram-name>.png -b transparent \
&& echo "Syntax valid — PNG rendered to figures/<diagram-name>.png"
fi
If verification fails:
- Read the error carefully
- Fix the syntax issue in both
.mmdand.md - Re-run verification
- Repeat up to
MAX_ITERATIONS
Step 5: Codex STRICT Visual Review & Scoring (MANDATORY)
After successful rendering, Codex MUST read the generated PNG and perform a strict review:
## Codex's STRICT Review of <diagram-name>
### What I See
[Describe the rendered diagram in detail]
### Files Generated
- `figures/<diagram-name>.mmd`
- `figures/<diagram-name>.md`
- `figures/<diagram-name>.png`
### ═══════════════════════════════════════════════════════════════
### STRICT VERIFICATION CHECKLIST (ALL must pass for score ≥ 9)
### ═══════════════════════════════════════════════════════════════
#### A. File Correctness
- [ ] `.mmd` contains valid Mermaid syntax
- [ ] `.
よくある質問
何種類の図がありますか?
フローチャート、シーケンス図、クラス図、ER図、ガントチャートなど、多くの種類を扱います。
ファイルはどこに保存されますか?
既定では、プロジェクト内のfiguresフォルダーに保存されます。
インターネットが必要ですか?
まず組み込みのMermaidの知識を使い、環境が提供する場合にだけ外部のドキュメントを取得します。
詳細
作者による元の説明
Generate Mermaid diagrams from user requirements. Save .mmd and .md files to figures/ with syntax verification. Supports flowcharts, sequence diagrams, class diagrams, ER diagrams, Gantt charts, and many more diagram types.
人気
- GitHubのスター
- 18k
- ランキング
- #10605
- ライセンス
- MIT
- 更新日
- 2026/11/2
コメント
- …
このリポジトリの他のスキル
ablation-planner
18kエージェントが論文のアブレーション研究を計画し、主要な結果が良好に見えた後に、査読者が求めそうな試験を選ぶよう支援します。
alphaxiv
18kエージェントが、AlphaXivの要約を使って1本の研究論文を素早く読めるよう支援します。arXivのリンクやIDから読み込みます。
analyze-results
18kエージェントが機械学習の実験結果を分析し、実行結果をベースラインと比較して、数値を明確な所見と次の作業につなげるよう支援します。
arxiv
18kエージェントが、arXivで学術論文を検索し、詳細を読んで、研究テーマに合わせてPDFをライブラリに保存できるよう支援します。