Skip to Content
Project Init

Project Init

kalam init scaffolds a KalamDB project in the current directory (or --project-dir). It creates kalam.toml, a schema source, kalam/migrations/, generated-output paths, optional starter code from built-in templates, and—when TypeScript is selected—runs your JavaScript package manager to install SDK dependencies.

Run this once per repository before kalam dev, kalam migration, or kalam deploy.

Quick start

BASH
mkdir my-app && cd my-appkalam initkalam dev

For TypeScript projects, init detects npm, pnpm, yarn, or bun on PATH, prompts when more than one is installed, writes the choice to kalam.toml, and runs <manager> install after scaffolding.

Non-interactive bootstrap:

BASH
kalam init --yes \  --name chat-app \  --schema-mode sql \  --languages typescript \  --template simple-live \  --package-manager pnpm \  --server-mode local

What kalam init creates

ArtifactPurpose
kalam.tomlProject config: environments, schema mode, codegen targets, dev orchestration, optional package_manager
schema.sqlActive schema source when schema.mode = "sql" (from template or a starter stub)
kalam/migrations/Migration history directory (default path; omitted from kalam.toml when unchanged)
kalam/.schema-baseline.sqlCreated on first successful schema apply during kalam dev
kalam/.gitignoreIgnores local KalamDB state under kalam/ (server data, CLI logs, baselines)
kalam/server/server.tomlLocal server config when --server-mode local (includes auth.root_password)
Generated outputsPaths from [schema.targets.<language>] (for example src/generated/kalam.ts)
Template filesTypeScript starter when selected (default with --yes: simple-live)
package.json + lockfileTypeScript starter dependencies (when TypeScript is selected)
.env / .env.exampleSets KALAM_PROFILE=kalam-dev so workflow commands resolve saved CLI credentials

kalam.toml stores URLs, namespaces, and toolchain choices only — no secrets. Authenticate with kalam login for remote servers, or let kalam dev bootstrap local root credentials on loopback.

Namespace naming

[connection.dev].namespace is derived from the project name using KalamDB identifier rules (for example chat-appchat_app). If normalization changes the name, init prints the namespace it chose.

Init flags

