Loading...
Loading...
This skill should be used when the user asks to "create a Supabase table", "write RLS policies", "set up Supabase Auth", "create Edge Functions", "configure Storage buckets", "use Supabase with Next.js", "migrate API keys", "implement row-level security", "create database functions", "set up SSR auth", or mentions 'Supabase', 'RLS', 'Edge Function', 'Storage bucket', 'anon key', 'service role', 'publishable key', 'secret key'. Automatically triggers when user mentions 'database', 'table', 'SQL', 'migration', 'policy'.
npx skill4agent add velcrafting/codex-skills supabase-expert| Key Type | Prefix | Safety | Use Case |
|---|---|---|---|
| Publishable | | Safe for client | Browser, mobile, CLI |
| Secret | | Backend only | Servers, Edge Functions |
| Legacy anon | JWT-based | Safe for client | Being deprecated |
| Legacy service_role | JWT-based | Backend only | Being deprecated |
references/api-keys.mdget()set()remove()@supabase/auth-helpers-nextjs@supabase/ssrgetAll()setAll()getUser()supabaseResponseImportant: As of Next.js 16+, useinstead ofproxy.ts. See https://nextjs.org/docs/app/api-reference/file-conventions/proxymiddleware.ts
references/auth-ssr-patterns.md(SELECT auth.uid())auth.uid()TO authenticatedTO anonFOR ALLreferences/rls-policy-patterns.mdSECURITY INVOKERsearch_path = ''public.table_nameSECURITY DEFINERDeno.servenpm:/jsr:/node:_shared//tmpreferences/edge-function-templates.mdreferences/storage-patterns.mdUser mentions database/Supabase work?
├─> Creating new tables?
│ └─> Use: Table Creation Workflow
├─> Creating RLS policies?
│ └─> Use: RLS Policy Workflow (references/rls-policy-patterns.md)
├─> Creating database function?
│ └─> Use: Database Function Workflow (references/sql-templates.md)
├─> Setting up Auth?
│ └─> Use: Auth SSR Workflow (references/auth-ssr-patterns.md)
├─> Creating Edge Function?
│ └─> Use: Edge Function Workflow (references/edge-function-templates.md)
├─> Setting up Storage?
│ └─> Use: Storage Workflow (references/storage-patterns.md)
├─> Next.js integration?
│ └─> Use: Next.js Patterns (references/nextjs-caveats.md)
└─> API key questions?
└─> Use: API Keys Guide (references/api-keys.md)idcreated_atupdated_atcreated_byCREATE TABLE IF NOT EXISTS public.table_name (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name TEXT NOT NULL,
status TEXT DEFAULT 'active',
created_by UUID REFERENCES auth.users(id),
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW()
);
COMMENT ON TABLE public.table_name IS 'Description';
ALTER TABLE public.table_name ENABLE ROW LEVEL SECURITY;
CREATE INDEX idx_table_name_status ON public.table_name(status);references/sql-templates.mdimport { createBrowserClient } from '@supabase/ssr'
export function createClient() {
return createBrowserClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!
)
}import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'
export async function createClient() {
const cookieStore = await cookies()
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
{
cookies: {
getAll() { return cookieStore.getAll() },
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options)
)
} catch { /* Ignore in Server Components */ }
},
},
}
)
}// proxy.ts (at root or src/ directory)
import { createServerClient } from '@supabase/ssr'
import { NextResponse, type NextRequest } from 'next/server'
export async function proxy(request: NextRequest) {
let supabaseResponse = NextResponse.next({ request })
const supabase = createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY!,
{
cookies: {
getAll() { return request.cookies.getAll() },
setAll(cookiesToSet) {
cookiesToSet.forEach(({ name, value }) =>
request.cookies.set(name, value)
)
supabaseResponse = NextResponse.next({ request })
cookiesToSet.forEach(({ name, value, options }) =>
supabaseResponse.cookies.set(name, value, options)
)
},
},
}
)
// CRITICAL: Must call getUser() to refresh session
await supabase.auth.getUser()
return supabaseResponse // MUST return supabaseResponse
}| Operation | USING | WITH CHECK |
|---|---|---|
| SELECT | Required | Ignored |
| INSERT | Ignored | Required |
| UPDATE | Required | Required |
| DELETE | Required | Ignored |
CREATE POLICY "Users view own records"
ON public.table_name
FOR SELECT
TO authenticated
USING ((SELECT auth.uid()) = user_id);INSERT INTO storage.buckets (id, name, public)
VALUES ('avatars', 'avatars', false);CREATE POLICY "Users upload own avatar"
ON storage.objects
FOR INSERT
TO authenticated
WITH CHECK (
bucket_id = 'avatars' AND
(SELECT auth.uid())::text = (storage.foldername(name))[1]
);/storage/v1/object/public/bucket/image.jpg?width=200&height=200&resize=coverimport { createClient } from 'npm:@supabase/supabase-js@2'
Deno.serve(async (req: Request) => {
if (req.method === 'OPTIONS') {
return new Response('ok', {
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'authorization, content-type',
}
})
}
// User-scoped client (respects RLS)
const supabase = createClient(
Deno.env.get('SUPABASE_URL')!,
Deno.env.get('SUPABASE_PUBLISHABLE_KEY')!,
{ global: { headers: { Authorization: req.headers.get('Authorization')! } } }
)
// Admin client (bypasses RLS) - use SUPABASE_SECRET_KEY for admin operations
// const adminClient = createClient(
// Deno.env.get('SUPABASE_URL')!,
// Deno.env.get('SUPABASE_SECRET_KEY')!
// )
// Your logic here
return new Response(JSON.stringify({ success: true }), {
headers: { 'Content-Type': 'application/json' }
})
})sb_publishable_...sb_secret_...references/api-keys.mdreferences/storage-patterns.mdreferences/nextjs-caveats.mdreferences/sql-templates.mdreferences/rls-policy-patterns.mdreferences/auth-ssr-patterns.mdreferences/edge-function-templates.mdreferences/auth-ssr-patterns.md