AI-Assisted Software Architecture: Generating the C4 Model and Views Directly from Code

AI-powered C4 model and views: Analyze any codebase with Claude Code, generate a Structurizr-DSL based architecture model, and create architecture diagrams in minutes instead of hours.

AI-Assisted Software Architecture: Generating the C4 Model and Views Directly from Code
AI-Assisted Software Architecture: Generating the C4 Model and Views Directly from Code

Let me start with a short story.

Yesterday, a colleague showed me an app he had mostly vibe-coded. The product itself was interesting, but after the demo he said something that caught my attention:

“Let me show you the architecture.”

His instinct was to jump straight into the codebase and start navigating files and folders. Instead, I suggested a different approach.

Instead of browsing code, why don’t we model the architecture first?

Skipping Code Browsing, Starting with Architecture

The idea was simple: instead of mentally reverse-engineering the architecture from code, we create a C4-based architecture model using the Structurizr DSL that provides all the relevant views at once.

With the help of Claude Code, we were able to:

  • analyze the codebase quickly,
  • generate a Structurizr DSL model,
  • and refine it iteratively.

Once the DSL was ready, we copied it into playground.structurizr.com and generated the defined diagrams.

Within minutes, we could navigate through the different C4 views:

No guesswork. No scrolling through files. Just a hierarchical overview of the software architecture.

The “Wait a Second…” Moment

That experience sparked an idea.

What if this wasn’t just a one-time experiment?

What if there is a Claude Code skill that does exactly this:

  • Analyze an entire codebase
  • Derive an architecture model automatically
  • Generate a Structurizr DSL
  • Produce ready-to-use C4 diagrams

In other words: Architecture documentation as an AI-assisted, repeatable process.

Why This Matters

Modern codebases evolve quickly, but architecture diagrams usually do not. If we can:

  • generate architecture models quickly
  • keep them close to the code
  • and make them easy to browse and discuss

then architecture becomes a living artifact, not a forgotten document.

The Repository

I turned this idea into a first experiment, which you can find here 👇

GitHub - bitsmuggler/c4-skill: Claude Code skill to create a C4 model based on an existing code base
Claude Code skill to create a C4 model based on an existing code base - bitsmuggler/c4-skill

The Demo

About three years ago, I wrote an article about the Supabase architecture, where I analyzed the architecture in a few hours. See the full blog post here 👇

Architecture and Technology Stack of Supabase ⚡
Supabase under the hood. This post shows you the high-level architecture and the technology stack of Supabase.

With this first draft of the C4-Architecture Claude Code skill, the process takes just minutes.

In the following screenshots, you'll see how Claude Code works with this new C4 model architecture skill.

Prerequisites

To use this additional C4 Claude Code architecture skill, you must clone the repository:

  • Clone the repository into your Claude config directory
  • Symlink the command
  • Optional: Pull the required Docker images (for better initial performance)
  • Restart Claude Code

Starting the analysis

If you see the command and type /c4, the plugin is correctly installed. By selecting the command and pressing Enter, you will start the command.

Typing the C4 command in Claude Code (Visual Studio Code)

The command initiates the entire skill on Claude Code.

Starting the C4 skill in Claude Code

While analyzing the entire codebase, it will ask you for some C4 specifics, such as which views you would like to specify in the DSL.

Selecting the architecture views based on the C4 model

Additionally, you will be asked which part of Supabase you want to analyze because it is a large codebase.

Selecting the scope of the architecture analysis

After analyzing the codebase, the skill can write the architecture model using the Structurizr DSL in a workspace.dsl file.

Writing the architecture model in Structurizr DSL based workspace.dsl
Analyzing the finished architecture model and all views created based on the written Structurizr DSL.

Here you will find the completed workspace.dsl file for Supabase, which can be viewed at playground.structurizr.com, along with all generated architecture diagrams.

Generated Supabase Architecture Model in Structurizr DSL (workingsoftware.dev)
Generated Supabase Architecture Model in Structurizr DSL (workingsoftware.dev) - workspace.dsl

Reviewing the created views

Level 1: System Context View

Generated System Context Diagram with C4-PlantUML
Generated Context Diagram with PlantUML

Level 2: Container View (all containers)

The first version of the skill it generates all containers in one view. This should probably improved. It doesn't make sense to have such big overview diagrams. Ideally, there are several with with selected person and containers (e.g. per per person, per use case, per what ever which makes sense for the communication).

Generated Container Diagram with C4-PlantUML
Generated Container Diagram with PlantUML

This is a first draft of a C4 architecture skill for Claude Code. It provides an initial overview of the major building blocks and third-party dependencies of your system. This was my first attempt to support AI-assisted software architecture work.

I hope this helps as a software architect! But be aware - the code doesn't tell the whole story 😉.

Let me know if you have any feedback or thoughts on this idea.

Thank you.