CLI Reference
Every `ratchet` command, from `init` to `studio`.
ratchet <command>ratchet init
Scaffolds a new project in the current directory: package.json, tsconfig.json, ratchet.config.ts, models/example.model.ts, migrations/, and a .gitignore. Never overwrites a file that already exists — safe to re-run.
ratchet generate
Reads models/**/*.model.ts and emits, into generatedDir (.ratchet/ by default):
schema.ts— the Drizzle schemavalidators.ts— Zod validatorsregistry.ts— the model registryratchet serveandratchet buildread fromconsole-forms.ts— the custom console form registry, one entry permodels/**/*.form.tsxconsole-field-inputs.ts— the custom field input registry, one entry permodels/**/*.input.tsx
It then runs drizzle-kit generate to diff the fresh schema against migrationsDir (migrations/ by default) and write any new SQL migration files. Review those files, then apply them with ratchet migrate.
Run this any time your models change and you're not using ratchet dev.
ratchet migrate
Runs drizzle-kit migrate against migrationsDir (migrations/ by default), applying and tracking any pending SQL migration files. It does not touch your models or the schema — run ratchet generate first to produce the migration files. Use this for a durable, versioned migration history — the workflow you want outside of local development.
ratchet dev
Watches models/**/*.model.ts. On every change: regenerates, runs drizzle-kit push (pushes schema changes directly, no migration files), and restarts the dev server. Faster iteration loop than migrate, intended for local development only.
ratchet serve
Boots the API server: reads ratchet.config.ts and the generated registry, and starts a listening server with the console (/console by default — see consolePath), /api/auth/*, and /api/:model mounted. No server entry file needed.
PORT=3000 DATABASE_URL=postgres://... ratchet serveratchet build
Builds the console client (Bun's bundler + Tailwind, hashed assets + manifest) and a bundled server artifact, for deploying without dev tooling at runtime.
ratchet studio
Proxies to drizzle-kit studio, for browsing/editing your Postgres database directly.