/supabase-pack:supabase-sdk-patternsfrom supabase-pack
Provides production-ready, type-safe patterns for Supabase SDKs (supabase-js and supabase-py) covering queries, auth, realtime, storage, and RPC calls with explicit error handling.
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 patterns for @supabase/supabase-js v2 and supabase-py, with explicit error handling for each service; database queries return { data, error }. Covers client initialization, CRUD with filters, auth, realtime, storage, and RPC, with Python equivalents for the query patterns.
@supabase/supabase-js v2 installed (TypeScript) or supabase pip package (Python)supabase gen types typescriptReuse a client within an appropriate browser context. Cookie-authenticated SSR
requires a request-scoped @supabase/ssr client; never share a mutable user session
across unrelated server requests. The HTTP SDK client is not a direct SQL pool.
The following example is browser-only and uses public build-time configuration,
not server secret/service-role credentials.
// lib/supabase.ts
import { createClient } from '@supabase/supabase-js';
import type { Database } from './database.types';
let supabase: ReturnType<typeof createClient<Database>>;
export function getSupabase() {
if (!supabase) {
supabase = createClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
{
auth: { autoRefreshToken: true, persistSession: true },
db: { schema: 'public' },
global: { headers: { 'x-app-name': 'my-app' } },
},
);
}
return supabase;
}
Python: use create_client(url, key) with the intended identity. Do not cache
mutable user-authenticated clients across unrelated requests; Python raises service-
specific exceptions and does not universally return a JavaScript-style error tuple.
See Python initialization.
Destructure { data, error } and check error before touching data. Chain
filters onto .from(table).select(...); use .select().single() after an
insert/upsert to return the affected row. Skeleton:
const { data, error } = await getSupabase()
.from('users')
.select('id, name, email')
.eq('active', true)
.order('name')
.limit(10);
if (error) throw error;
For the full CRUD set (insert-with-select, upsert on conflict, update, delete, RPC), the complete 12-filter reference table, and the Python equivalents, see queries and filters.
These APIs have distinct contracts: onAuthStateChange returns subscription data,
Realtime reports status through callbacks, and getPublicUrl builds a URL without
checking object existence. Check each documented result/callback rather than
assuming every call returns a database-query error tuple. Auth exposes signUp / signInWithPassword / getSession /
onAuthStateChange; realtime subscribes to postgres_changes on a channel and
requires removeChannel cleanup; storage does upload / download /
getPublicUrl / createSignedUrl per bucket. Full walkthroughs with code for
each: see auth, realtime, and storage.
Applying these patterns yields:
Database genericsDatabase query results return { data, error }. Check the returned error;
handle thrown transport/application exceptions at the appropriate caller boundary.
const { data, error } = await getSupabase().from('users').select('*');
if (error) {
// error is a PostgrestError with these fields:
// error.message — human-readable description
// error.code — Postgres error code (e.g., '23505')
// error.details — additional context
// error.hint — suggested fix from Postgres
console.error(`Query failed [${error.code}]: ${error.message}`);
throw error;
}
// Only safe to use data after the error check
| Error Code | Meaning | What to Do |
|---|---|---|
PGRST116 | Singular result expected, but zero or multiple rows | Use .maybeSingle() for zero-or-one; multiple rows still require correction |
23505 | Unique-constraint violation (Postgres duplicate key) | Use .upsert() or show conflict error |
42501 | RLS policy violation (Postgres insufficient privilege) | Check auth state and RLS policies |
PGRST000 | Connection error | Retry with exponential backoff |
42P01 | Table does not exist | Verify table name and run migrations |
23503 | Foreign key violation | Ensure referenced row exists first |
42703 | Column does not exist | Check column name, regenerate types |
The recommended production shape is a typed service layer that wraps the client so callers never touch raw queries, plus a pagination helper that returns a page of rows and the total count in one round trip. Both full, copy-ready implementations are in service patterns.
For database schema design, see supabase-schema-from-requirements. For auth deep-dive with RLS policies, see supabase-install-auth. For realtime architecture patterns, see supabase-auth-storage-realtime-core.
What 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".
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin supabase-packOther plugins' skills for the same job