Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>DIAGRAM-X-RAYNew to Visual Studio Code? Get it now.
DIAGRAM-X-RAY

DIAGRAM-X-RAY

Shunsuke F

|
2 installs
| (0) | Free
AI-agent-ready Mermaid and SVG linter with bounded deterministic repairs for VS Code, MCP, and CLI.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

DIAGRAM-X-RAY

Visual Studio Marketplace Version Visual Studio Marketplace Installs License

Japanese version

Linter, validator, and MCP scanner for AI-generated Mermaid and SVG diagrams.

Stop discovering diagram defects only after rendering or review. DIAGRAM-X-RAY checks Mermaid syntax risks, node identities, flow direction, SVG text boundaries, and label collisions, then exposes deterministic findings through VS Code, CLI, and MCP.

Why use DIAGRAM-X-RAY?

AI agents can return diagram source that looks valid while hiding unquoted User / Admin labels, duplicated node IDs, fabricated arrows, dense LR flows, SVG labels outside the viewBox, or overlapping text. These defects can delay a document review even when generation completed successfully.

DIAGRAM-X-RAY closes the generation-and-verification loop:

AI agent generates or edits Mermaid or SVG
                  |
                  v
DIAGRAM-X-RAY scan -> Problems and structured findings
                  |
                  v
AI agent applies a bounded repair or regenerates the source
                  |
                  v
DIAGRAM-X-RAY rescan -> resolved, remaining, or regressed findings

Built for AI agents and developers

  • VS Code diagnostics: Scan an active diagram or workspace and review exact findings in Problems.
  • Structured MCP results: Compatible VS Code AI clients receive stable IDs, locations, evidence, and rule-specific findings through the bundled local stdio MCP server.
  • CLI and CI/CD checks: Save JSON scans and compare before-and-after reports in automated workflows.
  • Bounded correction: Quote affected Mermaid labels and normalize supported arrows or declarations. Mermaid ID references and SVG geometry require human review or source regeneration.
  • Local deterministic analysis: Mermaid and SVG sources are scanned without a browser renderer or external upload.

Quick start

  1. Open VS Code.
  2. Press Ctrl+P on Windows or Linux, or Cmd+P on macOS.
  3. Run:
ext install ShunsukeF.diagram-xray
  1. Open a Mermaid or SVG source file.
  2. Run DIAGRAM-X-RAY: Scan Active Diagram from the Command Palette.
  3. Review findings in Problems. For repairable Mermaid or Markdown sources, run DIAGRAM-X-RAY: Apply Bounded Repairs, then rescan.

AI-agent workflow

Tell Copilot in agent mode:

Generate the architecture diagram, run diagramx_scan, apply only DIAGRAM-X-RAY bounded repairs, rescan, and report findings that require human review.

The extension contributes the following VS Code commands:

  • DIAGRAM-X-RAY: Scan Active Diagram
  • DIAGRAM-X-RAY: Scan Workspace
  • DIAGRAM-X-RAY: Apply Bounded Repairs
  • DIAGRAM-X-RAY: Copy AI Report
  • DIAGRAM-X-RAY: Save AI Report

diagramXray.autoScanOnSave is enabled by default.

Rules

Rule Severity Detects Bounded repair
DIAG-001 Error Mermaid labels that require quoting Quote only the affected label
DIAG-002 Warning Repeated node IDs in one diagram Human review; ID references are not guessed
DIAG-003 Warning Dense LR flowcharts that are likely to overflow Human review
DIAG-004 Error / Info Fabricated arrows and legacy graph declarations Normalize supported arrows and the declaration
DIAG-005 Error SVG text estimated to cross the viewBox Human review or source regeneration
DIAG-006 Warning SVG labels with overlapping estimated bounds Human review or source regeneration

MCP integration

Installing the extension registers a local stdio MCP server with compatible VS Code clients. The server exposes:

  • diagramx_scan
  • diagramx_repair
  • diagramx_scan_workspace
  • diagramx_diff_scans

Standalone MCP clients can launch the bundled server documented by the extension. Use diagramx_repair only on Mermaid or Markdown sources; SVG layout findings require source-side correction.

CLI

From a built repository checkout:

node dist/cli.cjs scan .\architecture.mmd
node dist/cli.cjs repair .\architecture.mmd
node dist/cli.cjs scan .\diagram.svg --json report.json --fail-on-error
node dist/cli.cjs diff .\before.json .\after.json --fail-on-regressed

Typical use cases

  • Validate AI-generated Mermaid before embedding it in architecture or operations documents.
  • Detect repeated IDs and risky node labels before rendering a complex flowchart.
  • Check generated SVG text bounds and label collisions without opening a browser renderer.
  • Let an MCP-capable agent apply a bounded source repair and verify the result with a rescan.
  • Gate generated diagrams before merge or document delivery.

Safety and limitations

  • Scanning does not upload diagram source or use a browser renderer.
  • Mermaid repairs are limited to conclusive label quoting and supported arrow or declaration normalization.
  • DIAGRAM-X-RAY does not invent node IDs, redirect relationships, or rewrite SVG coordinates.
  • SVG text bounds are estimates from stored geometry and font assumptions; use the final renderer for pixel-exact verification.

Part of AI-IN-THE-LOOP PACK

AI-IN-THE-LOOP PACK provides deterministic checks for AI-generated non-code artifacts.

Report bugs and request features in GitHub Issues.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft