zmdbzero-maintenance data layer
Docs Benchmarks Anti-patterns OpenAPI
Docs / Build an application

CLI OverviewSupported

@zmdb/cli owns the single installed zmdb executable. Its commands delegate reflection and AOT compilation to @zmdb/compiler, and schema snapshots, plans, files and ledger execution to @zmdb/migrations. These libraries are independently usable; see Tooling Boundaries.

The pieces#

FunctionModuleDoes
compileProject, writeCompileResult, watchCodegen@zmdb/compilerproject artifacts, freshness checks and retained-session watch
snapshot(schemas)@zmdb/migrationsschema objects → a plain snapshot object
diff(prev, next)@zmdb/migrationstwo snapshots → operations
emitUp(op, dialect)@zmdb/migrationsone operation → SQL
emitDown(op, dialect)@zmdb/migrationsthe reverse
sqliteIntrospector@zmdb/sqliteSQLite catalog → normalized snapshot
database.introspectorselected database packagedatabase-owned catalog reader
emitDeclarations(snapshot, …)@zmdb/migrations/declarationssnapshot → generated TypeScript files
up, down, status@zmdb/migrations/runnerapplies / reverts, records versions
runEmbedded(conn, migrations)@zmdb/migrations/embeddedapplies bundle-resident SQLite migrations

The commands, and where each stands#

drizzle-kit / mikro-ormzmdb todayPage
newproject and application-component scaffoldsscaffolding
codegenzmdb codegen, --check and --watchcode generation
generatezmdb generategenerate
embedbundle-resident SQLite migration moduleweb/mobile migrations
migrate / upzmdb migrate; up is deliberately refusedmigrate · up
pushlive-catalog diff with a destructive SQL guardpush
checksnapshot, file-history, and optional live-drift checkscheck
exportzmdb exportexport
pull / generate-entitiesprotected zmdb pull declaration stagingpull
client generateOpenAPI and typed client from configured HTTP contractsgenerated client
studioinstalled read-only loopback browserstudio

The catalog-backed pull is packaged with overwrite protection, dry-run, and check modes. Studio's installed binary is parsed by plain Node and exercised against its loopback index by publish verification.

A single entry point#

Install the CLI and its required TypeScript peer, or install @zmdb/core@1.0.0-beta.2 for the product that includes the same CLI. Command help comes from the installed version:

yarn add --dev @zmdb/cli@1.0.0-beta.2 typescript@^7.0.2
yarn zmdb --help
yarn zmdb codegen --help

The database workflow uses that one entry point:

yarn zmdb codegen --check
yarn zmdb generate --name add_slug
yarn zmdb embed
yarn zmdb migrate
yarn zmdb check --json
yarn zmdb export > schema.sql
yarn zmdb pull --dry-run
yarn zmdb client generate --check
yarn zmdb new controller posts

The schema and HTTP-generation commands accept --config <path> and --project <tsconfig>. client generate writes both configured artifacts, --check reports stale output without writing, and --watch regenerates from the compiled contract dependency set. Scaffolding instead accepts --package <name-or-path> and --dry-run and does not load database config. Add --json when a script needs the stable CliResult envelope instead of human output; watch mode is deliberately not JSON.

Exit codes and streams#

ExitMeaning
0The command completed and found no requested check failure.
1Work ran, but an operation failed or a check found drift.
2The invocation, config, safety confirmation, or command name was invalid.

Human progress goes to stdout. Under --json, stdout is one CliResult document and progress or warnings move to stderr, so a caller can parse stdout without filtering log lines.

---

See also: Generated HTTP Client · Migrations · Config File · generate