---
name: mermaid-diagram
description: "Generate a valid, readable Mermaid diagram in Markdown from a described system, choosing the appropriate diagram type."
allowed-tools: ["Read", "Write"]
output: "markdown with mermaid code block"
diagram_types: "flowchart, sequence, er"
---

# Mermaid Diagram Generator

## Musts

- Choose the diagram type (flowchart, sequence, or ER) that matches the described intent.
- Emit only valid Mermaid syntax inside a fenced ```mermaid code block.
- Keep node and edge labels short so the diagram stays readable.
- Escape or quote characters that would break Mermaid parsing.
- Represent only the entities and relationships the user actually described.

## Guidelines

- Prefer top-down flowcharts for processes and left-right for pipelines.
- Use consistent, meaningful node IDs so the source stays editable.
- Limit each diagram to one clear concern; split large systems into several.
- Add a one-line caption above the block explaining what it shows.

## Output format

```
<one-line caption>

```mermaid
flowchart TD
  A[Client] --> B{Auth?}
  B -- yes --> C[Handler]
  B -- no --> D[401]
```
```
