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
| Command | Flags | Action |
|---|---|---|
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-report | None | Scaffold 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> | None | Create jobs/<name>.rs without editing any existing file. |
slabs fmt | --check | Run 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-explain | Run 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 doctor | None | Check 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 list | None | Print all compile-time discovered slabs and background jobs in --app-dir. |
slabs css | --watch | Compile 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>, --ephemeral | Compile 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> / -p | Generate 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>, --json | List 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), --json | Fetch 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), --json | Print 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>]andslabs check --slab <feature>/<action>limit formatting,[security]scanning, andcargo-nextestexecution to modified or named slab files.slabs check --explain(warning mode) andslabs check --strict-explain(non-zero exit on violation) boot an in-memory SQLite database frommigrations/orschema.sql, runEXPLAIN QUERY PLANon staticSELECTandWITHqueries extracted fromslabs/andjobs/, and flag unintended full-tableSCANs. 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.--diffflags removed routes and marks auth guard downgrades with[SECURITY].slabs dev --ephemeralbinds127.0.0.1:0against a throwaway SQLite database seeded fromseeds.sql, printsSLABS_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)
| Variable | Default | Description |
|---|---|---|
SLABS_ENV | development | Deployment environment (development, test, staging, production). staging and production enforce fail-closed validation in AppConfig::validate(). |
SLABS_BIND | 127.0.0.1:3000 | Socket address passed to TcpListener::bind. |
DATABASE_URL | sqlite://{app_name}.db?mode=rwc | Database connection URL. sqlite::memory: uses a shared in-memory connection. |
SLABS_SECRET_KEY | Ephemeral random 32-byte key in dev/test; required in staging/prod | Signing 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_MS | 500 | Background job worker poll interval in milliseconds (minimum 50). |
SLABS_JOB_CONCURRENCY | 4 | Maximum concurrent background job worker tasks (minimum 1). |
SLABS_COOKIE_SECURE | true in staging/production, false in development/test | Sets Secure on cookies, names the session cookie __Host-slabs_session, and enables the Strict-Transport-Security header. |
SLABS_CSRF_ENFORCE | true | Enables Fetch Metadata (Sec-Fetch-Site) and Origin CSRF checks on cookie-authenticated mutations. |
SLABS_CORS_ORIGINS | Unset (no CORS headers) | Comma-separated allowlist of browser origins permitted for cross-origin requests and WebSockets. |
SLABS_TRUST_PROXY | false | Allows 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_TOKEN | Unset | Bearer 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_BYTES | 4194304 (4 MiB) | Maximum HTTP request body size enforced by RequestBodyLimitLayer. |
SLABS_MAX_BLOB_BYTES | 10485760 (10 MiB) | Maximum blob upload size accepted by slabs-storage. |
SLABS_WEBHOOKS_LIVE | false | Sends 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_LOCAL | false | Permits outbound webhooks to target loopback or private addresses when "1" or "true". Leave false in production. |
RUST_LOG | info,tower_http=info,sqlx=warn | Tracing filter read by slabs::init_tracing(). |
SLABS_LOG_FORMAT | Plain text | Set to json (case-insensitive) to emit newline-delimited JSON logs. |
Incidents and performance
| Variable | Default | Description |
|---|---|---|
SLABS_URL | http://127.0.0.1:3000 | Base URL read by slabs incidents subcommands. |
SLABS_GIT_SHA | Unset | Deployment 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_MS | 500 | HTTP latency threshold in milliseconds for recording slow_request incidents. |
SLABS_SLOW_JOB_MS | 5000 | Background job latency threshold in milliseconds for recording slow_job incidents. |
SLABS_INCIDENT_STALE_DAYS | 30 | Auto-resolves open and reopened incidents with no new occurrences after this many days. Set to 0 to disable stale auto-close. |
SLABS_INCIDENT_WEBHOOK_URL | Unset | Outbound webhook URL notified on incident.opened, incident.reopened, and incident.resolved (slabs.incident.v1). |
SLABS_INCIDENT_WEBHOOK_SECRET | Unset | HMAC-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.
| Variable | Default | Description |
|---|---|---|
SLABS_RESEND_API_KEY | Unset | Enables Resend HTTP API delivery (MailTransport::Resend). |
SLABS_RESEND_URL | https://api.resend.com/emails | Overrides the Resend API endpoint URL. |
SLABS_SMTP_URL | Unset | Enables 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.
| Variable | Default | Description |
|---|---|---|
SLABS_S3_BUCKET | Required for S3 | Target S3 bucket name (must be non-empty). |
SLABS_S3_ACCESS_KEY_ID | Required for S3 | AWS SigV4 access key ID. |
SLABS_S3_SECRET_ACCESS_KEY | Required for S3 | AWS SigV4 secret access key. |
SLABS_S3_REGION | us-east-1 | AWS SigV4 signing region (such as auto for Cloudflare R2). |
SLABS_S3_ENDPOINT | https://s3.<region>.amazonaws.com | Base endpoint URL without a trailing slash for AWS S3, R2, MinIO, Tigris, or Garage. |