Skip to content

The strukts CLI

Audience: build engineers, CI authors, anyone who wants checks and generated code without opening the IDE · about 12 minutes · Prerequisites: a struktJS checkout with npm install done, or a standalone dist/strukts-cli/ folder, plus Node.js 20 to 22.

What it is

strukts is a command-line program that runs struktJS's own checker, generators and test runner on models without the IDE. It loads a project the same way the IDE does, resolves each model's language, and then performs one verb on it. Because it reuses the engine's code instead of re-implementing it, a check run reports the same findings as the Problems panel, and generate writes the same text as Run Generator.

It works on three kinds of target:

  • one shipped project by id (--project hello): every folder under samples/ and every plugin's models/
  • every shipped project in one process (--all); add --jobs <n> (or set STRUKTS_JOBS) to spread a sweep of heavy projects over n child processes. It gives the same report; for light projects such as the shipped ones it is slower, because each child starts the engine
  • any project folder on disk (--project-dir ./my-project)

Results are JSON on standard output. Progress lines go to standard error, so > result.json captures clean JSON. The process exit code tells a build whether the run passed; see CLI exit codes and JSON.

The CLI is read-only with respect to your project by default: it never writes into the project folder. The only things it writes are generated files, a manifest, and a JUnit report, and only into the locations you name. Two verbs can write into a project folder, each only when you pass --write: migrate (rewrites model files to the current language version) and script (lets a script you named save models and write files under that folder).

Two ways to run it

From a checkout Standalone bundle
Command npm run strukts -- <verb> ... (this is node tools/strukts-cli/bin.mjs) node dist/strukts-cli/strukts.mjs <verb> ...
Needs the repository with npm install done only Node.js; no node_modules, no checkout
How it is made nothing to build npm run build:cli writes dist/strukts-cli/ (strukts.mjs, plus wasm/ and typeshed/ folders that must stay beside it)
Speed slower to start: it launches a private Vite module runner because language plugins are TypeScript faster to start
Test assertions that replay keypresses work (jsdom is found in node_modules) need jsdom installed where you run it, or --skip-unsupported

The -- after npm run strukts is required: it tells npm that everything after it belongs to strukts, not to npm.

To copy the standalone build to a CI machine, copy the whole dist/strukts-cli/ folder, not just strukts.mjs. Run strukts info there first to confirm it found its data (see below).

As an npm package. npm run build:package also packs the standalone build as @struktjs/cli (dist/struktjs-cli-<version>.tgz, about 5.5 MB). npm install ./struktjs-cli-<version>.tgz puts a strukts command on the project's path (npx strukts info). It is self-contained: it carries its own engine and every language, so it needs none of the other @struktjs/* packages and does not share their copy of @struktjs/core. Its one dependency is the pyodide package, which strukts run uses when the machine has no python3.

How to use it

  1. See what is available. From the repository root:

    npm run strukts -- list
    

    This prints every shipped project with its id, whether it is a sample or a plugin demo, and the models and roots inside it. The id is what --project takes.

  2. Check the installation (optional but useful in CI):

    npm run strukts -- info
    
  3. Check a model.

    npm run strukts -- check --project hello
    
  4. Generate code.

    npm run strukts -- generate --project hello --output build/generated
    
  5. Run its tests, with a JUnit report for your CI dashboard:

    npm run strukts -- test --project decision-table --junit build/junit.xml
    
  6. Package it: check, generate and write a manifest in one step.

    npm run strukts -- package --project multi-root-demo --output build/packages
    
  7. Point it at your own project. A project folder is the folder holding your models (the one that contains project.json, or a bare model/ folder):

    npm run strukts -- check --project-dir path/to/my-project
    

    Every model inside is loaded, including nested folders and models with several roots. A check run can see the project's other models, as Check Entire Project in the IDE does. The project's id (used in output folders) is the folder's name, or its parent's name when you point at a folder called model.

The verbs

list