FlagDescription
--name <NAME>Project name (written to [project].name)
--schema-mode <sql|remote>Active schema source mode (remote is rejected until supported)
--languages <typescript,dart>Comma-separated codegen targets. Aliases: tstypescript
--template <id>Built-in TypeScript template (default simple-live with --yes)
--package-manager <npm|pnpm|yarn|bun>JavaScript package manager for TypeScript projects
--server-mode <local|remote>Whether kalam dev starts a local server or uses an existing URL
--server-url <URL>KalamDB URL for remote mode (local defaults to http://localhost:2900)
--project-dir <PATH>Directory to initialize (default: current directory)
--yesSkip prompts; use defaults for unspecified values

Defaults with --yes

When a flag is omitted and --yes is set:

SettingDefault
Schema modesql
Languagestypescript
Templatesimple-live (TypeScript only)
Package managerFirst available in order: invoking tool from npm_config_user_agent (when present), then pnpm, bun, yarn, npm
Server modelocal
Server URLhttp://localhost:2900
Project nameCurrent directory name, or my-app

Interactive flow

When run in a TTY without --yes, kalam init walks through:

  1. Project name
  2. Schema mode — SQL file (schema.sql) or remote (coming soon)
  3. Language targets — multi-select TypeScript and/or Dart
  4. Template source & template — built-in TypeScript templates (simple-live today; repository templates are listed but not available yet)
  5. Package manager — when TypeScript is selected and multiple of npm/pnpm/yarn/bun are on PATH
  6. Server mode — local (kalam dev starts or reuses a server) or remote
  7. Server URL — when server mode is remote

Menus support Up/Down, Space (multi-select), Enter to confirm, and Esc to cancel.

In CI or piped shells without a TTY, pass --yes and every flag you need (including --package-manager when multiple managers are installed).

TypeScript package managers

TypeScript scaffolding lives under the CLI’s ts/ SDK module. Init only runs a package manager when typescript is in --languages (or selected interactively).

BehaviorDetail
DetectionScans PATH for npm, pnpm, yarn, and bun
Single manager installedSelected automatically
Multiple installedInteractive prompt; with --yes, uses preference order above
Explicit flag--package-manager pnpm (or npm, yarn, bun)
PersistenceWritten to [project].package_manager in kalam.toml
Install stepRuns <manager> install in the project root after files are created
Dart-only projectsNo package manager field and no install step

If dependency install fails, project files remain on disk. The CLI prints command output and recovery steps (for example cd <project> && pnpm install, then kalam dev).

Example kalam.toml

This matches the default scaffold (local server, TypeScript, SQL schema). [migrations].dir defaults to kalam/migrations and is usually omitted from the file.

TOML
[project]name = "chat-app"default_env = "dev"package_manager = "pnpm" [connection.dev]url = "http://localhost:2900"namespace = "chat_app" [schema]mode = "sql"path = "schema.sql"watch = truelanguages = ["typescript"] [schema.targets.typescript]output = "src/generated/kalam.ts" [migrations]auto_create = true [dev]auto_start_db = trueapply_schema = truegenerate_types = truewatch = true [logging]file = truecapture_process_output = true

Add child processes when you want kalam dev to supervise an app server alongside KalamDB:

TOML
[dev.processes]frontend = "pnpm run dev"

Use the same package manager in [dev.processes] that you recorded in [project].package_manager (for example pnpm run dev vs npm run dev). The simple-live template ships package.json scripts but does not add [dev.processes] automatically — configure it when you want the CLI to start your frontend.

After init, add or update named environments without re-running init:

BASH
kalam link --env staging --url https://staging-db.example.com --namespace app

kalam link updates [connection.<env>] in kalam.toml only. Login credentials stay in ~/.kalam/.

Schema commands (no database mutation for gen)

BASH
# Regenerate SDK artifacts from schema.sqlkalam schema gen # Limit to one languagekalam schema gen --languages typescript # Pull live schema into schema.sql (remote mode only)kalam schema pull

Inspect project state

BASH
kalam statuskalam status --env prod --namespace app

Reports resolved URL, namespace, schema mode, codegen targets, and migration counts.

Built-in templates

TypeScript projects can start from embedded templates:

BASH
kalam init --languages typescript --template simple-live

simple-live is a live-subscription starter with sample schema.sql, src/index.ts, and SDK dependencies. Run it manually with your package manager (pnpm run dev, npm run dev, …) or add a [dev.processes] entry so kalam dev supervises it. List available templates interactively during kalam init, or pass --template with --yes.

Troubleshooting

interactive setup needs a terminal (TTY)

Run in a regular terminal, or pass non-interactive flags:

BASH
kalam init --yes --name my-app --languages typescript --package-manager npm

No JavaScript package manager on PATH

Install Node.js (includes npm), pnpm , or bun , open a new terminal, then rerun init. For TypeScript with --yes, add --package-manager <name> once a manager is available.

Explicit package manager not found

If you pass --package-manager npm but only pnpm is installed, either install npm or choose an installed manager:

BASH
kalam init --yes --languages typescript --package-manager pnpm

Dependency install failed after scaffolding

Project files are already created. Finish manually:

BASH
cd my-apppnpm install   # or npm / yarn / bun installkalam dev

The CLI surfaces network, permission, Node version, and registry errors when it can infer them from the package manager output.

Project already exists

If kalam.toml is already present in the directory, init refuses to overwrite. Use a different --project-dir, or open the existing project and run kalam dev.

Next steps

  1. Local Development — run kalam dev
  2. Migrations — draft, seal, and apply schema history
  3. Schema Watch — file watch vs remote polling
Last updated on