Skip to content

8. CLI Reference

Every command except import dbt (which takes a dbt manifest) and mcp takes one or more PATHs: a .txt or .dbml file, or a folder (every *.txt and *.dbml under it, recursively). QuickDBD and DBML files can be mixed. qdbd <command> --help shows all options.

8.1 check

qdbd check PATH... [--strict] [--format text|github|json] [--symbols] [--stdin-file FILE] [--each]

qdbd check output

Validates the schema. Prints No errors found. Good job!, or file:line: error: message lines and exits 1. --strict also fails on QuickDBD-compatibility warnings.

--format changes the output:

  • github also prints GitHub Actions annotations, so each problem shows on its line in the pull request's Files changed tab. Under --strict, warnings are annotated as errors. The GitHub Action turns this on for you.
  • json prints one report to stdout, for editors, hooks and scripts:
{
  "ok": false,
  "errors": 1,
  "warnings": 0,
  "diagnostics": [
    {"path": "schema/orders.txt", "line": 3, "severity": "error", "message": "Unrecognized keyword 'foo'"}
  ]
}

Paths are relative to the current directory. Under --strict, warnings are reported as errors here too. The exit code is the same in every format.

--each checks every PATH as its own schema, the way build --site builds them, so two diagrams can both have a customers table. Folders with no schema files are skipped, so a glob like docs/erd/*/ works. It can't be combined with --format json or --stdin-file.

Two options are there for editors, and the VS Code extension uses both:

  • --symbols (with --format json) adds tables (name, aliases, file, first and last line, columns with their lines) and rels (file, line and both ends) to the report.
  • --stdin-file FILE reads that schema file's text from stdin instead of disk, so an unsaved buffer gets checked along with the other files on disk. FILE has to be one of the files being checked.

8.2 serve

qdbd serve PATH... [--port 8765] [--by-group] [--layout FILE] [--no-open] [--read-only | --embed] [--diff-base REF]

qdbd serve: editor pane and live diagram

Local live editor on 127.0.0.1: reloads when files change, browser editor pane that writes the file on Save (or Ctrl/Cmd+S), drag tables to save positions. Ctrl+C stops it. The VS Code extension's Open in Browser runs this, on any free port.

The default port is 8765. If it's busy (for example, a second qdbd serve is running), the next free port is used and printed. An explicit --port that's busy is an error.

--read-only serves a live view with no editor that never writes to disk, so viewers can't change anything. Before you put it behind a tunnel, see 4.4 Sharing a Link.

--embed is the page behind the VS Code extension's preview: a live view with no editor pane, where dragging still saves positions but files can't be written. It talks to the editor through postMessage. --port 0 picks any free port.

--by-group starts from a fresh layout that keeps each file / dbt folder together, with regions on, and saves it to the layout file like qdbd layout --by-group (the saved positions are replaced; with --read-only, nothing is saved). After that, dragging and new tables work as usual.

--diff-base REF colours what changed since that ref, as build --diff-base does, and keeps comparing as you edit: the ref is read once, at start.

8.3 build

qdbd build PATH... [-o FILE | --site DIR] [-s SELECTOR] [--exclude SELECTOR] [--diff-base REF] [--by-group] [--layout FILE] [--strict]

qdbd build output

Writes one self-contained HTML page, diagram.html unless -o names another. Builds are deterministic (same input, same bytes), and the layout file is read but never written.

--site DIR builds one page per PATH instead, named after it (docs/erd/sales/ gives DIR/sales.html), plus DIR/index.html linking them all. Each PATH is its own schema with its own layout file, so --layout can't be used. Folders with no schema files are skipped. If any schema has errors, nothing is written. Files already in DIR are left alone, so a diagram you remove stays there until you delete it:

qdbd build docs/erd/*/ --site public/

With --by-group, the Wrote … line also counts the regions: (200 tables, 211 relationships, 5 regions).

8.4 share

qdbd share PATH... [-s SELECTOR] [--exclude SELECTOR] [--diff-base REF] [--by-group] [--layout FILE] [--strict] [--public] [--new] [-y/--yes]

Builds the page like build and publishes it as a secret GitHub gist (with the gh CLI), then prints a link. Sharing the same files again updates the same gist. Off unless the QDBD_ALLOW_SHARE environment variable is 1: the gist is outside your organisation's control. Even then, it shows a disclaimer and asks before uploading; --yes accepts it without asking, for scripts. See 4.4 Sharing a Link.

8.5 export

qdbd export PATH... -o out.png|out.svg|out.drawio [-s …] [--exclude …] [--focus TABLE --depth N] [--mode full|keys|header] [--regions] [--by-group] [--layout FILE] [--scale 2] [--strict]

qdbd export output

See 4.3 Exports.

8.6 layout

qdbd layout PATH... [--reset] [--by-group] [--layout FILE]

qdbd layout output

Writes positions to the layout file: placing new tables, re-laying out everything (--reset), or grouping by file / folder (--by-group). See 3.4 Table Positions.

8.7 path

qdbd path PATH... --from TABLE --to TABLE

qdbd path output

Prints the shortest relationship path and a SQL FROM … JOIN … ON … snippet. Exits 1 when the tables aren't connected.

A composite foreign key joins on every column: a DBML Ref: a.(x, y) > b.(x, y), or QuickDBD FK lines that together point at all of a table's composite primary key. Between two tables with several relationships, one with join columns wins over a table-level rel. Dotted names such as sales.orders come out as schema.table.

8.8 diff

qdbd diff OLD NEW
qdbd diff --base GIT_REF PATH... [--format text|markdown|json] [-o FILE] [--exit-code]

qdbd diff output

See 6. Reviewing Changes.

8.9 import dbt

qdbd import dbt target/manifest.json [-o FILE_OR_DIR] [--catalog FILE] [--package NAME] [--select GLOB] [--no-sources] [--infer-fks] [--check]

qdbd import dbt output

Writes schema.txt unless -o names another .txt file, or a folder for one file per dbt folder. See 5.1 dbt Import.

8.10 convert

qdbd convert PATH... --to dbml|quickdbd [-o FILE_OR_DIR]

qdbd convert output

Converts between QuickDBD text and DBML. With one file and no -o, prints the result; with -o DIR, writes each file under it with the new extension (DBML TableGroups become one QuickDBD file each). Anything the target syntax can't express is a warning; the output is recompiled and must otherwise match the input, or nothing is written. See 3.2 DBML.

8.11 mcp

qdbd mcp [PATH...] [--root DIR] [--infer-fks]

Runs an MCP server on stdin/stdout, so AI agents (Claude, Copilot, Cursor) can query the schema: tables, join paths with SQL, checks, diffs and diagrams. With no PATH it serves every schema project under --root (default: $CLAUDE_PROJECT_DIR, else the current folder); with paths, just that schema or dbt manifest.json. It runs until the client closes it. See 3.7 AI Agents (MCP).

8.12 Exit codes

Code Meaning
0 success
1 schema errors, no matching tables, no path, or (diff --exit-code) changes found
2 bad arguments, missing files, git errors, or share turned off, not confirmed or failing to upload