zanith

CLI

Five command groups: migrate · recover · studio · db · schema. The same binary that ships the engine ships these.

Migrations

Generate, plan, verify, apply, roll back. Every operation is risk-classified and audited per step.

SHELLterminal
zanith migrate generate <name> # scaffold a migration
[--from-diff] # auto-fill from live-DB drift
zanith migrate plan [--json] # risk summary, no writes
[--max-risk <n>] # CI gate (0–100)
zanith migrate verify # apply on shadow + diff
zanith migrate up [--to <id>] # apply pending
[--shadow-verified] # honor-system gate
[--allow-destructive] # opt in to drops
[--max-risk <n>] [--dry-run]
zanith migrate down [--steps <n>] # roll back
zanith migrate status # applied / pending list
zanith migrate diff [--out <file>] # bootstrap SQL
zanith migrate history [--verbose] # per-step risk + snapshots

Recovery (Phase 2)

Every destructive op writes a row to _zanith_migration_artifacts. These commands walk that table.

SHELLterminal
zanith recover list # all reversible artifacts
zanith recover inspect <table[.col]> # row + recovery_sql
zanith recover restore-column <t.col> # re-add column
[--pk <pkColumn>] # archive-restore join key
zanith recover restore-table <table> # re-add table
zanith recover export <table[.col]> # archive rows out
[--format csv|json|jsonl]
[--out <file>] [--limit <n>]
zanith recover purge <artifact-id> # drop archive + delete row
zanith cleanup --older-than <Nd> # bulk purge by age

Studio

The bundled web UI — runs in-process with the engine. Three deployment modes via auth flags.

SHELLterminal
zanith studio # http://127.0.0.1:4321
[--port <n>] [--host <h>]
[--allow-sql] # raw-SQL playground on
[--auth-token <t>] # admin (full access)
[--read-only-auth-token <t>] # viewer (safe GETs only)
[--workspace-data-dir <path>] # default ~/.zanith
[--project-root <path>] # zanith.config search root
[--no-project] # skip declared schema
[--activity-log] # NDJSON activity to disk
[--audit-log [<path>]] # mutating-request audit

Schema + DB

Read-side commands for inspecting the live database and checking for drift.

SHELLterminal
zanith db introspect # print live-DB summary
zanith schema check # diff declared vs live
# exit 1 on drift
zanith schema diff [--out <file>] # SQL to bring DB into sync

Configuration

The CLI reads zanith.config.{ts,mjs,js,cjs} in the current directory. The default export is the same object you pass to createZanith — adapter, schema, plus optional migrationsDir, safety, and shadow blocks.

FieldWhat it controls
adapterDatabase connection (PgAdapter / SqliteAdapter / postgres.js)
schemaThe compiled schema graph
migrationsDirWhere migration files live (default: migrations)
safety.requireShadowDbInProductionRefuse up without --shadow-verified in prod
shadow.adapterThrowaway Postgres for migrate verify
shadow.resetShadowHook to wipe shadow before each verify