/supabase-pack:supabase-multi-env-setupfrom supabase-pack
Configures three-tier Supabase environments (dev, staging, production) with separate projects, environment-specific secrets, and safe migration promotion via supabase db push.
Ships in supabase-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Production Supabase deployments require a separate project per environment — each with its
own URL, API keys, database, and RLS policies. This skill configures a three-tier
architecture (local dev, staging, production) with safe migration promotion via
supabase db push, environment-aware createClient initialization, database branching
for preview deployments, and CI/CD that prevents accidental cross-environment operations.
When to use: setting up a new project with multiple environments, migrating from a single-project setup, adding staging to an existing dev/prod split, or configuring preview environments with database branching.
npm install --save-dev supabase or npx supabase --version@supabase/supabase-js v2+ installed in your project.env files (Next.js, Nuxt, SvelteKit, etc.)The workflow is three steps. Each step below gives the shape and the one command that matters; the full implementation walkthrough carries the complete env files, TypeScript client factory, RLS policies, CI/CD workflow, and seed data verbatim.
Keep one Supabase CLI project with shared migrations and one .env.* file per
environment. Credential-bearing files, including .env.local, stay gitignored. Commit only a reviewed .env.example containing placeholders, never real local or hosted credentials.
supabase/migrations/ # shared schema — every env applies the same migrations
.env.local # local credentials (gitignored)
.env.staging # staging project creds (gitignored)
.env.production # production project creds (gitignored — NEVER commit)
.env.example # reviewed placeholders only (may be committed)
The CLI links one project at a time. Before any db push or functions deploy,
re-link to the target:
npx supabase link --project-ref <target-ref>
See the implementation walkthrough (Step 1)
for full .env.* contents, the .gitignore block, and the local-port reference.
Detect the active environment once, then build browser (anon key, respects RLS) and server (service-role key, bypasses RLS) clients from it. Gate every destructive helper behind a production guard so seeds and resets can never fire against prod:
export function requireNonProduction(operation: string): void {
if (isProduction()) {
throw new Error(`[BLOCKED] "${operation}" is not allowed in production.`);
}
}
The implementation walkthrough (Step 2)
has the full lib/env.ts detection, the createBrowserClient / createServerClient
factory, the seedTestData / resetDatabase guards, and environment-scoped RLS policies.
Promote schema changes strictly local → staging → production. db reset applies
everything plus seed.sql locally; db push applies only new migrations to a linked
remote:
npx supabase db reset # local: all migrations + seed
npx supabase link --project-ref <staging-ref> && npx supabase db push # then staging
npx supabase link --project-ref <prod-ref> && npx supabase db push # then production
For preview deployments, supabase branches create (Pro plan) gives each feature its own
isolated database, URL, and keys. Full migration workflow, branching commands, the
GitHub Actions deploy workflow (with a production approval gate), and seed data live in the
implementation walkthrough (Step 3).
Completing this skill produces:
.env files — .env.local, .env.staging, .env.production with correct credentialscreateClient — browser and server clients auto-configured from env vars with x-environment header trackingrequireNonProduction() blocks destructive operations outside local/stagingsupabase db push promotes schema changes local → staging → productiondatabase.types.ts generated from local or linked project schema| Error | Cause | Solution |
|---|---|---|
Cannot find project ref | CLI not linked to a project | Run npx supabase link --project-ref <ref> before db push |
Migration has already been applied | Re-running an existing migration | Check supabase_migrations.schema_migrations table; migrations are idempotent by ref |
Permission denied for schema public | Wrong database password | Verify SUPABASE_DB_PASSWORD matches the project's database password in dashboard |
Seed data appeared in production | Ran supabase db reset on prod | seed.sql only runs on db reset — never reset production; use db push instead |
Wrong environment keys in client | .env file mismatch | Check SUPABASE_ENV var and verify URL matches expected project ref |
Branch creation failed | Free plan or branching not enabled | Database branching requires Supabase Pro plan; enable in project settings |
Migration drift between envs | Skipped staging promotion | Always promote through staging first; compare with supabase migration list per project |
Type generation mismatch | Types generated from wrong env | Regenerate from local (--local) or re-link to the canonical environment |
Three worked examples live in references/examples.md. The fastest
path — a full three-env bootstrap from supabase init to a production db push — is:
npx supabase init && npx supabase start # local, copy keys to .env.local
npx supabase migration new create_users # author schema, then:
npx supabase db reset # verify locally
npx supabase link --project-ref "<staging-ref>" && npx supabase db push
npx supabase link --project-ref "<prod-ref>" && npx supabase db push
Examples 2 and 3 (full file) show a Next.js middleware that
stamps and gates on x-supabase-env, and an admin handler that calls requireNonProduction
before a destructive RPC.
supabase-auth-storage-realtime-coresupabase-policy-guardrailssupabase-local-dev-loopsupabase-observabilityWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
30 skills in this plugin
/supabase-advanced-troubleshootingDeep Supabase diagnostics: pg_stat_statements for slow queries, lock debugging
with pg_locks, connection leak detection, RLS policy conflicts, Edge Function
cold starts, and Realtime connection drop analysis.
Use when standard troubleshooting fails, when investigating performance
regressions, when debugging race conditions, or when building evidence for a
Supabase support escalation.
Trigger with "supabase deep debug", "supabase slow query", "supabase lock
contention", "supabase connection leak", "supabase RLS conflict", "supabase
cold start".
/supabase-architecture-variantsUse when choosing how to integrate Supabase into a specific stack — setting up
Next.js SSR auth flows, wiring an SPA or React Native client, configuring mobile
deep links, or designing multi-tenant data isolation. Covers where the client runs
(browser vs server) and which key it uses (anon respects RLS, service_role bypasses it).
Trigger with phrases like "supabase next.js", "supabase SSR", "supabase react native",
"supabase SPA", "supabase serverless", "supabase multi-tenant", "supabase server component",
"supabase architecture", "supabase service_role server".
/supabase-auth-storage-realtime-coreImplement Supabase Auth (signUp, signIn, OAuth, session management), Storage (upload, download, signed URLs, bucket policies), and Realtime (Postgres changes, broadcast, presence). Use when building user auth flows, file upload features, or live-updating UIs with Supabase. Trigger with phrases like "supabase auth", "supabase storage upload", "supabase realtime subscribe", "supabase oauth", "supabase file upload", "supabase presence", "supabase rls storage". /supabase-ci-integrationConfigure Supabase continuous-integration and deployment pipelines with
GitHub Actions: link projects, push migrations, deploy Edge Functions,
generate types, and run tests against local Supabase instances.
Use when setting up CI pipelines for Supabase, automating database
migrations, deploying Edge Functions in CI, or running integration tests.
Trigger with phrases like "supabase CI", "supabase GitHub Actions",
"supabase deploy pipeline", "CI supabase migrations", "supabase preview branches".
/supabase-common-errorsDiagnose and fix Supabase errors across PostgREST, PostgreSQL, Auth, Storage, and Realtime.
Use when encountering error codes like PGRST301, 42501, 23505, or auth failures.
Use when debugging failed queries, RLS policy violations, or HTTP 4xx/5xx responses.
Trigger with "supabase error", "fix supabase", "PGRST", "supabase 403", "RLS not working",
"supabase auth error", "unique constraint", "foreign key violation".
/supabase-cost-tuningOptimize Supabase costs through plan selection, database tuning, storage cleanup,
connection pooling, and Edge Function optimization.
Use when analyzing Supabase billing, reducing costs, right-sizing compute,
or implementing usage tracking and budget alerts.
Trigger with phrases like "supabase cost", "supabase billing",
"reduce supabase costs", "supabase pricing", "supabase expensive", "supabase budget".
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin supabase-packOther plugins' skills for the same job