Skip to content

CLI Reference

The Pulsabase CLI is your main tool for managing and deploying projects. It handles everything from authentication to schema migrations and deployments.

Terminal window
npm install -g @pulsabase/cli

Verify:

Terminal window
pulsabase --version

Authenticate with your Pulsabase account. Opens a browser window using a secure OAuth2 PKCE flow — no password is stored locally.

Terminal window
pulsabase login

Your access and refresh tokens are saved to ~/.pulsabase/credentials.json (with strict 600 permissions). Tokens are automatically refreshed before they expire.

Options:

FlagDefaultDescription
--idp-url <url>http://localhost:4000IDP URL (for self-hosted setups)
--auth-url <url>http://localhost:8889Auth service URL
--project-id <id>Optionally scope the login to a specific project

Remove stored credentials and sign out.

Terminal window
pulsabase logout

Display the currently authenticated user’s email and identity.

Terminal window
pulsabase whoami

Initialize a new Pulsabase project in the current directory or link to an existing one.

Terminal window
pulsabase init
pulsabase init my-app # Provide the project name directly

The interactive wizard will:

  1. Ask you to create a new project or link to an existing one
  2. Prompt for your API key (shown once on project creation)
  3. Ask your preferred language (TypeScript, Dart, Swift, Kotlin)
  4. Set up the models directory (default: src/models)
  5. Optionally configure OAuth client credentials

Generated files:

  • .pulsabase/config.json — local machine config (added to .gitignore automatically)
  • src/config.ts — developer-facing config with URLs and API key

Shorthand to link an existing project interactively (without creating a new one).

Terminal window
pulsabase link

Synchronize your local TypeScript models to the remote database schema. Pulsabase prioritizes safety: destructive changes (dropping a table or column) are blocked by default.

Terminal window
# Preview what SQL migrations will be generated (no changes applied)
pulsabase db:sync --dry-run
# Apply safe migrations to the database
pulsabase db:sync
# Apply ALL changes, including destructive ones (requires confirmation)
pulsabase db:sync --force

How it works:

  1. Reads your TypeScript models from the configured modelsDir
  2. Resolves dependency order (foreign key dependencies sorted topologically)
  3. Sends the schema to the backend, which diffs against the current database
  4. Reports a plan: safe changes (adding columns, tables, indexes) vs. unsafe changes (dropping or altering)
  5. If --force is used, prompts for confirmation before applying destructive changes

Flags:

FlagDescription
--dry-runPreview the migration plan without applying any changes
--forceBypass safety checks and apply destructive changes. Interactive confirmation required.

Always run --dry-run before --force. Dropped columns cannot be recovered.


Pull the existing schema from the database and generate local model files. This is the code-first → pull direction: you build tables in the Dashboard, then pull them as typed models.

Terminal window
# Pull all tables into src/models/
pulsabase db:pull
# Overwrite local files without prompting
pulsabase db:pull --force
# Specify a custom output directory
pulsabase db:pull --output src/lib/models
# Only pull specific tables
pulsabase db:pull --tables 'users,posts,comments'

Revert the remote database schema to a previous version.

Terminal window
# Revert the most recent migration
pulsabase db:rollback
# Rollback to a specific historical version
pulsabase db:rollback --to 5

Scaffold a new TypeScript model file with the correct decorator structure.

Terminal window
pulsabase generate:model Post
pulsabase generate:model Comment --table comments

This creates src/models/Post.ts (or the equivalent in your configured modelsDir) with:

  • @primary ID column
  • Common column decorators
  • static schema: ModelSchema block with tableName

Deploy your project — schema, RLS policies, edge functions, and static hosting — in a single command.

Terminal window
pulsabase deploy
pulsabase deploy --dir build # Specify a custom build directory
FlagDescription
--dir <path>Build output directory (default: dist)
--dry-runPreview changes without applying
--forceSkip all confirmation prompts

Show the current authentication status and linked project information.

Terminal window
pulsabase status

Display the installed CLI version.

Terminal window
pulsabase --version

The CLI uses two config files:

FileScopeContents
~/.pulsabase/credentials.jsonGlobal (machine-wide)OAuth tokens, IDP URL
.pulsabase/config.jsonPer-projectProject ID, API key, language, models dir

Both are created automatically by pulsabase login and pulsabase init. Neither should be committed to version control.