Skip to Content

Kalam CLI Command Reference

The Kalam CLI (kalam) is the SQL-first terminal client for KalamDB. This guide documents every CLI flag and interactive command currently implemented in ../KalamDB/cli, including live subscriptions, topic consumers, credential workflows, and agent scaffolding.

Install and verify

Choose one of these installation options:

curl -fsSL https://kalamdb.org/install.sh | bash

Option 2: GitHub release binaries

Use prebuilt binaries from releases if you do not want a Rust toolchain:

Option 3: Build from source

cd cli cargo build --release ./target/release/kalam --help

After installation, verify your CLI:

kalam --help kalam --version

Execution modes and precedence

kalam supports four execution modes:

  1. --init-agent: generate a TypeScript agent scaffold and exit.
  2. --subscribe / --list-subscriptions / --unsubscribe: subscription management flow.
  3. --consume --topic ...: topic consumer mode.
  4. SQL execution mode:
    • --file <path> executes file and exits
    • --command <sql> executes one statement and exits
    • no --file/--command starts interactive shell

Important behavior:

  • --consume takes precedence over --file and --command.
  • --file and --command together are invalid.

Connection and authentication options

OptionDescription
-u, --url <URL>Full server URL (for example http://localhost:8080).
-H, --host <HOST>Host-only alternative to --url; combines with --port.
-p, --port <PORT>Port used with --host (default 3000).
--token <JWT>JWT auth token.
--username <USER>Basic auth username.
--password [PASS]Basic auth password. If passed with no value in interactive mode, CLI prompts.
--instance <NAME>Credential profile name (default local).

URL defaults and resolution:

  • If --url is set, that value is used.
  • If --host is set, URL becomes http://<host>:<port>.
  • Otherwise CLI uses stored credentials URL for the selected --instance when present.
  • Final fallback is http://localhost:8080.

Query execution and output options

OptionDescription
-c, --command <SQL>Execute a single SQL statement and exit.
-f, --file <PATH>Execute SQL from file and exit.
--format <table|json|csv>Output format (default table).
--jsonShorthand for --format json.
--csvShorthand for --format csv.
--no-colorDisable ANSI colors.
--no-spinnerDisable spinner animations.
--loading-threshold-ms <MS>Spinner threshold in milliseconds.

Examples:

kalam --command "SELECT * FROM system.tables LIMIT 5;" kalam --command "SELECT * FROM system.tables LIMIT 5;" --json kalam --file ./setup.sql --csv

Credential and instance management

OptionDescription
--list-instancesList stored credential instances.
--show-credentialsShow stored credentials for --instance.
--update-credentialsLogin and refresh stored JWT/refresh token for --instance.
--delete-credentialsDelete credentials for --instance.
--save-credentialsSave credentials after successful login when using username/password flow.

Examples:

kalam --list-instances kalam --show-credentials --instance dev kalam --update-credentials --instance dev --url http://localhost:8080 --username admin kalam --delete-credentials --instance dev

Live query subscription options

OptionDescription
--subscribe <SQL>Run a live query subscription.
--subscription-timeout <SECONDS>Idle timeout after initial data (0 means no timeout).
--initial-data-timeout <SECONDS>Maximum wait for initial data batch (0 means no timeout).
--list-subscriptionsPrint current subscription model/capabilities.
--unsubscribe <ID>Prints unsubscribe guidance (active cancellation is Ctrl+C in running session).

Examples:

kalam --subscribe "SELECT * FROM app.messages WHERE conversation_id = 7" kalam --subscribe "SELECT * FROM app.messages" --subscription-timeout 120 --initial-data-timeout 15

Topic consumer options (--consume)

Use this mode to consume topic records directly from a terminal.

OptionDescription
--consumeEnable topic consumer mode.
--topic <TOPIC>Topic name (required with --consume).
--group <GROUP_ID>Consumer group (offsets committed when set).
--from <earliest|latest|OFFSET>Start position. Supports numeric offset.
--consume-limit <N>Maximum number of messages before exit.
--consume-timeout <SECONDS>Stop after idle runtime window.

Examples:

# Read newest events and keep running kalam --consume --topic blog.summarizer --from latest # Replay from earliest with bounded run kalam --consume --topic blog.summarizer --group summarizer-agent --from earliest --consume-limit 50 --consume-timeout 60

Agent scaffolding options (--init-agent)

The CLI can generate a ready-to-run TypeScript summarizer-style agent project.

OptionDescription
--init-agentGenerate scaffold.
--init-agent-non-interactiveDisable prompts and use defaults/flags.
--agent-name <NAME>Project directory name.
--agent-output <DIR>Parent output directory (default current dir).
--agent-table <namespace.table>Target table id.
--agent-topic <namespace.topic>Topic id.
--agent-group <GROUP_ID>Consumer group id.
--agent-id-column <COL>Primary key column in table.
--agent-input-column <COL>Input text column.
--agent-output-column <COL>Output summary column.
--agent-system-prompt <TEXT>Default system prompt passed into scaffold.

Scaffold defaults:

  • table: blog.blogs
  • topic: <namespace>.<table>_agent
  • group: <project-name-slug>-group
  • id/input/output columns: blog_id, content, summary

Example:

kalam \ --init-agent \ --init-agent-non-interactive \ --agent-name summarizer-agent \ --agent-output ./examples \ --agent-table blog.blogs \ --agent-topic blog.summarizer \ --agent-group blog-summarizer-agent \ --agent-id-column blog_id \ --agent-input-column content \ --agent-output-column summary

Create a sample agent with CLI

Use the command above (or kalam --init-agent interactive mode), then:

cd ./examples/summarizer-agent npm install npm run start

If you want the published SDK package, install it from npm:

npm install kalam-link

Package reference: kalam-link on npm 

Generated src/agent.ts shape

The scaffold generates an agent.ts that wires runAgent() with retries and failure handling:

import { Auth, createClient, runAgent } from 'kalam-link'; const client = createClient({ url: process.env.KALAMDB_URL ?? 'http://127.0.0.1:8080', auth: Auth.basic( process.env.KALAMDB_USERNAME ?? 'root', process.env.KALAMDB_PASSWORD ?? 'kalamdb123', ), }); await runAgent<Record<string, unknown>>({ client, name: 'summarizer-agent', topic: process.env.KALAMDB_TOPIC ?? 'blog.summarizer', groupId: process.env.KALAMDB_GROUP ?? 'blog-summarizer-agent', start: 'earliest', batchSize: 20, retry: { maxAttempts: 3, initialBackoffMs: 250, maxBackoffMs: 1500, multiplier: 2, }, onRow: async (ctx, row) => { // Read row, generate summary, and write summary column. }, onFailed: async (ctx) => { // Persist terminal failures to failure table. }, ackOnFailed: true, });

Agent example references

Timeout and runtime tuning options

OptionDescription
--timeout <SECONDS>HTTP request timeout (default 30).
--connection-timeout <SECONDS>Connection/TLS handshake timeout (default 10).
--receive-timeout <SECONDS>Receive timeout (default 30).
--auth-timeout <SECONDS>WebSocket auth timeout (default 5).
--fast-timeoutsPreset tuned for local development.
--relaxed-timeoutsPreset tuned for high-latency networks.
--config <PATH>Config file path (default ~/.kalam/config.toml).
-v, --verboseVerbose logging.

Global utility options

OptionDescription
-h, --helpPrint command help.
-V, --versionPrint CLI version, commit, branch, and build timestamp.

Interactive shell commands by category

After launching interactive mode (kalam with no --command/--file), these backslash commands are available.

Core shell and inspection

CommandDescription
\help, \?Show help.
\quit, \qExit CLI.
\info, \sessionShow session info.
\history, \hOpen command history menu.
\healthServer health check.
\stats, \metricsQuery system stats metrics.

Schema and formatting

CommandDescription
\dt, \tablesList tables.
\d <table>, \describe <table>Describe table columns.
\format table|json|csvChange output format for current session.
\refresh-tables, \refreshRefresh autocomplete table metadata.

Credentials in interactive mode

CommandDescription
\show-credentials, \credentialsShow stored credentials for current instance.
\update-credentials <user> <pass>Update credentials for current instance.
\delete-credentialsDelete credentials for current instance.

Live query commands

CommandDescription
\subscribe <SQL>, \watch <SQL>Start live query subscription.
\unsubscribe, \unwatchStop current watch context (if active).

Topic consumer command (interactive)

CommandDescription
\consume <topic> [--group NAME] [--from earliest|latest|OFFSET] [--limit N] [--timeout SECONDS]Consume topic messages directly from interactive shell.

Example:

\consume blog.summarizer --group summarizer-agent --from earliest --limit 25 --timeout 45

Cluster and ingest control commands

CommandDescription
\flushRun STORAGE FLUSH ALL for current namespace context.
\pausePause ingestion (PAUSE).
\continueResume ingestion (CONTINUE).
\cluster snapshotTrigger cluster snapshot.
\cluster purge --upto <index> or \cluster purge <index>Purge cluster logs up to index.
\cluster trigger-election or \cluster trigger electionTrigger election.
\cluster transfer-leader <node_id> or \cluster transfer leader <node_id>Transfer leadership to node id.
\cluster stepdown or \cluster step-downStep down current leader.
\cluster clearClear old cluster snapshots.
\cluster list or \cluster lsShow cluster nodes (system.cluster).
\cluster list groupsShow cluster groups (system.cluster_groups).
\cluster statusAlias of cluster status query.
\cluster join <addr>Currently prints guidance (not implemented yet).
\cluster leaveCurrently prints guidance (not implemented yet).

Quick command map

# Interactive shell kalam # One-shot SQL kalam -c "SELECT * FROM system.tables LIMIT 5;" # File execution kalam -f ./queries.sql # Live subscription kalam --subscribe "SELECT * FROM app.messages" # Topic consumer kalam --consume --topic blog.summarizer --group summarizer-agent --from latest # Generate agent scaffold kalam --init-agent
Last updated on