Supabase CLI
Official CLI for Supabase. Manage PostgreSQL databases, auth, storage, edge functions, and local development.
- Official repo: https://github.com/supabase/cli
- Docs: https://supabase.com/docs/reference/cli
Authentication
supabase login # Browser-based login
supabase link --project-ref PROJECT_REF # Link to remote project
Common Commands
Local Development
supabase init # Initialize new project
supabase start # Start local Supabase stack
supabase stop # Stop local stack
supabase status # Show local service URLs/keys
supabase db reset # Reset local database
Database & Migrations
supabase migration new create_users # Create new migration
supabase migration list # List migrations
supabase db push # Push migrations to remote
supabase db pull # Pull remote schema as migration
supabase db diff --schema public # Diff local vs remote
supabase db dump --data-only -f seed.sql # Dump data
Edge Functions
supabase functions new my-function # Create new function
supabase functions serve my-function # Serve locally
supabase functions deploy my-function # Deploy to production
supabase functions list # List deployed functions
supabase functions delete my-function # Delete function
Type Generation
supabase gen types typescript --local > types/supabase.ts
supabase gen types typescript --linked > types/supabase.ts
Secrets
supabase secrets set MY_SECRET=value
supabase secrets list
supabase secrets unset MY_SECRET
Agent Best Practices
- Use
supabase statusto get local API URL and anon key - Always create migrations for schema changes instead of modifying directly
- Use
supabase db diffto check for drift between local and remote - Use
supabase gen typesafter schema changes to keep types in sync - Run
supabase db resetto test migrations from scratch - Use
supabase functions servewith--env-filefor local secrets
Example Workflows
Create and apply a migration
supabase migration new add_profiles_table
# Edit the migration file in supabase/migrations/
supabase db reset # Test locally
supabase db push # Deploy to remote
Generate TypeScript types
supabase gen types typescript --linked > src/types/database.ts