CLI And Maintenance Commands
Compass ships a repo CLI for database maintenance and a few legacy build paths.
Prefer this doc for safety context; use bun run cli --help for exhaustive
command syntax.
Entry Point
bun run cli <command>
Primary file:
packages/scripts/src/cli.ts
Environment loading:
bun run cliloadspackages/backend/.env.local.- Keep local development variables in
packages/backend/.env.local(bootstrap from.env.local.example).
CLI URL Resolution Contract
Primary source:
packages/scripts/src/common/cli.utils.ts
How API base URLs are resolved:
- local (
--environment local): returnsBASEURLdirectly (trailing slash removed) - staging/production: derives
https://<domain>/apifromFRONTEND_URL
Fallback behavior:
- if
FRONTEND_URLpoints atlocalhost, CLI prompts for a domain and buildshttps://<domain>/api - if
FRONTEND_URLis already a non-localhost URL, CLI uses that hostname directly - local mode does not prompt for a domain; it depends on
BASEURL
Commands To Know
Delete
Implementation:
packages/scripts/src/commands/delete.ts
Example:
bun run cli delete --user <id-or-email> --force
Use with care; this is full user purge logic. It removes Compass Mongo data, SuperTokens auth identities, user-id mappings, and SuperTokens metadata. Browser cleanup is still a separate local-only step for cookies, localStorage, and IndexedDB.
Migrate
bun run cli migrate <umzug-subcommand>
Implementation:
packages/scripts/src/commands/migrate.ts
Use pending, executed, up, down, and create through the wrapped Umzug
CLI. For bounded execution, inspect bun run cli migrate --help before running.
Common inspection commands:
bun run cli migrate pending
bun run cli migrate executed
Seed
bun run cli seed <umzug-subcommand>
Seeders use the same migration framework and Mongo-backed execution state.
Build
Builds usually use direct package scripts:
bun run build:webbun run build:backend --environment [local|staging|production]
Use CLI build commands only when you specifically need their legacy packaging behavior.
Migration Internals
The migration command:
- starts Mongo
- builds an Umzug CLI dynamically
- loads migrations from
packages/scripts/src/migrationsor seeders frompackages/scripts/src/seeders - stores execution state in Mongo collections
There is also a separate web-local migration system under packages/web/src/common/storage/migrations; do not confuse the two.
Runbook: Sync Watch Data Migration
Source migration:
packages/scripts/src/migrations/2025.10.13T14.22.21.migrate-sync-watch-data.ts
Intent:
- move Google watch-channel management to the dedicated
watchcollection - recreate active Google watches from sync-derived event watch entries
- leave sync token data in
syncrecords
What the migration does in up:
- clears existing
watchcollection entries - scans
syncrecords with Google event watch metadata and valid expirations - creates a Google client per user (
getGcalClient) - stops old watch channels referenced in sync data
- creates fresh event watches (per calendar) and one calendar-list watch
- inserts rebuilt watch records via
WatchSchema
Operational constraints:
- this migration performs live Google watch API calls; valid Google credentials are required per user
- execution can consume API quota on large datasets because channels are stopped and recreated
downis intentionally non-destructive and does not rebuild old sync-embedded watch state
Recommended execution pattern:
bun run cli migrate pending
bun run cli migrate up --name 2025.10.13T14.22.21.migrate-sync-watch-data
bun run cli migrate executed
Safety Guidance
- Prefer reading a command implementation before running it.
- Treat delete flows as destructive unless proven otherwise.
- For migration work, inspect existing migration naming and ordering first.
- For build work, use
bun run build:weborbun run build:backenddirectly (not the CLI). - There is no waitlist invite CLI command in the current codebase.
Mobile waitlist signup is handled in the web app via
packages/web/src/components/MobileGate/MobileGate.tsx.