Prints the catalogue of shipped projects. It takes no target. project-info is an older name for the same verb.

info

Reports what this installation can actually do, measured rather than assumed:

{
  "cliVersion": "0.3.0",
  "node": "v22.23.2",
  "mode": "source",
  "languages": 63,
  "shippedProjects": 56,
  "grammars": {
    "python": "ok",
    "javascript": "ok",
    "typescript": "ok",
    "json": "ok",
    "kernelf": "ok",
    "sexpr": "ok",
    "xml": "ok"
  },
  "typeshedModules": 5177,
  "dom": "jsdom available (test assertions that replay a keypress can run)"
}

mode is source from a checkout and bundle from the standalone build. A grammar showing failed: ..., or typeshedModules of 0, means the wasm/ or typeshed/ folder did not travel with the bundle. The language and project counts change as plugins and samples are added.

check

Runs every check, constraint and type rule on every root of every model, and prints each finding. A real run on the python-tour sample (output trimmed to the first finding of each kind):

$ npm run strukts -- check --project python-tour
{
  "project": "python-tour",
  "status": "findings",
  "ok": false,
  "diagnostics": [
    {
      "code": "STRUKT-CHK-no-literal-zero-divisor",
      "severity": "error",
      "message": "Division by zero: the divisor is the literal 0",
      "model": "python-tour",
      "root": "python-tour.model.py",
      "nodeId": "3207",
      "location": { "line": 5, "column": 5 }
    },
    {
      "code": "STRUKT-CHK-self-assign",
      "severity": "warning",
      "message": "Assignment of variable to itself",
      "model": "python-tour",
      "root": "python-tour.model.py",
      "nodeId": "3198",
      "location": { "line": 8, "column": 1 }
    }
  ],
  "summary": { "errors": 8, "warnings": 9 }
}

That run exits with code 3. Two things to know when reading diagnostics:

  • Identify a finding by model, root and location (line and column, counted from 1). The nodeId is assigned at run time and is not the same between runs, so do not store it.
  • A finding on a node that has no source position of its own (the first one above sits on the literal 0) gets the location of the nearest enclosing node that has one, here the statement. A finding has no location only when nothing around it was recorded.

generate

Runs each model's generator and writes the output. The layout is <output>/<model>/<root>.<extension>, where the extension follows the language: .py, .js, .ts, .kf, .sexpr, or .html for a language that generates a self-contained preview document (the Grid Robot sample does this). A project with one model uses the project id as the <model> folder; with several models it uses <id>/<model folder>, so two folders both named m never collide.

$ npm run strukts -- generate --project kernelf-demo --output build/generated
{
  "project": "kernelf-demo",
  "status": "ok",
  "ok": true,
  "artifacts": [
    {
      "path": "build/generated/kernelf-demo/kernelf-demo.kf",
      "file": "kernelf-demo/kernelf-demo.kf",
      "model": "kernelf-demo",
      "root": "kernelf-demo.model.kf",
      "generator": "text",
      "sha256": "1be5009238a6023d74cd57f3016c1b4ee46266dc75ee94c56ca552df354e8778",
      "bytes": 2631
    }
  ]
}

(The real output lists one artifact per root; this shows the first. path is relative to the directory you ran the command in, file to the output folder.)

A model is skipped, not failed, when its model.json says "generatable": false, or when its language's generator is a staged plan rather than source text (pass --plans to write the plan, see below). In a sweep a skipped project is fine. If you ask for one such project by name, the command exits 4, because you asked for output that cannot exist:

$ npm run strukts -- generate --project ruff-lint-demo
{ "project": "ruff-lint-demo", "status": "skipped", "ok": false, "artifacts": [],
  "skipped": [{ "model": "ruff-lint-demo", "reason": "model.json declares \"generatable\": false" }],
  "reason": "model.json declares \"generatable\": false" }
(exit code 4)

test

Runs the test suites inside each model, the same way the Tests window does (see Writing and running tests). A model with no suites is reported as skipped with the reason no test suites; that is not an error.

