| Auto-generated examples | `auth-flow.drawio`, `system-architecture.drawio`, `user-service-class-diagram.drawio`, `order-process-swimlane.drawio`, `aws-vpc-topology.drawio` |
Resources
3Install
npx skillscat add yincma/architecture Install via the SkillsCat registry.
Architecture Diagram Skill
1. Overview & Activation
Purpose
This Skill gives AI agents professional draw.io diagram generation, modification, validation, and optional export capabilities. Once activated, the AI agent can:
- Generate uncompressed plain-text
.drawiofiles from natural language descriptions - Read and modify existing
.drawiofiles while preserving unchanged content - Produce cleaner diagrams by planning layout before writing XML
- Use listed draw.io cloud stencil styles for AWS, Azure, GCP, and generic architecture diagrams, with safe fallback when an icon is unlisted
- Produce architecture comparison diagrams and benchmark reports when explicitly requested
- Export generated diagrams to PNG, SVG, or PDF when a compatible draw.io CLI is available
Activation
Activate this Skill when a user requests generation, modification, comparison, validation, or export of draw.io diagrams:
discloseContext("architecture")Supported Diagram Types
This Skill supports flowcharts, architecture diagrams, UML class diagrams, UML sequence diagrams, UML state diagrams, ER diagrams, network topology diagrams, mind maps, organization charts, and swimlane diagrams.
Tool Usage
| Operation | Tool | Description |
|---|---|---|
| Read existing diagram | readFile or filesystem read |
Read complete XML content of a .drawio file |
| Write new or updated diagram | fsWrite or filesystem write |
Write complete validated XML |
| Precise one-off replacement | strReplace |
Use only when the target XML fragment is unique and the change is local |
| Check file existence | fileSearch / listDirectory / filesystem check |
Avoid accidental overwrite |
| Validate generated output | python tools/validate_drawio.py <file.drawio> |
Validate XML structure and draw.io compatibility |
| Export optional formats | draw.io Desktop CLI, when available | Export .drawio to .drawio.png, .drawio.svg, or .drawio.pdf |
2. Progressive References
Keep this file loaded as the workflow controller. Read reference files only when needed.
| Need | Read |
|---|---|
| XML structure, mxCell rules, escaping, dark mode, compliance checklist | references/xml-spec.md |
| Shape styles, edge styles, color schemes, text wrapping | references/styles.md |
| Layout-first planning, readability checks, audience modes | references/layout-quality.md |
| Containers, grouping, child coordinates, edge routing, spacing | references/containers-layout.md |
| Diagram type selection and template index | references/templates/index.md |
| Specific XML examples | One file under references/templates/, such as architecture.md or uml-sequence.md |
| Cloud icon rules and provider index | references/cloud-icons/index.md |
| AWS icon rules and identifiers | references/cloud-icons/aws.md |
| Azure icon rules and identifiers | references/cloud-icons/azure.md |
| GCP icon rules and identifiers | references/cloud-icons/gcp.md |
| Export to PNG/SVG/PDF | references/export.md |
| Multi-option architecture comparisons and benchmark reports | references/architecture-benchmark.md |
Reference Loading Rules
- Always read
references/xml-spec.md,references/styles.md, andreferences/layout-quality.mdbefore generating or modifying XML. - Read only the template file for the requested diagram type. Do not load every template by default.
- For cloud diagrams, read
references/cloud-icons/index.mdand only the provider file that is needed. - Never guess cloud icon shape names. If an exact icon is not listed, use a generic rounded rectangle or cloud/service shape with the service name.
- For diagrams with nested groups, networks, swimlanes, cloud boundaries, or many edges, read
references/containers-layout.md.
3. Core Principles
Layout First, XML Second
Do not generate XML directly from the user's natural language request. First create an internal layout plan, then generate XML from the plan.
The internal layout plan must include:
- Diagram intent — diagram type, target audience, reading direction, and output format.
- Canvas plan — page size, background, title area, legend area, and main drawing area.
- Container hierarchy — parent ID for each container and node.
- Node table — id, label, semantic role, parent, x, y, width, height, style category, and whether it is a container.
- Edge table — id, source, target, label, flow type, line style, exit/entry points, and waypoints when needed.
- Quality pass — overlap check, spacing check, edge crossing check, label readability check, and export-readiness check.
Generate XML only after the internal layout plan is consistent.
Ask Only When It Changes the Diagram
If the request is underspecified, ask only for missing decisions that materially change the diagram, such as diagram type, required elements, or key relationships. Otherwise, make reasonable assumptions and state them briefly in the final response.
Audience-Aware Output
- For technical audiences, use precise service names, protocol labels, and detailed component boundaries.
- For executives or non-technical audiences, use shorter labels, numbered flows, fewer implementation details, and a legend.
- For mixed audiences, keep the diagram clean and provide technical detail in labels only where it helps understanding.
4. Workflows
Create New Diagram
- Parse the user's intent: diagram type, nodes/entities, relationships, direction, layout preference, audience, target filename, and whether cloud icons or export formats are required.
- Read the required references from Section 2.
- Create the internal layout plan described in Section 3.
- Run the visual quality self-check from Section 6 before writing XML.
- Generate a complete uncompressed
.drawioXML document using semantic shapes, consistent colors for same-type elements, orthogonal edges by default, grid-aligned top-level coordinates, and labels in the user's input language. - If no filename is provided, generate an English kebab-case
.drawiofilename such asauth-flow.drawioorsystem-architecture.drawio. - Before writing, check whether the target file exists. If it exists and the user did not explicitly request overwrite, choose a non-conflicting filename such as
system-architecture-v2.drawiounless the working environment requires explicit confirmation. - Write the file, then run the validation workflow in Section 7.
- If the user requested PNG, SVG, or PDF, follow
references/export.mdafter the.drawiofile validates.
Modify Existing Diagram
- Read the full existing
.drawiofile and parse its XML structure: vertices, edges, parents, containers, IDs, styles, geometry, and waypoints. - Identify the requested add/delete/update/layout changes.
- Preserve all unmodified IDs, values, styles, geometry, routes, waypoints, and container hierarchy.
- If the change affects layout, create an internal update plan that includes before/after positions and affected edges.
- Prefer parsing and writing the complete XML back. Use
strReplaceonly for a single, unique XML fragment where a partial replacement is safer and easier to audit. - When deleting a node, also remove edges whose
sourceortargetpoints to it. - Write back to the original file unless the user supplied a new path. For a new target path, apply the same overwrite rule as creation.
- Run the validation workflow in Section 7.
- If the user requested export formats, follow
references/export.md.
Architecture Comparison
Use the benchmark workflow only when the user explicitly asks to compare architecture approaches, benchmark options, evaluate trade-offs, or choose between multiple solution designs. Read references/architecture-benchmark.md, generate one .drawio file per option, and create the companion Markdown benchmark report.
Export Existing or Newly Generated Diagram
Use references/export.md when the user asks for PNG, SVG, PDF, or another rendered format. Always validate the .drawio file first. If a compatible draw.io CLI is unavailable, provide the .drawio file and clearly state that rendered export was not performed.
5. Required XML Self-Check
Before outputting or writing any .drawio XML, verify all of these requirements:
- Root element is
<mxfile>. <root>contains<mxCell id="0"/>and<mxCell id="1" parent="0"/>.- All
mxCell,object, andUserObjectIDs are unique within the same diagram. - Every
edge="1"mxCell contains<mxGeometry relative="1" as="geometry"/>. - No mxCell has both
vertex="1"andedge="1". - Generated XML contains no XML comments.
- Special characters in text attributes are escaped:
&,<,>,". - Top-level and ordinary vertex
xandycoordinates align to multiples of 10. Exception: internal rows inside UML/ER table-like containers, sequence activation boxes, lifeline markers, and other semantic micro-layout elements may use non-10px values when needed for precise visual alignment. mxGraphModelincludesadaptiveColors="auto".- Vertex mxCells with non-empty text include
whiteSpace=wrapin their style unless the shape is a tiny marker that intentionally has no text wrapping. - mxCells acting as parent containers include
container=1. - Child elements inside containers use coordinates relative to the parent container's top-left corner.
- Cloud icon styles use listed provider references only; unlisted services fall back to generic shapes rather than invented
mxgraph.*names.
6. Diagram Quality Self-Check
Before writing XML, verify the diagram's visual quality:
- The diagram has a clear reading direction: left-to-right, top-to-bottom, radial, swimlane, or layered.
- Related components are grouped into containers, zones, layers, swimlanes, or cloud boundaries.
- No two sibling vertices overlap.
- Sibling vertices keep at least 60px spacing, except for table rows or compact UML/ER internals.
- Major edges mostly follow the main reading direction.
- Edge crossings are minimized; use waypoints when needed.
- Edges entering the same node use distributed entry points.
- Important flows have labels; trivial edges may omit labels.
- The diagram includes a title unless the user requested otherwise or the filename/context makes it redundant.
- Architecture diagrams include a legend when colors, line styles, numbered flows, or trust boundaries carry meaning.
- Cloud diagrams use listed or externally verified icon references when available.
- External actors/systems are visually distinct from internal components.
- Async, sync, data, and control flows use distinguishable line styles when multiple flow types are present.
- Long labels are shortened, wrapped, or moved into a companion guide.
- The output fits the declared page size and remains readable after PNG/SVG/PDF export.
7. Post-Generation Validation
After creating or modifying a diagram, validate the file from the repository root when this Skill package's Python validator is available:
python tools/validate_drawio.py <file.drawio>If validation reports errors, fix the XML and rerun validation before presenting the result. If no automated validator is available, perform the Section 5 and Section 6 self-checks manually and clearly state that automated validation was unavailable.
8. File Naming
| Rule | Description |
|---|---|
| Native format | {descriptive-name}.drawio |
| Exported PNG | {descriptive-name}.drawio.png |
| Exported SVG | {descriptive-name}.drawio.svg |
| Exported PDF | {descriptive-name}.drawio.pdf |
| Naming style | English kebab-case |
| User-specified name | Use exactly as requested, adding .drawio only when appropriate |
| Auto-generated examples | auth-flow.drawio, system-architecture.drawio, user-service-class-diagram.drawio, order-process-swimlane.drawio, aws-vpc-topology.drawio |