Local Development
kalam dev is the canonical local orchestration entry point for KalamDB projects. It reads kalam.toml, prepares the development database, runs the schema pipeline, regenerates language artifacts, watches schema.sql for changes, and supervises configured child processes.
Quick start
With environment overrides:
Retry a paused schema pipeline on startup (skips draft confirmation prompts):
What kalam dev does
On startup, in order:
- Resolve environment — URL, namespace, and env name from flags, environment variables, then
kalam.toml - Prechecks — schema source exists, codegen target dirs, migrations dir,
kalam/.gitignore, CLI log dir, server reachability or binary availability - Authentication (early) — for remote servers (
auto_start_db = false) or when a local server is already running at the configured URL; verifies saved credentials or prompts you to runkalam login - Local server — when
[dev].auto_start_db = trueand nothing is listening yet, download (interactive) / locatekalamdb-server, spawn it, wait for health, then log in as local root and save credentials to~/.kalam/for profilekalam-<env>(for examplekalam-dev) - Schema pipeline — diff
schema.sql, update_draft.sql, apply numbered migrations, regenerate types when configured - Draft prompt — if
_draft.sqlremains and you did not pass--force, show Apply / Reset / Cancel - Child processes — start commands from
[dev.processes]when configured - File watch loop — poll the schema source every 2 seconds when both
[dev].watchand[schema].watcharetrue
Press Ctrl+C to shut down managed processes cleanly.
If you have no [dev.processes], no local server was spawned, and file watch is disabled, the session may exit after the schema pipeline completes.
Dev flags
| Flag | Description |
|---|---|
--project-dir <PATH> | Project root containing kalam.toml |
--env <NAME> | Environment to use (default from [project].default_env) |
--namespace <NAME> | Override namespace for this session |
--force | Skip draft confirmation prompts; use forceful migration apply options; retry a failed schema pipeline once on startup |
--progress | Deprecated — ignored; kalam dev always uses append-only multiplexed logs |
Environment resolution
| Setting | Resolution order (first match wins) |
|---|---|
| Environment name | --env → KALAM_ENV → [project].default_env → dev |
| Server URL | KALAM_URL → [connection.<env>].url |
| Namespace | --namespace → KALAM_NAMESPACE → [connection.<env>].namespace |
Credential profile for workflow auth comes from .env (KALAM_PROFILE, default kalam-dev) or kalam login --instance kalam-<env>.
Configuring kalam dev
Both [schema].watch and [dev].watch must be true for file watching. If either is false, kalam dev does not poll the schema file.
Match [dev.processes] commands to [project].package_manager from kalam init (for example pnpm run dev when package_manager = "pnpm"). Default kalam init does not add [dev.processes] — add it when you want the CLI to supervise your app.
Local KalamDB server
When [dev].auto_start_db = true (the default for --server-mode local during init):
- Health check — if the configured URL already responds, reuse that server (auth is verified during prechecks)
- Start binary — otherwise spawn
kalamdb-serverwith config atkalam/server/server.toml - Bootstrap auth — log in as
rootusingauth.root_passwordfromkalam/server/server.toml, ormypasson loopback when no password is configured, then save JWT credentials forkalam-<env> - Data & logs — server storage under
kalam/server/dataandkalam/server/logs
Finding kalamdb-server
The CLI resolves the server binary in this order:
KALAMDB_SERVER_BIN— absolute path to the binary (usekalamdb-server.exeon Windows)- Binary colocated next to the
kalamexecutable ~/.kalam/bin/kalamdb-server(managed install directory)kalamdb-serveronPATH
On first kalam dev in an interactive terminal, the CLI can download the matching server release into ~/.kalam/bin when no binary is found. Non-interactive environments (CI) must preinstall the server or set KALAMDB_SERVER_BIN.
See Server binaries for manual downloads.
Managed service logs
kalam dev multiplexes logs from the local server and every [dev.processes] entry into one append-only console stream:
- Each line is prefixed with a stable source label (
server,frontend,agent, …) - Sources use distinct colors when the terminal supports it
- When
[logging].file = true, the same lines are mirrored tokalam/cli/logs/kalam.log(secrets redacted)
If schema apply fails, the failure is shown prominently and only the schema pipeline pauses. Server and frontend logs keep streaming so you can debug without losing context.
Schema pipeline during dev
When apply_schema is enabled and schema.mode = "sql":
- Diff
schema.sqlagainstkalam/.schema-baseline.sql(when no numbered migrations are pending) - Write or update
kalam/migrations/_draft.sqlwhen changes exist - Apply numbered migrations that are not yet on the server (
--forceuses forceful apply options) - Update the baseline after a successful apply unless a draft is still pending confirmation
- Run
kalam schema genwhengenerate_types = true
With --force, numbered migrations still apply immediately, but _draft.sql is not auto-sealed — you still confirm draft application unless you seal/apply through migration commands.
See Migrations for draft sealing, kalam db migrate, and recovery commands.
Draft migration prompt
When _draft.sql exists and you did not pass --force, kalam dev pauses streaming output and shows a modal selector:
| Choice | Behavior |
|---|---|
| Apply changes | Seal and apply the draft migration, then refresh baseline/types |
| Reset and rebuild | Drop the namespace on the server, clear local numbered migrations + baseline, rebuild from schema.sql |
| Cancel | Stop kalam dev without applying |
In non-interactive terminals, send y (apply), r (reset), or any other key (cancel).
File watch behavior
When watch is enabled, kalam dev polls the schema file every 2 seconds. On change:
- Debounce — wait until the file metadata stabilizes (editors often save in bursts; up to ~2s)
- Diff — update
_draft.sqlfrom the new schema vs baseline when no numbered migrations are pending - Apply — run the schema pipeline (numbered migrations first; draft stays pending until you confirm)
- Regenerate — refresh TypeScript/Dart outputs when configured
- Prompt — show the draft modal again when
_draft.sqlremains (unless--force)
This is file-based watch — it reacts to edits on schema.sql in your repo. It does not poll system.tables on the server.
For server-side DDL watch (any client changing the database), use Remote Schema Watch (kalam --watch-schema).
Local vs remote server mode
Set during kalam init or in kalam.toml:
- Local (
--server-mode local,[dev].auto_start_db = true) —kalam devmay download, spawn, or reusekalamdb-server - Remote (
--server-mode remote,[dev].auto_start_db = false) —kalam devconnects to[connection.<env>].urland never starts a local binary
Troubleshooting
kalamdb-server was not found
Install or download the server, or set an explicit path:
In CI, preinstall the binary before running kalam dev. Interactive download requires a TTY.
KALAMDB_SERVER_BIN points to a file that does not exist
Unset the variable to let the CLI auto-locate the server, or fix the path (include .exe on Windows).
Dev process failed to start ([dev.processes])
The CLI prints the shell command and actionable hints:
- Verify the program exists on
PATH(or use an absolute path inkalam.toml) - Run the command manually from the project root
- On Windows, npm/pnpm/yarn are often
*.cmdshims —kalam devruns process commands through the system shell (cmd /C)
Example fix when pnpm is recorded in kalam.toml:
Schema pipeline paused
A migration or codegen step failed. Child processes and the local server may keep running while schema work is paused. Retry once at startup:
Check [server] and schema log lines, then fix schema.sql or migration files before rerunning.
Authentication / login errors
For remote servers, run kalam login --instance kalam-<env> and ensure .env sets KALAM_PROFILE to that profile.
For local servers, kalam dev tries saved credentials first, then root login using kalam/server/server.toml. If that fails, run kalam login or fix auth.root_password in the server config. See Authentication.