$ npm run strukts -- test --project decision-table
{
  "project": "decision-table",
  "status": "ok",
  "ok": true,
  "summary": { "passed": 2, "failed": 0 },
  "models": [ { "model": "decision-table", "status": "ok", "passed": 2, "failed": 0 } ]
}

A failing assertion appears under the model as failures, each with suite, test and message. --junit <file> writes one JUnit XML file covering every model that ran (the parent folder is created if needed):

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="struktJS TestLang" tests="45" failures="0">
  <testsuite name="constraints showcase" tests="2" failures="0" errors="0" skipped="0">
    <testcase classname="constraints showcase" name="flags division by literal zero — AssertChecks" time="0.0077">
    </testcase>

verify

verify is the one-command health check: it runs check, test and a generator dry run (the generator runs and its output is thrown away, so nothing is written) and reports all three even when an earlier one failed. It prints the same one-line summary as the IDE's Run > Execute > Verify Model (Overview):

$ npm run strukts -- verify --project hello
{ "project": "hello", "status": "ok", "ok": true,
  "line": "✓ no problems · no tests · generator ✓", "firstFailure": null,
  "check": { ... }, "tests": { ... }, "generator": { "status": "ok" } }

firstFailure is problems, tests, generator or null. The exit code follows it: 3 for check findings, else 5 for failing tests, else 4 for a generator failure. Use it as the single gate in CI instead of chaining three verbs.

package

package is this tool's own small definition of "ship a model": it runs check, and if there are no errors it runs generate and then writes manifest.json next to the generated files. There is no archive step; the folder is the package, and you archive it with whatever tool your build already uses.

$ npm run strukts -- package --project multi-root-demo --output build/packages
{
  "project": "multi-root-demo",
  "status": "ok",
  "ok": true,
  "package": "build/packages/multi-root-demo",
  "manifest": "build/packages/multi-root-demo/manifest.json",
  "summary": { "files": 2, "errors": 0, "warnings": 0 }
}

The manifest records the project, the check summary, each model's language and imports, the SHA-256 of every source file, and the SHA-256 and size of every generated file. It is sorted and contains no timestamps or absolute paths, so the same inputs always produce a byte-identical manifest. That makes it safe to cache and to compare between builds.

tree

Prints a project's structure as JSON, for a tool that browses it: strukts tree --project-dir <dir>. It lists each model (its label, folder and language) and each root file in it with the display name the IDE shows, plus a top-level outline per root. Every outline entry carries its head (the kind of statement), a label and a location (line and column, counted from 1, like a check finding), so a tool can jump to it. It reads the project and writes nothing. It needs exactly one project (--project or --project-dir); --all exits 2. The VS Code extension's Explorer view is built on it.

run

Runs the program(s) of a project on a real Python and prints a JSON result: strukts run --project-dir <dir>. It uses python3/python on the machine and, when there is none (or with --python pyodide), Pyodide, CPython compiled to WebAssembly, in a worker thread, so a CI image with no Python still runs the project. --python auto|host|pyodide chooses (host fails with a message when the machine has no Python). The program never reads the CLI's own stdin: each input() call takes the next --answer <line> (repeat it), then an empty line. --model <name> and --root <file> narrow what runs; --timeout <ms> (default 30000) stops a runaway program. A root that holds a test suite is reported as skipped (use strukts test). A program that fails (a Python exception, a non-zero exit) or times out exits 8; the traceback is in the run's stderr.

strukts run --project-dir . --answer Ann --python pyodide

Languages that are not Python-based still run on the evaluator. The standalone bundle carries Pyodide (about 14 MB), so strukts run needs neither Python nor node_modules.

explain

Answers "why is this value what it is?" for a language that evaluates synchronously (KernelF today): strukts explain --project-dir <dir> --name z. It runs each root with a trace and prints the declaration, its value, and the steps it was computed from, in the language's own syntax:

