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:
Option 1: install.sh (recommended)
curl -fsSL https://kalamdb.org/install.sh | bashOption 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 --helpAfter installation, verify your CLI:
kalam --help
kalam --versionExecution modes and precedence
kalam supports four execution modes:
--init-agent: generate a TypeScript agent scaffold and exit.--subscribe/--list-subscriptions/--unsubscribe: subscription management flow.--consume --topic ...: topic consumer mode.- SQL execution mode:
--file <path>executes file and exits--command <sql>executes one statement and exits- no
--file/--commandstarts interactive shell
Important behavior:
--consumetakes precedence over--fileand--command.--fileand--commandtogether are invalid.
Connection and authentication options
| Option | Description |
|---|---|
-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
--urlis set, that value is used. - If
--hostis set, URL becomeshttp://<host>:<port>. - Otherwise CLI uses stored credentials URL for the selected
--instancewhen present. - Final fallback is
http://localhost:8080.
Query execution and output options
| Option | Description |
|---|---|
-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). |
--json | Shorthand for --format json. |
--csv | Shorthand for --format csv. |
--no-color | Disable ANSI colors. |
--no-spinner | Disable 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 --csvCredential and instance management
| Option | Description |
|---|---|
--list-instances | List stored credential instances. |
--show-credentials | Show stored credentials for --instance. |
--update-credentials | Login and refresh stored JWT/refresh token for --instance. |
--delete-credentials | Delete credentials for --instance. |
--save-credentials | Save 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 devLive query subscription options
| Option | Description |
|---|---|
--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-subscriptions | Print 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 15Topic consumer options (--consume)
Use this mode to consume topic records directly from a terminal.
| Option | Description |
|---|---|
--consume | Enable 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 60Agent scaffolding options (--init-agent)
The CLI can generate a ready-to-run TypeScript summarizer-style agent project.
| Option | Description |
|---|---|
--init-agent | Generate scaffold. |
--init-agent-non-interactive | Disable 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 summaryCreate a sample agent with CLI
Use the command above (or kalam --init-agent interactive mode), then:
cd ./examples/summarizer-agent
npm install
npm run startIf you want the published SDK package, install it from npm:
npm install kalam-linkPackage 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
| Option | Description |
|---|---|
--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-timeouts | Preset tuned for local development. |
--relaxed-timeouts | Preset tuned for high-latency networks. |
--config <PATH> | Config file path (default ~/.kalam/config.toml). |
-v, --verbose | Verbose logging. |
Global utility options
| Option | Description |
|---|---|
-h, --help | Print command help. |
-V, --version | Print 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
| Command | Description |
|---|---|
\help, \? | Show help. |
\quit, \q | Exit CLI. |
\info, \session | Show session info. |
\history, \h | Open command history menu. |
\health | Server health check. |
\stats, \metrics | Query system stats metrics. |
Schema and formatting
| Command | Description |
|---|---|
\dt, \tables | List tables. |
\d <table>, \describe <table> | Describe table columns. |
\format table|json|csv | Change output format for current session. |
\refresh-tables, \refresh | Refresh autocomplete table metadata. |
Credentials in interactive mode
| Command | Description |
|---|---|
\show-credentials, \credentials | Show stored credentials for current instance. |
\update-credentials <user> <pass> | Update credentials for current instance. |
\delete-credentials | Delete credentials for current instance. |
Live query commands
| Command | Description |
|---|---|
\subscribe <SQL>, \watch <SQL> | Start live query subscription. |
\unsubscribe, \unwatch | Stop current watch context (if active). |
Topic consumer command (interactive)
| Command | Description |
|---|---|
\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 45Cluster and ingest control commands
| Command | Description |
|---|---|
\flush | Run STORAGE FLUSH ALL for current namespace context. |
\pause | Pause ingestion (PAUSE). |
\continue | Resume ingestion (CONTINUE). |
\cluster snapshot | Trigger cluster snapshot. |
\cluster purge --upto <index> or \cluster purge <index> | Purge cluster logs up to index. |
\cluster trigger-election or \cluster trigger election | Trigger election. |
\cluster transfer-leader <node_id> or \cluster transfer leader <node_id> | Transfer leadership to node id. |
\cluster stepdown or \cluster step-down | Step down current leader. |
\cluster clear | Clear old cluster snapshots. |
\cluster list or \cluster ls | Show cluster nodes (system.cluster). |
\cluster list groups | Show cluster groups (system.cluster_groups). |
\cluster status | Alias of cluster status query. |
\cluster join <addr> | Currently prints guidance (not implemented yet). |
\cluster leave | Currently 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