The VS Code extension
The CRAYON-C4 extension for VS Code brings the document-from-code workflow into your editor: generate a model from the workspace, explore it in the full interactive viewer beside your code, fill descriptions with AI, and hand the result to the web app when you want to curate or share it. It bundles the exact same extraction engine and viewer as the web app and the crayon-c4 CLI, so results match wherever you generate or view them.
It supports the same stacks as the CLI: Next.js, React, .NET, and Java (Maven & Gradle).
Install
The extension ships as a VSIX package (it is in preview). In VS Code, open the Extensions view, choose ⋯ → Install from VSIX…, and pick crayon-c4-vscode-<version>.vsix. It requires VS Code 1.85 or newer.
Generate, the viewer, and Open Web App are fully offline (the extension makes no network calls at all). Only the three AI commands need anything extra: an agent CLI on your PATH (default: Claude Code as claude; point the crayonC4.agentCommand setting at another CLI if you prefer).
Commands
All commands live in the command palette under the CRAYON-C4: prefix.
| Command | What it does |
|---|---|
| Generate Model | Builds the model from your workspace. The folders and depth come from the repo's .crayon/config.json, so you are only asked when that file cannot answer (several apps and nothing saying which). Run it again to refresh: re-runs merge in place and your on-disk curation is never overwritten. If a re-run finds elements that no longer come from the code (for example an excluded project), they are kept, and you are offered to remove them. |
| Open Architecture Viewer | Lists the crayon-c4-project*.json files in your workspace — and the model file your .crayon/config.json names — (plus Browse for a model file…) and opens the one you pick in the interactive C4 viewer beside your editor. It reads files exported from the web app too. If the file is not the one your settings point at, it offers to make it the project's model file. It only shows a model; it never generates one. The viewer always shows the full data, including enriched descriptions, and reloads by itself when the file changes. |
| Open in Architecture Viewer | The same viewer for one file: right-click a .json model in the Explorer, or use Open With… → CRAYON-C4 Viewer. |
| Edit Project Settings / Improve Project Settings with AI | Edit .crayon/config.json through menus (what to include or exclude, depth, grouping), or let your agent tune it against the measured diagram sizes. |
| Validate Model | Checks a model file against the published schema. |
| Enrich Descriptions with AI | Reads the open enrichment tasks (elements with empty descriptions) and launches your agent CLI in a terminal with a prompt that fills them. First you choose which sub-sections to write: let the AI decide, pick perspectives (Logical, Process, Development, Physical, Security…), add a longer Detailed version, or name your own. The choice is remembered per workspace. You approve the agent's edits in the terminal. |
| Extract Decisions with AI | Recovers the architecture decisions behind the code into the .adr slice — what was chosen, over what, and at what cost. Reads docs/adr, RFCs and design notes first and keeps their wording; anything it infers from the code alone is recorded as proposed and says so. Continues an existing slice rather than renumbering it. |
| Generate Model with AI | Builds the whole model from an AI agent reading the repository — no static extraction. The answer for a stack the scanners do not cover. Produces C4 + deployment (grounded in Dockerfiles, compose, K8s/IaC and runtime config), never an F4 slice, and must validate against the published schema. Your .crayon/config.json is part of its brief and wins over its own judgement. |
| Open Web App | Generates a model if needed, puts its path on your clipboard, and opens the web app's import page in your browser. Nothing is uploaded — choose From code (new project) or Update from code (existing project) there and pick the generated files; your manual edits are preserved by the merge. |
The viewer's title bar adds a Fill with AI button, which enriches only the elements currently visible on screen that still have empty descriptions. It fills the file you are viewing and asks for the same sub-sections as the command. The tab title shows the file name and when it was last modified.
Decisions
The Decisions view (the CRAYON-C4 icon in the activity bar) is where you find and manage the architecture decisions recorded in the model:
- Decisions are grouped by status, with anything needing review (an element it links to was removed) on top.
- Find Decisions… filters by text or status. Show Decisions for Element… answers "what was decided about this?", including what is inside the element and what contains it.
- New Decision records one and links it to the elements it concerns. Opening a decision opens its markdown file in the
adr/folder, which is where you write the context, the decision and its consequences. - Right-click a decision to change its status, supersede it, link or unlink elements, renumber it, or confirm that it still holds.
An accepted decision is a record: its text can't be edited, so you supersede it with a newer one. The model is the source of truth and adr/ its mirror — edits you make in a file come back with Import Decisions from adr/ Folder, and a status-bar hint appears when the two differ. Decisions: Sync then asks which copy is newer — it never picks a direction for you, because the model and adr/ share no history. See Working with a repository. The viewer also has a Decisions tab.
The crayon-c4 adr command offers the same actions from a terminal.
The generated files
Generate writes three files into each selected project's folder — the same files as npx crayon-c4 .:
crayon-c4-project.json— the model, validated against the published schema (name it yourself with"output": { "model": "my-project.json" }in.crayon/config.json; the sidecars then becomemy-project.provenance.jsonandmy-project.enrichment.json)crayon-c4-provenance.json— the sidecar that makes re-runs and merges rename-safecrayon-c4-enrichment.json— the open AI-enrichment task list
Settings
Under Settings → Extensions → CRAYON-C4:
| Setting | Default | Purpose |
|---|---|---|
crayonC4.modelDepth | component | Fallback depth for generated models when the repo's .crayon/config.json does not set depth. component keeps diagrams readable; code goes down to individual classes. |
crayonC4.diagramBudget | 20 | How many elements a diagram may hold before the run report flags it as too big. |
crayonC4.agentCommand | claude | The CLI launched for the AI passes. The prompt is passed as a single shell-quoted argument (use a {prompt} placeholder to control where it lands, e.g. aider --message {prompt}). |
crayonC4.promptAppend | empty | Extra user-level instructions appended to every AI prompt. Project-specific conventions belong in the repo's own .crayon/config.json instead, so they travel with the project — this setting is appended after those. |
crayonC4.webAppUrl | https://crayon-c4.com/projects | The web app import page opened by Open Web App (change it for self-hosting). |
Per-repository configuration — prompts, project exclude/bundle shaping, traced F4 flows — lives in the repo's .crayon/config.json, which the extension and the CLI read identically. See Document from code for every key. The editor settings above are only personal fallbacks: when the repo's config sets depth or budget, the config wins.
Working with project settings
Use Edit Project Settings instead of writing the file by hand. It opens a menu, and every change is written straight to .crayon/config.json:
- Pick the repository (skipped when there is only one). The extension measures it in a background process, so VS Code stays responsive. The progress notification has a Cancel button that really stops the work.
- Granularity (Next.js and React only): one component per folder or per file.
- What the model is about: choose Keep or Drop, then tick folders (with their project counts) and individual projects. Keep writes
projects.include, Drop writesprojects.exclude. Existing entries are pre-ticked, so unticking one removes it. Entries you typed by hand that have no row are left alone. - Software systems: group projects into named systems, picking folders first and then a name.
- Depth and the one-system option: the depth picker labels each level with what it will really contain. It warns when a depth hides your projects, for example Repository is one system combined with Container shows only the repository and the one app inside it.
- Removals: choose whether a re-run keeps or cleans elements the code no longer produces.
- Result: after each change the extension measures again and tells you how many diagrams are still over budget, so you see the effect without a second command.
Then run Generate Model. If elements are left over that no longer come from the code (an excluded project, say), the result says how many were kept and offers Remove. Always clean up writes removals: "clean" into the config so you are not asked again.
When the settings are hard to get right by hand, Improve Project Settings with AI hands your agent the config schema, your current config and the measured diagram sizes. It edits only .crayon/config.json and re-measures until the diagrams are readable, and it states anything it drops.
The AI prompts can be shaped per repository too: put guidance in .crayon/prompts/enrichment.md and point prompts.enrichment (and prompts.scoped for Fill with AI) at it. That file is the right place to say which sub-sections your team wants in a description.
Multiple projects in one workspace
The extension scans all open workspace folders and detects every supported project in them. Generate Model is multi-select, and each project's model files land in its own folder, so several apps in one workspace never collide. The other commands ask which project to act on — and skip the question when there's only one candidate.
Where next
- Document from code — the CLI, the
.crayon/config.jsonreference, and the update-and-merge loop in the web app. - Manage projects — bring a generated model into the web app as a new project.
- The three views of a system — what the generated C4, deployment, and F4 slices mean.