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:
| Command | Package |
|---|---|
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
| Command | Does |
|---|---|
kq init | Make a repository: kanoniq.repository.json, model/ with one Ecosystem, portal/Home.page.yml, and AGENTS.md for AI assistants |
kq build | Derive the model each path belongs to, write its .g.kq, and validate it |
kq validate | Check the model each path belongs to against every rule; write nothing |
kq audit | Check the model each path belongs to against its policies, however the repository sets them |
kq prune | Build, and remove orphaned derived elements and Ids from .g.kq |
kq fmt | Rewrite .kq files to canonical form |
kq arrange | Rewrite the model each path belongs to into the conventional layout |
kq materialize | Write the repository's preset out as a policy set you can edit |
kq dissolve | Fold a plateau into its neighbor and remove it |
kq plan | Print the model's data migrations, gap by gap, in time order; write nothing |
kq guide | Show how much of Kanoniq the model puts to work, and the next steps |
kq license | Show every license kq finds, what each grants, and the status they make together |
kq login | Sign this machine in to Kanoniq, to the seat assigned to you or the free plan |
kq logout | Sign this machine out of Kanoniq |
kq svg | Draw one view of the model as an SVG file |
kq png | Draw one view of the model as a PNG file |
kq portal:build | Build the portal of the repository a path belongs to |
kq threats:init | Declare the STRIDE framework in the repository |
kq threats:list | Write the threat list of a repository's model |
kq --help | Lists the commands; kq <command> --help shows one command's options |
kq --version | Prints 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
| Code | Means |
|---|---|
| 0 | Done, or with --check, nothing would change |
| 1 | A 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 |
| 2 | Unknown command or option, a path that doesn't exist, or a kq portal:build --out directory it will not empty |
| 3 | A 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
| File | Written by | Commit it? |
|---|---|---|
Your .kq files, under model/ | You | Yes |
kanoniq.repository.json | kq init, holding its id, its settings and three properties; then you, kq arrange, kq materialize and kq threats:init | Yes |
how-to-use-kanoniq.md | kq init, once; then you | Yes |
AGENTS.md, CLAUDE.md and .github/copilot-instructions.md | kq init, once, unless --no-agents; then you. In VS Code, Kanoniq: Add or Refresh the AI Authoring Brief rewrites AGENTS.md for the version installed | Yes |
portal/Home.page.yml and the other pages | kq init writes the home page; you write the rest | Yes |
model/<name>.g.kq | kq init, kq build, kq prune, and the Kanoniq extension for VS Code on save | Yes. It holds the Ids |
model/<name>.model.json | kq build | No. kq init ignores it in .gitignore |
© 2026 Extenza Works. All rights reserved.