Skip to content
Back to skills

Diagram As Code

ASecurity

Produces Mermaid diagrams of flows, sequences and data models read from the actual code, ready to commit next to your docs.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 15, 2026
ai-agentsgonode

Works with

  • cli

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill diagram-as-code --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Diagram As Code?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Diagram As Code
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-diagram-as-code/badge)](https://www.skillsdirectory.com/skills/workspace-templates-diagram-as-code)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: diagram-as-code
description: Produces Mermaid diagrams of flows, sequences and data models read from the actual code, ready to commit next to your docs.
---

# Diagram as code

Draw what the code does. Every box must trace to a file, table or service.

## Steps

1. Clarify the question the diagram answers (how a request flows, how services talk, what states an order has, how tables relate). One question per diagram.
2. Choose the type: `sequenceDiagram` for interactions over time, `flowchart` for decisions and pipelines, `stateDiagram-v2` for lifecycles, `erDiagram` for data models, `classDiagram` only for real type hierarchies.
3. Trace the code: start at the entry point (route, handler, job, CLI) and follow calls, queries and outgoing requests. For data models read migrations or ORM models for tables, keys and relations.
4. Write the Mermaid. Use real names from the code for nodes. Keep it to roughly 12 nodes; split into two diagrams when larger. Label edges with the verb or payload.
5. Check syntax: keep labels with brackets or colons in quotes, avoid reserved word `end` as a node id, and render with `npx @mermaid-js/mermaid-cli` if available.
6. Place the diagram in a Markdown file in a `mermaid` fenced block, with two sentences of explanation above it.

## Rules

- No invented components or "future" boxes.
- Do not draw every function; show boundaries that matter.
- Note what you left out below the diagram.

## Report

File path, what question each diagram answers, and the source files you traced.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.