/supabase-pack:supabase-common-errorsfrom supabase-pack
Diagnoses and fixes Supabase errors across PostgREST, PostgreSQL, Auth, Storage, and Realtime. Walks through error capture, layer classification, and fix application for codes like PGRST301, 42501, 23505.
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.
Diagnostic guide for Supabase errors across PostgREST (PGRST*), PostgreSQL (numeric codes), Auth, Storage, and Realtime. Identify the error layer, trace the root cause, and apply the correct fix — database queries return { data, error }; other SDK services have their own result, callback, and exception contracts.
The workflow is three steps: capture the error object, classify it by layer and code, then apply and verify the fix. Full step-by-step code lives in the diagnostic walkthrough; complete lookup tables are in the error reference.
@supabase/supabase-js installed (npm install @supabase/supabase-js)SUPABASE_URL and a publishable/anon key configured; normal request clients use verified user identity and RLSnpx supabase --version)Supabase database queries return a { data, error } result. Never assume data exists — always destructure and check error first, because data is null whenever error is set.
const { data, error } = await supabase.from('todos').select('*');
if (error) {
console.error(`[${error.code}] ${error.message}`);
return; // data is null here — do not touch it
}
console.log(`Found ${data.length} rows`);
Do not diagnose the installed SDK version solely from an undefined property. Check which service/method produced the result, its documented shape, and the locked dependency version. Realtime subscriptions and Python clients differ.
Match the code prefix to its subsystem, then look it up in the Error Handling tables below:
PGRST* → PostgREST (API gateway: JWT, query parsing, schema)42501, 23505) → PostgreSQL engine (RLS, constraints, migrations)AuthApiError → Auth service (credentials, confirmation, token expiry)StorageApiError → Storage service (bucket, RLS on storage.objects, size limits)A missing code needs service-specific inspection: 401 can reflect invalid user credentials or a missing bearer identity, and 500 has multiple possible causes. Status alone does not prove a wrong project key or failing SQL function. A paste-ready diagnoseSupabaseError() classifier is in the walkthrough.
Apply the fix from the matching Error Handling table, then re-run the original operation to confirm. Common recoveries:
PGRST301, verify the JWT/project/session configuration; it means the JWT cannot be decoded or is invalid. Use the Auth session recovery workflow only when appropriate, not an automatic retry loop.42501, inspect verified user identity, grants, and RLS under that identity. It means insufficient privilege, not necessarily RLS. Do not bypass the user boundary with a service-role client in the request path.NOTIFY pgrst, 'reload schema').Full before/after fix code for both cases is in the walkthrough.
Deliverables after applying this skill:
if (error) checks) preventing silent null-data bugsThe two most-cited layers are inline below. Auth, Storage, and Realtime tables are in the full error reference.
| Code | HTTP | Meaning | Root Cause | Fix |
|---|---|---|---|---|
PGRST301 | 401 | JWT cannot be decoded or is invalid | Invalid token or mismatched configuration | Verify token/project/session through the appropriate Auth workflow; do not retry blindly |
PGRST302 | 401 | Bearer request absent while anonymous role disabled | Request lacks required identity | Verify authenticated bearer propagation and server configuration |
PGRST116 | 406 | Singular result has zero or multiple rows | Result does not satisfy exactly-one contract | Use .maybeSingle() for zero-or-one; correct multiple matches |
PGRST200 | 400 | Relationship/schema-cache mismatch | Embedded relationship absent or stale | Check foreign keys and embedding; refresh cache if appropriate |
PGRST204 | 400 | Column not found | Column name doesn't exist in the table or view | Verify column exists with supabase gen types typescript; check for typos |
PGRST000 | 503 | Database connection unavailable | Invalid database URI or database not running | Inspect service configuration and availability |
PGRST003 | 504 | Pool acquisition timed out | No pool connection became available | Inspect query load and pool capacity; apply bounded admission |
| Code | Meaning | Root Cause | Fix |
|---|---|---|---|
42501 | Insufficient privilege | Grants or RLS deny this identity | Review grants and policies with the actual authorized user |
23505 | Unique constraint violation | INSERT/UPDATE conflicts with an existing row | Review conflict semantics; .upsert(row, { onConflict: 'column' }) can overwrite data and needs authorization |
23503 | Foreign key violation | Referenced row doesn't exist in the parent table | Insert the parent row first, or check the foreign key value |
42P01 | Table or relation doesn't exist | Migration not applied, or wrong schema | Run supabase db push; verify schema with \dt in SQL Editor |
42703 | Column doesn't exist | Schema out of sync with code | Regenerate types: supabase gen types typescript --local > types/supabase.ts |
57014 | Query cancelled (statement timeout) | Query took longer than statement_timeout | Add indexes; simplify the query; increase timeout in postgresql.conf |
The most common failure — calling .single() on optional data — is inline below. Three more worked examples (upsert to dodge 23505, Realtime subscription error handling, and serverless pool exhaustion) are in the examples reference.
.single() on optional data (PGRST116)const { data: profile, error } = await supabase
.from('profiles')
.select('id, display_name')
.eq('user_id', userId)
.maybeSingle();
if (error) throw error;
if (!profile) {
// A successful zero-row read is not authorization to create an arbitrary profile.
// Present the application's separately authorized create-profile workflow.
}
supabase-debug-bundle to generate a full diagnostic snapshot when errors persist after applying these fixes.supabase-security-basics to audit your RLS policies and prevent 42501 errors proactively.supabase-known-pitfalls for edge cases and SDK behavior that can cause subtle bugs.supabase-observability to set up logging and alerting so you catch errors before users report them.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin supabase-pack30 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-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".
/supabase-data-handlingImplement GDPR/CCPA compliance with Supabase: RLS for data isolation, user
deletion via auth.admin.deleteUser(), data export via SQL, PII column
management, backup/restore workflows, and retention policies.
Use when handling sensitive data, implementing right-to-deletion, configuring
data retention, or auditing PII in Supabase database columns.
Trigger with: "supabase GDPR", "supabase data handling", "supabase PII",
"supabase compliance", "supabase data retention", "supabase delete user",
"supabase data export".
Other plugins' skills for the same job