val z = double(y)  =>  84
  double(y)  =>  84
    double  =>  <function>
    y  =>  42
    n * 2  =>  84
      n  =>  42
      2  =>  2

--name <declaration> explains that one declaration in full depth; without it every top-level declaration is listed with its value only. --depth <n> limits how many levels of steps are kept (a cut is shown as … n more), and --format text prints these lines instead of JSON (the JSON has the same information as a tree, plus the node ids of the run). A failed step shows !! and its message instead of a value. A language that cannot run synchronously (Python-grammar Core, for example) is reported as unsupported, exit 0; an unknown --name exits 2. It needs exactly one project and writes nothing. A conditional says which way it went and a decision table which row decided, as [via else] or [via row 2] after the value:

val tariff = fee(30, true)  =>  9
  fee(30, true)  =>  9
    …
    Table rows  =>  9  [via row 2]

A language reports this by naming the branch it took (ctx.branch("row 2") in its evaluation rule); a concept that does not simply shows no via.

migrate

Brings model files up to their language's current version, using the language's recorded migration history (structural steps and scripted transform steps; see Migrating a language). strukts migrate --project-dir <dir> only reports: for each root file the version it was saved at (from), the language's version (to) and a status: current, pending, refused (saved by a newer version of the language than the one installed), failed (a step threw) or skipped (a syntax error). --check makes any pending root exit 6, for a CI gate. --write rewrites the pending files and stamps the new # langversion:. --from <n> assumes version n for a file that records none (no # langversion: header; a headerless grammar without a langVersion in model.json), which is otherwise taken to be version 1; a recorded version always wins.

strukts migrate --project-dir ./my-project --trust-project-code --write

A model is rewritten only when all of its roots migrated, a file with a syntax error is left alone, and each file is written whole or not at all. --write needs --project-dir (a shipped sample is never rewritten) and cannot be combined with --check. A project's own language is arbitrary JavaScript, so --trust-project-code applies as for every verb. Exit 6 when anything is refused or failed, or with --check when something is pending.

script

Runs a project script with the workbench API against a project, headless: strukts script scripts/tidy.script.js --project-dir ./my-project --trust-project-code. Put the file name first; it is relative to the project folder. The script is the body of an async function with workbench, args (from --args '<json>'), log and cancelled(). The result is JSON: the script's returned value, its logs, the files it wrote, the models it changed but did not save (unsaved), and the audit log of what it did. A script that throws exits 7 with the error in the JSON.

A script is arbitrary JavaScript, so --trust-project-code is required, exactly as for a project's own language file. A script is not sandboxed: it runs inside the CLI's own process with your privileges, so --trust-project-code is the real boundary. A trusted script can import Node's own modules and write any file or start any program, whatever --write and --shell say. Those two flags gate only the workbench API's fs, project.save() and shell; they keep a script that uses the API honest and tell you what to expect, they do not contain it.

Through the workbench API a script can, by default, read and query the project and edit models in memory, and nothing reaches disk. You open up the API's own paths, one flag each:

Flag Lets the script Limit
--write call workbench.project.save() and workbench.fs.write/mkdir/remove the API refuses a path that leaves --project-dir (also through a symlink) and never writes a shipped project; a script that bypasses the API is not held to that
--shell call workbench.shell.run(command, args) argument list only (no shell expansion), working directory inside the project, 60 s default timeout
--answer 'label=value' get an answer for workbench.prompts.ask/confirm/choose("label") repeat per prompt; a prompt with no answer fails the script instead of waiting for input
--model <name> choose which model is workbench.model.active() default: the first model

A language can offer a script as a task step with { verb: "script", args: ["scripts/tidy.script.js", "--write"] }.

lionweb export

