CLI reference
The ModelDesk CLI (@modeldesk/cli) pulls a model’s generated documentation content into a local
folder, so your own documentation pipeline (for example ReSpec with GitHub Actions) can render and
publish it. ModelDesk generates the content and hands it off; it does not render, host, or publish
documents.
The CLI also reads and edits models, on any of their branches, with the same draft the app shows you; see Work on a branch.
Install
Section titled “Install”The CLI runs on Node.js (version 22 or newer) on Linux, macOS, and Windows. Run it on demand with
npx, or install it globally.
npx @modeldesk/cli@latest bundle pull --model <modelId> --stack <stack> --template <template># or install it oncenpm install -g @modeldesk/cliCommands that read a model require you to be signed in first; see Log in below.
Commands
Section titled “Commands”modeldesk --help lists the commands:
Commands: bundle pull Materialize a model's content bundle into a local folder bundle templates List a model's document templates note add Create an empty note file for an element and add it to the repo's notes.json template lint Check a rendered document against the marker convention its index.json relies on auth login Log in through the browser, or with --device by approving a code on another device auth logout Log out of the active host and end the sign-in on the server auth status Show the active host, logged-in identity, and token validity model list List the models you can read model show Show a model's identity, dependencies and releases model tree Show a model's element tree model log List a model's commits model create Create a model model delete Delete a model model import Import a file or an address as a new model model imports list List imports, pending and finished model imports show Show one import model imports complete Complete a READY import as a model model imports delete Discard an import model export Encode a model in a format of its metamodel model pull Pull a model into a file workspace to edit model diff Show what pushing a workspace would change model push Stage a workspace's changes on your draft metamodel list List the metamodels a model can be written in metamodel extensions List the extensions of a metamodel el show Show one element of a model el create Stage a new element under a parent el set Stage new values for an element's attributes el unset Stage the removal of attribute or relation values el rm Stage the deletion of an element el mv Stage moving an element under another parent el relate Stage adding a target to an element's relation el unrelate Stage removing a target from an element's relation el bulk Stage one update of every element the criteria select el paste Stage a copy of elements, each with what it owns namespace create Stage a namespace namespace set Stage a change to a namespace namespace rm Stage the removal of a namespace attr-template base Stage the base IRI attribute templates share attr-template create Stage an attribute template attr-template set Stage a change to an attribute template attr-template rm Stage the removal of an attribute template diagram create Stage a diagram diagram set Stage a change to a diagram diagram rm Stage the removal of a diagram diagram materialize Stage a stored diagram of a template instance diagram rule create Stage a layout rule on a diagram diagram rule rm Stage the removal of a layout rule diagram rule mv Stage a move of a layout rule diagram group create Stage a hierarchy group on a diagram diagram group set Stage a change to a hierarchy group diagram group rm Stage the removal of a hierarchy group diagram group mv Stage a move of a hierarchy group search Find elements of a model by label or attribute value describe Describe the schema a model is written against validate Validate a model and gate on its findings draft open Aim your draft of a model at a branch draft status Show your draft of a model or dataset draft diff Show what your draft changes draft undo Undo the last change staged in your draft draft commit Commit your draft as one commit draft handoff Hand your draft off to a person for review, with a summary draft discard Discard your draft and everything staged on it draft rebase Move your draft onto the branch head branch list List a model's branches branch create Create a branch of a model branch delete Delete a branch with every draft on it branch diff Show what a branch changed since it diverged branch merge Merge a branch into the addressed one release create Release a model release list List a model's releases pin list List a model's pins and whether each is behind pin set Pin a dependency to a release or to the head dependency add Stage a dependency on another model dependency rm Stage the removal of a dependency dependency pin Stage a move of a dependency to another release dependency connect Stage the connection of an element to the model it represents dependency disconnect Stage the disconnection of an element from the model it represents agent-guide Print the guide for an agent that uses the CLIThe same help lists the global options and the exit codes. modeldesk <command> --help
describes one command with its flags and examples, and modeldesk bundle --help or
modeldesk branch --help lists the commands of a group. This page describes the commands for
documentation content, signing in and working on a branch; --help describes
the others. The el, namespace, attr-template, diagram and dependency commands each stage one
change in your draft, which you or the person you work for review and commit; dependency pin stages
the move of a dependency to another release that pin set commits to main directly.
Global options
Section titled “Global options”Every command accepts these options.
| Option | Effect |
|---|---|
--json |
Print one JSON document on stdout instead of text; see JSON output. |
--no-json |
Print text even where an agent host makes JSON the default. |
--host <host> |
The ModelDesk instance to target (default: modeldesk.io, or MODELDESK_HOST or the repository config; see Configuration). |
--dry-run |
Report what would change and write nothing. Only a command that writes accepts it (such as bundle pull, model push or branch merge); any other command refuses it with exit code 2 and runs nothing, so a dry run never runs for real. |
--yes |
Answer yes to confirmations. When the CLI cannot ask, this is the only way to confirm; see Interactive runs. |
--help, -h |
Show help. Help is always text, also with --json. |
--version, -v |
Show the CLI’s own version. |
Passing both --json and --no-json is a usage error. Inside bundle pull, --version is the pull’s
own flag and pins a model version instead (see Flags), so run modeldesk --version to see
the CLI’s version.
Log in
Section titled “Log in”modeldesk auth login opens your browser to the ModelDesk sign-in page. You authenticate there (the
CLI never sees your password). After a successful login the CLI stores your credential in
~/.modeldesk/credentials.json, which on Windows is %USERPROFILE%\.modeldesk\credentials.json: a
refresh token, and the current short-lived access token. The file is readable only by you: on Linux
and macOS the CLI restricts its permissions to your account, and on Windows it sits inside your user
profile, which is already closed to other users.
Later commands run unattended: they reuse the access token while it is valid, refresh it silently
when it expires, and re-open the browser only when the stored credential lapses. Several CLI
processes running at the same time share the file safely: they take turns refreshing, so one process
cannot invalidate another’s login. Outside CI, a command other than auth login that is not run
interactively (from a pipe or an agent) never opens a browser: without a stored
login that works, it exits with code 6 and tells you how to log in.
modeldesk auth loginmodeldesk auth status # shows who you are logged in as, and whether the credential is validmodeldesk auth logout # ends the sign-in on the server and removes the stored credentialWith --json, auth login prints the host, your identity, and whether a refresh token was
stored (refreshTokenStored); auth logout prints the host, whether a credential was removed,
and whether the server ended its sign-in (revokedOnServer).
auth logout ends the sign-in on the server, so it leaves the account security page at once. If the
server cannot be reached or refuses, the CLI still removes the stored credential and exits with code
0, and warns that the sign-in stays listed on the account security page until it expires or you
revoke it there.
Two rules apply to a login without a terminal:
- The host must be explicit. A login run without a terminal (an agent, a pipe, CI) takes its host
only from
--hostorMODELDESK_HOST, never from the committed.modeldesk/config.json, because anyone who can open a pull request can edit that file. If the committed config names a host and neither is set, the login stops with exit code 1 and tells you to pass--host. At a terminal the committed host still works; when it is notmodeldesk.io, the CLI prints a note naming the host and the file it came from. - No browser login in CI. In CI,
auth loginwithout--devicestops with exit code 6, because a browser login cannot complete there. Use a service account (see Authenticate in CI), orauth login --device.
Log in without a local browser
Section titled “Log in without a local browser”modeldesk auth login --device is for an SSH session, a container, or a remote agent, where no
browser can reach the machine the CLI runs on. The CLI prints a URL and a code. Open the URL in a
browser on any device, sign in, and enter the code; the CLI waits for your approval and then stores
the credential exactly as a browser login does.
modeldesk auth login --deviceDevice login works only on a ModelDesk instance where it is enabled. On any other instance the
command stops before it shows a code and reports Device login is not enabled on <host>.; log in
with modeldesk auth login on a machine where a browser can complete the sign-in instead. If the
code expires before you approve it, run the command again.
The CLI shows a code only when the address to open is on the instance’s own auth server, over HTTPS (or HTTP when the instance itself runs on HTTP, as a local stack does). It refuses any other address and shows no code.
Approve the sign-in in your browser
Section titled “Approve the sign-in in your browser”- Open the URL and sign in as usual. On Connect a device, type the code from your terminal and select Continue. If you opened the link that already carries the code, compare it with the code in your terminal before you continue.
- Confirm device sign-in shows the code, the application (ModelDesk CLI), what the device reported about itself under Requested by (as reported by the device), and the account it Signs in as. The device reports this itself, so it does not prove where the request came from.
- Select Approve only if you started this sign-in yourself and the code matches the one in your terminal. Otherwise, select Deny. Deny comes first, so pressing Enter denies.
After Approve, the page shows Device connected and the CLI stores your credential within a few
seconds. After Deny, the CLI stops with The sign-in was declined, so nothing was stored.
A code is valid for 5 minutes and works once. Never approve a code or link that someone else sent you: approving it signs their device in as you. After 10 codes within 15 minutes that match no sign-in, the page asks you to wait a few minutes before you try again.
Check your login
Section titled “Check your login”modeldesk auth status shows the active host and proves the credential the CLI would use: for your
login it silently refreshes the stored credential, and for a service account it requests a real token
(see Authenticate in CI). Its exit code tells a script the outcome:
| Exit code | Meaning |
|---|---|
| 0 | The credential is valid. |
| 6 | You are not logged in, or the stored login was rejected (for example, it expired or was revoked). Log in again. |
| 7 | The auth server could not be reached. Try again later. |
A service-account credential that the server refuses exits with code 1, with the reason in the message.
With --json, auth status prints one object with the host, the apiBase, the auth mode
(interactive, secret, or federated), credentialValid, and who the credential belongs to:
identity for your login, or account, organization and scopes for a service account (plus the
clientId and a secretFingerprint, never the secret itself, in secret mode, or the repository
and ref in federated mode). When the credential is not valid, problem says why, and the object is
still printed:
{ "schemaVersion": 1, "host": "modeldesk.io", "apiBase": "https://api.modeldesk.io", "mode": "interactive", "credentialValid": false, "problem": "not logged in. Run 'modeldesk auth login'."}Authenticate in CI
Section titled “Authenticate in CI”A pipeline has no browser, so the CLI authenticates as a service account instead: a machine identity an administrator creates in org settings. See Set up a service account for how to create one; this section covers the CLI side.
GitHub Actions: no stored secret
Section titled “GitHub Actions: no stored secret”Add a trust rule to the account for your repository (pin a branch, such as refs/heads/main),
grant the workflow id-token: write, and run the CLI. It recognises the runner, exchanges the
workflow’s own signed token for a short-lived ModelDesk token, and prints nothing:
permissions: contents: read # any permissions block drops the defaults, so restate what the job needs id-token: write # lets the workflow request a signed token; the CLI does the reststeps: - uses: actions/checkout@v7 - name: Pull the bundle run: npx @modeldesk/cli@latest bundle pull --version 1.0.0Nothing is stored on either side: there is no secret to leak, rotate, or forget.
Any other CI: an issued secret
Section titled “Any other CI: an issued secret”Have an administrator issue a secret for the account (it is shown exactly once), store it in your pipeline’s secret manager, and set both variables:
# From the pipeline's secret store, never committed, never in your shell history:# MODELDESK_CLIENT_ID the service account's ID# MODELDESK_CLIENT_SECRET the issued mdsk_… secretnpx @modeldesk/cli@latest bundle pull --version 1.0.0The CLI mints a token per run and keeps it in memory: nothing is written to disk, and no token appears in the log.
What to expect
Section titled “What to expect”- The mode is chosen for you. The secret variables win over GitHub federation, a half-configured pair fails immediately rather than quietly falling back, and a machine run never opens a browser. On a CI runner with no credentials at all, the CLI fails at once and says what to configure, instead of hanging on a sign-in that cannot happen.
modeldesk auth statusverifies the credential by actually requesting a token, and exits with code 1 if the server refuses it (or 7 if the auth server cannot be reached): a one-command check for a pipeline. Use it sparingly: every check counts as real use of the credential, which blurs the Last used signal administrators rely on before revoking something.- An expired secret says so, with its date. Rotate without downtime: issue a new secret, update the pipeline secret, then revoke the old one. The account keeps its name and its history.
- Preview first.
--dry-runshows what a pull would write and remove without touching anything.
Configuration
Section titled “Configuration”The model, stack, template, host, version, and local diagrams each resolve by precedence: a
command-line flag, then a MODELDESK_* environment variable, then a committed .modeldesk/config.json,
then (for the host only) a built-in default. A configured repository therefore runs modeldesk bundle pull with no
arguments, while CI can override any value per build with an environment variable.
.modeldesk/config.json, committed to your repository:
{ "model": "3f2b…-model-uuid", "stack": "respec", "template": "conceptueel-toc", "version": "1.0.0"}version is optional: include the name of one of the model’s published versions (created on its History
page) to pin the pull to that version, or omit it to follow the model’s current working state. See
Version your model.
| Setting | Flag | Environment variable | Config key | Default |
|---|---|---|---|---|
| Model | --model |
MODELDESK_MODEL |
model |
(required) |
| Stack | --stack |
MODELDESK_STACK |
stack |
(required) |
| Template | --template |
MODELDESK_TEMPLATE |
template |
(required) |
| Host | --host |
MODELDESK_HOST |
host |
modeldesk.io |
| Version | --version |
MODELDESK_VERSION |
version |
current state |
| Local diagrams | --local-diagrams |
MODELDESK_LOCAL_DIAGRAMS |
diagrams.local |
none |
modelis the model’s UUID (copy it from the model’s “Command-line access” panel in the app).hostdefaults tomodeldesk.io, so it is left out of the example above. Leave it out in a repository that pulls from CI too: a run holding a credential will not take its destination from the committed config.stackandtemplatetogether identify the document shape to pull. A template slug is unique only within its stack, so both are required: pass--stack/--template, set the env vars, or commit them. Runmodeldesk bundle templatesto list the validstack/templatepairs for a model.diagrams.localnames the local diagram templates whose diagrams a pull includes, one diagram per element (see Local diagrams). In the config it is one template id or an array of them,"diagrams": { "local": "<templateId>" }; the flag and the environment variable take one id or several separated by commas. A flag or environment variable replaces the config’s list rather than adding to it. Unlike the other settings, where an empty value is ignored, a flag or environment variable that is set but empty (--local-diagrams "",MODELDESK_LOCAL_DIAGRAMS=) means no local diagrams, whatever the config names: a CI variable that expands to nothing turns local diagrams off. Copy the id from the model’s Command-line access panel after you select a template under Local diagrams on the Content bundles page.- Machine credentials (
MODELDESK_CLIENT_ID,MODELDESK_CLIENT_SECRET) are read from the environment only and never belong in the committed config.
Two more keys serve notes. They are read from the config file only, and each folder is a path relative to the repository root:
notesDiris the notes folder. A pull places every Markdown file in it as a note, by its path, andmodeldesk note addcreates note files in it. It defaults tomd-notes/at the repository root, andnote add --diroverrides it for one note. It cannot be the repository root itself, lie in the content root or hold it, or be a symlink.publishDirslists the folders your document’s publish step copies, such as["data", "media", "js", "css"]for Geonovum’s NL-ReSpec-template. It has no default. When it is set, a pull warns about every image a note links outside these folders, since the published copy would miss it. See Images and the publish step.
Scripting and agents
Section titled “Scripting and agents”Every command has a machine-readable contract next to its text output, so a script, a CI job, or an AI agent can run the CLI and act on the result without parsing text.
JSON output
Section titled “JSON output”With --json, stdout carries exactly one JSON document and nothing else: an object whose first field
is schemaVersion (currently 1). Progress and other text meant for people is left out rather than
mixed in; notes and warnings go to stderr. The CLI prints the document on one line; the examples on
this page are formatted for reading.
- The shapes are stable. Fields are added over time, never renamed or removed.
- Help and version stay text, with or without
--json. - A result can come with a non-zero exit code.
auth statuswhen you are not logged in, or abundle pullwhose diagrams failed, still prints its document, so check the exit code as well. A command that fails without a result prints an error object instead.
For example, to list the template slugs of one stack:
modeldesk bundle templates --model <modelId> --stack respec --json | jq -r '.items[].template'conceptueelconceptueel-toclogischlogisch-tocErrors
Section titled “Errors”Without --json, a failure prints an error: line on stderr, followed by any details from the
server as an indented list. With --json, the CLI prints an error object instead, on one line, and
it is always the last line on stderr (a note or warning can come before it). For example, a run that
needs a login it cannot start:
{ "error": { "code": 6, "message": "Not logged in to modeldesk.io, and this run cannot open a browser to log in.", "hint": "Run 'modeldesk auth login' in a terminal, or 'modeldesk auth login --device' where no browser can reach this machine, then retry.", "retryable": false, "details": {} }}| Field | Content |
|---|---|
code |
The exit code; see Exit codes. |
message |
What went wrong. |
hint |
What to do about it, when the CLI knows. Left out otherwise. |
retryable |
true exactly when code is 7: the same command may succeed if you run it again. |
type |
The server’s problem type, such as change-validation-failed, when the ModelDesk API refused the request. Left out otherwise. |
requestId |
An ID that identifies the failed request on the server, when one is known. Left out otherwise. |
details |
The structured information the server sent with the problem, such as an errors list, passed on unchanged. Empty when there is none. |
Exit codes
Section titled “Exit codes”Every command exits with one of these codes. A script retries on 7, asks a person on 6, and treats any other non-zero code as final.
| Code | Meaning |
|---|---|
| 0 | Success. |
| 1 | Failure, generic or on the server. |
| 2 | Usage error: an unknown command or flag, or a missing, malformed or ambiguous argument. |
| 3 | Not found: the server has no such model or other resource (HTTP 404). |
| 4 | Validation or check failure: the input was refused, or a check you asked for failed. |
| 5 | Conflict: someone else changed the same thing first (HTTP 409). |
| 6 | Needs a person: a login (including a credential the server no longer accepts, HTTP 401) or a confirmation the run cannot ask for. |
| 7 | Transient, safe to retry: a network failure, HTTP 429, or a server error (5xx). |
Version 0.6.0 and earlier exited with code 1 on a usage error, such as an unknown command or flag. Later versions exit with code 2, so a script that checks for a usage error checks for 2. Codes are never renumbered, and 126, 127, and 128 plus a signal number are never used, because the shell reserves them.
Listings
Section titled “Listings”A command that lists rows (such as bundle templates or branch list) returns at most --limit rows, 50 by default (20 for model log). When
more rows exist, it says so and tells you how to continue: under --json, the document carries
truncated: true, a nextCursor, and a one-line hint; in text mode the hint goes to stderr as a
note: line, so the table on stdout stays clean. Pass the cursor back to get the next rows:
modeldesk bundle templates --model <modelId> --cursor <nextCursor>--all returns every row. Under --json it prints one JSON object per row, one per line (NDJSON),
instead of a single document.
Agent mode
Section titled “Agent mode”The CLI recognizes an AI agent host by an environment variable the host sets:
| Variable | Agent host |
|---|---|
CLAUDECODE, CLAUDE_CODE_CHILD_SESSION |
Claude Code (claude-code) |
CURSOR_AGENT |
Cursor (cursor) |
AI_AGENT |
Any agent; the value names it (agent when the value is just 1 or true) |
A variable counts as set unless it is empty or 0. Under an agent host:
-
Output is JSON by default, as if you passed
--json, and a one-line note on stderr says so. Pass--no-jsonfor text. When you pass--jsonyourself, the note is left out.note: running under claude-code, so output is JSON. Pass --no-json for text. -
The CLI never prompts (see Interactive runs): a command that needs a confirmation exits with code 6 unless you pass
--yes, and a command that needs a login exits with code 6 instead of opening a browser. -
Commits, merges and deletes are left to you. An agent commits only on a branch of its own, unless you allow more; see Agents commit on a branch of their own.
-
Requests name the agent host. Requests to the ModelDesk API carry it in their
User-Agentheader:modeldesk-cli/<version> (<host>), for examplemodeldesk-cli/0.3.0 (claude-code). -
Sign-in requests name the device. The requests that sign the CLI in carry
modeldesk-cli/<version> (<computer name>; <platform>). ModelDesk lists each CLI sign-in under that name, with when it signed in and when it was last used, on the account security page, where you can revoke any of them. A revoked CLI must sign in again; a token it already holds works for up to ten minutes.
The guide for your agent
Section titled “The guide for your agent”modeldesk agent-guide prints how an agent with a shell should work in a model: always write the ref
(<model>@<branch>), stage small steps with a message each, and end either with a hand-off for you to
review in your draft or with commits on a branch of its own for you to merge. It needs no login. Point
your agent at the command instead of copying the text, so the guide stays in step with the CLI.
Under an agent host the output is JSON, with the guide as the guide member. Pass
--no-json to print the Markdown itself:
modeldesk agent-guide --no-jsonInteractive runs
Section titled “Interactive runs”The CLI treats a run as interactive when stdin and stdout are both a terminal, CI is not set (a
value of false or 0 counts as not set), and no agent host is detected. Only an interactive run
asks a question or opens a browser to log in. In any other run (a pipe, a CI job, an agent):
- A command that needs a confirmation exits with code 6 and changes nothing, unless you pass
--yes. - Outside CI, a command that needs your login and finds no stored login that works exits with code 6
instead of opening a browser. Log in first with
modeldesk auth login, or withmodeldesk auth login --devicewhere no browser can reach the machine. In CI the CLI expects a service account, and without one it exits with code 1 and says what to configure; see Authenticate in CI.
bundle pull
Section titled “bundle pull”A pull is a full sync of the content root (for ReSpec, data/model/). It writes every
generated fragment, removes files a previous pull left orphaned, and renders and fetches the
diagrams, streaming the render progress to your terminal. The whole pull is pinned to a
single commit, so edits made while the pull runs cannot mix content from two states. Text lands
first: if the diagrams then fail to render or download, the text stays on disk, the pull exits with
code 1, and you can run it again.
Each diagram arrives as two files side by side under the same name: an SVG, whose elements the CLI
links to the sections that describe them, and a PNG, which the document shows when the SVG is
missing. The Diagrams: line of the plan a pull prints counts diagrams, not files. An SVG that
fails ModelDesk’s safety check is not written: the pull prints a warning naming the file and exits
with a non-zero status, as it does for any diagram file it could not fetch. A diagram that shows
no model element is left out: the pull writes neither of its files, takes its figure out of the
Markdown, removes the copies an earlier pull wrote, and lists the diagram by its SVG under
Left out. That is not an error, so the exit status stays zero. See
Diagrams in the bundle.
A pull also places your notes: Markdown files of your own in the notes folder (md-notes/), each at the path of
its element’s generated file, and any other files .modeldesk/notes.json assigns to elements. It records each
new note file in notes.json, so commit .modeldesk with the pulled text. It needs no earlier pull for this,
so it works the same in CI. It checks notes.json and the files it names before it asks the server for
anything, and stops before writing when a note cannot be placed, including a note file that matches no
element. With --dry-run it lists each note file it would record on an adopt line and each note it would
place on a fill line. See Add notes to a generated document.
modeldesk bundle pull # in a configured repository (model, stack, template from config)modeldesk bundle pull --model <modelId> --stack respec --template conceptueel-tocA pull also writes index.json beside the model’s index.md (data/model/index.json): every element
the document shows, with its anchor, the file that holds it, its kind and the elements it refers to, and
every diagram with the elements it draws, read from the diagram’s SVG. Commit it with the fragments. A pull
with --no-diagrams writes it without what each diagram draws. The ReSpec runtime reads it for its reading
features; see Add reading features to a generated document.
| Flag | Effect |
|---|---|
--model <id> |
The model’s UUID (required, unless set via env or config). |
--stack <id> |
The content stack to render (required; see bundle templates). |
--template <slug> |
The document shape within the stack (required; see bundle templates). |
--version <name> |
Pin a published model version for a reproducible pull (default: current state). |
--local-diagrams <ids> |
Include the diagrams of these local diagram templates, one per element (template ids, comma-separated). |
--no-diagrams |
Write text fragments only; skip the diagram render and fetch (a fast inner loop). |
--adopt |
Allow the CLI to prune a content root it did not previously manage. |
--allow-empty |
Permit a pull that returns no fragments (a genuinely emptied model). |
A pull also takes the global options, with this meaning:
| Option | Effect on a pull |
|---|---|
--host <host> |
Target a specific instance (default: modeldesk.io). |
--dry-run |
Preview the plan (writes, overwrites, removals, diagram count) and touch nothing. |
--yes |
Confirm an unusually large removal set. A run that is not interactive needs it for that removal; see Safe removal. |
--json |
Print a summary instead of the report. |
--no-diagrams is convenient while iterating on text, but any diagram data-include will 404 at
bake time, and the PNG it falls back to is missing too, until you run a full pull.
Local diagrams
Section titled “Local diagrams”When the model’s metamodel offers a local diagram template, --local-diagrams,
MODELDESK_LOCAL_DIAGRAMS or diagrams.local adds its diagrams to the pull: one diagram per element,
written beside the element’s file, with its figure first in the element’s section. See
Local diagrams. The plan line names them, as in
Pulling <modelId> (stack …, template …, local diagrams <templateId>) at …, and the Diagrams: line
counts them like any other diagram. A value that is not a template id stops the pull before it contacts
the server. An id that is not a local diagram template of the model’s metamodel is refused by the server,
and the pull prints its message, which names the local templates there are.
--no-diagrams and --dry-run keep the option: the text and the plan are those of a full pull, local
figures included, and the local diagram files an earlier full pull wrote stay. In a fresh checkout their
figures miss their files until a full pull, as every other diagram does under --no-diagrams. Keep the
option the same on every pull: a pull without it takes the local figures out of the text and removes their
files.
JSON summary
Section titled “JSON summary”With --json, a pull prints a summary instead of its report. Under --dry-run, the summary
describes what a real pull would do.
| Field | Content |
|---|---|
written |
The number of files written, text and diagram images together. |
overwritten |
How many of those already existed. |
removed |
The paths of the files removed. In a dry run: the orphaned files a real pull would consider removing. |
withheld |
The number of orphaned files left in place because the content root is not adopted yet (see --adopt). |
moved |
Files that moved since the previous pull, each as a from and a to path. |
diagrams |
The diagram count (each diagram once, though it arrives as an SVG and a PNG), a status (complete; partial when some files could not be fetched or written; failed when the render failed; skipped for a dry run, --no-diagrams, or a model with no diagrams), the failed paths, and in leftOut the SVG of each diagram the pull left out for showing no model element. |
notes |
Your notes: the note files adopted into notes.json, the number of slots filled, the entry names renamed, and the slot lines removed unfilled (slotsRemoved). |
warnings |
The warnings of the pull, in the order they occurred: about the removal (such as orphaned files left in place), your notes, and the diagrams (why a status is partial or failed). They also go to stderr. |
The summary also names what was pulled: the host, model, stack, stackVersion, and
template, the pinned commit, the version when you passed one, dryRun, and the syncMode.
Line endings
Section titled “Line endings”The CLI always writes bundle content with LF line endings. On Windows, a repository with
core.autocrlf=true converts them to CRLF on checkout while every pull writes LF again, so the same
files keep showing up as changed in git status no matter how often you commit them. Pin the
content root to LF in your repository’s .gitattributes:
data/model/** text eol=lfWindows-reserved names
Section titled “Windows-reserved names”Windows refuses files and folders named after its device names (CON, PRN, AUX, NUL, COM0
through COM9, and LPT0 through LPT9). To keep a bundle usable on every platform, ModelDesk
stops the pull with an error naming the element type when a metamodel type name would become a
folder with one of those names; rename that type in the metamodel. This is rare, and only custom
type names can trigger it. Element and diagram names need no attention: one that lands on a reserved
name gets a short id appended automatically, exactly as any other name collision does.
Safe removal
Section titled “Safe removal”A pull’s one destructive step, removing orphaned files, is guarded so a misconfiguration cannot delete files the CLI did not create:
- A pull that returns no fragments (usually a wrong model or template) writes and deletes nothing
and exits with an error; use
--allow-emptyonly for a genuinely emptied model. - In a repository the CLI already manages, it removes only files it recorded writing.
- A non-empty content root that the CLI has not managed before is not pruned until you confirm it
(interactively, or with
--adoptin CI). - An unusually large removal set (more files than the pull writes, or more than 100) needs
confirmation. At a terminal the CLI asks; in a run that cannot ask, the pull stops before writing
anything and exits with code 6, unless you pass
--yes. - All writes and removals stay within the content root; a manifest path that tries to escape it is refused.
The removal list is always shown: in the report, or in the removed field of the summary under
--json. In CI, run a --dry-run first as a safety gate.
bundle templates
Section titled “bundle templates”Lists the document templates available for a model: the shapes you can pass to --template. The
output is a table: the content STACK, the TEMPLATE slug (the --template value), and its display
NAME. A stack (for example respec) is the render engine and content root a template produces
for; a template slug is unique only within a stack, so the stack namespaces it. Read a row as
stack / template.
modeldesk bundle templates --model <modelId>STACK TEMPLATE NAMErespec conceptueel MIM conceptueelrespec conceptueel-toc MIM conceptueel (TOC hiërarchisch)respec logisch MIM logischrespec logisch-toc MIM logisch (TOC hiërarchisch)For an NL-SBB model the table has one row:
STACK TEMPLATE NAMErespec begrippenkader NL-SBB begrippenkaderTake a STACK / TEMPLATE pair from the table straight into a pull; the model and host are the
ones you already passed here:
modeldesk bundle pull --model <modelId> --stack respec --template logisch-tocPass --stack <id> to list only the templates of one stack.
modeldesk bundle templates --model <modelId> --stack respecThe list is a listing, so it also takes these flags:
| Flag | Effect |
|---|---|
--limit <n> |
Return at most this many rows (default: 50). |
--cursor <cursor> |
Continue a truncated listing from the nextCursor it returned. |
--all |
Return every row; with --json, one JSON object per line (NDJSON). |
With --json, the templates come back as items, each with its stack, template (the
--template value), display name, and id. The document also carries the model, the stack
filter when you passed one, and the listing fields: truncated, plus nextCursor and hint when
more rows exist.
note add
Section titled “note add”Creates a note file for an element at the path a pull reads it from, and adds it to .modeldesk/notes.json,
so the next pull places the note in one of the element’s slots. You can also create the file yourself, without
the CLI. See Add notes to a generated document for what notes are and where they
appear.
modeldesk note add <name> [--slot intro|after] [--heading <text>] [--dir <dir>] [--element <id>] [--stack <id>]modeldesk note add Gemeentegebiedmodeldesk note add Domein Bestuurlijk gebied --slot after --heading Afsluitingmodeldesk note add --element dafddbaf-9e2a-4eda-88f7-9fae3a47362f --slot afternote add reads the manifest of the last pull, .modeldesk/<stack>.manifest.json, and contacts no server, so
it needs no sign-in. When there is no manifest, as in a fresh checkout, it asks you to run
modeldesk bundle pull first.
It finds the element by name, ignoring case, and a name of several words can go unquoted. When several elements
have the name, note add lists them with their type and file and asks which one you mean; Ctrl-D cancels and
creates nothing. When it cannot ask, as in CI, it fails and lists their ids, so you can pass one with
--element. The parts shown inside an element’s file, such as attributes and relations, carry no slots, and
note add refuses them with that reason.
| Flag | Effect |
|---|---|
<name> |
The element’s name, as the document shows it. Not needed with --element. |
--slot <slot> |
intro (default) or after. |
--heading <text> |
The heading the note comes under, written as the note’s first line. Required for the after slot of a package or the model, refused for any other slot. |
--dir <dir> |
The folder for the note file, relative to the repository root (default: notesDir from the config, or md-notes/). |
--element <id> |
Pick the element by its id instead of its name. A name given as well is ignored. |
--stack <id> |
The stack whose manifest to read (default: MODELDESK_STACK, or stack from the config). |
The note file goes at the path of the element’s generated file under data/model/, in <dir> instead, ending
in .after.md for the after slot: md-notes/bestuurlijk-gebied/objecttype/gemeentegebied.md. For the after
note of a package or the model, its first line is the heading, <!-- heading: Afsluiting -->; any other note
starts empty. note add never overwrites an existing file, never replaces a slot that already has a note, and
never names a file another entry already names: it refuses each before writing anything. If it cannot write
notes.json, it removes the note file it just created.
With --json, note add prints the note’s file and slot, the element’s elementId, its name and the label the text output uses, and the heading when it wrote one.
template lint
Section titled “template lint”Checks a rendered document against the marker convention, the attributes a script in the document finds its elements and links by. It is the check the built-in templates are held to, for a document a template of your own rendered.
modeldesk template lint data/modelThe folder is the one that holds index.json beside the fragments. Every element the index lists has to
be declared in its file by the element that carries its markers (<h2 id="…" data-md-element="…">, or any
other element with both the id and the markers), every link to one of them has to carry data-md-ref, and no markers
may name an element the index leaves out. A heading or link written in Markdown cannot carry the markers,
so it counts as a problem. Each problem is printed with its file and line, and the command exits with code 4
when there is one. It contacts no server. With --json, it prints the folder as dir, the number of files
it read and of elements the index lists, and the problems, each with its kind, path, line and message.
Work on a branch
Section titled “Work on a branch”The CLI reads and edits a model on any of its branches, with the same draft the app shows you. For how branches and your draft fit together, see Drafts & branches.
Address a model at a ref
Section titled “Address a model at a ref”A command that works on one model takes the model as one argument: its id, followed by @ and a ref
when you want something other than the default. Names are not unique, so a model, a metamodel and an
extension are always addressed by id. modeldesk model list prints the ids of your models,
modeldesk metamodel list those of the metamodels, modeldesk metamodel extensions <metamodel> those
of a metamodel’s extensions, and modeldesk pin list <model> those of a model’s dependencies.
| Address | Reads or writes |
|---|---|
<model> |
Your draft while it holds changes, else the head of your working branch. |
<model>@draft |
Your draft. |
<model>@head |
The head of your working branch, without your draft. |
<model>@main |
The head of main. |
<model>@feat/x |
The head of the branch feat/x, by name, ignoring case. |
<model>@<commit id> |
That commit, for model tree, el show and search. |
modeldesk model tree <model>@feat/x --depth 2modeldesk el set <model>@feat/x SHACL/NodeShape abstract=true -m "NodeShape is only ever specialized"The address splits at the first @, so a branch name may contain @. A draft command (draft status, diff, undo, commit,
discard, rebase) also takes dataset/<id>, without a ref, because a dataset has no branches.
model show, model log, validate and pin list take @draft, @head or a branch, but not a commit.
model log without a ref lists the working branch, and model log <model>@draft lists the changes
staged in your draft. A few commands always read main and take no ref at all: model export,
model delete, describe, branch list, release list, and the model of pin set. A ref there,
@main included, is a usage error (exit code 2). model show reads the model’s identity at the ref,
and its overview and releases at main, and says so.
An address the command does not accept exits with code 2 before anything is sent. A branch name the
model does not have, or @draft when you hold no draft, exits with code 3.
Which branch a command works on
Section titled “Which branch a command works on”A command works on the ref its address names. When the address names none, it works on your
working branch: the branch your draft aims at, or main when you hold no draft. No setting,
environment variable or file in your directory changes this, and the app follows the same rule, so
the CLI and the app always agree on where you are.
Committing a draft deletes it, in the CLI and in the app alike. So after you commit a draft on
feat/x, you hold no draft, and commands without a ref work on main again. The commit says so:
Unaddressed invocations now default to main. Address 8d9a04e0-a822-4442-a40c-24cf67eec398@feat/x, or run: modeldesk draft open 8d9a04e0-a822-4442-a40c-24cf67eec398@feat/xTo keep working on a branch, write the ref in every command, or open your draft there again.
Open your draft on a branch
Section titled “Open your draft on a branch”modeldesk draft open <model>@<branch> aims your draft at the branch, so the commands that name no
branch stage there:
- A draft already on that branch is left as it is.
- A draft on another branch that holds no changes is discarded and opened on this one. That loses nothing.
- A draft with changes on another branch is refused with exit code 5. Commit or discard those changes first.
modeldesk draft open <model>@feat/xA write (an el command or model push) stages into your draft on the branch its address names.
With no draft, the first change opens one there. With a draft on another branch, the write is
refused with exit code 5 before anything is sent, and the message names the ways out: commit or
discard the changes on that branch, address the branch the draft aims at, or, when the draft holds
nothing, draft open the branch you want. A write never discards your draft.
The other draft commands act on your draft wherever it aims. Given a branch, as in
modeldesk draft commit <model>@feat/x, they first check that your draft aims there and exit with
code 5 when it does not, so a script cannot commit on the wrong branch. modeldesk draft status
shows the branch your draft aims at, how many changes it holds of the 500 a draft can hold, and what
a command without a ref reads right now.
modeldesk draft commit takes -m for the commit message. On a model you can leave it out: the
message is then made from the messages of the staged changes, oldest first. A dataset draft needs
-m. modeldesk model log <model> --changes lists, under each commit made from a draft, the changes
it held, each with where it came from (cli, mcp, web for the app, or api) and its message.
Create, compare and delete branches
Section titled “Create, compare and delete branches”| Command | Does |
|---|---|
branch list <model> |
Lists the branches, main first, with each head, the drafts that aim at it, and how many of its commits main does not have. A * marks your working branch. |
branch create <model>[@<from>] <name> [--open] |
Creates a branch at the head of your working branch, or of the branch the address names. --open then aims your draft at it, as draft open does. |
branch diff <model>[@<branch>] [--base <branch>] |
Shows what the branch changed since it split from main, or from --base, per element. |
branch delete <model>@<branch> [--force] |
Deletes the branch and every draft on it, whoever owns the draft. It asks first, or needs --yes when it cannot ask. |
branch create refuses a name another branch already has, in any case, with exit code 5, unless you
pass --exist-ok, which answers with the existing branch. It refuses draft, head, main and a
name shaped like a UUID with exit code 4, because an address could not reach such a branch.
branch delete refuses main (exit code 2). While other users’ drafts on the branch hold changes, or
the branch has commits main does not have, it exits with code 5 unless you pass --force, which
loses them. Deleting a branch needs a login or service account that may delete models.
Merge a branch
Section titled “Merge a branch”modeldesk branch merge <model>@<target> <source> merges the source branch into the target branch as
one commit. The target is always in the address. Preview the merge first with --dry-run:
modeldesk branch merge <model>@main feat/x --dry-runThe preview exits with code 0 when the merge would land without conflicts, 5 when the two branches
changed the same elements, and 4 when the merged model would break a rule that no choice of side
resolves. A merge with nothing to merge exits with code 0 and reports already-merged, so running it
again is safe.
Resolve conflicts with a file. With --json, the preview prints a report that is also the
resolution file. Save it, fill in take on each conflicting element, and pass the file back:
modeldesk branch merge <model>@main feat/x --dry-run --json > merge.json# edit merge.json: set "take" on each entrymodeldesk branch merge <model>@main feat/x --resolve merge.jsonEach entry in resolutions is one element both branches changed. Its take is target (keep the
target branch’s version), source (take the source branch’s version) or fields, with a take of
target or source on each field to pick field by field:
{ "elementId": "6dfdb74d-729b-408e-b71e-4596f2166db9", "label": "SHACL/NodeShape", "reason": "both-changed", "take": "fields", "fields": { "name": { "kind": "attribute", "base": ["NodeShape"], "target": ["NodeShape"], "source": ["Node"], "take": "source" } }}The CLI reads only the ids, the take values and the two branch heads back from the file. The other
values are there for you to read, and changing them changes nothing. --resolve - reads the file
from standard input. --take-others target or --take-others source takes every entry the file
leaves open from one side.
The file records the head of each branch the preview saw. If either branch moved since, the merge
exits with code 5, and you run the preview again. A merge that is refused with conflicts prints the
same report, so --json > merge.json gives you the file to fill in either way.
Resolve conflicts inline. At a terminal you can pick sides without a file:
--take <element>=source takes an element from a side, and --take <element>#<field>=source one
field of it. The element is its id, or its label path on the target branch. Inline picks need the two
heads the preview reported, as --expect <target-head> and --expect-source <source-head>, so they
apply only to what you reviewed.
modeldesk branch merge <model>@main feat/x --take SHACL/NodeShape#name=source --take-others target \ --expect <target-head> --expect-source <source-head>You can also merge in the app; see Work with branches.
Agents commit on a branch of their own
Section titled “Agents commit on a branch of their own”When an AI agent runs the CLI (see Agent mode), the CLI leaves to you what would put its work on a shared branch without your review:
- Commits (
draft commit, and--commiton a write ormodel push) are refused with exit code 6, except on a branch whose name starts withagent/. Such a branch is the agent’s own: it commits there as it goes, and you review and merge the branch in the app. - Merges, releases and pins (
branch merge,release create,pin set) are refused with exit code 6, also from or into anagent/branch.branch merge --dry-runruns. - Deleting a model or a branch is refused with exit code 6, always.
- Undoing, discarding or committing changes the agent did not make, such as yours in the app, is
refused with exit code 6, unless you give
draft undo,draft discardordraft committhe flag--any-surface.
To let an agent commit and merge anywhere without asking, set MODELDESK_ALLOW_COMMIT=1 in the
environment it runs in. Outside an agent host none of these refusals apply. They are a convention you
control, not a security boundary: what a login or service account may do is decided by ModelDesk
itself.
The agent starts with modeldesk branch create <model> agent/<topic> --open, works with
<model>@agent/<topic> in every command, and commits there. It shares your draft of the model, so
while your draft holds changes on another branch, the agent cannot open its own: commit or discard
yours first, or give the agent a service account, which has a draft of its own.
A workspace on a branch
Section titled “A workspace on a branch”modeldesk model pull <model>[@<branch>] <dir> writes the model as files to edit, and records the
branch in <dir>/.modeldesk/workspace.json. modeldesk model diff and modeldesk model push then
work on that branch, whatever your working branch is. A pull without a ref takes your working branch.
A commit is no ref to pull, since a workspace tracks a branch to push to (exit code 2).
When the branch or your draft moved since the pull, for example because someone edited the model in
the app, model push refuses with exit code 5 so it does not undo that edit, and you pull again. Two
moves do not count: committing the draft the files were pulled from, in the CLI or in the app, and a
move to exactly what your files already hold. In both cases model diff and model push report the
workspace as rebound and carry on with your local edits. When the branch was deleted, model diff
and model push exit with code 3 and name a branch with the same name if there is one; pull again to
use it.
Verify your setup
Section titled “Verify your setup”Against a running ModelDesk stack, confirm the interactive flow end to end:
- Run
modeldesk auth login. Your browser opens the sign-in page; complete it (including multi-factor authentication if enabled). - Run
modeldesk auth status. It reports the host and your logged-in identity. - Run
modeldesk bundle pull --model <modelId> --stack respec --template conceptueel-toc. It runs unattended (no second login), streams the diagram render progress, and writes the content underdata/model/. - Run
modeldesk auth logout. A subsequentmodeldesk auth statusreports that you are logged out.
See also Export a model for the in-app export options, and Download a content bundle for the same output from the app.