mermaid-diagram
Generate syntactically valid Mermaid.js diagrams. Use when user says "create a mermaid diagram", "generate a flowchart", "draw a sequence diagram", "visualize with mermaid", "mermaid architecture diagram", "create a class diagram", "make a state diagram", "ER diagram", "Gantt chart", "gitGraph", or when generating any Mermaid code block in markdown. Also use when asked to fix or debug a broken Mermaid diagram.
What this skill does
# Mermaid.js Diagram Generator
Generate valid Mermaid.js diagrams that render without syntax errors on the first attempt. When outputting a diagram, always wrap it in a fenced code block with the `mermaid` language tag.
## Syntax Rules
Follow every rule below. Violating any one will produce a render failure.
### 1. One Node Per Line
```mermaid
%% CORRECT
A[Service A]
B[Service B]
%% WRONG
A[Service A] B[Service B]
```
### 2. Alphanumeric Node IDs Only
No spaces, hyphens, or special characters in IDs. Display names go in brackets.
```mermaid
%% CORRECT
AuthService[Auth Service]
UserDB[User Database]
%% WRONG
Auth-Service[Auth Service]
User DB[User Database]
```
### 3. Quote Labels with Special Characters
Wrap in double quotes if a label contains parentheses, brackets, colons, math operators, or anything that could be parsed as Mermaid syntax.
```mermaid
%% CORRECT
A["Process (async)"]
B["array[0]"]
C["ratio: 3/4"]
D["calculate(x, y)"]
%% WRONG
A[Process (async)]
B[array[0]]
```
### 4. No HTML or Markdown in Labels
Use commas or semicolons instead of `<br>` or `\n`.
```mermaid
%% CORRECT
A["Input: raw data, Output: processed"]
%% WRONG
A[Input: raw data<br>Output: processed]
```
### 5. No Chained Arrows
Write each connection on its own line.
```mermaid
%% CORRECT
A --> B
B --> C
%% WRONG
A --> B --> C
```
### 6. Comments on Their Own Lines
`%%` comments must not appear at the end of code lines.
```mermaid
%% CORRECT
%% This is a comment
A --> B
%% WRONG
A --> B %% connection
```
### 7. Style Only Defined Nodes
Apply `style` directives only after the node has been defined.
```mermaid
%% CORRECT
A[Server]
style A fill:#f9f,stroke:#333
%% WRONG
style A fill:#f9f,stroke:#333
A[Server]
```
### 8. Subgraph Names
Use underscores or wrap in quotes — no bare spaces.
```mermaid
%% CORRECT
subgraph Backend_Services
subgraph "Backend Services"
%% WRONG
subgraph Backend Services
```
### 9. Validate Before Presenting
Trace through the diagram to confirm:
- Every node on its own line with unique alphanumeric ID
- No chained arrows
- Special-character labels double-quoted
- No HTML/Markdown in labels
- Comments on own lines
- Styles reference defined nodes only
- Subgraph names quoted or underscored
## Diagram Type Quick Reference
| Type | Directive | Use For |
| --------- | ------------------------------- | ---------------------------------- |
| Flowchart | `flowchart TD` / `flowchart LR` | Architecture, data flow, decisions |
| Sequence | `sequenceDiagram` | API calls, request/response |
| Class | `classDiagram` | Type relationships, OOP |
| State | `stateDiagram-v2` | State machines, lifecycles |
| ER | `erDiagram` | Database schemas, entities |
| Gantt | `gantt` | Timelines, schedules |
| Git | `gitGraph` | Branch strategies, merges |
## Common Patterns
### Architecture Diagram
```mermaid
flowchart TD
Client[Browser Client]
API[API Gateway]
Auth[Auth Service]
DB[(Database)]
Client --> API
API --> Auth
Auth --> DB
```
### Sequence Flow
```mermaid
sequenceDiagram
participant C as Client
participant S as Server
participant D as Database
C->>S: POST /api/data
S->>D: INSERT query
D-->>S: Result
S-->>C: 201 Created
```
## Fixing Broken Diagrams
When asked to fix a broken Mermaid diagram:
1. **Identify the error type** — parse errors almost always come from one of: chained arrows, unquoted special characters, bare subgraph names, or HTML in labels.
2. **Apply the relevant rules above** — check each rule against the broken code line by line.
3. **Rewrite the offending lines** — fix only what is broken; preserve the diagram's intent.
4. **Re-validate** using the checklist in Rule 9 before presenting the corrected diagram.
If the diagram is structurally ambiguous (missing nodes, unclear relationships), ask one clarifying question before rewriting.
Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.