Skip to main content
Version: Next

kq build

  1. Finds the repository: the nearest folder holding a kanoniq.repository.json, from the path upward. Where there is none, it stops and says to run kq init; it never creates one.
  2. Reads every .kq file under the repository's model/ as one model. A line of <name>.g.kq that can no longer stand, because what it names is gone or because you now declare what it derived, is left out and printed as dropped from …; its Id is kept, or orphaned if nothing takes it.
  3. Adds what your statements name and the model lacks (see What kq build adds), and marks as orphans the derived elements nothing names any more.
  4. Gives every element its Id from <name>.g.kq, and a new one to anything new. Every rename or move it takes is printed.
  5. Writes <name>.g.kq and <name>.model.json, in model/. <name>.g.kq holds what it added, the initial plateau where you declared none (see Change over time), and the Ids. The JSON is the built model, headed by what made it and which ecosystems each file holds.
  6. Validates the model and prints every finding, as kq validate does. An error makes it exit with 1, but the files are still written, so your Ids are kept. A lint is printed and changes nothing.
  7. Checks the model against your policies, where your repository turns them on, as kq validate does, as of today. A policy finding at error makes it exit with 1, after the files are written.
  8. Counts the model's assumptions, where it holds any, in one line on standard error such as 4 assumptions, 2 carried. The count never changes the exit code.
kq build [options] <path>...

Arguments

ArgumentIs
<path>...A file or folder of each model to build.

Options

OptionDoes
--checkWrite nothing; exit 1 if a .g.kq file would change.
--require-licenseFail with exit 3 where a policy set needs a feature no license grants, instead of skipping it with a warning.

Environment

VariableDoes
KANONIQ_TELEMETRYoff, 0 or false stops kq reporting the run; so does DO_NOT_TRACK=1.

Exit codes

CodeMeans
0Done
1Failed: the model has an error, a check found a change, or a file could not be read or written
2Usage error: an unknown command or option, a missing or extra argument, a path that does not exist, or an output folder kq will not clear
3A paid feature that no license found grants

It never writes a file you wrote. <name>.g.kq is the only .kq file it touches.

$ kq build models/my-model
rewrote models\my-model\model\my-model.g.kq
wrote models\my-model\model\my-model.model.json

An orphan is reported twice: once on its own line, and once as the lint KQ103.

© 2026 Extenza Works. All rights reserved.