Architecture Diagram
Generate an architecture diagram based on the current conversation context and/or codebase. The
selected --format controls the returned diagram representation; browser review
packaging is a separate operation handled by diagram-review-viewer when requested.
Workflow
1. Parse Arguments
Extract:
[description] — Optional free-text scope for the diagram. If omitted, diagram whatever was just discussed or the current project.
--type TYPE — Diagram type (default: component). Free-form; interpret as the user intends. Common values: component, sequence, class, deployment, flowchart, er, state, c4, data-flow, dependency.
--format FORMAT — Output format (default: ascii). Options: ascii, mermaid, plantuml, d2, dot, or any other format the user requests.
--deep-review — Perform a holistic architecture review before diagramming.
--output FILE — File path to write the diagram source to.
2. Gather Context
Standard mode (no --deep-review):
- Use the current conversation context — what was just discussed, code shown, decisions made.
- If a description is provided, use it to scope the diagram.
- If conversation context is insufficient, read key project files:
- Project manifest (
Cargo.toml, pyproject.toml, package.json).
- Source directory structure.
- Entry points (
main.rs, lib.rs, index.ts, etc.).
Deep review mode (--deep-review):
- Perform a systematic architecture review:
- Read project manifest and dependency graph.
- Enumerate modules/packages and their public APIs.
- Trace key data flows and control flows.
- Identify system boundaries (APIs, databases, external services).
- Identify coupling points, shared state, and cross-cutting concerns.
- Note architectural patterns in use (layered, hexagonal, event-driven, etc.).
- Produce a brief architecture review summary (10-20 bullet points).
- Generate a comprehensive diagram with annotations for coupling hotspots.
3. Generate Diagram
ASCII (default — --format ascii or no --format):
Output a box-and-arrow diagram using Unicode box-drawing characters in a fenced code block:
┌──────────────┐ ┌──────────────┐
│ Component A │────>│ Component B │
└──────────────┘ └──────┬───────┘
│
v
┌──────────────┐
│ Component C │
└──────────────┘
Use ─, │, ┌, ┐, └, ┘, ├, ┤, ┬, ┴, ┼ for structure.
Use ──>, <──, <─> for directed edges. Use ···> or - -> for async/optional.
Group related components with bounding boxes. Label edges inline.
Aim for max ~120 characters wide for terminal display.
Mermaid (--format mermaid):
```mermaid
graph TD
A[Component A] --> B[Component B]
```
Review-oriented Mermaid protocol
For component, dependency, ecosystem, capability, or composition diagrams intended for architectural review, make the diagram explain both structure and judgment. Apply this protocol unless the user requests another visual system. Do not force these semantics onto sequence, class, ER, or state diagrams when they would not carry useful meaning.
- Use a white canvas and white component boxes. Keep group or subgraph backgrounds white or nearly white.
- Encode importance with border weight: major or orchestration components use a thick border; minor or specialized components use a thin border.
- Encode disposition with border color while keeping the box fill white:
- Blue or neutral dark border: established component with no special disposition.
- Green border: missing, proposed, or future component.
- Orange border: existing component that needs improvement.
- Red border: redundant, deprecated, or consolidation/removal candidate.
- Do not rely on color alone. Label proposed components and consolidation candidates explicitly, and include a legend whenever any disposition or importance styling is used.
- Use solid arrows for established, currently supported relationships. Use dashed arrows for proposed, weakly defined, indirect, or untyped relationships, and explain that convention in the legend.
- For non-obvious relationships, especially where the task asks about composition gaps, interpose a concise explanatory note between the connected boxes instead of relying on a terse edge label. Give note boxes a pale-yellow fill, black border, and black text. Each note should state what currently flows or composes across the relationship and what contract, artifact, authority, adapter, or verification is missing.
- Keep factual and evaluative claims distinct. Never render a proposed or inferred component as existing; mark it as missing or future. Treat redundancy and improvement classifications as review judgments, not repository facts.
- When detailed relationship notes make one canvas unreadable, preserve the overview and split dense areas into focused companion diagrams rather than shrinking text below practical reading size.
For example, a Mermaid component diagram may use class definitions equivalent to:
classDef major fill:#ffffff,stroke:#1d4ed8,stroke-width:4px,color:#000000,font-weight:bold;
classDef minor fill:#ffffff,stroke:#64748b,stroke-width:1.5px,color:#000000;
classDef missing fill:#ffffff,stroke:#16a34a,stroke-width:3px,color:#14532d,font-weight:bold;
classDef improve fill:#ffffff,stroke:#f97316,stroke-width:3px,color:#7c2d12;
classDef redundant fill:#ffffff,stroke:#dc2626,stroke-width:3px,color:#7f1d1d,font-weight:bold;
classDef relationship fill:#fef3c7,stroke:#111827,stroke-width:1.5px,color:#000000;
PlantUML (--format plantuml):
```plantuml
@startuml
[Component A] --> [Component B]
@enduml
```
D2 (--format d2):
```d2
Component A -> Component B
```
DOT/Graphviz (--format dot):
```dot
digraph {
"Component A" -> "Component B"
}
```
If the user requests a format not listed, interpret and produce the closest reasonable output.
Do not silently switch to Mermaid or an HTML viewer because that format is
convenient. Preserve the user's selected format, and ask only when the choice
materially affects the deliverable.
If --output FILE is specified, write the selected diagram representation to
that file and confirm. Invoke diagram-review-viewer separately only when the
user asks for a browser-review package; that package retains the readable
Mermaid source and its digest.
Type Interpretation
The --type is free-form. Use best judgment:
| User says |
Diagram style |
| component |
Boxes and arrows showing system components |
| sequence |
Interactions between actors/components over time |
| class |
Types, structs, traits and their relationships |
| deployment |
Infrastructure nodes, services, networks |
| flowchart |
Decision/process flow |
| er |
Entity relationships (tables, fields, relations) |
| state |
State machine transitions |
| c4 |
C4 model (context, container, component) |
| data-flow |
Data pipeline / transformation focus |
| dependency |
Module/crate/package dependency DAG |
Examples
# Default: ASCII component diagram of what was just discussed
/archdiagram
# ASCII sequence diagram of the auth flow
/archdiagram auth flow --type sequence
# Mermaid class diagram
/archdiagram data model --type class --format mermaid
# Deep review, ASCII output
/archdiagram --deep-review
# Deep review as Mermaid, written to file
/archdiagram --deep-review --format mermaid --output docs/architecture.mmd
# PlantUML deployment diagram
/archdiagram production setup --type deployment --format plantuml
Guardrails
- Prefer clarity over exhaustiveness. A readable diagram beats a complete one.
- Group related components visually where it aids understanding.
- Use meaningful labels, not file paths (e.g., "gRPC API" not "src/api/grpc.rs").
- For deep review, the written summary should be concise (10-20 bullet points max).
- Distinguish data flow from control flow when both are present (solid vs dashed lines).
- For review-oriented Mermaid component diagrams, follow the visual and relationship-annotation protocol above.
- If the system is too large for one diagram, state that and offer to break it into focused sub-diagrams.
- Do not fabricate components that do not exist in the codebase or discussion.
1---2name: archdiagram3description: Generate an architecture diagram from the current context or codebase. Use when the user asks for an architecture diagram, system diagram, component diagram, or says /archdiagram. Supports --type for different diagram kinds, --format for output format (ascii default, mermaid, plantuml, d2, dot), and --deep-review for holistic architecture analysis.4---56# Architecture Diagram78Generate an architecture diagram based on the current conversation context and/or codebase. The9selected `--format` controls the returned diagram representation; browser review10packaging is a separate operation handled by `diagram-review-viewer` when requested.1112## Workflow1314### 1. Parse Arguments1516Extract:17- `[description]` — Optional free-text scope for the diagram. If omitted, diagram whatever was just discussed or the current project.18- `--type TYPE` — Diagram type (default: component). Free-form; interpret as the user intends. Common values: component, sequence, class, deployment, flowchart, er, state, c4, data-flow, dependency.19- `--format FORMAT` — Output format (default: ascii). Options: ascii, mermaid, plantuml, d2, dot, or any other format the user requests.20- `--deep-review` — Perform a holistic architecture review before diagramming.21- `--output FILE` — File path to write the diagram source to.2223### 2. Gather Context2425**Standard mode (no --deep-review):**26271. Use the current conversation context — what was just discussed, code shown, decisions made.282. If a description is provided, use it to scope the diagram.293. If conversation context is insufficient, read key project files:30 - Project manifest (`Cargo.toml`, `pyproject.toml`, `package.json`).31 - Source directory structure.32 - Entry points (`main.rs`, `lib.rs`, `index.ts`, etc.).3334**Deep review mode (--deep-review):**35361. Perform a systematic architecture review:37 - Read project manifest and dependency graph.38 - Enumerate modules/packages and their public APIs.39 - Trace key data flows and control flows.40 - Identify system boundaries (APIs, databases, external services).41 - Identify coupling points, shared state, and cross-cutting concerns.42 - Note architectural patterns in use (layered, hexagonal, event-driven, etc.).432. Produce a brief architecture review summary (10-20 bullet points).443. Generate a comprehensive diagram with annotations for coupling hotspots.4546### 3. Generate Diagram4748**ASCII (default — `--format ascii` or no --format):**4950Output a box-and-arrow diagram using Unicode box-drawing characters in a fenced code block:5152```53┌──────────────┐ ┌──────────────┐54│ Component A │────>│ Component B │55└──────────────┘ └──────┬───────┘56 │57 v58 ┌──────────────┐59 │ Component C │60 └──────────────┘61```6263Use `─`, `│`, `┌`, `┐`, `└`, `┘`, `├`, `┤`, `┬`, `┴`, `┼` for structure.64Use `──>`, `<──`, `<─>` for directed edges. Use `···>` or `- ->` for async/optional.65Group related components with bounding boxes. Label edges inline.66Aim for max ~120 characters wide for terminal display.6768**Mermaid (`--format mermaid`):**6970````71```mermaid72graph TD73 A[Component A] --> B[Component B]74```75````7677### Review-oriented Mermaid protocol7879For component, dependency, ecosystem, capability, or composition diagrams intended for architectural review, make the diagram explain both structure and judgment. Apply this protocol unless the user requests another visual system. Do not force these semantics onto sequence, class, ER, or state diagrams when they would not carry useful meaning.8081- Use a white canvas and white component boxes. Keep group or subgraph backgrounds white or nearly white.82- Encode importance with border weight: major or orchestration components use a thick border; minor or specialized components use a thin border.83- Encode disposition with border color while keeping the box fill white:84 - Blue or neutral dark border: established component with no special disposition.85 - Green border: missing, proposed, or future component.86 - Orange border: existing component that needs improvement.87 - Red border: redundant, deprecated, or consolidation/removal candidate.88- Do not rely on color alone. Label proposed components and consolidation candidates explicitly, and include a legend whenever any disposition or importance styling is used.89- Use solid arrows for established, currently supported relationships. Use dashed arrows for proposed, weakly defined, indirect, or untyped relationships, and explain that convention in the legend.90- For non-obvious relationships, especially where the task asks about composition gaps, interpose a concise explanatory note between the connected boxes instead of relying on a terse edge label. Give note boxes a pale-yellow fill, black border, and black text. Each note should state what currently flows or composes across the relationship and what contract, artifact, authority, adapter, or verification is missing.91- Keep factual and evaluative claims distinct. Never render a proposed or inferred component as existing; mark it as missing or future. Treat redundancy and improvement classifications as review judgments, not repository facts.92- When detailed relationship notes make one canvas unreadable, preserve the overview and split dense areas into focused companion diagrams rather than shrinking text below practical reading size.9394For example, a Mermaid component diagram may use class definitions equivalent to:9596```97classDef major fill:#ffffff,stroke:#1d4ed8,stroke-width:4px,color:#000000,font-weight:bold;98classDef minor fill:#ffffff,stroke:#64748b,stroke-width:1.5px,color:#000000;99classDef missing fill:#ffffff,stroke:#16a34a,stroke-width:3px,color:#14532d,font-weight:bold;100classDef improve fill:#ffffff,stroke:#f97316,stroke-width:3px,color:#7c2d12;101classDef redundant fill:#ffffff,stroke:#dc2626,stroke-width:3px,color:#7f1d1d,font-weight:bold;102classDef relationship fill:#fef3c7,stroke:#111827,stroke-width:1.5px,color:#000000;103```104105**PlantUML (`--format plantuml`):**106107````108```plantuml109@startuml110[Component A] --> [Component B]111@enduml112```113````114115**D2 (`--format d2`):**116117````118```d2119Component A -> Component B120```121````122123**DOT/Graphviz (`--format dot`):**124125````126```dot127digraph {128 "Component A" -> "Component B"129}130```131````132133If the user requests a format not listed, interpret and produce the closest reasonable output.134Do not silently switch to Mermaid or an HTML viewer because that format is135convenient. Preserve the user's selected format, and ask only when the choice136materially affects the deliverable.137138If `--output FILE` is specified, write the selected diagram representation to139that file and confirm. Invoke `diagram-review-viewer` separately only when the140user asks for a browser-review package; that package retains the readable141Mermaid source and its digest.142143## Type Interpretation144145The `--type` is free-form. Use best judgment:146147| User says | Diagram style |148|-----------|--------------|149| component | Boxes and arrows showing system components |150| sequence | Interactions between actors/components over time |151| class | Types, structs, traits and their relationships |152| deployment | Infrastructure nodes, services, networks |153| flowchart | Decision/process flow |154| er | Entity relationships (tables, fields, relations) |155| state | State machine transitions |156| c4 | C4 model (context, container, component) |157| data-flow | Data pipeline / transformation focus |158| dependency | Module/crate/package dependency DAG |159160## Examples161162```bash163# Default: ASCII component diagram of what was just discussed164/archdiagram165166# ASCII sequence diagram of the auth flow167/archdiagram auth flow --type sequence168169# Mermaid class diagram170/archdiagram data model --type class --format mermaid171172# Deep review, ASCII output173/archdiagram --deep-review174175# Deep review as Mermaid, written to file176/archdiagram --deep-review --format mermaid --output docs/architecture.mmd177178# PlantUML deployment diagram179/archdiagram production setup --type deployment --format plantuml180```181182## Guardrails183184- Prefer clarity over exhaustiveness. A readable diagram beats a complete one.185- Group related components visually where it aids understanding.186- Use meaningful labels, not file paths (e.g., "gRPC API" not "src/api/grpc.rs").187- For deep review, the written summary should be concise (10-20 bullet points max).188- Distinguish data flow from control flow when both are present (solid vs dashed lines).189- For review-oriented Mermaid component diagrams, follow the visual and relationship-annotation protocol above.190- If the system is too large for one diagram, state that and offer to break it into focused sub-diagrams.191- Do not fabricate components that do not exist in the codebase or discussion.