CLI Reference
The semilayer CLI is the primary way to interact with SemiLayer: configure projects,
push schemas, manage sources, generate the typed client, and monitor ingest status.
Installation
Verify with:
Authentication
semilayer login
Authenticate with SemiLayer Cloud or your enterprise instance.
| Flag | Description |
|---|---|
--service-url <url> | Target a self-hosted instance |
semilayer logout
Clear stored credentials.
semilayer whoami
Show the currently authenticated user.
Project Setup
semilayer init
Interactive wizard — select or create an org, project, and environment. Saves context
to .semilayerrc and optionally creates a starter sl.config.ts.
Run this first when setting up a new codebase. The .semilayerrc file tells all
subsequent CLI commands which org/project/environment to target.
| Flag | Description |
|---|---|
--service-url <url> | Override the service API URL |
semilayer config
View or update the active context (org, project, environment, service URL).
Schema
semilayer push
Push your sl.config.ts to the service. Registers new lenses, updates changed ones,
and marks removed ones for cleanup.
| Flag | Description |
|---|---|
--resume-ingest | Start ingest for new/modified lenses after push |
--rebuild | Full re-index for ALL lenses (clears existing data — prompts for confirmation) |
--skip-confirmation-dangerously | Skip rebuild confirmation for CI/CD |
--force | Skip drift detection — push even if Console has newer changes |
Drift detection runs automatically on every push. If the Console has modified a lens since your last push, you'll see a warning and a confirmation prompt.
semilayer export config
Pull the remote config back to your local sl.config.ts. Useful when the Console has
changes you want to sync back to code.
semilayer status
Show lens statuses, ingest queue, and (in SaaS mode) quota usage.
Output:
Code Generation
semilayer generate
Generate the typed Beam client from your sl.config.ts. Outputs TypeScript files
to ./generated/semilayer/ by default.
| Flag | Default | Description |
|---|---|---|
--out <dir> | ./generated/semilayer | Output directory |
The generated module exports a createBeam factory and a Beam class, both fully
typed against your lens definitions. See Beam Client.
Ingest Control
semilayer pause
Pause ingest for one or all lenses.
semilayer resume
Resume ingest for one or all lenses.
semilayer sync
Trigger a manual smart sync for a lens (or all lenses) — full scan with content-hash dedup and tombstone detection. Same handler the Console "Sync now" button invokes.
Manual runs count against the same smart_sync_jobs monthly tier quota
as scheduled runs from smartSyncInterval. A 429 response with
error: 'SMART_SYNC_QUOTA_EXHAUSTED' means you've hit the cap for this
billing cycle — check semilayer status for the current counter, or
upgrade via semilayer billing.
Streaming
semilayer stream
Subscribe to a live tail for a lens and print events to stdout.
semilayer observe
Watch a single record for changes.
Count
semilayer count <lens>
Count rows on a lens matching a where predicate. Sibling of query for
"how many" questions — uses the bridge's native count when available.
| Flag | Description |
|---|---|
--api-key <key> | sk_ or pk_ key (required) |
--where <json> | JSON predicate. Same grammar as query — supports $or, $and, $not, $in, $gte, $ilike, etc. |
--exit-code | Exit with the count itself (clamped to 0–255) for shell branching: count … --exit-code && alert. |
--json | Print the raw CountResponse body. |
--service-url <url> | Override service URL. |
Analyze
The semilayer analyze command group drives the analyze facet —
list, run, drill into, explain, and tune named analyses. Lens-analysis
identifier is <lens>.<analysisName> (mirrors how Beam emits them).
semilayer analyze list <lens>
List the named analyses declared on a lens.
| Flag | Description |
|---|---|
--api-key <key> | sk_ or pk_ key (required) |
semilayer analyze run <lens.name>
Run an analysis once and print buckets + totals.
| Flag | Description |
|---|---|
--api-key <key> | sk_ or pk_ key (required) |
--input <json> | Inline JSON body or @path/to/file.json |
--cache <directive> | Pass-through to the Cache-Control header — e.g. no-cache to force a recompute |
--json | Print the raw AnalyzeResult body |
--ndjson | Emit one bucket per line (NDJSON) — pairs with shell pipelines |
semilayer analyze rows <lens.name>
Drill into one bucket — fetch the contributing rows, paginate via cursor or stream the whole set out.
| Flag | Description |
|---|---|
--api-key <key> | sk_ or pk_ key (required) |
--bucket <key> | bucketKey from a bucket in analyze run (required) |
--cursor <token> | Cursor returned by the previous page |
--limit <n> | Page size (default 100, max 1000) |
--search <q> | Free-text query inside the bucket |
--search-mode <mode> | auto | simple | semantic | hybrid (default auto) |
--sort <col[:dir]> | Sort field, optionally with :asc or :desc. Repeatable for multi-key sort |
--export <path> | Stream all matching rows to a file; - for stdout. Pairs with --format |
--format <fmt> | ndjson or csv (default ndjson) — applies only when --export is set |
--json | Output raw JSON instead of a table (page mode) |
semilayer analyze explain <lens.name>
Full execution plan + cache decision for one analyze. Requires an sk_
key — pk_ keys are rejected client-side before the request fires.
| Flag | Description |
|---|---|
--api-key <key> | Service key (sk_) — pk_ rejected |
--input <json> | Inline JSON body or @path/to/file.json |
--json | Output raw JSON |
semilayer analyze plan <lens.name>
Print source-DB index recommendations for an analysis. sk_ only.
| Flag | Description |
|---|---|
--api-key <key> | Service key (sk_) |
--json | Output raw JSON |
--sql | Print only the DDL statements (pipe-friendly) |
Feeds
The semilayer feed command group drives the feed facet — list,
fetch, tail, and explain named feeds without going through Beam codegen.
The lens-feed identifier is <lens>.<feedName> (mirrors how Beam emits them).
semilayer feed list <lens>
List the named feeds declared on a lens.
| Flag | Description |
|---|---|
--api-key <key> | sk_ or pk_ key (required) |
semilayer feed view <lens.feedName>
Fetch one page of a named feed and render it as a table (or JSON).
| Flag | Description |
|---|---|
--api-key <key> | sk_ or pk_ key (required) |
--context <json> | Inline JSON or @path/to/file.json |
--cursor <token> | Cursor returned from a previous page |
--limit <n> | pageSize override |
--json | Output raw JSON instead of a table |
semilayer feed tail <lens.feedName>
Stream feed.tick events as NDJSON to stdout. Ctrl+C to stop.
Useful for observability and shell pipelines:
semilayer feed explain <lens.feedName>
Per-record per-scorer breakdown. Requires an sk_ key — pk_ keys get a
friendly client-side error before the request fires.
| Flag | Description |
|---|---|
--api-key <key> | Service key (sk_) — pk_ rejected |
--record <id> | Source row id (required) |
--context <json> | Inline JSON or @path/to/file.json |
--json | Output raw JSON instead of a table |
Sources
semilayer sources connect
Interactively connect a new data source and introspect available targets.
Prompts for a bridge package, connection details, and a name. Stores the source in your current environment. Lists available tables/collections/endpoints after connecting.
semilayer sources list
semilayer sources remove
Organization Management
These commands manage your org, projects, environments, members, and API keys from the terminal.
Billing (SaaS)
Global Flags
--help / -h — Show help for any command.
--version / -v — Show the CLI version.
Config File
The .semilayerrc file in your project root (or any parent directory) stores context:
The CLI walks up the directory tree to find the nearest .semilayerrc. Credentials
(auth tokens) are stored separately in ~/.semilayer/credentials.json.