AgentSkillsCN

drawio-diagram-forge

根据文本、图像或Excel文件,生成可编辑的draw.io图表(.drawio、.drawio.svg)。通过质量关口,协调三重智能体工作流(分析→声明→SVG生成)。当您需要创建架构图、流程图、序列图,或把现有图像转换为可编辑格式时,便可启用此技能。它支持Azure/AWS云图标。

SKILL.md
--- frontmatter
name: drawio-diagram-forge
description: Generate draw.io editable diagrams (.drawio, .drawio.svg) from text, images, or Excel. Orchestrates 3-agent workflow (Analysis → Manifest → SVG generation) with quality gates. Use when creating architecture diagrams, flowcharts, sequence diagrams, or converting existing images to editable format. Supports Azure/AWS cloud icons.
license: CC BY-NC-SA 4.0

Draw.io Diagram Forge

Generate draw.io editable diagrams using AI-powered orchestrated workflow.

When to Use

  • General diagram requests - "Create a diagram", "Draw me a chart", etc.
  • Creating architecture diagrams (Azure, AWS, on-premises)
  • Converting flowcharts, system diagrams from text descriptions
  • Transforming existing images/screenshots into editable draw.io format
  • Generating swimlane diagrams, sequence diagrams from Excel/Markdown

Prerequisites

ToolPurposeRequired
VS CodeIDE
Draw.io IntegrationEdit .drawio files
GitHub CopilotAI generation

Install extension: Draw.io Integration

Quick Start

Basic Usage

code
Create a login flow diagram
code
Generate an Azure architecture diagram with Hub-Spoke topology
code
Convert this Excel file to a flowchart

With Input Files

code
From inputs/requirements.md, create a system architecture diagram
code
Recreate this image (inputs/architecture.png) as an editable draw.io file

Output Formats

ExtensionDescriptionWhen to Use
*.drawioNative draw.io formatRecommended - Most stable
*.drawio.svgSVG + draw.io metadataEmbedding in Markdown/Web
*.drawio.pngPNG + draw.io metadataImage with edit capability

Output directory: outputs/

Workflow Overview

code
USER INPUT
    │
    ▼
┌─────────────────────────────────────────────────┐
│           FLOW ORCHESTRATOR                      │
│  ┌─────────────────────────────────────────┐    │
│  │ Internal Modules:                        │    │
│  │ • Analysis (input classification)        │    │
│  │ • Review (quality scoring)               │    │
│  │ • State (context management)             │    │
│  │ • Timeout (watchdog)                     │    │
│  └─────────────────────────────────────────┘    │
└─────────────────────────────────────────────────┘
    │
    ├──► MANIFEST GATEWAY (create manifest)
    │
    └──► SVG FORGE (generate diagram + validation)
    │
    ▼
COMPLETED (.drawio file)

Quality Gates

ScoreActionDescription
90-100✅ ProceedHigh quality, continue
85-89⚠️ NoteMinor issues noted
70-84🔄 FixAuto-fix and retry
50-69📉 SimplifyReduce complexity
30-49📦 PartialDeliver partial result
0-29❌ EscalateAsk user for clarification

Iteration Limits

LimitValueOn Exceed
Manifest revision2Force proceed with warning
SVG revision2Partial success
Total revisions4Partial success
Total timeout45minCheckpoint-based decision

Advanced: Agent Delegation

For complex diagrams, explicitly invoke the orchestrator:

code
@flow-orchestrator Create a detailed microservices architecture from inputs/requirements.md

This triggers the full manifest → review → generation → review cycle.

Cloud Icon Usage

When generating cloud architecture diagrams, follow this icon selection logic:

Step 1: Detect Cloud Provider

Scan input for provider-specific keywords:

ProviderKeywords
AzureAzure, Microsoft Cloud, App Service, Azure AD, VNET, AKS, Key Vault
AWSAWS, Amazon, EC2, Lambda, S3, RDS, VPC, EKS, DynamoDB
GCPGCP, Google Cloud, Cloud Run, BigQuery, GKE, Cloud Functions
AlibabaAlibaba Cloud, Aliyun, ECS (Alibaba context), OSS, MaxCompute
IBMIBM Cloud, IBM Watson, IBM OpenShift
CiscoCisco, Meraki, ACI, Nexus, ISE

Step 2: Search for Matching Icon

For each cloud service mentioned:

  1. Search the appropriate icon library for a matching icon
  2. If found: Use the provider-specific format (see below)
  3. If not found: Use a generic shape with the service name as label

Step 3: Apply Provider-Specific Format

ProviderIcon FormatLibrary Path
Azureimage=img/lib/azure2/{category}/{Icon}.svgazure2
AWSshape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.{icon}mxgraph.aws4.*
GCPshape=mxgraph.gcp2.{icon}mxgraph.gcp2.*
Alibabashape=mxgraph.alibabacloud.{icon}mxgraph.alibabacloud.*
IBMimage=img/lib/ibm/{category}/{icon}.svgibm
Ciscoshape=mxgraph.cisco19.{icon}mxgraph.cisco19.*

Step 4: Fallback for Unknown Services

If no matching icon exists:

xml
<!-- Generic rectangle with service name -->
<mxCell value="Custom Service" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#dae8fc;strokeColor=#6c8ebf;" />

⚠️ Critical: Azure Format

xml
<!-- ❌ WRONG - Will show blue square in VS Code -->
<mxCell style="shape=mxgraph.azure.front_door;..." />

<!-- ✅ CORRECT - Works everywhere -->
<mxCell style="aspect=fixed;image=img/lib/azure2/networking/Front_Doors.svg;..." />

Refer to cloud-icons.md for detailed SVG paths and style examples.

Resources

References

FileDescription
mxcell-structure.mdmxCell XML structure for draw.io
cloud-icons.mdAzure/AWS icon usage guide
style-guide.mdNode colors, edge styles

Scripts

FileDescription
validate_drawio.pyValidate mxCell structure

Cloud Icons (Azure/AWS)

To enable cloud icons in generated diagrams:

  1. Open generated .drawio file in VS Code
  2. Click "+ More Shapes" (bottom-left)
  3. Enable: ✅ Azure, ✅ AWS
  4. Click Apply

Troubleshooting

IssueCauseSolution
Blank in draw.ioMissing mxCellCheck content attribute
Edges not visibleInvalid source/targetVerify node IDs
Icons missingLibrary not enabledEnable Azure/AWS shapes

Technical Details

How It Works

AI generates XML/SVG text that renders as editable diagrams:

code
Natural Language  →  XML/mxGraphModel  →  Rendered Diagram
     ↑                    ↑                      ↑
  Human input        AI generates          SVG rendering

mxCell Completeness Rule

code
Required mxCells >= 2 + nodes + edges
  • mxCell id="0" (root)
  • mxCell id="1" (default parent)
  • One mxCell per node (vertex="1")
  • One mxCell per edge (edge="1")