skills/mermaid/SKILL.md
Generate diagrams with Mermaid syntax
npx skillsauth add jcsaaddupuy/badrobots mermaidInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Mermaid is a diagramming and charting tool that uses text-based syntax to create diagrams. It's perfect for creating visual documentation that lives in markdown files and version control.
IMPORTANT: Before creating diagrams, read the appropriate reference file:
ALWAYS use single quotes ' in Mermaid diagrams, NEVER double quotes "
# ❌ WRONG - Double quotes break rendering
graph LR
A["User asks question"] --> B["Generate SQL"]
# ✅ CORRECT - Single quotes work perfectly
graph LR
A['User asks question'] --> B['Generate SQL']
# ✅ ALSO CORRECT - No quotes when no spaces
graph LR
A[User] --> B[SQL]
Why? Mermaid parsers treat double quotes as special characters, causing syntax errors. Single quotes are safe for all text content.
Curly braces {} have special meaning in Mermaid and cause parse errors in node labels
# ❌ WRONG - Curly braces break parsing
graph LR
A[Request] --> B[Response: {success: true, data: [...]}]
# ✅ CORRECT - Describe structure without braces
graph LR
A[Request] --> B[Success Response:<br/>success, data, metadata]
# ✅ ALSO CORRECT - Use parentheses instead
graph LR
A[Request] --> B[Response (success, data)]
Why? Curly braces {} are reserved for decision nodes and subgraphs. Using them in labels causes "Expecting 'SQE', got 'DIAMOND_START'" errors.
Apply to:
NEVER use 1., 2., 3. format inside Mermaid diagrams - use bullet points or remove periods
# ❌ WRONG - Numbers with periods break parsing
graph TD
A[Step 1. DNS query] --> B[Step 2. Connect]
C[Item 1. First] --> D[Item 2. Second]
# ✅ CORRECT - Use bullet points instead
graph TD
A["Step - DNS query"] --> B["Step - Connect"]
C["Item - First"] --> D["Item - Second"]
# ✅ ALSO CORRECT - Just remove the periods
graph TD
A["Step 1 DNS query"] --> B["Step 2 Connect"]
C["Item 1 First"] --> D["Item 2 Second"]
Why? Mermaid number parsing gets confused by the period format (e.g., 1., 2.). It interprets the period as a decimal or special character, causing parsing errors.
Rule applies to:
Workaround for ordered sequences:
|Step 1: DNS| or |DNS query|- First step (outside diagram)A), B), C)Step - DNS querySafe characters: Letters, numbers, spaces, hyphens, underscores, parentheses (), colons :
Avoid in labels: {}, [] (use sparingly), <>, | (except in edge syntax)
Exception: Code blocks outside diagrams can use any syntax normally.
1. Identify diagram type needed
↓
2. Read appropriate reference file
├─ sequence-diagram.md for interactions
├─ class-diagram.md for structure
├─ er-diagram.md for data models
├─ state-diagram.md for states
├─ gantt.md for timelines
└─ gitgraph.md for git workflows
↓
3. Follow syntax from reference
├─ Start with diagram declaration
├─ Define entities/participants
├─ Add relationships/transitions
└─ Customize as needed
↓
4. Test rendering
├─ Use Mermaid Live Editor
├─ Or preview in VSCode
└─ Verify output matches intent
sequenceDiagram
Alice->>John: Hello John!
John-->>Alice: Hi Alice!
classDiagram
Animal <|-- Duck
Animal : +int age
Animal: +makeSound()
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
stateDiagram-v2
[*] --> Still
Still --> Moving
Moving --> Still
Moving --> Crash
Crash --> [*]
gantt
title Project Timeline
dateFormat YYYY-MM-DD
section Phase 1
Task A :a1, 2024-01-01, 30d
gitGraph
commit
branch develop
commit
checkout main
merge develop
When generating diagrams, you may need to organize them in folders like docs/diagrams/, docs/images/, etc. NEVER destructively delete directories without verifying their contents first.
# ❌ WRONG: Deletes everything without checking
rm -rf docs/diagrams
# ❌ WRONG: Assumes folder is yours to delete
rm -rf docs/diagramms # Typo in original folder name? Still don't delete!
# ❌ WRONG: No verification before destruction
mkdir -p docs/diagrams/er # If docs/diagrams exists, you might delete other content
# ✅ STEP 1: CHECK what exists FIRST
ls -la docs/
find docs/ -type f # List all files recursively
tree docs/ # If tree is available
# ✅ STEP 2: Review content before any deletion
ls -la docs/diagrams/
# If you see files you didn't create → STOP and ask user
# ✅ STEP 3A: Create in new subdirectory (safest)
mkdir -p docs/diagrams/er # Only creates new subdirectory
mkdir -p docs/diagrams/generated # Clear it's auto-generated
# ✅ STEP 3B: Only remove YOUR files specifically
rm -f docs/diagrams/er/*.png # Only remove specific files you created
rm -f docs/diagrams/er/*.mmd
# ✅ STEP 3C: If must remove directory, verify empty first
if [ -z "$(ls -A docs/diagrams/er)" ]; then
rmdir docs/diagrams/er # Only works if empty
else
echo "Directory not empty, please review contents"
ls -la docs/diagrams/er
fi
#!/bin/bash
# Safe diagram generation workflow
TARGET_DIR="docs/diagrams/er"
# 1. Check if directory exists and has content
if [ -d "$TARGET_DIR" ]; then
echo "⚠️ Directory exists: $TARGET_DIR"
echo "Current contents:"
ls -la "$TARGET_DIR"
# Count files
file_count=$(find "$TARGET_DIR" -type f | wc -l)
if [ "$file_count" -gt 0 ]; then
echo "❌ ERROR: Directory contains $file_count file(s)"
echo "Please review and manually clean if needed"
exit 1
fi
fi
# 2. Create directory safely
mkdir -p "$TARGET_DIR"
# 3. Generate diagrams
for mmd_file in *.mmd; do
mmdc -i "$mmd_file" -o "$TARGET_DIR/${mmd_file%.mmd}.png" -s 10 -b transparent
done
echo "✓ Diagrams generated in $TARGET_DIR"
# 1. Check git (if files were tracked)
git status docs/
git log --all --full-history -- docs/diagrams/
# 2. Check for IDE backups
ls -la .idea/ # IntelliJ/PyCharm
ls -la .vscode/ # VSCode local history
# 3. Check system trash (macOS)
ls -la ~/.Trash/
# 4. Time Machine (macOS)
tmutil listbackups
# 5. Ask user if they have backups
echo "⚠️ I may have deleted files. Do you have backups?"
BEFORE touching any directory:
ls -la target_dir/git status target_dir/AFTER creating files:
ls -la target_dir/# User asks: "Generate ER diagrams in docs/diagramms/er"
# Notice: User said "diagramms" (with double m)
# ❌ WRONG approach:
# rm -rf docs/diagramms # Deletes user's existing folder!
# mkdir -p docs/diagramms/er
# ✅ RIGHT approach:
echo "Checking target directory..."
ls -la docs/diagramms/ 2>/dev/null || echo "Directory doesn't exist yet"
# If directory exists with content:
if [ -d "docs/diagramms" ]; then
echo "Found existing docs/diagramms/ with:"
find docs/diagramms -type f
echo "Should I:"
echo " A) Create in docs/diagramms/er/ (preserves existing)"
echo " B) Create in docs/diagrams/er/ (standardize spelling)"
# Wait for user response
fi
# Create safely
mkdir -p docs/diagramms/er # Only creates subdirectory
# Generate diagrams...
When in doubt, ASK the user before deleting anything.
It's better to create a new subdirectory than to risk deleting user content.
# Test your safety practices
mkdir -p test_safety/existing
echo "important content" > test_safety/existing/data.txt
# Now try your workflow - it should:
# 1. Detect existing content
# 2. NOT delete data.txt
# 3. Either fail safely or create subdirectory
# Clean up test
rm -rf test_safety/
" in text → ✅ Always use single quotes '{} in labels → ✅ Use descriptive text instead1., 2.) → ✅ Use bullet points or remove periodsmermaid-cli (mmdc) converts Mermaid diagrams to image files.
Installation Status: ✅ Already installed (mmdc v11.12.0)
# PNG (ALWAYS use scale=10 for high quality)
mmdc -i diagram.mmd -o diagram.png -s 10 -b transparent
# SVG (for web, scalable)
mmdc -i diagram.mmd -o diagram.svg
# PDF (for documents)
mmdc -i diagram.mmd -o diagram.pdf
ALWAYS use -s 10 (scale 10) when generating PNG files.
# ✅ CORRECT - High quality PNG
mmdc -i diagram.mmd -o diagram.png -s 10 -b transparent
# ❌ WRONG - Low quality, blurry
mmdc -i diagram.mmd -o diagram.png
| Option | Value | Purpose |
|--------|-------|---------|
| -s 10 | Required for PNG | Scale factor (high quality) |
| -b transparent | Recommended | Transparent background |
| -t dark | Optional | Dark theme |
| -t default | Default | Light theme |
# Generate PNGs from all .mmd files in directory
for file in *.mmd; do
mmdc -i "$file" -o "${file%.mmd}.png" -s 10 -b transparent
done
# With dark theme
for file in *.mmd; do
mmdc -i "$file" -o "${file%.mmd}.png" -s 10 -b transparent -t dark
done
mmdc -i diagram.mmd -o diagram.png -s 10 -b transparent
mmdc -i diagram.mmd -o diagram.png -s 10 -b transparent -t dark
mmdc -i diagram.mmd -o diagram.svg
cat << 'EOF' | mmdc -i - -o output.png -s 10 -b transparent
graph TD
A[Start] --> B[End]
EOF
# PNG (high quality, transparent)
mmdc -i diagram.mmd -o diagram.png -s 10 -b transparent
# PNG (dark theme)
mmdc -i diagram.mmd -o diagram.png -s 10 -b transparent -t dark
# SVG (for web)
mmdc -i diagram.mmd -o diagram.svg
# Batch process
for f in *.mmd; do mmdc -i "$f" -o "${f%.mmd}.png" -s 10 -b transparent; done
-s 10 for PNG files-b transparent for flexible backgrounds| Use Case | Diagram Type | Reference | |----------|-------------|-----------| | API interactions | Sequence | sequence-diagram.md | | Class structure | Class | class-diagram.md | | Database schema | ER | er-diagram.md | | State machines | State | state-diagram.md | | Project timeline | Gantt | gantt.md | | Git workflows | GitGraph | gitgraph.md |
development
DuckDB patterns for JSON/JSONL analysis, array unnesting, and common gotchas. Use when querying JSON files, nested data, or encountering "UNNEST not supported here" errors.
development
Mealie recipe manager API: recipes, shopping lists, meal plans. Requires MEALIE_BASE_URL and MEALIE_API_KEY.
business
TimeWarrior time tracking: start/stop intervals, query durations by tag or issue, compute totals for issue tracker time reporting
development
Bookmark manager for saving, searching, and annotating web content. Use when: (1) saving a webpage for later reference, (2) searching previously saved bookmarks, (3) adding highlights/annotations to saved content, (4) user asks to 'bookmark this' or 'save this article'. Requires READECK_BASE_URL and READECK_API_KEY environment variables.