Skip to main content
Version: 0.4.1

Your first model from the command line

Make a repository, write a small model, and format, build, check and draw it with kq, the way a pipeline does. About fifteen minutes. The same model in the editor is Your first model in VS Code.

1. Install​

Install the kq command line, as Install describes, and check that it runs:

kq --help

It prints an overview of the commands.

2. Make a repository​

A model lives in a repository: a folder that kq init sets up. Make one, say my-model/:

kq init my-model

It writes:

FileWhat it is
kanoniq.repository.jsonMarks the folder as a repository and holds its permanent id and its settings: how strictly policies are checked, and three properties: brand, for the brands your applications are sold under, and two for APQC's and BIAN's identifiers. It is JSON with comments
how-to-use-kanoniq.mdA short guide to the repository and its commands, yours to edit
AGENTS.mdThe authoring brief, for an AI assistant you work with: how to write the model. CLAUDE.md and .github/copilot-instructions.md point Claude Code and GitHub Copilot at it
model/my-model.kqYour model, to start with one empty Ecosystem named after the folder: ecosystem my-model "my-model"
model/my-model.g.kqThe file Kanoniq writes: what it adds to your model, and every element's Id. Never edit it
portal/Home.page.ymlThe home page of the portal
.gitignoreIgnores the build output

3. Write a model​

Open my-model/model/my-model.kq in any editor and replace its Ecosystem with this one:

ecosystem my-model "Shop" { domain selling "Selling" { function place-order "Place an order" } platform storefront "Storefront" { component web-shop "Web Shop" : user-facing-app technology "Next.js" { spa web-shop-ui "Web Shop" } component order-service "Order Service" : backend web-shop -> order-service/orders-api over http auth user-token web-shop realizes selling/place-order order-service realizes selling/place-order } }

A domain and its function say what the shop does; the platform's two components do it, the web shop calling the order service's API. The VS Code tutorial reads it from the top, in 3. Write a model.

4. Format it​

kq fmt rewrites .kq files to canonical form, the one layout every model is kept in:

kq fmt my-model

The file you wrote is rewritten in place if its layout was off. kq fmt --check my-model writes nothing and exits with 1 if a file would change, which is how a pipeline holds the layout.

5. Build it​

Build the model:

kq build my-model

The build fills model/my-model.g.kq with what Kanoniq added, here the orders-api interface, and an Id for every element. It also writes model/my-model.model.json, the built model as JSON, which can be rebuilt at any time and is ignored by git.

Then check it, as CI would:

kq validate my-model

A clean model prints one line, saying how many models were validated, validated 1 model. A new repository checks the recommended policies too, so the line also counts their findings, listed above it under policy findings:. Most are KP001 lines, at info because kq init set the severity of that check to info: policies your small model gives nothing to check yet. See Govern the landscape.

6. Draw it​

kq svg draws one view of the model as an SVG file. It comes with a paid seat, so without a license that grants it, it says so and exits with 3:

kq svg my-model

With one, it draws the whole model to my-model.svg. kq svg --domain my-model/selling my-model draws the Selling Domain's layered view instead.

7. Commit it​

Commit every .kq file, model/my-model.g.kq included: it holds the Ids that keep each element's identity when you rename or move it. .gitignore, which kq init wrote, keeps the build output out.

Next​

  • CI: the same checks on every pull request, with a workflow to start from.
  • Modeling guides: one task at a time, each growing one model a step at a time.
  • Concepts: the ideas the rest follows from, one page each.
  • The kq command line: every command, its options and its exit codes.

© 2026 Extenza Works. All rights reserved.