skills/vercel-supabase-alignment/SKILL.md
Verify that Vercel environment variables point to the correct Supabase project for each environment to prevent staging/production cross-wiring. Triggers on: vercel supabase check, environment alignment, env var check, supabase environment.
npx skillsauth add mdmagnuson-creator/yo-go vercel-supabase-alignmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Verify that Vercel environment variables point to the correct Supabase project for each environment. This prevents the common issue where staging deployments accidentally connect to production databases (or vice versa).
Load this skill when:
vercel CLI installed and authenticated (vercel whoami succeeds)supabase CLI installed (optional, for local link verification)environments configured in docs/project.json with database objectsWhen the user reports an issue, map their context to an environment:
| User Says | Likely Environment | Look Up |
|-----------|-------------------|---------|
| "Helm Dev", "dev app", "staging app" | staging | environments.staging.desktop.appName |
| "Helm", "prod app", "production app" | production | environments.production.desktop.appName |
| "localhost", "local", "my machine" | development | environments.development |
| API URL like *-api.vercel.app | staging | environments.staging.apiUrl |
| API URL like api.example.com | production | environments.production.apiUrl |
Detection algorithm:
# Read project.json to get environment config
PROJECT_JSON=$(cat docs/project.json)
# Try to match user context to environment
# 1. Check desktop app names
# 2. Check API URLs
# 3. Check branch names
# 4. Ask user if ambiguous
Once environment is identified, read expected database from project.json:
# For staging:
jq -r '.environments.staging.database.projectRef' docs/project.json
jq -r '.environments.staging.database.projectName' docs/project.json
# For production:
jq -r '.environments.production.database.projectRef' docs/project.json
jq -r '.environments.production.database.projectName' docs/project.json
# List all env vars for the Vercel project
vercel env ls
# Get specific Supabase-related vars by environment
# Note: Vercel uses "production", "preview", "development"
# For Preview (typically maps to staging):
vercel env pull .env.preview --environment=preview --yes 2>/dev/null
grep -E "SUPABASE|DATABASE" .env.preview
# For Production:
vercel env pull .env.production --environment=production --yes 2>/dev/null
grep -E "SUPABASE|DATABASE" .env.production
# Clean up
rm -f .env.preview .env.production
Supabase URLs contain the project ref:
https://[PROJECT_REF].supabase.co
Parse the project ref:
# Extract project ref from SUPABASE_URL or NEXT_PUBLIC_SUPABASE_URL
SUPABASE_URL=$(grep SUPABASE_URL .env.preview | cut -d= -f2)
ACTUAL_REF=$(echo "$SUPABASE_URL" | sed -E 's|https://([^.]+)\.supabase\.co.*|\1|')
echo "Actual project ref: $ACTUAL_REF"
EXPECTED_REF=$(jq -r '.environments.staging.database.projectRef' docs/project.json)
ACTUAL_REF="[extracted from Vercel env]"
if [ "$EXPECTED_REF" != "$ACTUAL_REF" ]; then
echo "⚠️ MISMATCH DETECTED"
echo "Expected: $EXPECTED_REF"
echo "Actual: $ACTUAL_REF"
fi
Problem: Vercel defaults main branch deployments to use "Production" environment variables, but the project uses main for staging and production branch for actual production.
Detection:
# Check Vercel project settings
vercel inspect --scope [team] | grep -A5 "Production Branch"
Fix options:
Change Vercel production branch (recommended):
# In Vercel dashboard: Settings → Git → Production Branch → "production"
# Or via API/CLI if supported
Use Preview for main branch: Configure main branch deployments to use Preview env vars.
Create explicit environment mapping: Use Vercel's branch-specific env vars feature.
Problem: supabase link was run against production instead of staging.
Detection:
# Check which project is linked locally
cat supabase/.temp/project-ref 2>/dev/null || supabase status
Fix:
# Re-link to correct project
supabase link --project-ref [CORRECT_PROJECT_REF]
Problem: Migration ran successfully but app still shows "column not found".
Diagnosis:
Verify migration was applied to expected database:
# Check which database the migration was applied to
supabase db remote status
Compare with app's actual database:
# Get app's database from Vercel env
vercel env pull .env.check --environment=preview --yes
grep SUPABASE_URL .env.check
If different, apply migration to correct database:
# Switch to correct project and apply
supabase link --project-ref [CORRECT_REF]
supabase db push
When running alignment check, output this report:
═══════════════════════════════════════════════════════════════════════
ENVIRONMENT ALIGNMENT CHECK
═══════════════════════════════════════════════════════════════════════
PROJECT: [Project Name]
CHECK TIME: [Timestamp]
ENVIRONMENT MAPPING (from project.json)
───────────────────────────────────────────────────────────────────────
Environment Branch Database Project Desktop App
───────────── ─────────── ────────────────── ───────────
staging main Helm (rvuy...) Helm Dev
production production helm-prod (hiuh...) Helm
VERCEL ENVIRONMENT VARIABLES
───────────────────────────────────────────────────────────────────────
Vercel Env SUPABASE_URL Project Ref Expected Status
────────── ─────────────────────── ──────── ──────
preview rvuylmblhafnryfdlnkj rvuy... ✅ MATCH
production hiuhimcmmqdeeyhvdkrb hiuh... ✅ MATCH
LOCAL SUPABASE LINK
───────────────────────────────────────────────────────────────────────
Linked to: rvuylmblhafnryfdlnkj (Helm - staging) ✅ CORRECT
VERCEL BRANCH CONFIGURATION
───────────────────────────────────────────────────────────────────────
Production Branch: production ✅ CORRECT
Branch → Env Mapping:
main branch → Preview env vars
production branch → Production env vars
RESULT: ✅ All environments aligned correctly
═══════════════════════════════════════════════════════════════════════
Or if issues found:
═══════════════════════════════════════════════════════════════════════
ENVIRONMENT ALIGNMENT CHECK
═══════════════════════════════════════════════════════════════════════
...
RESULT: ❌ MISALIGNMENT DETECTED
Issues Found:
1. ⚠️ Vercel preview env points to PRODUCTION database
Expected: rvuylmblhafnryfdlnkj (staging)
Actual: hiuhimcmmqdeeyhvdkrb (production)
FIX: Update SUPABASE_URL in Vercel Preview environment:
vercel env rm SUPABASE_URL preview
vercel env add SUPABASE_URL preview
→ Enter: https://rvuylmblhafnryfdlnkj.supabase.co
2. ⚠️ Vercel production branch is set to 'main'
Expected: 'production'
FIX: Go to Vercel Dashboard → Settings → Git → Production Branch
Change from 'main' to 'production'
═══════════════════════════════════════════════════════════════════════
When Builder encounters a database error:
This prevents the common mistake of applying migrations to the wrong database.
Before running supabase db push or migration commands:
# Verify we're pushing to the intended environment
LINKED_REF=$(cat supabase/.temp/project-ref 2>/dev/null)
STAGING_REF=$(jq -r '.environments.staging.database.projectRef' docs/project.json)
PROD_REF=$(jq -r '.environments.production.database.projectRef' docs/project.json)
if [ "$LINKED_REF" = "$PROD_REF" ]; then
echo "⚠️ WARNING: About to push migrations to PRODUCTION database"
echo "Press Ctrl+C to cancel, or Enter to continue"
read
fi
After deploying to Vercel, verify the deployment uses correct env vars:
# Get the deployment URL
DEPLOY_URL=$(vercel ls --json | jq -r '.[0].url')
# Check which database it's using (if app exposes this info)
# Or verify by testing a known staging-only vs prod-only data point
data-ai
Generate verification contracts before delegating tasks to sub-agents, defining how success will be measured. Triggers on: verification contract, delegation contract, task verification, contract-first delegation.
development
Manage codebase and database vectorization for semantic search. Use when initializing, refreshing, or querying the vector index. Triggers on: vectorize init, vectorize refresh, vectorize search, semantic search, vector index, enable vectorization.
testing
Patterns for XCUITest UI tests for native Apple apps (macOS/iOS). Use when writing or reviewing XCUITest tests for Swift apps. Triggers on: XCUITest, xcuitest, native app testing, Apple UI tests, SwiftUI tests, AppKit tests, UIKit tests.
testing
Quality-beyond-correctness E2E testing patterns. Catches visual glitches, performance issues, layout shifts, and intermediate bad states. Triggers on: flicker test, visual stability, performance budget, negative assertion, CLS test, drag drop test, animation test.