Skip to main content
Version: 0.4.0

The kq command line

kq starts a repository, builds, validates, prunes and formats its model, draws a view of it as SVG or PNG, builds its portal, and shows your Kanoniq license. Paths are relative to where you type the command.

Installing​

kq is the npm package @extenza-works/kanoniq-app-cli, and needs Node 24 or later:

npm install --global @extenza-works/kanoniq-app-cli

Signing in and drawing come in packages of their own, so the command line stays small when you don't need them. Install each beside kq, the same way:

CommandPackage
kq license, kq login, kq logout@extenza-works/kanoniq-lib-licensing
kq svg@extenza-works/kanoniq-export-svg
kq png@extenza-works/kanoniq-export-png
kq portal:build@extenza-works/kanoniq-export-portal
kq threats:init, kq threats:list@extenza-works/kanoniq-export-threats
npm install --global @extenza-works/kanoniq-lib-licensing @extenza-works/kanoniq-export-svg @extenza-works/kanoniq-export-png @extenza-works/kanoniq-export-portal @extenza-works/kanoniq-export-threats

kq svg, kq png and kq portal:build need a license, so install the licensing package with any of them.

Without its package, kq svg, kq png or kq portal:build is unknown to kq, and kq license, kq login or kq logout says which package to install. In a project that installs them as dependencies instead, run npx kq.

Commands​

CommandDoes
kq initMake a repository: kanoniq.repository.json, model/ with one Ecosystem, portal/Home.page.yml, and AGENTS.md for AI assistants
kq buildDerive the model each path belongs to, write its .g.kq, and validate it
kq validateCheck the model each path belongs to against every rule; write nothing
kq auditCheck the model each path belongs to against its policies, however the repository sets them
kq pruneBuild, and remove orphaned derived elements and Ids from .g.kq
kq fmtRewrite .kq files to canonical form
kq arrangeRewrite the model each path belongs to into the conventional layout
kq materializeWrite the repository's preset out as a policy set you can edit
kq dissolveFold a plateau into its neighbor and remove it
kq planPrint the model's data migrations, gap by gap, in time order; write nothing
kq guideShow how much of Kanoniq the model puts to work, and the next steps
kq licenseShow every license kq finds, what each grants, and the status they make together
kq loginSign this machine in to Kanoniq, to the seat assigned to you or the free plan
kq logoutSign this machine out of Kanoniq
kq svgDraw one view of the model as an SVG file
kq pngDraw one view of the model as a PNG file
kq portal:buildBuild the portal of the repository a path belongs to
kq threats:initDeclare the STRIDE framework in the repository
kq threats:listWrite the threat list of a repository's model
kq --helpLists the commands; kq <command> --help shows one command's options
kq --versionPrints the version

kq build, kq validate, kq audit, kq prune, kq fmt and kq arrange take one or more paths, and kq svg, kq png, kq plan and kq portal:build one, to a file or a directory. A path belongs to the repository whose kanoniq.repository.json is nearest above it, and the model is every .kq file under that repository's model/ folder. The model takes the repository folder's name, not model.

When something goes wrong​

A path that doesn't exist exits with 2, like a mistyped command. A file kq can't read or write, because of its permissions, a full or read-only disk, or a broken link, is named with the reason, kq build: model/shop.g.kq: permission denied, and exits with 1. Anything kq writes before that stays written. A message that starts kq: internal error is a bug in kq: please report it with the lines below it.

Exit codes​

CodeMeans
0Done, or with --check, nothing would change
1A file would change (--check), the model has a parse or reference error, or it breaks a rule (with --strict, a lint too); kq svg or kq png names an element or a Domain the model doesn't have, or kq png's image would be too large; kq portal:build finds an error in the model or the pages
2Unknown command or option, a path that doesn't exist, or a kq portal:build --out directory it will not empty
3A paid feature, kq svg or kq png, that your license does not grant, or kq portal:build without the Portal package, or with no license for the repository

A build error, such as a parse or reference error, is printed with its file, line and column, and its code:

x.kq:4:10 error KB003 'b' names nothing

Files​

FileWritten byCommit it?
Your .kq files, under model/YouYes
kanoniq.repository.jsonkq init, holding its id, its settings and three properties; then you, kq arrange, kq materialize and kq threats:initYes
how-to-use-kanoniq.mdkq init, once; then youYes
AGENTS.md, CLAUDE.md and .github/copilot-instructions.mdkq init, once, unless --no-agents; then you. In VS Code, Kanoniq: Add or Refresh the AI Authoring Brief rewrites AGENTS.md for the version installedYes
portal/Home.page.yml and the other pageskq init writes the home page; you write the restYes
model/<name>.g.kqkq init, kq build, kq prune, and the Kanoniq extension for VS Code on saveYes. It holds the Ids
model/<name>.model.jsonkq buildNo. kq init ignores it in .gitignore

© 2026 Extenza Works. All rights reserved.