CLI Specification

See Use Cases for the functional overview of all CLI commands.

Command Overview

Command Description Status

bausteinsicht init

Initialize a new architecture model with default specification, sample model, and template

Implemented

bausteinsicht sync

Bidirectional synchronization between model and draw.io diagrams

Implemented

bausteinsicht validate

Validate the architecture model for consistency and report errors/warnings

Implemented

bausteinsicht watch

Watch mode — continuously sync on file changes

Implemented

bausteinsicht add element

Add a new element to the model (LLM-friendly)

Implemented

bausteinsicht add relationship

Add a new relationship to the model (LLM-friendly)

Implemented

bausteinsicht add view

Create a new view or modify a view’s include list (LLM-friendly)

Implemented

bausteinsicht add specification

Add element or relationship types to the specification (LLM-friendly)

Implemented

bausteinsicht rename

Rename an element and rewrite every reference to it (LLM-friendly)

Implemented

bausteinsicht update element

Change the title, technology, description or kind of an element (LLM-friendly)

Implemented

bausteinsicht remove element

Remove an element and its children, optionally with the references to it

Implemented

bausteinsicht remove relationship

Remove a relationship

Implemented

bausteinsicht export

Export diagram views to PNG or SVG using the draw.io CLI

Implemented

bausteinsicht export-table

Export element attributes as AsciiDoc or Markdown table per view

Implemented

bausteinsicht export-diagram

Export views as PlantUML C4 or Mermaid C4 text diagrams

Implemented

bausteinsicht export-sequence

Export dynamic views as PlantUML or Mermaid sequence diagrams

Implemented

bausteinsicht lint

Check the model against the architectural constraints defined in it

Implemented

bausteinsicht health

Compute an architecture health score (completeness, conformance, complexity)

Implemented

bausteinsicht graph

Analyze the relationship graph: cycles, centrality, dependency depth

Implemented

bausteinsicht stale

Flag elements that are old (beyond a threshold) and carry neither a lifecycle status nor an ADR link

Implemented

bausteinsicht status

List elements by lifecycle status

Implemented

bausteinsicht find

Full-text search over elements, relationships, and views

Implemented

bausteinsicht show

Show all details of a single element

Implemented

bausteinsicht snapshot

Save, list, diff, restore, and delete versioned model snapshots

Implemented

bausteinsicht diff

Compare the model’s as-is and to-be sections

Implemented

bausteinsicht changelog

Generate an architecture changelog between two versions

Implemented

bausteinsicht import

Import a model from Structurizr DSL or LikeC4

Implemented

bausteinsicht generate-template

Generate a draw.io template from the specification

Implemented

bausteinsicht layout

Compute hierarchical layout and write positions back to draw.io

Implemented

bausteinsicht overlay

Apply/list/remove metric heatmap overlays on the diagram

Implemented

bausteinsicht repl

Interactive shell for editing the model

Implemented

bausteinsicht adr

List and show Architecture Decision Records linked to elements

Implemented

bausteinsicht workspace

List, merge, validate and fetch (remote sources) multi-model workspaces

Implemented

bausteinsicht schema

Generate the JSON Schema from the Go model types

Implemented

bausteinsicht --version

Display version number

Implemented

Global Flags

These flags are available on all subcommands via persistent flags on the root command.

Flag Description Default

--format text|json

Output format. json produces machine-readable output suitable for LLM and scripting use. Errors in JSON mode are written to stderr as {"error": "…​", "code": N}.

text

--model <path>

