kq build
- Finds the repository: the nearest folder holding a
kanoniq.repository.json, from the path upward. Where there is none, it stops and says to runkq init; it never creates one. - Reads every
.kqfile under the repository'smodel/as one model. A line of<name>.g.kqthat can no longer stand, because what it names is gone or because you now declare what it derived, is left out and printed asdropped from …; its Id is kept, or orphaned if nothing takes it. - Adds what your statements name and the model lacks (see What
kq buildadds), and marks as orphans the derived elements nothing names any more. - Gives every element its Id from
<name>.g.kq, and a new one to anything new. Every rename or move it takes is printed. - Writes
<name>.g.kqand<name>.model.json, inmodel/.<name>.g.kqholds what it added, theinitialplateau 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. - Validates the model and prints every finding, as
kq validatedoes. 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. - Checks the model against your policies, where your repository turns them on, as
kq validatedoes, as of today. A policy finding aterrormakes it exit with 1, after the files are written. - 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
| Argument | Is |
|---|---|
<path>... | A file or folder of each model to build. |
Options
| Option | Does |
|---|---|
--check | Write nothing; exit 1 if a .g.kq file would change. |
--require-license | Fail with exit 3 where a policy set needs a feature no license grants, instead of skipping it with a warning. |
Environment
| Variable | Does |
|---|---|
KANONIQ_TELEMETRY | off, 0 or false stops kq reporting the run; so does DO_NOT_TRACK=1. |
Exit codes
| Code | Means |
|---|---|
0 | Done |
1 | Failed: the model has an error, a check found a change, or a file could not be read or written |
2 | Usage 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 |
3 | A 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.