CLI Reference
@tenantscale/cli provides command-line tools for initializing your TenantScale project, running migrations, and managing tenants. It is the primary interface for administrative operations.
Overview
The TenantScale CLI lets you:
- Initialize a new TenantScale project with database migrations
- Run & roll back database schema migrations
- Create, list, and inspect tenants
- Generate and revoke API keys
- Sync subscription plans to Stripe
- Purge old audit log entries
Commands
| Command | Description | Source |
|---|---|---|
init | Initialize TenantScale and create database tables | docs |
migrate | Run or roll back database migrations | docs |
create-tenant | Create a new tenant | docs |
list-tenants | List all tenants (table or JSON output) | docs |
get-tenant | Get details for a specific tenant | docs |
create-api-key | Generate a new API key for a tenant | docs |
revoke-api-key | Revoke an existing API key | docs |
stripe:sync | Sync subscription plans to Stripe products/prices | docs |
audit:purge | Purge expired audit log entries | docs |
Using npx vs Global Install
npx (No Install Required)
Run any command without installing:
bash
npx @tenantscale/cli init
npx @tenantscale/cli list-tenants
npx @tenantscale/cli create-tenant --name "Acme Corp"Use npx for one-off commands or CI/CD pipelines.
Global Install
Install once for repeated use:
bash
npm install -g @tenantscale/cli
tenantscale init
tenantscale list-tenantsUse the global install for local development workflow.
Source
The CLI is part of the TenantScale monorepo:
@tenantscale/cli
├── src/
│ ├── commands/ # Command implementations
│ │ ├── init.ts
│ │ ├── migrate.ts
│ │ ├── create-tenant.ts
│ │ ├── list-tenants.ts
│ │ ├── get-tenant.ts
│ │ ├── create-api-key.ts
│ │ ├── revoke-api-key.ts
│ │ ├── stripe-sync.ts
│ │ └── audit-purge.ts
│ ├── config.ts # Config file loading
│ ├── db.ts # Database connection
│ └── utils.ts # Shared utilities
├── package.json
└── tsconfig.jsonSource: github.com/TenantScale/sdk/tree/main/packages/cli
Getting Started
bash
# Quick start with npx
npx @tenantscale/cli init
# Or install globally
npm install -g @tenantscale/cli
tenantscale initConfiguration
The CLI needs a connection to your Supabase database. Configure it via:
- Config file —
.tenantscalerc(JSON or YAML) in your project root - Environment variables —
SUPABASE_URLandSUPABASE_SERVICE_KEY .envfile — Auto-loaded from the current directory
See CLI Configuration for full details.
Global Options
| Option | Alias | Description |
|---|---|---|
--config | -c | Path to config file |
--env | -e | Path to .env file |
--json | -j | Output as JSON (machine-readable) |
--help | -h | Show help for a command |
--version | -V | Show CLI version |
Command Documentation
Detailed documentation for each command is available:
- Commands Reference — Full command details with options and examples
- Installation Guide — Installation prerequisites and verification
- Configuration Guide — Config files, environment variables, and secrets
Version
bash
npx @tenantscale/cli --version
# or
tenantscale --versionCurrent stable version: 1.0.0