Writes a project's languages and models as LionWeb serialization chunks, the exchange format that other language workbenches can read and write. strukts lionweb export --project <id> only reports; add --output <dir> to write languages/<key>.json (the language as an M2 model, with the platform language it depends on), models/<model>.json (all the model's roots in one chunk) and models/<model>.ids.json. The folder must be new or empty, and nothing is ever written into the project.

  • A language needs a namespace to be exported. A model whose language has none is reported as skipped with the reason, and a run with nothing exported exits 4.
  • Node ids are derived from the node's position in the tree, or read from the model's model.json (lionweb.ids, written by the IDE's File > Export > Export Model as LionWeb…, with a fingerprint per node in lionweb.fps, which is what keeps the ids of the other nodes when a node is inserted, removed or renamed; a <model>.fps.json beside the ids is written and read the same way). --ids <dir> takes precedence and reads the <model>.ids.json of an earlier export (the models/ folder it wrote) so that a re-export after edits keeps the ids of the nodes that did not move.
  • --lionweb-version 2026.1|2023.1 picks the serialization format (default 2026.1, the current specification; the official TypeScript libraries read 2023.1).
  • Each language and model lists its losses: what LionWeb cannot express (enumeration integer values, cardinalities such as 2..n, a property kind with no LionWeb type of its own) and was written approximately.

Checked against the official LionWeb validator and by importing the chunk back (tree equal). Not tested against a chunk that another language workbench produced.

lionweb import

Reads a LionWeb chunk. strukts lionweb import <chunk.json> --project <id> reads the chunk in the language of that project (the project model whose language the chunk's nodes name) and only reports; add --output <dir> to write <name>/ (a model.json and one source file per root) and <name>.ids.json, the node ids to pass to lionweb export --ids so a later export keeps them. --name sets the model's name (default: the chunk file's name). The folder must be new or empty.

  • What the project's language cannot hold (a LionWeb reference, annotations, a node of an unknown concept) is listed under losses and left out, never guessed.
  • A chunk that is a language is read, and reported (kind: "language": namespace, version, concept count, losses). With --output <dir> each language that is not already installed is written as languages/<name>.lang.js and languages/<name>.language.json (copy them into a project, which then needs --trust-project-code, or into the IDE's language folder); a language of the same namespace or name that is already available is listed under alreadyInstalled and never written.
  • Exit 2 for a missing or unreadable file, something that is not a chunk, an unsupported serializationFormatVersion, or a non-empty output folder; 4 when the chunk names no language of the project or has no root.

lionweb partitions, lionweb push and lionweb pull

To try them without setting a server up, npm run lionweb:demo starts a local one in Docker (deploy/lionweb-demo/) and walks through them; npm run lionweb:demo -- down removes it.

These talk to a LionWeb repository (the lionweb-server; tested against ghcr.io/lionweb-io/lionweb-server). All three need --server <http://host:port>; --repository <name> picks the repository (default default); a server that has a token set needs it in STRUKTS_LIONWEB_TOKEN (or --token, which then shows up in your shell history). A repository speaks one serialization format, and chunks are written in that one (2023.1, 2024.1 or 2026.1).

  • strukts lionweb partitions --server <url> lists the partitions the repository holds.
  • strukts lionweb push <target> --server <url> --output <new folder> writes every model of the project to the repository. Nodes that have no id yet get theirs from the server, so two models with the same name cannot overwrite each other. The ids are written to --output (models/<model>.ids.json and .fps.json): keep them and pass that folder as --ids next time, or the next push creates every node a second time (the verb refuses to run without --output for that reason; it never writes into the project). A partition the repository already has is written over only with --force, otherwise the model is reported as exists and the exit code is 4. Nodes removed from the model are removed on the server.
  • strukts lionweb pull <target> --server <url> --partition <id>[,<id>] [--output <dir>] reads partitions in the language of the project and writes them the way lionweb import does. A partition the repository does not have is an error.

Exit 2 for a missing flag, a server address that is not http(s)://, or a token the server rejects; 4 when the repository cannot be reached, refuses the request (its own message is the error), or a push finds a partition it may not write over.

tasks and task

A language can declare named tasks (a chain of verbs and external commands; see Tasks and the project terminal). strukts tasks --project-dir <dir> lists the ones the project's languages declare, as JSON. strukts task <name> --project-dir <dir> runs one: each step in order, stopping at the first failure and exiting with that step's code (127 if an external command cannot be started). An unknown name exits 2 and lists the declared ones.

serve

strukts serve --project-dir <dir> [--port <n>] [--token-env <NAME>] keeps a project in memory and offers the commands its languages contribute (Concept#contributes().commands) as JSON over HTTP, so a web application can keep its own user interface and let struktJS do the modelling, the checks and the storing. A request is POST /v1/command with {"command": "octo.saveCheckin", "args": {...}}; the command answers {status, body} (the status and JSON to relay) and a command that saves writes the project's files. GET /v1/commands lists the commands, GET /v1/health answers when it is up and POST /v1/reload rereads the folder after you edited it elsewhere.

It is meant for a developer's machine or a private network, and it is strict about it: it listens on 127.0.0.1 only (the Host header must be that address), every request needs Authorization: Bearer <token> with the token read from the environment variable (default STRUKTS_SERVE_TOKEN, at least 16 characters; it refuses to start without one), a request is JSON of at most 2 MB, one request runs at a time, and only commands a language registered can be called: never the application's own commands and never script text from a request. It needs --project-dir (a shipped sample is not served: it saves). The worked example is the original Octo web app, whose API route relays to the octo.* commands of the Octo language (docs/octo-struktjs-backend-plan.md in the repository).

mcp

Starts a Model Context Protocol server on standard input and output, so an AI agent in an MCP client (Claude Code, an IDE, the MCP Inspector) can read a project the way the IDE's own AI chat does. It is the headless counterpart of the chat agent's read tools, computed by the same code as the verbs above. The target is optional and only sets the default for calls that name no project: strukts mcp --project-dir ./my-project.

Tool Returns
strukts_list_projects the shipped projects (use an id as project)
strukts_get_model each model's language and roots, every root's source text and a located outline (includeSource: false for the outline only)
strukts_get_concepts the concepts the project's language supports, as text or format: "json"
strukts_get_checks the checker's findings, each with severity, message, rule code, file and line/column
strukts_run_generator the generated text per root, in the response (nothing is written)
strukts_run_program runs each root like the IDE's Run: what it printed, its final value, any error
strukts_run_tests pass/fail per test
strukts_verify check, tests and generator dry run in one report

Every tool takes project (a shipped id) or projectDir (a folder on disk). The project is reloaded from disk on every call, so an agent can edit the model files with its own file tools and call strukts_get_checks again to see the result. Findings are identified by file and location, never by node id.

By default the server is read-only: there is no tool that edits a model, and the headless host rejects every write. Start it with --write and it gains one more tool, strukts_run_script: it runs a script (JavaScript text from the agent) against the project with the workbench API. Edits stay in memory and are reported as unsaved unless the call also passes write: true (a real projectDir only) and the script saves. workbench.shell is not offered over MCP, but that is the API's rule only: a script is JavaScript running in the server's own process, so strukts mcp --write gives the agent code execution with your privileges (it can import Node's modules and write files or start programs directly). Start it only for an agent and a project you trust, with --trust-project-code understood the same way. Anything else is still the client's own file tools. The IDE chat agent's apply_code and node operations act on a live editor and are not offered. strukts_run_program does execute the model, exactly as Run does and with no sandbox beyond the evaluator's own: input() always answers an empty string (a headless run has nobody to ask, and the program must never read the protocol's input), output is capped at 1000 lines, and a run is cancelled after timeoutMs (default 30 seconds; cooperative, like test --timeout). A failing call comes back as a tool result flagged isError, which the agent can read; a project with its own *.lang.js is refused unless the server was started with --trust-project-code. Progress lines go to standard error; standard output carries only the protocol, so don't wrap the command in anything that prints to it.

To register it in Claude Code: claude mcp add strukts -- node dist/strukts-cli/strukts.mjs mcp --project-dir ./my-project (or, from a checkout, npm run --silent strukts -- mcp: without --silent npm prints a banner to standard output, which breaks the protocol).

Every option

Option What it does Default Gotcha
--project <id> Selects one shipped project by folder name none An unknown id exits 2 with unknown project "x" (try \strukts list`)`
--all Selects every shipped project and runs them in one process off Output becomes a sweep summary; skipped projects do not fail the run
--project-dir <dir> Selects any project folder on disk none Takes precedence over --project and --all if several are given. --model-dir is an exact alias. A missing folder gives a STRUKT-LOAD error and exit 1
--output <dir> Where generate and package write build/generated Relative paths resolve against the directory you run the command in, not the project
--plans generate and package write staged-plan languages as <root>.plan.kdl off The plan file is a debug form (what Run Generator shows for a plan language), not source code
--fail-on error\|warning Makes check (and the check inside package) fail on warnings too error Any other value exits 2
--allow-findings package writes the package even if check found errors off Only for package
--junit <file> test writes a JUnit XML report off Written even when tests fail, so a dashboard can show them
--timeout <ms> Cancels a model's test run after this many milliseconds 60000 Cancellation is cooperative: a runner that never yields to the event loop cannot be interrupted. Must be a positive number or the command exits 2
--skip-unsupported Reports test assertions that need a DOM as unsupported instead of failing off The default counts them as failures so nothing passes silently
--trust-project-code Loads a project's own *.lang.js language files, and is required to run a script and the JS tests (describe / it) of a project folder (a bundled sample's are trusted) off See below; never use it on a project you did not write or review
--write migrate and script: allow writing into the project folder. mcp: add the strukts_run_script tool off Needs --project-dir; shipped projects are never rewritten
--shell script: allow workbench.shell.run off Argument list only; not available over MCP
--answer label=value script: answer a workbench.prompts call. run: the next line input() returns (plain text, no label=) none Repeatable. An unanswered prompt fails the script; run answers an empty line once the list is used up
--python auto\|host\|pyodide run: which Python runs the program auto auto = the machine's python3/python, else Pyodide. host with no Python on PATH is a failed run
--model <name>, --root <file> run: only that model / root file all A name that matches nothing reports skipped ("no root matched")
--args <json> script: the value passed to the script as args none Must be valid JSON
--format json\|matcher json prints the JSON report. matcher (for check and verify) prints one file:line:column: severity: message line per finding instead json Any other value, or matcher with another verb, exits 2. The exit code is unchanged; the IDE's strukts: check task reads this format

Note: strukts help prints a shorter usage summary; the table above is complete.

Projects that bring their own language

A project can contain language files (*.lang.js at the project's root). Those files are JavaScript, so loading one means running code. The IDE loads it without asking (see Trusting project code); a batch tool has nobody to ask, so the CLI refuses such a project by default:

$ npm run strukts -- check --project-dir ./project-with-lang-js
{
  "project": "project-with-lang-js",
  "status": "error",
  "ok": false,
  "error": {
    "code": "STRUKT-LANG-UNTRUSTED",
    "message": "the project has its own language file(s) (my.lang.js), which are arbitrary JavaScript — pass --trust-project-code to load them"
  }
}
(exit code 1)

Add --trust-project-code only after you have read the file, exactly as you would before running any script from the same source. See Trusting project code and Security and privacy.

What the CLI does not do

  • It does not load languages you installed into the app's language folder (~/.struktjs/languages/). Only the built-in plugins and a project's own root-level *.lang.js are available.
  • It does not run programs from the command line; the verbs check, generate, test and package. To execute a model, use the IDE (or the strukts_run_program tool of strukts mcp).
  • It does not edit models on its own. migrate --write, a script you run with --write and the commands a served language contributes do; strukts mcp only can with --write and then only through strukts_run_script. The headless host itself still rejects every command other than reading files.
  • It does not know about the IDE's extension allowlist, collaboration, or AI features.