AgentSkillsCN

supabase-verification

当您需要验证 Supabase 的模式变更,或生成类型定义时,可使用此技能。

SKILL.md
--- frontmatter
name: supabase-verification
description: Use when verifying Supabase schema changes or generating types

Supabase Verification Workflow

Prerequisites

Before running any PNPM scripts (including Supabase commands), you MUST verify the script exists in package.json. See the general-pnpm-scripts skill for the verification workflow.

Type Generation

  • Command: pnpm sb:dev:types
  • Generates TypeScript types from local Supabase schema
  • Output: src/types/database.types.ts

When to Run Type Generation

  • After applying migrations
  • After schema changes via Supabase Studio
  • Before committing database changes
  • When TypeScript shows type mismatches with DB

Testing Migrations

Apply incrementally (preserves data):

  • Command: pnpm sb:dev:push
  • Applies new migrations only
  • Preserves existing test data
  • Use for day-to-day development

Full reset (clean slate):

  • Command: pnpm sb:dev:reset
  • Resets local database to clean state
  • Re-applies all migrations in order
  • Use for final verification before production or when DB is corrupted

Verification Workflow

Daily development:

  1. Make schema changes (migration or Studio)
  2. Apply migrations: pnpm sb:dev:push
  3. Regenerate types: pnpm sb:dev:types
  4. Test application with new types
  5. Commit migration files AND regenerated types together

Before production push:

  1. Verify migrations from scratch: pnpm sb:dev:reset
  2. Regenerate types: pnpm sb:dev:types
  3. Test application thoroughly
  4. Push to production: pnpm sb:prod:push

Database Lint Verification

CRITICAL: Run after every migration:

bash
cd spark/frontend/my-vite-app
supabase db lint

What It Checks:

  • RLS performance (auth.uid() optimization)
  • Duplicate policies
  • Duplicate indexes
  • Other performance issues

Required Action: Fix all warnings before deploying.