Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI commands and environment variables

This reference documents every slabs CLI subcommand, flag, and runtime environment variable read by Slabs v0.5.0.

CLI global options

Pass --app-dir <PATH> before any subcommand to target an app directory outside the current working directory (defaults to .):

slabs --app-dir examples/campfire list

When running directly from the Slabs workspace without installing the binary, invoke it via Cargo:

mise exec -- cargo run -p slabs-cli -- --app-dir examples/campfire list

CLI subcommands

CommandFlagsAction
slabs new app <name>--dir <path>Create a standalone PWA-ready Slabs app (slabs-framework = "0.5", slabs-build = "0.5", #[cfg(test)] test_app(), starter and PWA slabs, cargo-chef + Litestream v0.3.13 Dockerfile, docker-entrypoint.sh, .dockerignore, litestream.yml, seeds.sql, bundled .claude/skills/, CLAUDE.md, and least-privilege CI).
slabs new slab <feature> <name>--method <verb> (default post), --path <route> (default /api/<feature>/<name>)Validate identifiers and route syntax, then create slabs/<feature>/<name>.rs with a starter guard and co-located test without editing any existing file.
slabs new bug-reportNoneScaffold slabs/support/report_bug.rs with a zero-JS HTML/HTMX multipart form (up to 3 image, video, or file attachments stored via ctx.storage.put_scoped("bug_report", ...)), server-side user_id, sanitized Referer path, User-Agent, ctx.incidents recording, and co-located tests.
slabs new job <name>NoneCreate jobs/<name>.rs without editing any existing file.
slabs fmt--checkRun cargo fmt on the crate and rustfmt --edition 2021 on every .rs file in slabs/ and jobs/. With --check, exits non-zero if any file needs formatting.
slabs check--workspace, --no-docs, --changed, --base <ref>, --slab <feature>/<action>, --explain, --strict-explainRun the 6-step CI suite (formatting, [security] static analyzer, Clippy -D warnings, Rustdoc -D warnings, doctests, and cargo nextest or cargo test). --changed [--base <ref>] and --slab <feature>/<action> run targeted formatting, security scanning, and cargo-nextest on only the selected slab(s). --explain and --strict-explain run SQLite EXPLAIN QUERY PLAN over static SELECT/WITH queries in slabs/ and jobs/ and flag unintended full-table SCANs (// slabs:allow-scan: <reason> opts out).
slabs manifest--json, --write <path>, --diff <snapshot_or_git_ref>Emit a deterministic route, auth guard, SQL table, job, and test contract summary for --app-dir. --write <path> saves a snapshot file. --diff <snapshot_or_git_ref> compares against a snapshot or git ref and flags removed routes and [SECURITY] auth guard downgrades.
slabs doctorNoneCheck the Rust toolchain, unsafe_code = "forbid", schema.sql, .dockerignore, SLABS_ENV and SLABS_SECRET_KEY rules, and the [security] static scan summary.
slabs deploy init--target <kamal|fly|vps>, --db <sqlite|postgres> (default sqlite)Generate deployment templates (config/deploy.yml for Kamal 2, fly.toml for Fly.io, or deploy/Caddyfile plus a hardened systemd unit for a bare Linux VPS) tuned for single-writer SQLite (boot.limit: 1 with kamal-proxy buffering, or Fly immediate) or multi-replica PostgreSQL (rolling).
slabs listNonePrint all compile-time discovered slabs and background jobs in --app-dir.
slabs css--watchCompile assets/input.css to assets/styles/app.css with the standalone tailwindcss v4 binary (minified one-shot by default, or continuous with --watch).
slabs dev--package <name> / -p, --bind <addr>, --ephemeralCompile Tailwind CSS, run tailwindcss --watch, and run cargo watch (or cargo run when cargo-watch is absent). With --ephemeral, boots a throwaway SQLite database seeded from seeds.sql on 127.0.0.1:0, prints SLABS_EPHEMERAL_URL, and cleans up temporary files on exit.
slabs db migrate--database-url <url> (env: DATABASE_URL)Create all 12 system tables and apply SQL migrations from <app_dir>/migrations to SQLite or PostgreSQL.
slabs db seed--database-url <url> (env: DATABASE_URL), --file <path> (optional)Run an idempotent SQL seed file (defaults to <app_dir>/seeds.sql) against SQLite or PostgreSQL.
slabs db dump-schema--database-url <url> (env: DATABASE_URL)Write the live database schema snapshot to <app_dir>/schema.sql for SQLite or PostgreSQL.
slabs db prepare--database-url <url> (optional, env: DATABASE_URL), --package <name> / -pGenerate offline .sqlx/ metadata for compile-time sqlx::query! checks. Defaults to a temporary SQLite database migrated from <app_dir>/migrations.
slabs incidents list--url <url> (env: SLABS_URL), --token <token> (env: SLABS_METRICS_TOKEN), --status <active|open|reopened|resolved|all> (default active), --limit <n>, --jsonList incidents from GET /_slabs/incidents, ordered by last_seen_at DESC.
slabs incidents show <id>--url <url> (env: SLABS_URL), --token <token> (env: SLABS_METRICS_TOKEN), --jsonFetch one incident from GET /_slabs/incidents/{id}, including source_file, repro_hint, recent_occurrences_json, attachment IDs, and a ready-to-paste repro_test Rust skeleton.
slabs incidents resolve <id>--sha <git_sha>, --url <url> (env: SLABS_URL), --token <token> (env: SLABS_METRICS_TOKEN)Mark an incident resolved via POST /_slabs/incidents/{id}/resolve with an optional deployed commit SHA.
slabs incidents perf--url <url> (env: SLABS_URL), --token <token> (env: SLABS_METRICS_TOKEN), --jsonPrint per-route p50/p95/p99 latency percentiles, job queue stats, and active incident count from GET /_slabs/metrics.

Harness engineering CLI contracts

The four zero-dependency Harness Engineering tools added in v0.5.0 operate directly on the local repository without external services:

  • slabs check --changed [--base <ref>] and slabs check --slab <feature>/<action> limit formatting, [security] scanning, and cargo-nextest execution to modified or named slab files.
  • slabs check --explain (warning mode) and slabs check --strict-explain (non-zero exit on violation) boot an in-memory SQLite database from migrations/ or schema.sql, run EXPLAIN QUERY PLAN on static SELECT and WITH queries extracted from slabs/ and jobs/, and flag unintended full-table SCANs. Add // slabs:allow-scan: <reason> immediately above an intentional scan to suppress the finding.
  • slabs manifest [--json] [--write <path>] [--diff <snapshot_or_git_ref>] extracts a deterministic route, auth guard, table, job, and test manifest. --diff flags removed routes and marks auth guard downgrades with [SECURITY].
  • slabs dev --ephemeral binds 127.0.0.1:0 against a throwaway SQLite database seeded from seeds.sql, prints SLABS_EPHEMERAL_URL=http://127.0.0.1:<port> to stdout, and removes temporary files on exit.

Runtime environment variables

Core (slabs-core::AppConfig::from_env and slabs::init_tracing)

VariableDefaultDescription
SLABS_ENVdevelopmentDeployment environment (development, test, staging, production). staging and production enforce fail-closed validation in AppConfig::validate().
SLABS_BIND127.0.0.1:3000Socket address passed to TcpListener::bind.
DATABASE_URLsqlite://{app_name}.db?mode=rwcDatabase connection URL. sqlite::memory: uses a shared in-memory connection.
SLABS_SECRET_KEYEphemeral random 32-byte key in dev/test; required in staging/prodSigning key for cookies, magic links, tokens, and HMAC digests. In staging and production, boot fails if unset, shorter than 32 bytes, or equal to the legacy dev sentinel.
SLABS_STORAGE_DIR./storage/{app_name}Local filesystem root for StorageBackend::Local.
SLABS_ASSETS_DIR./assets (or ./examples/{app_name}/assets)Directory scanned at boot by Assets::from_dir.
SLABS_JOB_POLL_MS500Background job worker poll interval in milliseconds (minimum 50).
SLABS_JOB_CONCURRENCY4Maximum concurrent background job worker tasks (minimum 1).
SLABS_COOKIE_SECUREtrue in staging/production, false in development/testSets Secure on cookies, names the session cookie __Host-slabs_session, and enables the Strict-Transport-Security header.
SLABS_CSRF_ENFORCEtrueEnables Fetch Metadata (Sec-Fetch-Site) and Origin CSRF checks on cookie-authenticated mutations.
SLABS_CORS_ORIGINSUnset (no CORS headers)Comma-separated allowlist of browser origins permitted for cross-origin requests and WebSockets.
SLABS_TRUST_PROXYfalseAllows client_ip to read CF-Connecting-IP, Fly-Client-IP, and the rightmost valid IP in X-Forwarded-For. Enable only behind a trusted reverse proxy.
SLABS_METRICS_TOKENUnsetBearer token protecting GET /_slabs/metrics and the four /_slabs/incidents* endpoints, and read by slabs incidents. In staging and production, these endpoints return 404 when unset.
SLABS_MAX_BODY_BYTES4194304 (4 MiB)Maximum HTTP request body size enforced by RequestBodyLimitLayer.
SLABS_MAX_BLOB_BYTES10485760 (10 MiB)Maximum blob upload size accepted by slabs-storage.
SLABS_WEBHOOKS_LIVEfalseSends live HTTP requests for outbound webhooks when "1" or "true". When false, marks deliveries 200 in the outbox without network I/O.
SLABS_WEBHOOKS_ALLOW_LOCALfalsePermits outbound webhooks to target loopback or private addresses when "1" or "true". Leave false in production.
RUST_LOGinfo,tower_http=info,sqlx=warnTracing filter read by slabs::init_tracing().
SLABS_LOG_FORMATPlain textSet to json (case-insensitive) to emit newline-delimited JSON logs.

Incidents and performance

VariableDefaultDescription
SLABS_URLhttp://127.0.0.1:3000Base URL read by slabs incidents subcommands.
SLABS_GIT_SHAUnsetDeployment commit SHA attached to recorded incidents and each recent_occurrences_json ring-buffer entry (seen_at, git_sha, request_id, latency_ms).
SLABS_SLOW_REQUEST_MS500HTTP latency threshold in milliseconds for recording slow_request incidents.
SLABS_SLOW_JOB_MS5000Background job latency threshold in milliseconds for recording slow_job incidents.
SLABS_INCIDENT_STALE_DAYS30Auto-resolves open and reopened incidents with no new occurrences after this many days. Set to 0 to disable stale auto-close.
SLABS_INCIDENT_WEBHOOK_URLUnsetOutbound webhook URL notified on incident.opened, incident.reopened, and incident.resolved (slabs.incident.v1).
SLABS_INCIDENT_WEBHOOK_SECRETUnsetHMAC-SHA256 signing secret used to emit X-Slabs-Signature: sha256=<hex> on incident webhooks.

Mail transport (slabs-mail::MailTransport::from_env)

Selection priority order is SLABS_RESEND_API_KEY, then SLABS_SMTP_URL, then OutboxOnly.

VariableDefaultDescription
SLABS_RESEND_API_KEYUnsetEnables Resend HTTP API delivery (MailTransport::Resend).
SLABS_RESEND_URLhttps://api.resend.com/emailsOverrides the Resend API endpoint URL.
SLABS_SMTP_URLUnsetEnables SMTP delivery via lettre (such as smtps://user:pass@smtp.host).

S3 object storage (slabs-storage::S3Config::from_env)

When all three required variables are set, AppCtx::connect selects StorageBackend::S3. Otherwise it uses StorageBackend::Local.

VariableDefaultDescription
SLABS_S3_BUCKETRequired for S3Target S3 bucket name (must be non-empty).
SLABS_S3_ACCESS_KEY_IDRequired for S3AWS SigV4 access key ID.
SLABS_S3_SECRET_ACCESS_KEYRequired for S3AWS SigV4 secret access key.
SLABS_S3_REGIONus-east-1AWS SigV4 signing region (such as auto for Cloudflare R2).
SLABS_S3_ENDPOINThttps://s3.<region>.amazonaws.comBase endpoint URL without a trailing slash for AWS S3, R2, MinIO, Tigris, or Garage.