---
name: uml-diagram-maker
description: Create, update, or review UML and software diagrams as Mermaid text. Use when the user asks for a class, sequence, state, component, use-case, data-model, or codebase architecture diagram.
---

# UML Diagram Maker

Create diagrams that are traceable to the user's request and, when available, the codebase.

1. Read the repository guidance and inspect the relevant code, schemas, and documentation before drawing.
2. Choose the smallest diagram that answers the question:
   - `classDiagram` for types, interfaces, inheritance, composition, and dependencies.
   - `sequenceDiagram` for request flow, call order, async work, and service boundaries.
   - `stateDiagram-v2` for lifecycle states, transitions, guards, and terminal outcomes.
   - `flowchart` for components, deployment topology, decisions, or a use-case view.
   - `erDiagram` for persisted entities and their cardinality.
3. Preserve names found in source. Do not invent services, methods, relationships, or guarantees. Label user-provided or inferred structure as an assumption.
4. Keep the Mermaid source reviewable:
   - Start with the diagram declaration.
   - Prefer short stable identifiers and readable labels.
   - Keep one relationship or message per line.
   - Add `%% Source: relative/path` comments when the diagram is grounded in files.
   - Avoid click handlers, embedded HTML, and external links.
5. Optimize for comprehension. Show the main path first, group related nodes, and omit detail that does not change the reader's understanding.
6. Follow the repository's existing diagram location and style. If none exists and the user asked for a file, default to `docs/diagrams/<descriptive-name>.mmd`.
7. Validate with the repository's existing Mermaid check or an already-installed `mmdc`. Do not install packages without permission. If no renderer is available, inspect the syntax and explicitly say that render validation was not run.
8. Return the Mermaid source, the selected diagram type, material assumptions, source files inspected, and validation performed.

For updates, preserve useful layout and labels unless the requested change requires restructuring the diagram.
