Skip to main content
Version: Next

Working in VS Code

Kanoniq comes to VS Code as one extension, Kanoniq. It colors, checks, formats and navigates .kq files, builds the model on save, draws the model beside the editor, and builds the portal.

Install it from the Marketplace, extenza-works.vscode-kanoniq, or search for Kanoniq in the Extensions view.

It needs VS Code 1.101 or later. It needs no server: the model is read, checked and drawn on your machine. Reading and checking need no account; seeing the diagram needs you to be signed in, on the free plan at least.

Writing a model​

Open the folder of a repository, the one holding kanoniq.repository.json. Every .kq file under its model/ folder is one model, and the extension reads them together: a reference in one file to an element in another is understood everywhere below. The Explorer marks the model/ folder with an M and the portal/ folder with a P.

You want toDo
See what is wrongThe Problems panel lists every error and lint across the model's files as you type, and each is underlined where it is. See Validation. Where your repository checks policies, their findings are listed too, under the source kanoniq policy. Sets a license is needed for and none grants are skipped, with one warning on <name>.g.kq whose code links Your license
Fix a mistyped path or keyword, and some findingsQuick Fix (Ctrl+., or the light bulb) on the underlined text. It offers the closest Code or keyword where a path or a word names nothing, and a fix for the findings where the right edit is certain. See Quick fixes
Know what a Code namesHover over it, or over any segment of a path: the element's declaration, full path and description. On a data-migration, the plateau it delivers and the one before, with their dates, and each change of authority it covers: the Domain Object, and from and to, each by path
Know what a DDD keyword meansHover over conforms-to, customer-of, open-host, acl, core or another of them: the pattern spelled out with its abbreviation, and on a relationship which context is upstream and which downstream. See Relationships between contexts
Go to an elementGo to Definition (F12) on a reference
See where an element is usedFind All References (Shift+F12)
Rename an elementRename Symbol (F2) on its Code. It changes the declaration and every path naming it, in every file, and refuses a rename that would change what another path means. The portal's pages follow, with Refactor: Move… too: every path in a page or decision record naming the element is rewritten in the same edit, and the rename is refused while one of those pages has unsaved changes
Delete an elementRefactor: Delete in the editor's context menu, on its Code or on a path naming it. It lists what goes and asks first: the element and everything under it, in every file, what Kanoniq added under it in <name>.g.kq, and every relationship naming it. It saves the files it changed; run Kanoniq: Prune afterwards to remove the Ids it leaves orphaned. It refuses an element something else still names, such as a domain its Domain Objects belong to, and says where
Adopt a derived data migrationAdopt data migration in the refactorings (Ctrl+Shift+R), on a derived data-migration line in <name>.g.kq that is no orphan. It writes a declaration at the same path in the same plateau, with the derived one's covers lines and an empty name, into the file whose block for the plateau opens the migration's Ecosystem, else the file declaring the plateau, and puts the cursor in the name. Saving keeps its Id. It is offered only where the model would build as it does now, the empty name aside. See Derived or declared
Move an elementRefactor: Move… in the editor's context menu or the Command Palette, with the cursor on its Code or on a path naming it. Pick the new parent from the list, which holds only parents its type may have and filters as you type a path, then keep its Code or change it. It lists what changes and asks first: every path naming it, in every file, is updated, its Ids are kept, a folder named after it moves too, and it saves the files it changed. It refuses a move that would break the model or that the model does not allow, and says why. To change only the Code, use Rename (F2)
Write a referenceCompletion offers the Codes visible where you type, each with its description
Write a propertyType @ above a declaration or statement: completion offers the properties your repository declares for it, and assumed, then the values of an enum, a boolean or a ref. Hover over the name to see its declaration. See Open properties
Use a constantHover over its name: its value, its type, whether it is the model's or which element's, and its description. Go to Definition, Find All References and Rename Symbol work on it too; a rename changes its definition and every use, and keeps its Id. Completion offers the constants seen where you type, wherever a value of their type is taken (see Constants)
Tidy a fileFormat Document, also run on save. Comments are kept
See a file's elementsThe Outline view

Completion after a / offers only the first segment of a path.

Saving builds. Saving a .kq file in a repository writes model/<name>.g.kq, exactly as kq build would from the files on disk: what Kanoniq adds, and the Id of every element. Saving never removes anything. To remove the orphans a build reports, run Kanoniq: Prune from the command palette, as kq prune does.

  • The model is its files on disk. Opening one .kq file loads every file of its model, so it is checked and drawn with the rest even in a window with no folder open. A save builds from the files on disk: another file's unsaved changes are not in it until that file is saved.
  • A save that leaves the model broken writes nothing, and the viewer keeps its last good picture under a warning bar naming the errors.
  • <name>.g.kq is never edited by hand. If it is open with unsaved edits when a save rebuilds it, those edits are dropped and it reloads from disk.
  • A change that arrives without a save, such as a checkout or a pull, is checked and drawn but writes nothing: the <name>.g.kq that came with it is already right.
  • There is no build command: saving is the build. <name>.model.json is written only by kq build.

