AgentSkillsCN

architecture-diagram

使用 drawio MCP 工具创建专业的架构图。当 Claude 需要绘制软件架构图、系统图、流程图、序列图,或数据流图时使用。可通过诸如“draw architecture”、“create diagram”、“visualize system”、“flowchart”、“sequence diagram”等请求触发。

SKILL.md
--- frontmatter
name: architecture-diagram
description: Create professional architecture diagrams using drawio MCP tools. Use when Claude needs to create software architecture diagrams, system diagrams, flowcharts, sequence diagrams, or data flow diagrams. Triggers on requests like "draw architecture", "create diagram", "visualize system", "flowchart", "sequence diagram".

Architecture Diagram Skill

Create clear, professional architecture diagrams using drawio tools.

Workflow

Creating a new diagram:

  1. Call start_session to open browser preview
  2. Analyze requirements → identify diagram type and components
  3. Plan layout → sketch component placement mentally
  4. Call create_new_diagram with complete mxGraphModel XML

Modifying existing diagram:

  1. Call get_diagram to fetch current state
  2. Call edit_diagram with add/update/delete operations

Exporting:

  • Call export_diagram with path to save .drawio file

Design Principles

Layout Rules

  • Flow direction: Left→Right (data/process flow) or Top→Bottom (hierarchy)
  • Viewport: Keep within x=40-760, y=40-560 (800x600 canvas with margins)
  • Spacing: 150-200px between components for clear edge routing
  • Grouping: Related components should be visually clustered
  • Alignment: Align components on grid (multiples of 20px)

Visual Hierarchy

  • Entry points (users, external triggers): Left or top edge
  • Core services: Center area
  • Data stores: Bottom or right edge
  • External services: Right edge or separate zone

Color Palette (Light Theme)

Component TypeFillStrokeUsage
Primary/Core#E8F4FD#5B9BD5Main services, core modules
Secondary#F0F9FF#7FB3E0Supporting services
Entry/User#FFF4E6#FF8C42Users, API gateway, triggers
Database/Storage#E8F5E9#66BB6ADB, cache, file storage
External Service#F3E5F5#AB47BC3rd party APIs, cloud services
Queue/Message#FFF8E1#FFB300MQ, event bus, streams
Container/Group#FAFAFA#BDBDBDGrouping boxes, swimlanes

Text color: #333333 (dark gray for readability)

Shape Styles

code
# Core shapes
rounded=1;whiteSpace=wrap;fillColor=#E8F4FD;strokeColor=#5B9BD5;

# Database (cylinder)
shape=cylinder3;whiteSpace=wrap;boundedLbl=1;fillColor=#E8F5E9;strokeColor=#66BB6A;

# User/Actor
shape=umlActor;fillColor=#FFF4E6;strokeColor=#FF8C42;

# Cloud/External
ellipse;shape=cloud;whiteSpace=wrap;fillColor=#F3E5F5;strokeColor=#AB47BC;

# Queue
shape=parallelogram;whiteSpace=wrap;fillColor=#FFF8E1;strokeColor=#FFB300;

# Group container
rounded=1;whiteSpace=wrap;fillColor=#FAFAFA;strokeColor=#BDBDBD;dashed=1;

Edge Styles

code
# Standard arrow
edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;endArrow=classic;strokeColor=#5B9BD5;

# Dashed (optional/async)
edgeStyle=orthogonalEdgeStyle;rounded=1;dashed=1;endArrow=classic;strokeColor=#999999;

# Bidirectional
edgeStyle=orthogonalEdgeStyle;rounded=1;endArrow=classic;startArrow=classic;strokeColor=#5B9BD5;

Edge Routing Rules

  • Specify exitX, exitY, entryX, entryY explicitly
  • Use different Y values for multiple edges between same nodes
  • Bidirectional: use opposite sides (exitX=1 → entryX=0)
  • Add 20-30px clearance around obstacles

Diagram Types

1. System Architecture

2. Flowchart

3. Sequence Diagram

4. Data Flow Diagram

XML Structure

xml
<mxGraphModel>
  <root>
    <mxCell id="0"/>
    <mxCell id="1" parent="0"/>
    <!-- Components start from id="2" -->
    <mxCell id="2" value="Label" style="..." vertex="1" parent="1">
      <mxGeometry x="100" y="100" width="120" height="60" as="geometry"/>
    </mxCell>
    <!-- Edges reference source/target by id -->
    <mxCell id="edge-1" style="..." edge="1" parent="1" source="2" target="3">
      <mxGeometry relative="1" as="geometry"/>
    </mxCell>
  </root>
</mxGraphModel>

Quick Reference

Standard component size: 120x60 (services), 80x80 (databases), 40x80 (actors)

Common mistakes to avoid:

  • Edges overlapping → use different exitY/entryY
  • Cramped layout → increase spacing to 200px
  • Missing labels → always set value attribute
  • Wrong parent → top-level shapes use parent="1"

For complete patterns and examples, see references/patterns.md.