Path to the model file (.jsonc). When omitted, auto-detection scans the current directory for a single *.jsonc file; if more than one is present, the command aborts and asks for --model (see Auto-Detection Behavior). The path may be relative and contain .. (a model in the parent directory), or absolute; the same holds for --template (#700).

auto-detect

--template <path>

Path to a custom draw.io template file. Must have a .drawio extension. When omitted, the built-in default template is used.

built-in template

--verbose

Enable verbose output. Verbose messages are written to stderr so they do not interfere with JSON output on stdout.

false

Note
--version is a root-level flag only, not a global flag. It is used as bausteinsicht --version and prints the version string.

Auto-Detection Behavior

When --model is not specified, every command that requires a model file invokes auto-detection (health, graph, status, stale, diff, changelog, snapshot, overlay and adr included, #692):

  1. The current working directory is scanned for files matching *.jsonc.

  2. If exactly one .jsonc file is found, it is used.

  3. If more than one .jsonc file is found, the command aborts with exit code 2 and the message multiple .jsonc files in <dir> — use --model to select one. It does not silently pick one, because the tool mutates files and synchronizes — operating on the wrong model must never happen by accident.

  4. If no .jsonc file is found, the command exits with code 2 and the message no model file found in <dir> (looked for *.jsonc) — use --model to select one.

Every command prints these messages as written, without a prefix: they all use one helper for the detection (#692, #774).

Concurrent Use

Commands that change the model (add element|relationship|view|specification|add-from-pattern, update, rename, remove, sync, and every sync cycle of watch) hold an exclusive operating-system file lock on <model>.lock from before they read the model until after they have written it, so parallel runs no longer overwrite each other’s changes (#712). The system releases the lock when the process ends, however it ends, and keeps it while the process is suspended, so there is no time limit and no takeover. A waiting command retries for up to 30 seconds and then fails with exit code 2, naming the lock file and the process that holds it. The lock file stays after the command (it holds only the process ID of the last owner); it can be added to .gitignore. The lock path must be a regular file; a symbolic link there is refused. The lock is advisory and does not cover repl (its save writes the whole session), import --force (it replaces the output file without taking the lock, so importing over a model that another command is changing can lose either write) and programs that edit the file directly.

Writing Files

The model, the draw.io diagram and the other files that a command changes are written atomically: a temporary file next to the target is written and renamed over it. A target that is a symbolic link is updated in place (#723). A target that is read-only (no write bit for its owner) is not replaced: the command fails with exit code 2 and file is read-only: <path>, and the file is left as it is (#724). The replacing file gets the mode of the file it replaces, so 0664 stays 0664; a new file is created with mode 0600.

Text that a command inserts into the model (add element|relationship|view|specification, the comment-preserving patches) gets the line ending that most lines of the file have: a model with CRLF line endings stays CRLF, also inside a value that spans several lines, and a model with LF stays free of CR; when the whole file is rewritten (the fallback that announces note: model rewritten, comments and formatting were not preserved), the line endings of the file are kept as well (#729).

Exit Codes

Code Meaning

0

Success

1

Validation error, sync conflict, duplicate element/relationship, or partial export failure

2

File not found, I/O error, invalid arguments, or missing prerequisites

Detailed Command Specifications

bausteinsicht init

Initializes a new Bausteinsicht project in the current directory by creating a sample model, a default template, an initial draw.io diagram, and the sync state file.

Flags:

  • --generate-template — Generate the template from the model’s specification instead of writing the built-in default template.

Created files:

  • architecture.jsonc — sample architecture model

  • template.drawio — default draw.io template

  • architecture.drawio — initial diagram generated via forward sync

  • .bausteinsicht-sync — sync state file

Behavior:

  • If any of the four files already exist, the command aborts with exit code 2.

  • After writing the model and template, an initial forward sync is performed to generate the draw.io diagram.

  • A page is created for each view defined in the sample model.

Exit codes:

  • 0 — project initialized successfully

  • 2 — file already exists, or I/O error

Example:

$ bausteinsicht init
Initialized Bausteinsicht project:
  - architecture.jsonc
  - template.drawio
  - architecture.drawio
  - .bausteinsicht-sync

$ bausteinsicht init --format json
{"files":["architecture.jsonc","template.drawio","architecture.drawio",".bausteinsicht-sync"],"success":true}

bausteinsicht validate

Validates the architecture model file for consistency. Reports both errors and warnings.

Flags: No command-specific flags. Uses global flags only.

Behavior:

  • Loads the model (via --model or auto-detection).

  • Runs validation checks including referential integrity and model consistency.

  • In --verbose mode, prints element/relationship/view counts to stderr before validation.

  • Warnings are printed with WARNING: prefix; errors with ERROR: prefix.

  • Keys that no field of the model knows are warnings, not errors, because the model is still usable: WARNING: [model.x] unknown field "titel" (did you mean "title"?), and [(top level)] unknown top-level key "modle" (did you mean "model"?). The closest field name within two edits is suggested. Such keys are dropped when the file is rewritten (update, rename), so the warning is the only notice. The free-form maps meta, style and metadata may hold any keys and are not checked (#725).

JSON output structure:

{
  "valid": true,
  "errors": [],
  "warnings": [
    {"path": "relationships[0]", "message": "..."}
  ]
}

Exit codes:

  • 0 — model is valid (may include warnings)

  • 1 — validation errors found

  • 2 — model file not found or cannot be loaded

Example:

$ bausteinsicht validate
Model is valid.

$ bausteinsicht validate --model my-arch.jsonc --verbose
Validating model: my-arch.jsonc
  5 elements, 3 relationships, 2 views
Model is valid.

$ bausteinsicht validate --format json
{
  "valid": true,
  "errors": [],
  "warnings": []
}

bausteinsicht sync

Runs one bidirectional synchronization cycle between the architecture model and the draw.io diagram.

Flags:

  • --relayout — Re-apply auto-layout to all view pages, resetting element positions to the layout engine’s computed positions. Without this flag, existing element positions are preserved.

  • --mermaid — Also write Mermaid diagrams of the views to a Markdown file after syncing.

  • --mermaid-output <path> — Output file for the Mermaid diagrams (default architecture.md). Implies --mermaid.

  • --drawio <path> — The diagram of this model (default architecture.drawio next to the model, #650).

  • --sync-state <path> — The sync state of this model (default .bausteinsicht-sync next to the model, #650).

Behavior:

  • Loads the model, draw.io document, sync state, and template.

  • Validates the model before syncing. If validation fails, the sync is aborted with exit code 1.

  • If the draw.io file is missing or has no diagram pages, it is recreated from the template and sync state is reset.

  • Pages are created for new views and orphaned pages (views removed from model) are deleted.

  • New view pages are appended in a fixed order: views without a scope (landscape and context views) first, then the scoped views, each group sorted by view key. The model file is read into a map, so the declaration order is not available; the same order is used by init, watch and for the files export writes, so regenerating architecture.drawio from the same model gives the same file and draw.io opens on the first context view (#683). Pages that already exist keep their position.

  • The title, technology and description of an element and the label of a relationship are written into html=1 text cells as HTML: <, >, & and " are escaped, so R&D <Team> is shown as typed and not read as a tag by draw.io. Reading back (reverse sync) decodes the entities again; text that contains no entity is read as it is, so files written before this rule keep working. The sub-cells and connectors get html=1 in their style if the template lacks it (#699), also when a connector’s style is replaced or the connector is re-keyed. Cells without html=1 show their value literally and are read without decoding. An element with a tooltip takes its description from the tooltip, so an edit of the description sub-cell does not reach the model for such an element.

  • Forward sync propagates model changes to draw.io; reverse sync propagates draw.io changes back to the model.

  • Conflicts are resolved with model wins strategy.

  • Model saves preserve JSONC comments and key ordering when possible (patch save), falling back to full save for structural changes.

Derived file paths: Unless --drawio and --sync-state say otherwise, the draw.io file and sync state file paths are derived from the model file location:

  • <model-dir>/architecture.drawio

  • <model-dir>/.bausteinsicht-sync

One model per directory: The model, its diagram and its sync state form one unit with these default names; the intended unit of work is one model per directory, and several perspectives on one architecture are views (one page per view, ADR-009), not several models. A directory with more models (--model a.jsonc) gives each its own files with --drawio and --sync-state; otherwise two models would share one diagram and one state. The sync state records the file name of the model it was written for (model_file). sync, watch and rename refuse a state that belongs to another model with exit code 2 and a message that names both models and the two flags (rename then leaves the diagram untouched and prints its usual note); a state without that field (written by an earlier version) is accepted and gets it at the next save. A path given by flag is a written file and must not contain .. (exit code 2) (#650).

JSON output structure:

{
  "forward_added": 2,
  "forward_updated": 1,
  "forward_deleted": 0,
  "reverse_added": 0,
  "reverse_updated": 0,
  "reverse_deleted": 0,
  "conflicts": 0
}

Exit codes:

  • 0 — sync completed without conflicts

  • 1 — sync completed but conflicts were detected (resolved with model wins), or model validation failed

  • 2 — file not found or I/O error

Example:

$ bausteinsicht sync
Forward (model -> draw.io): 3 added, 0 updated, 0 deleted

$ bausteinsicht sync --verbose
Syncing model: architecture.jsonc
  5 elements, 3 relationships, 2 views
Forward sync: 2 elements created, 1 updated, 0 deleted; 1 connectors created, 0 updated, 0 deleted
Already in sync. No changes.

$ bausteinsicht sync --format json
{
  "forward_added": 0,
  "forward_updated": 0,
  "forward_deleted": 0,
  "reverse_added": 0,
  "reverse_updated": 0,
  "reverse_deleted": 0,
  "conflicts": 0
}

bausteinsicht watch

Watches the model and draw.io files for changes and automatically runs a sync cycle on each detected change.

Flags:

  • --mermaid — Also write Mermaid diagrams of the views to a Markdown file after each sync.

  • --mermaid-output <path> — Output file for the Mermaid diagrams (default architecture.md). Implies --mermaid.

  • --drawio <path>, --sync-state <path> — As for sync (#650).

Behavior:

  • Loads the model path (via --model or auto-detection) and derives the draw.io path (or takes --drawio).

  • Both files must exist before the watcher starts (exit code 2 otherwise).

  • Uses file system notifications with debouncing to detect changes.

  • On each change, runs a full sync cycle (same logic as bausteinsicht sync).

  • Blocks until SIGINT or SIGTERM is received, then stops gracefully.

  • The watcher suppresses sync-triggered file events to avoid infinite loops.

Exit codes:

  • 0 — watcher stopped gracefully via signal

  • 2 — model or draw.io file not found, or watcher creation failed

Example:

$ bausteinsicht watch
Watching architecture.jsonc and architecture.drawio...
[14:32:05] Sync triggered by architecture.jsonc
Forward (model -> draw.io): 1 added, 0 updated, 0 deleted
^CStopped watching.

$ bausteinsicht watch --model path/to/model.jsonc
Watching path/to/model.jsonc and path/to/architecture.drawio...

bausteinsicht add element

Adds a new element to the architecture model. Designed for LLM-driven workflows.

Flags:

Flag Description Required Default

--id

Unique identifier for the element. Must match [a-zA-Z][a-zA-Z0-9_-]* (no dots).

Yes

 — 

--kind

Element kind as defined in the model’s specification section.

Yes

 — 

--title

Display title for the element. Must not be empty.

Yes

 — 

--parent

Parent element ID in dot notation (e.g., webshop.backend). The parent must exist and its kind must be a container.

No

(top-level)

--technology

Technology description for the element.

No

(empty)

--description

Element description.

No

(empty)

Behavior:

  • Validates the ID format, kind against the model specification, and parent existence.

  • Checks for duplicate elements at the target level.

  • Uses comment-preserving insertion to update the JSONC file. If patching fails it falls back to a full save and prints note: model rewritten, comments and formatting were not preserved to stderr (#635).

  • The full element ID is <parent>.<id> when a parent is specified, or just <id> at the top level.

Exit codes:

  • 0 — element added successfully

  • 1 — invalid ID, unknown kind, parent not found, parent is not a container, or duplicate element

  • 2 — model file not found or I/O error

Example:

$ bausteinsicht add element --id api --kind component --title "REST API" \
    --parent webshop --technology "Go/Gin"
Added element 'webshop.api' (kind: component) to model.

$ bausteinsicht add element --id customer-portal --kind system --title "Customer Portal" \
    --format json
{"id":"customer-portal","kind":"system","title":"Customer Portal"}

bausteinsicht add relationship

Adds a new relationship between two existing elements. Designed for LLM-driven workflows.

Flags:

Flag Description Required Default

--from

Source element in dot notation (e.g., webshop.api).

Yes

 — 

--to

Target element in dot notation (e.g., webshop.db).

Yes

 — 

--label

Relationship label displayed on the connector.

No

(empty)

--technology

Protocol or technology shown on the arrow, e.g. HTTPS/JSON (#642).

No

(empty)

--kind

Relationship kind as defined in the model’s specification section.

No

(empty)

--description

Relationship description.

No

(empty)

Behavior:

  • Validates that both --from and --to elements exist in the model.

  • If --kind is specified, validates it against the model’s specification.

  • Checks for duplicate relationships: the same from, to, kind and label as an existing relationship is refused; another label (or kind) makes another relationship, as in validate (BR-012, #697).

  • A relationship of an element to itself is added; if the element’s kind is not a container kind in the specification, a warning <id> is related to itself, but its kind "<kind>" is not a container kind is written to stderr.

  • Uses comment-preserving array append to update the JSONC file. If patching fails it falls back to a full save and prints note: model rewritten, comments and formatting were not preserved to stderr (#635).

Exit codes:

  • 0 — relationship added successfully

  • 1 — element not found, unknown kind, or duplicate relationship

  • 2 — model file not found or I/O error

Example:

$ bausteinsicht add relationship --from webshop.api --to webshop.db \
    --label "reads/writes" --kind uses
Added relationship: webshop.api -> webshop.db (reads/writes)

$ bausteinsicht add relationship --from webshop.api --to webshop.db --format json
{
  "from": "webshop.api",
  "to": "webshop.db"
}

bausteinsicht add view

Creates a new view or modifies an existing view’s include list. Designed for LLM-driven workflows to dynamically filter architecture diagrams.

The <view-key> argument must match [a-zA-Z][a-zA-Z0-9_-]* (the same identifier form as element IDs and specification keys). Dots are not allowed — they are reserved as element-hierarchy separators.

Flags:

Flag Description Required Default

--scope

Parent element ID to set the view’s scope (drill-down level).

No

(none)

--include

Element to include in the view (repeatable, e.g., --include elem1 --include elem2). Supports wildcard patterns like system.*.

No

(empty)

--title

View title (display name) (required for new views).

No

(empty)

--description

View description.

No

(empty)

Behavior:

  • For new views: requires --title; creates view with all specified fields.

  • For existing views: merges fields:

    • --title, --scope, --description update respective fields (if specified)

    • --include elements are appended to the existing include list (deduplicated); the order of the existing entries is kept

  • Validates that scope element exists (if specified).

  • Validates that all include elements exist (if specified, excluding wildcard patterns).

  • The text output says what happened: View '<key>' added to model for a new view, View '<key>' updated (include: +<id>, …​) for an existing one (include list unchanged if nothing was added), the entries that were already in the list (Already included), and the include list as it is now (#704). The JSON output has created and added for the same.

  • Uses comment-preserving updates for the JSONC file (#635): a new view is inserted into views; for an existing view only the given fields are replaced and new include entries are appended. Comments, key order and the formatting of everything else stay as they are. If patching fails it falls back to a full save and prints note: model rewritten, comments and formatting were not preserved to stderr.

Exit codes:

  • 0 — view added or updated successfully

  • 1 — scope or include element not found, or missing title for new view

  • 2 — model file not found or I/O error

Example:

# Create a new system context view
$ bausteinsicht add view context \
  --include system external_system user \
  --title "System Context"
View 'context' added to model
  Title: System Context
  Includes: [system external_system user]

# Create a nested container view
$ bausteinsicht add view containers \
  --scope system \
  --include "system.*" \
  --title "Containers"
View 'containers' added to model
  Title: Containers
  Scope: system
  Includes: [system.*]

# Merge: add element to existing view's include list
$ bausteinsicht add view containers --include system.logging
View 'containers' added to model
  Includes: [system.* system.logging]

# Merge: update title without changing include
$ bausteinsicht add view containers --title "Updated Containers"
View 'containers' added to model
  Title: Updated Containers

# JSON output
$ bausteinsicht add view context --title "System Context" --include system --format json
{
  "view_key": "context",
  "created": true,
  "title": "System Context",
  "scope": "",
  "include": ["system"],
  "added": ["system"]
}

# JSON output when merging into an existing view: the view after the change
$ bausteinsicht add view context --include user --format json
{
  "view_key": "context",
  "created": false,
  "title": "System Context",
  "scope": "",
  "include": ["system", "user"],
  "added": ["user"]
}

The JSON result always describes the view as it is after the change, not just the arguments of this call: title, scope and include are the resulting values (description is added when set), created tells whether the view is new, and added lists the --include entries that were not in the view before (an empty array if none).

bausteinsicht add add-from-pattern

bausteinsicht add add-from-pattern <pattern-id> --id <base> [--title <title>] [--prefix <prefix>]
bausteinsicht add pattern list

Expands a pattern of specification.patterns into elements and relationships of the model: the top-level elements of the pattern are added at the top level of the model, their children below them, and the pattern’s relationships to the relationships. {base} is replaced by --id ({BASE} upper-cased, {Title} by --title, default the ID), and --prefix turns {base} into <prefix>-<base>.

  • Refuses the pattern (exit code 2, nothing written) if a new top-level ID already exists in the model. The children live below the new elements, so an unrelated element with the ID of a child is no conflict (#702).

  • Prints every created element with its full ID, children below their parent (pay, pay.db), then the relationships.

  • --id (with --prefix) and the IDs the pattern derives from it must follow the ID rules of add element (exit code 1).

  • The expanded model is validated before it is saved: a pattern that would add an element of an unknown kind, a relationship to an element that does not exist or any other new validation error is refused with exit code 1, the new errors are listed on stderr and nothing is saved. Errors the model had before do not count (#703).

  • Known gap: patterns are only added at the top level (no --parent).

bausteinsicht add specification

Adds new element or relationship types to the model’s specification. Enables definition of custom architecture notations.

The new type is inserted into specification.elements or specification.relationships (the section is created if it does not exist yet) without rewriting the rest of the file: comments, key order and formatting stay as they are (#635). If patching fails, the command falls back to a full save and prints note: model rewritten, comments and formatting were not preserved to stderr.

The <key> names the kind and must match [a-zA-Z][a-zA-Z0-9_-]* (letters, digits, hyphens, underscores — the same identifier form as element IDs). Dots are not allowed — they are reserved as element-hierarchy separators. camelCase kinds such as boundaryObject or applicationService are supported.

Add Element Type

Adds a new element kind to the specification.

Command: bausteinsicht add specification element <key>

Flags:

Flag Description Required Default

--notation

Display notation/name for this element type (e.g., "Custom Component").

Yes

 — 

--description

Description of this element type.

No

(empty)

--container

Whether this element can contain child elements.

No

false

Exit codes:

  • 0 — element type added successfully

  • 1 — invalid key format or duplicate element type

  • 2 — model file not found or I/O error

Example:

$ bausteinsicht add specification element custom_box \
  --notation "Custom Component" \
  --description "A custom element type" \
  --container
Element type 'custom_box' added to specification
  Notation: Custom Component
  Description: A custom element type
  Container: yes

$ bausteinsicht add specification element data_store \
  --notation "Data Store" --container --format json
{
  "key": "data_store",
  "notation": "Data Store",
  "container": true
}
Add Relationship Type

Adds a new relationship kind to the specification.

Command: bausteinsicht add specification relationship <key>

Flags:

Flag Description Required Default

--notation

Display notation/label for this relationship type (e.g., "calls").

Yes

 — 

--description

Description of this relationship type.

No

(empty)

--dashed

Whether this relationship is displayed as a dashed line.

No

false

Exit codes:

  • 0 — relationship type added successfully

  • 1 — invalid key format or duplicate relationship type

  • 2 — model file not found or I/O error

Example:

$ bausteinsicht add specification relationship depends_on \
  --notation "depends on" \
  --dashed
Relationship type 'depends_on' added to specification
  Notation: depends on
  Style: dashed

$ bausteinsicht add specification relationship async_call \
  --notation "calls (async)" --format json
{
  "key": "async_call",
  "notation": "calls (async)",
  "dashed": false
}

bausteinsicht rename

Renames an element and rewrites every reference to it, so that IDs no longer have to be changed by hand in six places (#634).

Flags:

Flag Description Required Default

--id

Element to rename, in dot notation (e.g. shop or shop.web).

Yes

 — 

--to

New key of the element: its new last path segment, without dots (--id shop.web --to frontend gives shop.frontend).

Yes

 — 

--dry-run

Show what would change without saving.

No

false

--drawio, --sync-state

The diagram and the sync state to migrate, as for sync (#650).

No

next to the model

Behavior:

  • Moves the element, with its children, to the new key.

  • Rewrites every reference to the element and to its children: relationship from/to, view scope, include and exclude (including patterns such as shop.*), message steps of dynamic views, and from/to selectors of constraints.

  • Lists every rewritten location (path, from, to); with --format json as { "dry_run": false, "changes": [ …​ ] }.

  • Validates the model before saving: if the change would introduce validation errors, they are printed and nothing is saved. Errors that were already in the model do not block the command.

  • The change is written as a patch of the file text (#685): comments and formatting stay, a field is replaced in place (or inserted, or removed when it is set to an empty value), an element or relationship is removed together with the comment lines directly above it, and a rename changes the key and every reference in place. The patched text is parsed again and must hold exactly the model the command produced; only if the patch cannot be applied or that check fails is the file rewritten as a whole (note: model rewritten, comments and formatting were not preserved on stderr).

  • After the model is saved, the rename is carried into architecture.drawio and .bausteinsicht-sync next to the model (under the same lock): the bausteinsicht_id of the cells of the element and of its children, the page-scoped cell IDs (<view>--<id>), their sub-cells and icons, the connectors that start or end at them (their IDs rel-<from>-<to>-<index> and source/target), and the element, relationship and rendered-element entries of the sync state. Position, size and style are kept: the next sync reports no deleted or added cells and no warning about the old ID (#686). Without --dry-run it prints note: N draw.io cell(s) of <old> renamed to <new>, their position and style are kept on stderr. If there is no draw.io file, nothing is migrated; if it cannot be read or written, the model rename still stands and note: the draw.io file was not migrated (…​) is printed. If the file could not be written, it is unchanged and the next sync falls back to deleting and re-creating the cells of the element; if it is malformed, sync fails to load it as well until it is repaired, restored or deleted (a deleted file is recreated from the template). The migration is skipped for --dry-run.

Exit codes: 0 — renamed (or dry run); 1 — element not found, new key invalid or already taken, or the change would make the model invalid; 2 — model file not found or I/O error.

bausteinsicht update element

Changes fields of an existing element.

Flags: --id (required, dot notation); at least one of --title, --technology, --description, --kind (the kind must be defined in specification.elements; an empty value for --technology or --description clears the field); --dry-run.

Behavior: Only the fields that are given are changed; fields that already have the requested value are not reported. Validation, JSON output, saving and exit codes work as for rename.

bausteinsicht remove element

Removes an element and its children.

Flags: --id (required, dot notation), --cascade, --dry-run.

Behavior:

  • If relationships, view include/exclude entries or dynamic view steps still reference the element, the command fails and lists them. With --cascade it drops them: the relationships, the view entries and the message steps; a dynamic view that is left without a message step is removed as well. Everything that is dropped is listed.

  • A view whose scope is the element, or a constraint whose from/to names it, always blocks the removal (even with --cascade): change the view or the constraint first.

  • Validation, JSON output, saving and exit codes work as for rename.

bausteinsicht remove relationship

Removes a relationship.

Flags: --from and --to (required, dot notation), --label (only remove the relationship with this label; default: the first relationship between the two elements), --dry-run.

Behavior: Fails with exit code 1 if no such relationship exists. Validation, JSON output, saving and exit codes work as for rename.

bausteinsicht export

Exports draw.io diagram views to image files (PNG or SVG) using the draw.io CLI.

Flags:

Flag Description Required Default

--image-format

Image format for export: png or svg.

No

png

--view

Export only a specific view by its key. When omitted, all views are exported.

No

(all views)

--drawio

The diagram to export (#650).

No

<model-dir>/architecture.drawio

--output

Output directory for exported files.

No

. (current directory)

--scale

Export scale factor (e.g. 2.0 for retina, 3.0 for print). Values greater than 1 require a hardware GPU.

No

1

--embed-diagram

Embed the draw.io XML source in the exported image file.

No

false

--drawio-path

Explicit path to the draw.io CLI binary. Overrides BAUSTEINSICHT_DRAWIO_PATH and auto-detection. Exits with code 2 if the path does not exist.

No

(auto-detected)

--timeout

Time limit for the export of one view, as a Go duration (60s, 2m). When draw.io has not finished by then it and its child processes are killed and the view is reported as failed (#716). 0 means no limit.

No

60s

--no-validate

Export even if the model has validation errors. By default the export aborts with the same errors as validate and exit code 1 (#636).

No

false

draw.io binary resolution (highest precedence first):

  1. --drawio-path flag — must point at an existing file

  2. BAUSTEINSICHT_DRAWIO_PATH environment variable — must point at an existing file

  3. Auto-detection: drawio-export or drawio or draw.io on PATH, then platform-native install paths (Scoop, Chocolatey, Homebrew, standard installer)

Behavior:

  • Loads the model and draw.io document to determine which pages to export.

  • Detects the draw.io CLI binary automatically. Exits with code 2 if not found.

  • Creates the output directory if it does not exist.

  • Output files are named architecture-<view-key>.<format> (e.g., architecture-context.png).

  • Each view page is exported individually; partial failures are reported.

  • A view whose draw.io process does not finish within --timeout is reported as view "<key>": draw.io export timed out after <duration>; see <troubleshooting link> followed by everything draw.io printed (stdout and stderr) before it was stopped. The process group of the draw.io wrapper is killed, so no xvfb-run/drawio child stays behind. The other views are still exported (#716).

Note
Use --image-format svg when element link fields must remain clickable in the output. SVG export preserves link attributes as native <a href> elements, which are clickable when the SVG is embedded in HTML or processed by Asciidoctor PDF. PNG export is a raster format and discards all link information.
Note
SVG export always passes draw.io’s --embed-svg-fonts false internally (not a flag; not applicable to PNG). Without it, draw.io falls back to rasterizing each text label as an embedded base64 PNG whenever it can’t embed a font subset headlessly, inflating file size by roughly 20× for no visual benefit (#560). Text then relies on the viewer’s system fonts — the normal trade-off for unembedded SVG text, and how GitHub’s own AsciiDoc blob preview renders these diagrams.

JSON output structure (the errors array is present only on partial failure):

{
  "files": ["architecture-context.png", "architecture-container.png"],
  "success": true
}

Exit codes:

  • 0 — all views exported successfully

  • 1 — one or more exports failed (partial failure)

  • 2 — unsupported format, model/diagram not found, draw.io CLI not available, or no views to export

Example:

$ bausteinsicht export
Exported: ./context.png
Exported: ./container.png

$ bausteinsicht export --image-format svg --output docs/images --view context
Exported: docs/images/context.svg

$ bausteinsicht export --format json --embed-diagram
{
  "files": ["./context.png"],
  "errors": [],
  "success": true
}

bausteinsicht export-table

Exports element attributes as an AsciiDoc or Markdown table per view or as a combined table across all views.

Flags:

Flag Description Required Default

--view

Export only a specific view by its key. When omitted, all views are exported.

No

(all views)

--table-format

Table output format: adoc (AsciiDoc) or md (Markdown).

No

adoc

--output

Output directory for exported files. When omitted, the table is written to stdout.

No

(stdout)

--combined

Export a single combined table with elements from all views, deduplicated.

No

false

--no-validate

Export even if the model has validation errors. By default the export aborts with the same errors as validate and exit code 1 (#636).

No

false

Behavior:

  • Loads the model and resolves view elements.

  • For each view, generates a table with columns: ID, Kind, Title, Technology, Description.

  • Elements are sorted alphabetically by ID within each table.

  • Without --output, the table(s) are written to stdout. With --output <dir>, files are written there and the output filenames depend on the selection:

    • A single view (--view <key>) → <view-key>-elements.adoc (or .md).

    • All views, no --combined → one file all-views-elements.adoc (or .md) covering every view.

    • --combined → one deduplicated file elements.adoc (or .md).

  • Creates the output directory if it does not exist.

JSON output structure — --format json always emits an array of element rows on stdout (not a file list), with or without --output. With --output <dir>, the same rows are additionally written to all-views-elements.json, <view-key>-elements.json or elements.json (same selection rules as above) and Exported: <absolute path> is printed to stderr (#631):

[
  { "id": "customer", "title": "Customer", "kind": "actor", "description": "..." },
  { "id": "webshop.api", "title": "REST API", "kind": "container", "technology": "Go", "description": "..." }
]

Exit codes:

  • 0 — table(s) exported successfully

  • 1 — one or more exports failed (partial failure)

  • 2 — model file not found, invalid format, or no views to export

Example:

$ bausteinsicht export-table --view context        # writes to stdout
=== System Context
...

$ bausteinsicht export-table --table-format md --output docs/tables --view context
Exported: docs/tables/context-elements.md

$ bausteinsicht export-table --combined --output docs/tables
Exported: docs/tables/elements.adoc

$ bausteinsicht export-table --view context --format json
[
  { "id": "customer", "title": "Customer", "kind": "actor", "description": "..." }
]

bausteinsicht export-diagram

Exports views as text diagrams in one of several formats (C4-PlantUML, Mermaid, Graphviz DOT, D2, standalone HTML, or Structurizr DSL).

Flags:

Flag Description Required Default

--view

Export only a specific view by its key. When omitted, all views are exported. Not supported with --diagram-format structurizr (which always exports the whole workspace).

No

(all views)

--diagram-format

Diagram output format: plantuml, mermaid, dot, d2, html, or structurizr.

No

plantuml

--output

Output directory for exported files. When omitted, the diagram is written to stdout.

No

(stdout)

--no-validate

Export even if the model has validation errors. By default the export aborts with the same errors as validate and exit code 1 (#636).

No

false

Behavior:

  • Loads the model and resolves view elements and relationships.

  • Auto-detects the C4 level (Context, Container, or Component) from the C4 macros the view’s elements resolve to (see below), so kinds mapped via c4 override or notation select the matching C4_Container / C4_Component include (#633).

  • Generates diagram source in the requested format. C4-PlantUML uses the stdlib include syntax (!include <C4/C4_Context>, etc.).

  • C4-PlantUML diagrams carry the view title (title <view title>) and, unless the view sets "legend": false, LAYOUT_WITH_LEGEND() right after the include, so readers can tell the C4 shapes apart (#642). Mermaid diagrams carry the title as before.

  • The D2 output must compile with the d2 compiler: a node is written as id: "Title\n[kind]" { …​ } (D2 accepts nothing after the quoted label), quote characters are escaped (#713). The e2e tests run it through d2 when it is installed.

  • Line breaks in titles, descriptions, technologies and relationship labels (CRLF, LF or CR) never reach the output as raw breaks inside a quoted string: PlantUML (C4 and sequence diagrams), DOT and D2 write \n, Mermaid C4 writes <br/>. Double quotes become single quotes in the C4 and DOT formats (#690).

  • The arguments of the C4 macros (PlantUML and Mermaid): Person and System (and their _Ext variants) take (alias, title, description); Container and Component (with their Db, Queue and _Ext variants) take (alias, title, technology, description). An element of such a kind without technology but with a description gets an empty technology, so that the description stays in its own slot (#828).

  • A relationship technology is passed as the technology argument of Rel() (Rel(a, b, "charges", "HTTPS/JSON")); dashed PlantUML arrows and the DOT, D2 and HTML formats show label [technology]; the Structurizr DSL gets it as the fourth token (#642).

  • C4 macro selection (PlantUML and Mermaid) — each element is rendered with the C4 macro resolved from its kind, in this order (#633):

    1. the kind’s explicit specification.elements.<kind>.c4 override, if set (for example "c4": "Person");

    2. the kind’s key (case-insensitive): actor, person → Person; system → System; external_system → System_Ext; container, ui, mobile, filestore → Container; datastore → ContainerDb; queue → ContainerQueue; component → Component;

    3. the kind’s notation (case-insensitive): Person, Actor → Person; Software System, System → System; External System → System_Ext; Container → Container; Database, Data Store, Datastore → ContainerDb; Queue → ContainerQueue; Component → Component.

      The same resolution decides the scope boundary of a scoped view: Container_Boundary when the scope element’s kind resolves to a Container* macro, otherwise System_Boundary. The scope element is rendered only as this boundary, never additionally as a regular element, even if the view’s include also matches it (for example with ); a duplicate alias would make PlantUML silently drop one of the two declarations (#640). Note that matches only top-level elements, so the boundary of a scoped view stays empty unless the view includes the scope’s children, e.g. ["", "<scope>."].

      A kind that matches none of these falls back to System and a WARNING: element kind "<kind>" is not a recognised C4 kind and is rendered as System(…​) — set specification.elements.<kind>.c4 to choose a macro is printed to stderr once per kind per run (exit code stays 0). For a kind that is not declared in specification.elements at all, the warning says so instead (…​ is not declared in specification.elements …​).

  • Relationships are filtered to those visible in the view. Endpoints are lifted to visible ancestor elements when the original endpoints are not included in the view.

  • A relationship whose kind resolves to specification.relationships.<kind>.dashed: true renders as a dashed line: style="dashed" edge attribute in DOT, a style.stroke-dash block in D2, a stroke-dasharray SVG line in HTML, and a raw ..> arrow instead of the Rel() macro in PlantUML (C4-PlantUML’s own dashed-line style override errors on the versions tested). Mermaid does not yet support a dashed-line override in its C4 syntax, so dashed relationships render the same as solid ones there (#518).

  • A model without views has nothing to export: export-diagram (and export-table) write No views defined in model; add one with 'bausteinsicht add view'. to stderr, as export-sequence does for dynamic views; the exit code is 0, and no file is written (#737).

  • The HTML viewer (html) shows the view title as the heading of the page. Every relationship is a line from the border of the source box to the border of the target box with an arrowhead at the target; the exporter computes the two points (they are part of the embedded diagram data as x1, y1, x2, y2), so the arrowhead is not hidden behind the box. Lines are drawn behind the boxes and the labels have a white outline so that they stay readable where lines cross. The boxes are placed on a simple grid and the lines are straight: a line can still run behind a box that lies between its ends (#732).

  • Without --output, the diagram(s) are written to stdout. With --output <dir>, per-view files are named <view-key>.<ext>, where <ext> is puml, mmd, dot, d2, or html.

  • --diagram-format structurizr is special: it exports the entire workspace as a single workspace.dsl file and rejects --view (exit code 1).

  • The Structurizr DSL follows Structurizr’s argument order: container/component are written name description technology (a technology without description keeps its slot as an empty description), person/softwareSystem take no technology. A view is written <type> <scope> "<key>" "<description>", the key then the title; a system-scoped view that shows an element below the scope is a container view, otherwise a systemContext view, a container-scoped view is a component view. import --from structurizr reads the same: the first argument after the scope is the view key and the second the description, which becomes the title; with a single argument the key is also the title, and a view with neither is keyed by its scope (#687, #688).

  • Creates the output directory if it does not exist.

  • Before rendering each view, prints a WARNING: view "<key>" resolves to 0 elements — check its scope/include/exclude; the exported diagram will be empty to stderr if the view’s resolved element set is empty. This does not fail the export (exit code stays 0) — it only surfaces a diagram that would otherwise silently look successful despite being empty (#512).

JSON output structure — --format json emits an array of one object per exported view (not a file list):

[
  { "view": "context", "format": "plantuml", "source": "@startuml\n!include <C4/C4_Context>\n..." }
]

With --output <dir> the diagrams are written to files (same names as without --format json) and each entry carries the absolute path of its file instead of source (#631):

[
  { "view": "context", "format": "plantuml", "path": "/abs/docs/diagrams/context.puml" }
]

Views whose keys map to the same output file name are rejected with exit code 1 before anything is written. --diagram-format structurizr yields a single entry with "view": "workspace" (file workspace.dsl).

Exit codes:

  • 0 — all diagrams exported successfully

  • 1 — one or more exports failed, or --view used with structurizr

  • 2 — model file not found, invalid format, or no views to export

Example:

$ bausteinsicht export-diagram --view context        # writes to stdout
@startuml
!include <C4/C4_Context>
...

$ bausteinsicht export-diagram --diagram-format mermaid --output docs/diagrams --view context
Exported: docs/diagrams/context.mmd

$ bausteinsicht export-diagram --diagram-format structurizr --output docs
Exported: docs/workspace.dsl

$ bausteinsicht export-diagram --view context --format json
[
  { "view": "context", "format": "plantuml", "source": "@startuml\n..." }
]

bausteinsicht export-sequence

Exports dynamic views from the model as PlantUML or Mermaid sequence diagram source files. Dynamic views describe the runtime behaviour of the system as ordered message sequences between elements.

Flags:

Flag Description Required Default

--model

Path to the model file.

No

Auto-detected

--view

Export only the dynamic view with this key.

No

All dynamic views

--diagram-format

Diagram format: plantuml or mermaid.

No

plantuml

--output

Output directory for exported files. When omitted, output is written to stdout.

No

stdout

--format

Output format: text or json.

No

text

--no-validate

Export even if the model has validation errors. By default the export aborts with the same errors as validate and exit code 1 (#636).

No

false

Behavior:

  • Loads the model and reads dynamicViews entries.

  • Steps are sorted by index and rendered in order.

  • Participants are listed in first-appearance order.

  • Participant display names are resolved from the element title; falls back to element ID if the element is not in the model.

  • Participant shapes follow the C4 export: elements that render as Person become actor (PlantUML and Mermaid); in PlantUML, data stores (*Db macros) become database and queues queue; everything else is a participant (#637).

  • Step numbers are produced by autonumber (one line at the top of the diagram), not by prefixing the labels, so they can be styled; index only orders the steps. Double quotes in labels are written as typed.

  • Block steps (alt, else, opt, group, end) become PlantUML blocks or the Mermaid equivalents (alt, else, opt, end); Mermaid has no group, so it is drawn as a grey rect; a rect has no title, so the label of the group is written as the first line inside it, as a note over the first and the last participant of the diagram (Note over u,s: <label>; Note over u: <label> with one participant; no note without a label) (#711). Steps inside a block are indented. A message without a label is written without a dangling separator: a → b in PlantUML, a→>b: in Mermaid.

  • Mermaid text (diagram title, participant names, step labels, block conditions) is made safe for one statement: ; ends a statement in Mermaid and is written as the entity 59;, a line break becomes <br/> (#714). Other characters (:, , %%, ,, <, >, {, }, --, &, |) need no escaping in labels and names.

  • If --output is given, files are named sequence-<view-key>.puml (PlantUML) or sequence-<view-key>.md (Mermaid). The .md file holds the diagram as a fenced code block (` mermaid ` …​ ` ), so that Markdown viewers render it and `mmdc -i finds it; the output on stdout and the source of a JSON entry without --output are the raw diagram, and .puml files are never fenced (#715).

  • If no dynamic views are defined in the model, a warning is written to stderr and the command exits with 0.

Arrow type mapping:

Step type PlantUML Mermaid

sync (or omitted)

A → B

A→>B

return

A -→ B

A-→>B

async

A →> B

A-)B

JSON output structure:

[
  {
    "view": "checkout-flow",
    "format": "plantuml",
    "source": "@startuml checkout_flow\n..."
  }
]

With --output <dir> the files sequence-<view-key>.<ext> are written and each entry carries the absolute path instead of source (#631).

Exit codes:

  • 0 — all sequence diagrams exported successfully (or no dynamic views defined)

  • 1 — specified --view key not found

  • 2 — model file not found, invalid --diagram-format, or I/O error

Example:

$ bausteinsicht export-sequence
@startuml checkout_flow
title Checkout Flow
...
@enduml

$ bausteinsicht export-sequence --output docs/sequences
Exported: docs/sequences/sequence-checkout-flow.puml

$ bausteinsicht export-sequence --diagram-format mermaid --view checkout-flow
sequenceDiagram
    title Checkout Flow
...

$ bausteinsicht export-sequence --format json
[
  {
    "view": "checkout-flow",
    "format": "plantuml",
    "source": "@startuml checkout_flow\n..."
  }
]

bausteinsicht lint

Evaluates the architectural constraints defined in the model and reports violations.

Flags: none beyond the global flags.

Behavior: loads the model and evaluates each constraint. Prints All constraints passed. when constraints exist with no violations, No constraints defined. when the model declares none, or the list of violations otherwise. Use in CI as an architecture gate. A violation message starts with the constraint’s description only if it has one, and lists elements by their full ID (shop.api.deep (depth 3)). A constraint that lacks what its rule needs (a from or to selector, max, field, technologies, an element-kind or tag) is reported as a violation constraint is incomplete: … instead of silently matching nothing or everything; validate reports the same as an error (#727). technology-allowed selects its elements by element-kind or tag, like required-field.

bausteinsicht health

Computes an architecture health score (0–100, with a letter grade) across weighted categories such as completeness, conformance, and complexity.

Flags:

Flag Description Required Default

--summary

Print only the overall score and grade.

No

false

--output

Write the report to a file instead of stdout.

No

(stdout)

Behavior: finds the model via --model or auto-detection. Emits a human-readable report (or JSON with --format json) of the overall score, per-category scores, and model statistics.

bausteinsicht graph

Analyzes the relationship graph: cycle detection, dependency depth, and centrality metrics.

Flags:

Flag Description Required Default

--centrality

Show centrality metrics per element.

No

false

--cycles-only

Show only detected cycles.

No

false

--output

Write the report to a file instead of stdout.

No

(stdout)

Behavior: finds the model via --model or auto-detection. Reports element/relationship counts, max dependency depth, graph type (DAG / has cycles), and strongly connected components.

bausteinsicht stale

Flags elements that look forgotten. An element is reported only when all three hold: its last modification is older than the threshold, it has no lifecycle status, and it links no ADR (decisions is empty). Archived elements are skipped.

Flags:

Flag Description Required Default

--days, -d

Consider an element stale if unmodified for this many days.

No

90

--model, -m

Model file path.

No

(auto-detect)

--drawio-file

draw.io diagram path (auto-detected if empty).

No

(auto-detect)

--mark-drawio

Highlight stale elements in the diagram.

No

false

--unmark-drawio

Remove stale markers from the diagram (restores original styles).

No

false

--format, -f

Output format: text or json.

No

text

Behavior: the last-modified date comes from per-element git history, or from the element’s explicit lastModified field if set. Outside a git repository, elements without an explicit lastModified have no known date and are therefore not flagged by age. Output is deterministically ordered (by risk, then ID).

bausteinsicht status

Lists elements by lifecycle status (proposed, design, implementation, deployed, deprecated, archived).

Flags:

Flag Description Required Default

--filter, -f

Show only elements with this status.

No

(all)

Behavior: finds the model via --model or auto-detection. Groups elements under their status. Elements whose status is not one of the lifecycle statuses (validate warns about them, BR-029) are listed after unset in a section unknown status (<n>) with the status they carry, so that the sections add up to all elements; the JSON summary counts them under that status (#710).

bausteinsicht find

Full-text search over the model.

Arguments: <query> (required) — the search string.

Flags:

Flag Description Required Default

--type

Limit results to element, relationship, view, or all.

No

all

Behavior: returns ranked matches grouped by object type, with the matched fields. --format json emits a structured result.

bausteinsicht show

Displays all fields, relationships, and views for a single element.

Arguments: <element-id> (required) — the dot-path ID.

Behavior: prints the element’s kind, title, description, technology, relationships, and the views it appears in. --format json emits the element as structured data.

bausteinsicht snapshot

Manages versioned model snapshots stored in .bausteinsicht-snapshots/.

Subcommands:

Subcommand Description

save

Capture the current model as a snapshot (--message adds a note; the model comes from the global --model or auto-detection, #693).

list

List saved snapshots as a table; the global --format json (or --output-format json, which wins when both are given) prints a JSON list, [] when there is none (#693).

diff <id1> [id2]

Diff snapshot id1 against id2, or against the current model if id2 is omitted (--format text|json).

restore <id> <output-path>

Restore a snapshot to a file (--force to overwrite).

delete <id>

Delete a snapshot.

Behavior: diff reports a structured architecture delta (added/removed elements and relationships), not a text diff. The directory also holds index.json; it is not a snapshot, so index is an unknown snapshot ID for diff, restore and delete (exit code 2, snapshot not found: index) and the index is never removed by them (#693).

bausteinsicht diff

Reports the gap between the model’s asIs and toBe sections.

Flags:

Flag Description Required Default

--model

Model file path.

No

(auto-detect)

--view

Show only the changes that concern the elements of this view (the view of the model, resolved like for the diagrams, against the elements of the model and of both states, so that an element that exists only as-is or only to-be can be named): the changes of those elements and the relationship changes whose both ends are among them; the summary counts only these. An unknown view is an error (exit code 1) that lists the known ones (#709).

No

(all)

--format

Output format: text or json.

No

text

Behavior: exits with an error if the model has no asIs/toBe sections. A relationship without a label is printed as from → to, without empty parentheses.

bausteinsicht changelog

Generates a human-readable changelog between two versions of the model.

Flags:

Flag Description Required Default

--since

Starting git ref (commit SHA, tag or branch) or snapshot ID.

No

the previous tag: the latest tag before --until, or, if --until is itself tagged, the one before it (#698)

--until

Ending git ref or snapshot ID.

No

HEAD

--model

Model file path.

No

(auto-detect)

--changelog-format

Output format: markdown, asciidoc, or json.

No

markdown

--output

Write to a file instead of stdout.

No

(stdout)

Behavior: loads the model at each git ref (via git rev-parse / git show) and reports the architecture changes between them. A ref that is the ID of a snapshot in .bausteinsicht-snapshots/ (see snapshot) is read from the snapshot store instead of git, so two snapshots can be compared without a repository, and a snapshot can be compared with a git ref (#728); any other ref is a git ref. --since is required when --until is a snapshot, because a snapshot has no previous tag. Errors say what is wrong, exit code 2: no git repository found outside a repository, no tag found before <ref>: tag a release or use --since <git ref> when --since is omitted and there is no tag, and cannot resolve git ref "<ref>": <git’s message> for an unknown ref (#698). (Note: changelog uses --changelog-format, not the global --format.)

bausteinsicht import

Imports an architecture model from an external DSL and writes a Bausteinsicht .jsonc file.

Arguments: <input-file> (required) — the source DSL file.

Flags:

Flag Description Required Default

--from

Source format: structurizr (.dsl), likec4 (.c4), or xmi (.xmi/.xml).

Yes

(none)

--output

Output model file path.

No

architecture.jsonc

--dry-run

Print the generated model to stdout instead of writing the file.

No

false

--force

Overwrite the output file if it already exists.

No

false

--kind-map

XMI only: comma-separated Type=kind overrides (e.g. Component=service,Class=entity).

No

(none)

--generate-template

Also write template.drawio next to the output file, with a style for every kind of the imported specification, so that sync finds a style for each of them. The template is created exclusively and before the model is written: exit 2, with nothing written, if template.drawio already exists (a link of that name counts). Ignored with --dry-run.

No

false

--json

Print the post-import summary as machine-readable JSON instead of human-readable text.

No

false

Behavior: parses the source DSL, maps people/systems/containers and relationships, and generates a matching specification. Exit 2 if the output file already exists and neither --force nor --dry-run is set — --dry-run prints to stdout and skips the existence check, so it never fails on an existing output. Exit 1 on any other import failure (unknown --from, unreadable input, parse/encoding error). Exit 1 with no elements found in <file> - is --from <format> correct? if the import yields no element (a file in another format, a text file without a model), with and without --dry-run; nothing is written and an existing output file is left alone (#705). A file in another format that happens to contain a line that parses as an element is not detected.

Post-import summary: on a successful (non-dry-run) import, prints an element count per kind, the output file path, the generated view count (omitted when zero — xmi never produces views), and any warnings collected during import. --json emits the same information as {"elements":{"<kind>":<count>,…​},"outputPath":"…​","views":<count>,"warnings":["…​"]} instead (the views key is present but 0 in JSON mode, unlike the omitted text line, since machine consumers should not have to distinguish "zero" from "absent"). Followed by a next-steps hint: bausteinsicht sync and bausteinsicht export diagram on a fresh import; bausteinsicht diff instead of sync when --force overwrote an existing output file (the existing file likely already has synced draw.io state, so reviewing the delta is more useful than re-syncing). The hint is suppressed entirely under --dry-run, since nothing was persisted.

XMI-specific behavior: reads XMI 2.1 files (e.g., Enterprise Architect exports). UML element types are mapped to Bausteinsicht element kinds using --kind-map overrides or the built-in defaults (e.g., uml:Component → component). EA stereotypes (inside xmi:Extension) take precedence over the UML type mapping. Unknown UML types produce a warning and are imported with kind element. Unresolvable relationship endpoints are skipped with a warning. DOCTYPE declarations are rejected (XXE mitigation). Element hierarchy depth is capped at 50 levels. This is a one-way migration — XMI-specific data (layout, tagged values, OCL constraints) is not preserved.

Structurizr-specific behavior: the tag External on a softwareSystem selects the kind external_system and the tag Database on a container the kind datastore, as the default specification names them; the tag itself is not kept. An element with children keeps its kind and its tag, because these two kinds have no children. export-diagram --diagram-format structurizr writes the tags argument again (the tag that its kind stands for first, then the element’s tags), so a round trip keeps kinds and tags. Every other tag (from the tags argument, comma separated, or from a tags statement) stays in the element’s tags and is defined in specification.tags, so the model validates. A view’s key is the key written in the DSL (see export-diagram, #688). a view’s autoLayout <direction> directive is mapped to Bausteinsicht’s layered layout (there is no direction-aware equivalent). The direction argument itself is not preserved, and a warning is emitted noting the dropped value (e.g. line 12: view "context": autoLayout direction "lr" not preserved, mapped to layout: "layered"). include on a container/component view is expanded to also include the view’s scope’s children (e.g. ["", "<scope>."], plus the parent scope for component views), matching Structurizr’s semantics where a scoped view’s wildcard include means "everything visible in this scope" rather than Bausteinsicht’s default top-level-only match. filtered, dynamic, and deployment views are not supported and are skipped with a warning (#512).

LikeC4-specific behavior: the include and exclude predicates of a view are translated into the view’s include and exclude lists: names are resolved to element paths, name. and name.* keep their wildcard. A plain include becomes [""], and in a view of <element> it also adds that element’s children (["", "<element>."]), as for Structurizr; a view without include shows the top-level elements. An imported view is never left without an include list, so sync does not report it as resolving to 0 elements (#706).

bausteinsicht generate-template

Generates a draw.io template with a styled shape for each element kind in the specification.

Flags:

Flag Description Required Default

--style

Visual preset: default, c4, minimal, or dark.

No

default

--output

Output template file.

No

architecture-template.drawio

--model

Model file (auto-detected if omitted).

No

(auto-detect)

Behavior: the generated file carries the bausteinsicht_template attributes the sync engine needs, so it works directly as a --template.

bausteinsicht layout

Computes a layered layout for every page of the draw.io diagram and writes the element positions back to the draw.io file.

Flags:

Flag Description Required Default

--algorithm

Layout algorithm (currently only hierarchical).

No

hierarchical

--rank-dir

Ranking direction: TB (top-to-bottom) or LR (left-to-right).

No

TB

--preserve-pinned

Do not move elements marked bausteinsicht-pinned=true (and what is nested inside them).

No

true

--view

Lay out only the page of this view: the key of the view, as in export (the ID of its page, view-<key>, is accepted too, #823).

No

(every page)

--drawio

The diagram to lay out (#650).

No

<model-dir>/architecture.drawio

Behavior (#654):

  • Per page. Every page is laid out on its own, from the elements and connectors that are on that page. The model is not read, so a view only shows the structure that the view shows. A connector into an element inside a boundary counts as a connector to the boundary on the outer level.

  • Sizes are kept. An element keeps its width and height (template size, person shape, …​), except that it grows if its title or technology needs more lines than its text cells have (the cells wrap; synchronization specification, "Long text", #718). Only a boundary or container is resized: to fit the elements inside it, but not smaller than 300x200.

  • Nested elements. Elements inside a boundary or container are laid out inside it and get coordinates relative to it, as draw.io expects, so they stay within the boundary.

  • Info boxes. The metadata box, the legend and the doc-link icon row of the view (cells without a bausteinsicht_id) are moved below the laid-out content: y is the bottom of the lowest cell on the page, pinned ones included, plus 80; x, width and height are kept, and the icon row keeps its place relative to the metadata box. A page without elements, or without these boxes, is left as it is (#772).

  • Deterministic. Elements are ordered by ID and crossings are reduced by a fixed barycenter sweep, so running the command twice, or on a copy of the file with the cells in another order, gives the same positions. A cycle is drawn as a chain that starts at the smallest ID.

  • Connectors. Stored waypoints of connectors on a laid out page are removed, because they belong to the old positions; draw.io routes the connectors again. Only the connectors of opposite directions between the same two elements get new waypoints for the new positions, so that both labels stay readable (#717; see the new-relationship rule of the synchronization specification).

  • No diagram. If architecture.drawio does not exist, or has no pages, the command fails with exit code 2 and no diagram yet (<path>): run 'bausteinsicht sync' first; a model without views has no diagram, add one with 'bausteinsicht add view' (#737).

  • Exit codes: 1 unknown --view (view "x" not found in the diagram; views: context, containers, #823), invalid --rank-dir or unknown --algorithm (the message names the value and the valid one, hierarchical; the diagram is not changed, #691); 2 the diagram next to the model cannot be read or written.

bausteinsicht overlay

Loads external metrics (error rate, coverage, …) from a JSON file and overlays them as a heatmap on draw.io elements; original styles are preserved.

Subcommands:

Subcommand Description

apply <metrics-file>

Apply a metric heatmap (--metric <key>, default: the first metric by name; --output or --drawio, default <model-dir>/architecture.drawio, i.e. next to the model file).

list <metrics-file>

List the metrics available in the file, each with its minimum, maximum, number of elements and the description from meta.metric_descriptions (JSON: metrics list). The header names source and date only if the file has them.

remove

Remove the overlay and restore original colors (--output or --drawio, same default).

Metrics file:

{
  "meta": { "source": "grafana", "generated": "2026-11-28", "metric_descriptions": { "error_rate": "Errors per request" } },
  "metrics": [
    { "elementId": "customer", "error_rate": 0.5, "coverage": 70 },
    { "elementId": "shop.api", "error_rate": 0.1 }
  ]
}

meta is optional. elementId is the model ID (dot path); every other key of an entry is a number and a metric. A file in another shape (no metrics list, metrics not a list, an empty list) is refused with exit code 2 and a message that shows this shape; overlay apply --help shows it too. apply warns on stderr about every elementId that is not in the model and ignores it (#696).

apply and remove find the model via --model or auto-detection. When --output is omitted it resolves relative to the model file’s directory, not the current directory. Any overlay failure (missing model/metrics file, unreadable diagram, unknown metric) exits with code 2.

bausteinsicht repl

Starts an interactive shell for editing the model.

Flags: none beyond the global flags.

Behavior: keeps the model in memory; supports add/remove/list/show/validate/undo/save (plus help and exit). The start line names the number of all elements, nested ones included. remove element <id> [--cascade] takes a dot path and works like the remove element command: the element and its children go; relationships, view entries and dynamic view steps that refer to it block the removal unless --cascade drops them too, and a view scope or constraint that names it always blocks it (#695). Pure additions are patched comment-preserving; modifications/deletions fall back to a full rewrite (with a warning). exit with unsaved changes prompts for confirmation before quitting; Ctrl-D (EOF) warns about unsaved changes and exits cleanly.

Validate-before-save gate: save runs validation and aborts if the in-memory model has more errors than the on-disk model had at load time. This allows saving valid edits even when the on-disk model already contains validation errors (e.g. a broken view reference that cannot be fixed via REPL commands). If the error count would increase, save is aborted and all errors are listed.

Overwrite behavior: when add element targets an ID that already exists, the existing element is overwritten. The description prompt shows the current description in brackets; pressing Enter without input keeps the existing description unchanged rather than clearing it.

Known limitation: remove relationship tokenizes the label using whitespace splitting. Labels containing consecutive spaces (e.g. "A B") can never be matched — use a single space in labels or remove such relationships by editing the model file directly.

bausteinsicht adr

Lists and shows Architecture Decision Records linked to model elements (the decisions field).

Subcommands:

Subcommand Description

list

List all ADRs, or only those linked to one element (--element <id>).

show <adr-id>

Show details of a specific ADR.

Flags: --model, -m (default: auto-detect). adr list supports --format text|json and --element <id> to filter; adr show prints text only.

bausteinsicht workspace

Works with multi-model workspaces that combine several architecture models.

Subcommands:

Subcommand Description

list <config-file>

List the models in a workspace configuration.

merge <config-file> <output-file> [--force]

Merge the configured models into one unified model. An existing output file is only replaced with --force (exit code 2 otherwise). The configuration, its bausteinsicht.lock and the local input models are never overwritten, not even with --force (exit code 2), also when the output is reached through another path or a symbolic link (#708).

validate <config-file>

Validate a workspace configuration: every model, and what the models cannot check alone (see below).

fetch <config-file> [--update]

Download the remote models (source) into the local cache and write bausteinsicht.lock. The only subcommand that uses the network (see Remote sources).

Workspace configuration (JSONC like the models: comments and trailing commas are allowed; paths relative to the configuration file):

A key that no field has (a typo such as depthh for depth, or allowedHost for allowedHosts) is not ignored: workspace validate fails with exit code 2 and names the key with its path and the nearest field (unknown key models[0]: unknown field "depthh" (did you mean "depth"?)); list, merge and fetch print the same as a warning: on stderr and go on. The optional key $schema is allowed (#805); point it at schemas/bausteinsicht-workspace.schema.json (https://raw.githubusercontent.com/docToolchain/Bausteinsicht/main/schemas/bausteinsicht-workspace.schema.json) and the IDE completes the keys, flags a typo and offers the layout values (#806). The schema is generated from the configuration types, with additionalProperties: false, and a test keeps the committed file in sync.

{
  "workspace": { "name": "landscape" },
  "models": [
    // import the whole model of team A
    { "id": "team_a", "path": "../team-a/architecture.jsonc" },
    // import only the element "billing" of team B, as a black box
    { "id": "team_b", "path": "../team-b/architecture.jsonc", "prefix": "b", "elements": ["billing"], "depth": 1 }
  ],
  "crossModelRelationships": [
    { "id": "pay", "from": "team_a:shop.api", "to": "team_b:billing", "label": "charges via", "kind": "uses" }
  ],
  "views": {
    // one page with the systems of both teams
    "landscape": { "title": "Landscape", "include-from": ["team_a", "team_b"], "include-kinds": ["system"] }
  }
}
Field Meaning

models[].id

Name of the model; used in cross-model relationships. Must be unique.

models[].prefix

Prefix for the element IDs of this model in the merged model (<prefix>_<element>); default: the id. Must be unique.

models[].elements

Optional. Top-level elements to import, each with its children (default: all). Only top-level IDs, without dots.

models[].depth

Optional. How many levels of the imported elements to keep: 1 is the element alone (a black box), 2 adds its children; 0 or omitted means all. A model with elements or depth is imported partially: relationships between the elements that are kept stay; its views, dynamic views and constraints are not imported.

crossModelRelationships[]

Relationships between models. from and to have the form <model id>:<element id> (for example team_a:shop.api); they are translated to the merged IDs. id must be unique; label, kind and description are copied to the relationship.

views

Workspace views that select elements from several models, keyed by the view key of the merged model. Fields: title (required), description, layout (layered, grid, none), include-from (model IDs; omitted or empty: every model), include-kinds (keep only these element kinds), exclude-kinds (drop these kinds). merge applies them (see below). The merged model also contains the views of the fully imported models, prefixed (<prefix>_<view key>).

Behavior (#227):

  • merge combines the models into one: elements get the prefix, each nested element appears once below its parent, and the cross-model relationships are added. A cross-model relationship whose model or element does not exist makes merge fail (exit 2) and nothing is written.

  • validate checks every model and then the workspace: duplicate model IDs or prefixes, cross-model relationships that point at models or elements that do not exist (or repeat an ID), and workspace views that are wrong (unknown model or kind, invalid layout, no elements, key already taken). It reports every problem and exits 2 if there is one.

  • The element kinds and relationship kinds of all models are merged. A kind that only one model defines is added. If two models define the same kind differently (element kind: notation, container or c4; relationship kind: notation or dashed), merge and validate fail with one message per kind that names both models (ADR-012); a different description is not a conflict, the first one is kept.

  • merge turns every workspace view into an ordinary view of the merged model: the selected elements are listed by their merged IDs, so nested elements are included, and a partially imported model contributes only what it imports. A kind in include-kinds/exclude-kinds must exist in the merged specification. merge and validate fail, naming the view, if a view selects no elements, names an unknown model or kind, has an invalid layout, or has the key of a prefixed model view (<prefix>_<view key>); nothing is written then.

  • Constraints of a model are merged too; their from and to (element IDs) get the model’s prefix, so they keep matching the prefixed elements. Selectors by kind or tag are unchanged. Constraint IDs are not prefixed and must be unique: merge fails on the merged model if two models define the same ID (#689).

  • Prefix and element (or view key) are joined with _, so different pairs can give the same merged ID (prefix a with element b_c, and prefix a_b with element c). merge fails on such a collision instead of replacing one element with the other, and validate reports it. validate also reports constraint IDs that more than one model defines.

  • Models in other repositories are used either by checking them out (for example as a git submodule) and pointing path at the checkout, or as a pinned remote source (next section).

Remote sources (#227, ADR-012 Phase 2):

A model reference has either a local path or a source: an https URL of a model file, pinned by a tag or a commit in the URL (for example https://raw.githubusercontent.com/acme/billing/v1.4.0/architecture.jsonc). The real pin is the SHA-256 in bausteinsicht.lock: a changed file is an error unless workspace fetch --update; a tag or commit in the URL is the recommended form. A URL with a branch-like path segment (main, master, HEAD, trunk, develop, dev, refs/heads/…​) is accepted, but validate, list, merge and fetch print warning: …​ not pinned by a tag or commit (#805). Remote sources are off by default.

{
  "workspace": { "name": "landscape", "allowedHosts": ["raw.githubusercontent.com"] },
  "models": [
    { "id": "team_a", "path": "../team-a/architecture.jsonc" },
    { "id": "billing", "source": "https://raw.githubusercontent.com/acme/billing/v1.4.0/architecture.jsonc", "prefix": "b" }
  ]
}
Item Rule

workspace.allowedHosts

Exact, lower-case host names (no scheme, port or wildcard). A source on a host that is not listed is a configuration error, so fetch, validate and merge refuse the configuration before any request.

models[].source

https only, port 443 only, no credentials and no fragment in the URL. Mutually exclusive with path. The id of a remote model may contain only letters, digits, - and _ (it becomes the cache file name).

fetch

Downloads each remote model to .bausteinsicht-cache/<id>.jsonc (next to the configuration; the directory gets a .gitignore containing *) and records its SHA-256 and URL in bausteinsicht.lock. A model that is cached and matches the lock is not downloaded again (up-to-date); a missing cache file is restored from the lock (restored) and must have the locked hash. If the downloaded content differs from the lock, fetch fails and changes nothing; --update accepts the new content (updated) and rewrites the lock. A changed source URL is a new source (fetched). Lock entries of models that are no longer remote are removed.

merge, validate, list

Never use the network. A remote model is read from the cache after its SHA-256 matches the lock; a missing lock entry or cache file is an error that names workspace fetch, a hash mismatch is an error that names the expected and the actual hash.

Network rules

HTTPS with certificate verification, 30 second timeout, response limited to the model file size limit (10 MiB), no redirects (a redirect is an error: use the final URL), no proxy. The host name is resolved by Bausteinsicht and the connection is refused if any resolved address is loopback, private (RFC 1918, ULA), link-local (including the metadata address 169.254.169.254), multicast, unspecified or in a reserved range; the validated address is the one that is connected to.

Authentication

Only through the environment variable BAUSTEINSICHT_FETCH_TOKEN_<HOST> (host upper-cased, every character other than A-Z and 0-9 replaced by _, e.g. BAUSTEINSICHT_FETCH_TOKEN_RAW_GITHUBUSERCONTENT_COM), sent as Authorization: Bearer. Never stored in the configuration, the lock file or the cache.

bausteinsicht.lock

JSON {"version": 1, "sources": {"<id>": {"url": "…​", "sha256": "…​"}}} next to the configuration; commit it. Written with permissions 0600.

A download is parsed as a model before anything is written, with the loader that local files go through: content that does not parse (a README, an HTML error page behind a status 200) or that has neither a specification nor a model (a JSON error object) is refused with <url> is not a Bausteinsicht model: <reason>, and neither the cache nor bausteinsicht.lock changes, also with --update (the pin that is there stays) (#734).

The SHA-256 in the lock file is compared as a hex number: a hash written in upper case is the same hash, and it is written in lower case the next time the lock is saved. When a model is no longer remote (removed from the configuration, renamed, or given a path), fetch drops its lock entry and deletes its cache file .bausteinsicht-cache/<id>.jsonc; other files in the cache directory, and lock entries whose ID cannot be a file name, are left alone (#735).

fetch prints one line per remote model (<id>: fetched|restored|updated|up-to-date (sha256 <prefix>)) or {"results": […​]} with --format json. Exit code 2 on any error.

bausteinsicht schema

Manages the JSON Schema for Bausteinsicht models.

Subcommands:

Subcommand Description

generate

Generate the JSON Schema from the Go model types (--output, default schemas/bausteinsicht.schema.json, relative to the current directory). With --workspace it generates the schema of the workspace configuration instead (default output schemas/bausteinsicht-workspace.schema.json, #806). Missing parent directories of the output file are created.

Behavior: the schema is generated from internal/model types, so it stays in sync with the model definitions.