A .kq file outside any repository is still checked and formatted, but saving it writes nothing. A .kq file in a repository but outside its model/ folder gets one error saying so, and is no part of the model. Run kq init to make a repository.

Navigation pages are checked too. A *.page.yml file is checked as you type for valid YAML and the fields a page may have. Its fields are completed too, and with Red Hat's YAML extension installed they're also explained on hover. A decision record, a *.adr.md file, has its frontmatter checked and completed the same way, its element picked from the model. See The portal.

What the model makes of a statement​

Two read-only features show, in the editor, what the model makes of what you wrote. They need no license.

A code lens sits above the declaration of each Domain, Platform, monolith, Component and Broker, and only above the declaring occurrence: a reopening gets none. Its parts are separated by |:

7 references | 5 relationships | on 1 page
component order-service "Order Service" : backend technology "Java" {
PartCountsClick
N referencesPath segments naming the element in the files you write, never in <name>.g.kq. Always shown, 0 references includedA peek on those places, as Peek References shows them
N relationshipsConnections and Realizations at the element, or at an Interface or Channel it holds, each counted once, in either direction. Shown only when not zeroA peek listing them at their statements
on N pagesNavigation page files (see The portal) under portal/ with a view tile whose domain, focus or iam names the element; a page counts once. Shown only when not zero, and only in a repository with a portal/. Generated landscape pages are not countedA peek listing the pages at the tile's view: line. Choosing one opens it

A data migration has a lens of its own, wherever it is declared: Show in Viewer, which selects it in the viewer, then how many entities it covers, how many links it has, and its plateau with the gap's dates, into To be, 2026-10-01 – 2027-06-30. Each Data Entity it covers has one on its line, migrated into To be by Move customers, which selects the migration in the viewer too. See Data migrations on a view.

In <name>.g.kq, each derived element has a lens too: derived from N statements, which peeks at the statements that derive it. An orphan shows orphan: nothing names it and a Prune lens that runs Kanoniq: Prune. The derived initial plateau shows derived: the model declares no plateau. See Orphans.

Inlay hints appear only where a statement derives something, and only in the files you write, never in <name>.g.kq:

storefront-bff -> platform-orders/order-service/order-api over http ⇒ derives http-api
  • A path that creates an Interface is followed by ⇒ derives http-api, or grpc-api, graphql-api, web-socket-api, signal-r-hub, ipc-api, mail-api, snmp-api or ldap-api, whichever the protocol implies. A path that creates a Channel is followed by ⇒ derives channel (Topic), the broker's Channel kind. Every statement naming the derived element shows it.
  • Ctrl+click (Cmd+click on a Mac) on a hint goes to the declaration in <name>.g.kq, once a save has written it there.
  • A reference to an Interface or Channel you declared yourself gets no hint.

While the model has an error, anywhere in it, there are no hints, and each lens keeps the text it had at the last build that worked and does nothing when clicked. Fix the error and they come back. Both follow unsaved text and refresh after every change.

Settings. kanoniq.codeLens.enabled (default true) turns off every Kanoniq lens, and kanoniq.inlayHints.derivations (default true) turns off the hints. VS Code's own editor.codeLens and editor.inlayHints.enabled turn them off for every language.

Seeing the model​

Right-click a .kq file or the model/ folder and choose Show Kanoniq Viewer, or use the Kanoniq button in the title bar of a .kq editor. The viewer opens beside the editor and redraws as you type. What it draws, and how to move around in it, is in Views and notation.

  • Show in Kanoniq Viewer (Ctrl+K V, Cmd+K V on a Mac, or right-click in a .kq editor) shows the element at the cursor: a Domain that has a layered view opens it, anything else is focused in the whole model, and the viewer's pane says what it is. With the cursor between declarations, the element around it is shown. On a data-migration, the viewer selects the migration instead. An open viewer on the model is reused, and the cursor stays in the text.
  • A parse error in the viewer opens its file at the error when you click it.
  • The viewer keeps its view, and its history, when it is hidden or the window reloads.
  • It follows your theme, light or dark. ☀ in the viewer switches it to light, ☾ to dark; a pick unlike your theme is kept for that viewer, and picking your theme's own goes back to following it.
  • ↓ PNG and ↓ SVG export the diagram; they need a license. Without one, a bar above the diagram says why and links to what a paid seat adds.

The viewer's commands​

The viewer's own controls work the same here as in a browser tab: hovering, the right-click menu, Find, the keyboard keys, the legend and the fit and zoom buttons are described in Selecting and moving around. In VS Code the viewer's actions are also commands of the editor. They are in the Command Palette while the viewer has the focus, and each does what the same gesture in the viewer does. A browser tab and the read-only portal have no Command Palette; they offer the same actions through the viewer's own controls, and an export there is downloaded.

CommandKeysDoes
Kanoniq: Find Element in Viewer…A quick pick of every element by path and type. Choosing one goes to it.
Kanoniq: Export View as SVGExport the view as SVG through a Save dialog. It needs a license, as the viewer's export button does.
Kanoniq: Export View as PNGExport the view as PNG through a Save dialog. It needs a license, as the viewer's export button does.
Kanoniq: BackAlt+LeftStep back through the views you have opened. Disabled at the first.
Kanoniq: ForwardAlt+RightStep forward through the views you have opened. Disabled at the last.
Kanoniq: Lens: AllSwitch to the All lens.
Kanoniq: Lens: ImplementationSwitch to the Implementation lens.
Kanoniq: Lens: CommunicationSwitch to the Communication lens.
Kanoniq: Lens: DataSwitch to the Data lens.
Kanoniq: Clear FocusGo back to the whole model.
Kanoniq: Collapse AllCollapse every container the view draws.
Kanoniq: Expand AllExpand every container the view draws.

VS Code takes none of the canvas's keys inside the viewer; Alt with an arrow is left to VS Code, which is what steps back and forward.

Building the portal​

The extension builds and serves the portal of a repository's navigation pages, using kq:

  • Right-click the portal/ folder and choose Build Kanoniq Portal. It runs kq portal:build . --out portal-dist in a terminal, lists what it finds in the Problems panel, and when the build succeeds, serves portal-dist/ on your machine only and opens it in your browser.
  • Run Kanoniq Portal on a built portal-dist/ folder serves it again; Stop Kanoniq Portal stops it.

It is served on port 47620, set in portal-dist/.kanoniq-server.json. If the port is in use, it says so and does nothing else: change the port in that file and try again.

It runs kq from your PATH, with @extenza-works/kanoniq-export-portal installed beside it; see Installing. Where kq is not on your PATH, set Kanoniq: Kq Path (kanoniq.kqPath) in your settings to its full path.

Commands and settings​

Every command of the extension, as the Command Palette names it, and every setting, under Kanoniq in the Settings editor. The viewer's own commands are in The viewer's commands.

Commands

CommandKeysDoes
Kanoniq: PruneRemove the orphans a build reports from <name>.g.kq, as kq prune does: in the model of the file or folder you pick, else of the viewer that has the focus, else of the active .kq file.
Refactor: DeleteDelete the element whose Code or path is at the cursor, with everything under it and every relationship naming it, in every file. It lists what goes and asks first, and refuses an element something else still names.
Kanoniq: Refactor: Move…Move the element whose Code or path is at the cursor under a parent you pick, then keep its Code or change it. Every path naming it, in every file, is updated and its Ids are kept; it lists what changes and asks first.
Show Kanoniq ViewerOpen the viewer on the model beside the editor, redrawn as you type. On a .kq file or the model/ folder in the Explorer, or the Kanoniq button in a .kq editor's title bar.
Kanoniq: Show in Kanoniq ViewerCtrl+K V (Cmd+K V on a Mac)Show the element at the cursor in the viewer: a Domain with a layered view opens it, anything else is focused in the whole model, and the cursor stays in the text.
Build Kanoniq PortalBuild the portal from the portal/ folder with kq portal:build, list what it finds in the Problems panel, and serve the result on your machine. On the portal/ folder in the Explorer.
Kanoniq: Add or Refresh the AI Authoring BriefWrite AGENTS.md, the authoring brief that tells an AI assistant how to write and change this model, at the repository's root, with CLAUDE.md and .github/copilot-instructions.md pointing at it. A brief already there is replaced by this version's; an AGENTS.md of your own is replaced only once you confirm, and a pointer file already there is kept.
Run Kanoniq PortalServe a built portal-dist/ folder again on your machine and open it in your browser. On that folder in the Explorer.
Stop Kanoniq PortalStop serving a portal. On its portal-dist/ folder in the Explorer.
Kanoniq: Enter LicenseEnter an offline license, for a network that cannot reach Kanoniq. It is kept in VS Code's secret storage.
Kanoniq: Sign InSign in to Kanoniq: it shows a short code and opens the Customer Hub page where you confirm it.
Kanoniq: Sign OutSign out of Kanoniq on this machine, ending the lease that VS Code and kq share.

Settings

SettingDefaultWhat it does
kanoniq.codeLens.enabledtrueShow a code lens above each Domain, Platform, monolith, Component and Broker: its references in authored files, its relationships and the pages that show it, each opening a peek; and, in .g.kq, what derives each derived element. editor.codeLens turns every language's code lens off.
kanoniq.inlayHints.derivationstrueShow an inlay hint where a statement derives something: after a path that creates an Interface or a Channel. editor.inlayHints.enabled turns every language's inlay hints off.
kanoniq.kqPath"kq"The command that runs kq for Build Kanoniq Portal. Set the full path to the kq executable where kq is not found on the PATH. Write a path with spaces in quotes.

© 2026 Extenza Works. All rights reserved.