Back to Skills

creating-mermaid-flowcharts

majiayu000
Updated Today
1 views
58
9
58
View on GitHub
Metaaidata

About

This skill helps developers create and debug Mermaid flowchart syntax, providing guardrails for node shapes, connections, and styling to prevent parse errors. It's specifically designed for crafting Obsidian-compatible diagrams using modern syntax. Use it when writing or editing flowcharts, converting from other formats, or troubleshooting syntax issues.

Quick Install

Claude Code

Recommended
Plugin CommandRecommended
/plugin add https://github.com/majiayu000/claude-skill-registry
Git CloneAlternative
git clone https://github.com/majiayu000/claude-skill-registry.git ~/.claude/skills/creating-mermaid-flowcharts

Copy and paste this command in Claude Code to install this skill

Documentation

Creating Mermaid Flowcharts

Overview

Mermaid has strict syntax rules: node identifiers must be simple alphanumeric (a, b, node1), while labels can contain any text. Modern @{ shape: ..., label: "..." } syntax is preferred over legacy shorthand for clarity and reliability.

When to Use

Use this skill when:

  • Creating new Mermaid flowchart diagrams
  • Encountering parse errors ("Expecting 'SEMI'", syntax errors)
  • Converting diagrams from other formats (dot, graphviz)
  • Unsure about shape syntax, connection types, or styling
  • Need to add colors or classes to nodes

Don't use for:

  • Other Mermaid diagram types (sequence, gantt, class diagrams)
  • Complex state machines (use stateDiagram instead)

Quick Reference

Common Shapes

ShapeModern SyntaxUse Case
Diamonda@{ shape: diam, label: "Decision?" }Decisions, questions
Rectanglea@{ shape: rect, label: "Action" }Process steps, actions
Stadiuma@{ shape: stadium, label: "Start/End" }Start/end points (preferred)
Circlea@{ shape: circle, label: "Start" }Alternative for start/end
Roundeda@{ shape: rounded, label: "Event" }Events, states

Note: Use stadium for start/end nodes (more readable). Use circle for compact diagrams.

See mermaid-flowchart-reference.md for complete shape list.

Connections

TypeSyntaxExample
Solid arrow-->a --> b
Labeled arrow-->|label|a -->|yes| b
Dotted-.->a -.-> b
Thick==>a ==> b

Styling

PatternSyntaxPurpose
Define classclassDef name fill:#colorCreate reusable style
Apply classnode:::classNameStyle specific node

Core Pattern

❌ WRONG - Spaces in identifiers:

graph LR
    "New constraint revealed?" --> "Return to Phase 1"

Error: Identifiers can't have spaces. Parse will fail.

✅ CORRECT - Simple IDs + Labels:

graph LR
    a@{ shape: diam, label: "New constraint revealed?" }
    b@{ shape: rect, label: "Return to Phase 1" }
    a -->\|yes\| b

Implementation

Step 1: Choose Graph Direction

graph TD    ← Top-down (vertical flow)
graph LR    ← Left-right (horizontal flow)

Choose based on flow:

  • TD (or TB) = Top-down for sequential processes, workflows
  • LR = Left-right for timelines, state transitions
  • BT = Bottom-up (rare)
  • RL = Right-left (rare)

Step 2: Define Nodes with Modern Syntax

graph TD
    a@{ shape: diam, label: "Your question here?" }
    b@{ shape: rect, label: "Your action here" }

Rules:

  • Identifier = simple alphanumeric only (a, b, node1, step2)
  • Label = any text in quotes after label:
  • Shape = from reference list (diam, rect, circle, stadium, etc.)

Step 3: Connect Nodes

    a -->\|yes\| b
    a -->\|no\| c

Always label decision branches (yes/no, true/false, etc.)

Step 4: Apply Styling (Optional)

    classDef highlight fill:#ffcccc
    classDef success fill:#ccffcc

    b:::highlight
    c:::success

Define classes before applying them. Each node can only have one class applied.

Styling patterns:

  • Multiple end nodes: Use separate end nodes when paths have different outcomes; use single end node when all paths converge naturally
  • Decision nodes: Keep neutral (no styling) or style based on their context (error flow vs success flow)
  • Need composite styles? Create a new class combining properties rather than applying multiple classes

Common Mistakes

Mistake 1: Spaces in Identifiers

Problem:

"My Node" --> "Other Node"

Fix: Use simple IDs with labels:

a@{ shape: rect, label: "My Node" } --> b@{ shape: rect, label: "Other Node" }

Mistake 2: Missing Edge Labels on Decisions

Problem:

decision --> optionA
decision --> optionB

Fix: Label your decision branches:

decision -->\|yes\| optionA
decision -->\|no\| optionB

Mistake 3: Applying Undefined Classes

Problem:

a:::highlight  ← Class never defined

Fix: Define before applying:

classDef highlight fill:#ffcccc
a:::highlight

Mistake 4: Mixing Legacy and Modern Syntax

Problem:

a@{ shape: diam, label: "Modern" }
b{"Legacy"}  ← Inconsistent

Fix: Use modern syntax consistently throughout diagram.

Debugging Checklist

When you get parse errors:

  • All identifiers are simple alphanumeric (no spaces, no special chars)
  • Modern @{ shape: ..., label: "..." } syntax used consistently
  • Decision nodes have labeled edges
  • Classes defined before applied
  • No trailing semicolons or extra whitespace
  • Graph direction specified (LR, TD, etc.)

Real-World Impact

Using modern syntax eliminates 90% of parse errors. Proper identifier naming allows diagrams to render on first attempt in Obsidian without web lookups or trial-and-error debugging.

GitHub Repository

majiayu000/claude-skill-registry
Path: skills/creating-mermaid-flowcharts

Related Skills

content-collections

Meta

This skill provides a production-tested setup for Content Collections, a TypeScript-first tool that transforms Markdown/MDX files into type-safe data collections with Zod validation. Use it when building blogs, documentation sites, or content-heavy Vite + React applications to ensure type safety and automatic content validation. It covers everything from Vite plugin configuration and MDX compilation to deployment optimization and schema validation.

View skill

sglang

Meta

SGLang is a high-performance LLM serving framework that specializes in fast, structured generation for JSON, regex, and agentic workflows using its RadixAttention prefix caching. It delivers significantly faster inference, especially for tasks with repeated prefixes, making it ideal for complex, structured outputs and multi-turn conversations. Choose SGLang over alternatives like vLLM when you need constrained decoding or are building applications with extensive prefix sharing.

View skill

evaluating-llms-harness

Testing

This Claude Skill runs the lm-evaluation-harness to benchmark LLMs across 60+ standardized academic tasks like MMLU and GSM8K. It's designed for developers to compare model quality, track training progress, or report academic results. The tool supports various backends including HuggingFace and vLLM models.

View skill

langchain

Meta

LangChain is a framework for building LLM applications using agents, chains, and RAG pipelines. It supports multiple LLM providers, offers 500+ integrations, and includes features like tool calling and memory management. Use it for rapid prototyping and deploying production systems like chatbots, autonomous agents, and question-answering services.

View skill