Noureddine RAMDI / Swark: generating architecture diagrams from code using GitHub Copilot in VS Code

Created Sat, 23 May 2026 20:41:14 +0000 Modified Sat, 23 May 2026 20:41:27 +0000

swark-io/swark

Swark solves a common developer pain point: visualizing software architecture directly from source code without juggling multiple tools or configuration hassles. What makes it stand out is its clever use of the VS Code Language Model API to tap into GitHub Copilot’s free tier for generating Mermaid.js diagrams. This means no separate API keys, no external servers, and no language-specific parsers to maintain — the heavy lifting is offloaded to the LLM behind Copilot.

How Swark generates architecture diagrams from source code using LLMs

Swark is a Visual Studio Code extension written in TypeScript that integrates tightly with GitHub Copilot via the VS Code Language Model API. When you invoke Swark, it sends your source code files to Copilot as LLM queries. The language model returns Mermaid.js markup describing the architecture diagram based on the code it analyzed.

This design effectively delegates all parsing, language understanding, and diagram logic to the LLM, which means Swark natively supports any programming language without additional development effort. The output is Mermaid.js code, a popular text-based diagram syntax that integrates well with VS Code and other markdown tools.

Swark saves the generated diagrams and logs in a dedicated swark-output folder inside your workspace, with timestamped filenames for easy tracking. Privacy is a core consideration: your source code is only shared with GitHub Copilot, never with other third-party services. This keeps the data flow minimal and focused.

Technical strengths and design tradeoffs of Swark’s LLM-driven approach

Swark’s standout technical feature is its use of the VS Code Language Model API to piggyback on GitHub Copilot’s free tier. This approach removes the typical friction of managing API keys, authentication, or paying for LLM usage.

From a code quality standpoint, the extension is implemented in clean TypeScript, aligning with VS Code extension best practices. It handles file selection via user prompts and manages output files cleanly.

The biggest tradeoff is relying on the LLM’s interpretation of code to generate diagrams. This means accuracy and completeness depend heavily on the model’s understanding, which can vary by language and complexity. Unlike traditional parsers or static analysis tools, the results are probabilistic rather than deterministic.

Another consideration is the dependency on GitHub Copilot availability and the VS Code environment. While Copilot now offers a free tier, users must have it installed and configured. This limits standalone or non-VS Code usage.

Despite these tradeoffs, Swark’s zero-config, universal language support, and privacy-focused design make it a practical tool for developers who want quick architecture visualization without overhead.

Quick start with Swark in VS Code

Requirements

  • GitHub Copilot: Install from the Visual Studio Marketplace. Note that GitHub Copilot offers a free tier.
  • [Optional] Mermaid Markdown Preview: Install the Markdown Preview Mermaid Support extension for inline diagram previews in VS Code, or use external Mermaid Live Editor links.

Installation

Simply install Swark via the VS Code Extension Marketplace.

How to use

  1. Open the Command Palette in VS Code and run: Swark: Create Architecture Diagram.
  2. Alternatively, use the default keybindings: cmd+shift+r (Mac) or ctrl+shift+r (Windows).
  3. Select the folder you want Swark to analyze.
  4. After a few seconds, a new tab will open displaying the Mermaid.js architecture diagram.

Output files

Swark generates two files under a swark-output folder in your workspace root:

  • A Mermaid diagram file with the suffix __diagram.md containing the diagram code.
  • A log file with the suffix __log.md containing run details and configuration for debugging.

Example output structure:

workspace-root
└── swark-output
    ├── 2025-01-09__20-18-38__diagram.md
    └── 2025-01-09__20-18-38__log.md

who benefits from using Swark and its limitations

Swark is a neat fit for developers who want quick, language-agnostic architecture visualization inside VS Code without configuring parsers or external tools. Its zero-config nature and privacy-conscious approach make it appealing for teams wary of sharing code broadly.

That said, you must have GitHub Copilot installed and be comfortable with the LLM-driven approach, which means the diagrams are interpretive rather than guaranteed precise. For complex or large codebases, the output might miss some details or require manual refinement.

Also, the extension is tightly coupled to VS Code and Copilot, so it’s not a standalone tool you can run outside that environment.

Overall, Swark demonstrates a practical way to turn LLMs into interactive developer tools by piggybacking on existing APIs and free tiers. For many teams, it can speed up understanding and documenting code architecture with minimal setup and no extra cost.


→ GitHub Repo: swark-io/swark ⭐ 1,678 · TypeScript