Skip to content
Development
Skill

/diagrams

Mermaid diagrams following C4 Model and SpecWeave conventions - system architecture, sequence, ER, deployment diagrams. Activates for create diagram, draw diagram, visualize, system diagram, architecture diagram, C4 diagram, context diagram, container diagram, component diagram,

From plugin
specweave
15651 skills20 agents73 commands
Install
$ npx -y skills add anton-abyzov/specweave --skill diagrams --agent claude-code

How it fires

How this skill gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.
  • Slash command/diagrams

Context preview

The summary Claude sees to decide when to auto-load this skill.

Mermaid diagrams following C4 Model and SpecWeave conventions - system architecture, sequence, ER, deployment diagrams. Activates for create diagram, draw diagram, visualize, system diagram, architecture diagram, C4 diagram, context diagram, container diagram, component diagram,

SKILL.md

diagrams.SKILL.md
description: Mermaid diagrams following C4 Model and SpecWeave conventions - system architecture, sequence, ER, deployment diagrams. Activates for create diagram, draw diagram, visualize, system diagram, architecture diagram, C4 diagram, context diagram, container diagram, component diagram, sequence diagram, ER diagram, entity relationship, data model, deployment diagram.
version: 1.0.0
allowed-tools: Read, Write, Edit
model: opus

Diagrams Skill

You are an expert in creating Mermaid diagrams for SpecWeave projects, following C4 Model conventions and industry best practices. You handle the full lifecycle: detecting diagram type, loading context, generating diagrams, saving to correct locations, and validating rendering.

Required Reading (LOAD FIRST)

**CRITICAL**: Before creating ANY diagrams, read this guide:

  • **[Diagram Conventions Guide](.specweave/docs/internal/delivery/guides/diagram-conventions.md)**

This guide contains:

  • C4 Model levels (Context, Container, Component, Code)
  • Mermaid syntax rules (C4 diagrams start WITHOUT `mermaid` keyword!)
  • Diagram placement conventions
  • Validation requirements (MUST verify rendering)
  • SVG generation for production

**Load this guide using the Read tool BEFORE creating diagrams.**

---

Core Responsibilities

1. **Detect** diagram type from user requests 2. **Load context** from specs and architecture docs when available 3. **Create C4 architecture diagrams** (Context, Container, Component, Code) 4. **Generate sequence diagrams** from API flows and use cases 5. **Design ER diagrams** from data models 6. **Create deployment diagrams** from infrastructure docs 7. **Update diagrams** when architecture changes 8. **Validate syntax** and conventions 9. **Place diagrams in correct locations** (HLD vs LLD, architecture vs operations) 10. **Ensure diagrams render correctly** - Validate before saving

Activation Keywords

This skill activates when user mentions:

  • **General**: "create diagram", "draw diagram", "visualize", "generate diagram"
  • **C4 Model**: "C4 diagram", "context diagram", "container diagram", "component diagram"
  • **Flows**: "sequence diagram", "flow diagram", "interaction diagram"
  • **Data**: "ER diagram", "entity relationship", "data model", "database schema"
  • **Infrastructure**: "deployment diagram", "architecture diagram", "infrastructure diagram"

---

Workflow

Step 1: Detect Diagram Type

Analyze user's request to determine:

**C4 Context (Level 1)**: System boundaries, external actors

  • Keywords: "context", "system", "boundaries", "external"

**C4 Container (Level 2)**: Services, applications, databases

  • Keywords: "container", "services", "applications", "microservices"

**C4 Component (Level 3)**: Internal module structure

  • Keywords: "component", "internal", "module", "service internals"

**Sequence**: Interaction flows

  • Keywords: "sequence", "flow", "interaction", "steps", "process"

**ER Diagram**: Data models

  • Keywords: "ER", "entity", "relationship", "data model", "schema"

**Deployment**: Infrastructure

  • Keywords: "deployment", "infrastructure", "hosting", "cloud"

Step 2: Load Context (Optional)

If relevant specifications exist, load them before generating:

  • Specs from `.specweave/docs/internal/`
  • Architecture docs from `.specweave/docs/internal/architecture/`
  • Existing diagrams for reference

Step 3: Generate Diagram

Create the diagram following all syntax rules and conventions documented below.

Step 4: Save to Correct Location

  • **C4 Context/Container**: `.specweave/docs/internal/architecture/diagrams/`
  • **C4 Component**: `.specweave/docs/internal/architecture/diagrams/{module}/`
  • **Sequence**: `.specweave/docs/internal/architecture/diagrams/{module}/flows/`
  • **ER Diagram**: `.specweave/docs/internal/architecture/diagrams/{module}/data-model.mmd`
  • **Deployment**: `.specweave/docs/internal/operations/diagrams/deployment-{env}.mmd`

Step 5: Validate & Confirm

After saving, instruct the user to validate rendering (see Validation section below).

---

CRITICAL: Mermaid C4 Syntax Rules

**DO NOT include the `mermaid` keyword in C4 diagrams!**

WRONG (will not render):

mermaid
C4Context
  title System Context Diagram

CORRECT (will render):

C4Context
  title System Context Diagram

**Why**: Mermaid C4 diagrams start DIRECTLY with `C4Context`, `C4Container`, `C4Component`, or `C4Deployment`. The `mermaid` keyword is ONLY used in standard diagrams (sequence, ER, class, flowchart), NOT in C4 diagrams.

Validation Checklist (MANDATORY)

Before saving any diagram, verify:

1. **C4 diagrams**: Start with `C4Context`, `C4Container`, `C4Component`, or `C4Deployment` (NO `mermaid` keyword) 2. **Other diagrams**: Start with `mermaid` keyword (sequenceDiagram, erDiagram, classDiagram, graph) 3. **Syntax valid**: No missing quotes, parentheses, or braces 4. **Indentation correct**: 2 spaces per level 5. **File location correct**: HLD in `architecture/diagrams/`, LLD in `architecture/diagrams/{module}/`

Rendering Test (MANDATORY)

After creating a diagram, instruct the user to:

1. Open the `.mmd` file in VS Code 2. Enable Mermaid Preview extension (if not already installed) 3. Verify diagram renders correctly 4. Report any syntax errors immediately

**If diagram does not render**, FIX IT before marking task as complete.

---

C4 Model Mapping to SpecWeave

Overview

SpecWeave adopts the **C4 Model** (Context, Container, Component, Code) for architecture diagrams.

| C4 Level | SpecWeave Equivalent | Status | Purpose | Location | |----------|----------------------|--------|---------|----------| | **C4-1: Context** | HLD Context Diagram | Defined | System boundaries, external actors | `.specweave/docs/internal/architecture/diagrams/` | | **C4-2: Container** | HLD Component Diagram | Defined | Applications, services, data stores | `.specweave/docs/internal/architecture/diagrams/` | | **C4-3: Component** | LLD Component Diagram |

Read more
Ships withspecweave

Spec-first AI development: describe a feature → AI creates spec + plan + tasks, builds autonomously, syncs to GitHub/JIRA. Domain-expert skills for PM, Architect, Frontend, QA learn your patterns permanently. Claude Code, Codex, Cursor, Copilot & more.

Get the whole plugin