Skip to main content
skill CX Codex

supabase-admin — Claude Code skill for RLS, migrations, schema design

supabase-admin — a skill for Supabase database work: schema design, Row Level Security policies, migrations, and query debugging. It helps when an agent modifies the database structure or figures out why a query returns nothing.

MIT 200 installs ★ 274 updated 2026-10-30

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add curiositech/some_claude_skills --skill supabase-admin -a claude-code
Open on GitHub

What supabase-admin does

The skill handles common Supabase tasks. It writes RLS policies — public read, owner-only write, role checks against the profiles table. It knows auth.uid() and auth.jwt(), and can make policies faster by indexing the columns they reference and moving auth.uid() into a subquery so the JWT is parsed once, not per row.

Migrations get their own section. Files should be numbered (001_initial_schema.sql, 002_add_profiles_trigger.sql), wrapped in a transaction, with a down migration kept as a comment. For safe changes it has patterns like adding a column with a default without locking the table and CREATE INDEX CONCURRENTLY.

Auth integration is covered too: a trigger that creates a profile row on signup, auth.role() checks inside policies. For debugging, it checks whether RLS is on, lists policies for a table, and tests queries as the anon role or a specific user via SET request.jwt.claims. The skill skips Auth UI configuration — that belongs in the dashboard — and edge functions, where the author points to cloudflare-worker-dev.

What it helps with

  • design RLS policies for tables with user data
  • speed up policies with indexes and an auth.uid() subquery
  • write a migration with a transaction and down part
  • create a trigger that builds a profile on signup
  • find why a query returns empty results with no error

Example prompts for the agent

  • Enable RLS on posts and add a policy: anyone can read, only the owner can write.
  • Write a migration that adds a status column defaulting to active without locking the table.
  • Why does a logged-in user get no rows from projects even though the table has data?

How to install supabase-admin

1Skills CLI (Vercel)

npx skills add curiositech/some_claude_skills --skill supabase-admin -a claude-code

2Manually: put the files in place

~/.claude/skills/supabase-admin/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/supabase-admin/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about supabase-admin

How do I install supabase-admin in Claude Code?

Run npx skills add curiositech/some_claude_skills --skill supabase-admin -a claude-code, then check ~/.claude/skills/supabase-admin/SKILL.md.

What does supabase-admin do?

It helps with Supabase schema design, Row Level Security policies, migrations, and debugging access issues. It knows patterns like indexes for auth.uid() and triggers on auth.users.

What does this skill not cover?

Auth UI configuration — that is done in the Supabase dashboard — and edge functions, where the author suggests the cloudflare-worker-dev skill. Plain SQL without Supabase context is also out of scope.

Source text

SKILL.md · MIT
---
name: supabase-admin
description: Supabase administration, RLS policies, migrations, and schema design. Use for database architecture, Row Level Security, performance tuning, auth integration. Activate on "Supabase", "RLS",
  "migration", "policy", "schema", "auth.uid()". NOT for Supabase Auth UI configuration (use dashboard), edge functions (use cloudflare-worker-dev), or general SQL without Supabase context.
allowed-tools:
- Read
- Write
- Edit
- Bash
- Grep
- Glob
- mcp__supabase__*
metadata:
  category: DevOps & Site Reliability
  tags:
  - supabase
  - rls
  - database
  - postgres
  - migration
  - schema
  - security
  pairs-with:
  - skill: postgresql-optimization
    reason: Supabase runs PostgreSQL; performance tuning applies directly to Supabase databases
  - skill: modern-auth-2026
    reason: Supabase Auth provides the backend for passkey, OAuth, and magic link implementation
  - skill: database-design-patterns
    reason: Supabase schema and RLS policy design follows relational database design patterns
  - skill: drizzle-migrations
    reason: Drizzle ORM manages schema migrations against Supabase PostgreSQL databases
---

# Supabase Administration Expert

Master Supabase schema design, Row Level Security policies, migrations, and performance optimization for production applications.

## When to Use

✅ **USE this skill for:**
- Row Level Security (RLS) policy design and debugging
- Database migrations and schema changes
- Auth integration (triggers, profile creation)
- Query performance optimization
- Supabase-specific SQL patterns (`auth.uid()`, `auth.jwt()`)

❌ **DO NOT use for:**
- Supabase Auth UI configuration → use Supabase dashboard docs
- Edge Functions → use `cloudflare-worker-dev` skill
- General PostgreSQL without Supabase context → use standard SQL resources
- Client-side Supabase SDK usage → use Supabase JS docs

## Core Competencies

### 1. Row Level Security (RLS)

**Always Enable RLS on User Tables:**
```sql
ALTER TABLE your_table ENABLE ROW LEVEL SECURITY;
```

**Policy Patterns:**

```sql
-- Public read, authenticated write
CREATE POLICY "Public read" ON posts FOR SELECT USING (true);
CREATE POLICY "Owners can write" ON posts FOR INSERT
  WITH CHECK (auth.uid() = user_id);

-- Owner-only access
CREATE POLICY "Users own their data" ON profiles
  FOR ALL USING (auth.uid() = id);

-- Role-based access
CREATE POLICY "Admins can do anything" ON content
  FOR ALL USING (
    EXISTS (
      SELECT 1 FROM profiles
      WHERE profiles.id = auth.uid()
      AND profiles.role = 'admin'
    )
  );
```

**Performance-Critical: Index auth.uid() Columns:**
```sql
-- 100x performance improvement for RLS policies
CREATE INDEX idx_posts_user_id ON posts(user_id);
CREATE INDEX idx_profiles_id ON profiles(id);
```

**Subquery Optimization for JWT Functions:**
```sql
-- BAD: JWT parsed for every row
CREATE POLICY "slow" ON posts FOR SELECT
  USING (user_id = auth.uid());

-- GOOD: JWT parsed once via subquery
CREATE POLICY "fast" ON posts FOR SELECT
  USING (user_id = (SELECT auth.uid()));
```

### 2. Migration Best Practices

**File Naming Convention:**
```
supabase/migrations/
├── 001_initial_schema.sql
├── 002_add_profiles_trigger.sql
├── 003_forum_tables.sql
└── 004_add_rls_policies.sql
```

**Migration Template:**
```sql
-- Migration: 005_feature_name
-- Description: What this migration does
-- Author: name
-- Date: YYYY-MM-DD

-- Up migration
BEGIN;

-- Your DDL here
CREATE TABLE ...;
ALTER TABLE ...;
CREATE POLICY ...;

COMMIT;

-- Down migration (as comment for reference)
-- DROP TABLE ...;
-- DROP POLICY ...;
```

**Safe Migration Patterns:**
```sql
-- Add column with default (no table lock)
ALTER TABLE users ADD COLUMN status text DEFAULT 'active';

-- Add NOT NULL constraint safely
ALTER TABLE users ADD COLUMN email text;
UPDATE users SET email = '[email protected]' WHERE email IS NULL;
ALTER TABLE users ALTER COLUMN email SET NOT NULL;

-- Create index concurrently (no lock)
CREATE INDEX CONCURRENTLY idx_users_email ON users(email);
```

### 3. Auth Integration

**Auto-create Profile on Signup:**
```sql
-- Function to create profile
CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS TRIGGER AS $$
BEGIN
  INSERT INTO public.profiles (id, email, display_name)
  VALUES (
    NEW.id,
    NEW.email,
    COALESCE(NEW.raw_user_meta_data->>'display_name', split_part(NEW.email, '@', 1))
  );
  RETURN NEW;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

-- Trigger on auth.users
CREATE TRIGGER on_auth_user_created
  AFTER INSERT ON auth.users
  FOR EACH ROW EXECUTE FUNCTION public.handle_new_user();
```

**Check Auth Status in Policies:**
```sql
-- Authenticated users only
CREATE POLICY "Authenticated access" ON data
  FOR SELECT USING (auth.role() = 'authenticated');

-- Get current user's ID
SELECT auth.uid();

-- Get current user's JWT claims
SELECT auth.jwt();
```

### 4. Common Schema Patterns

**Timestamps with Defaults:**
```sql
CREATE TABLE posts (
  id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id uuid REFERENCES auth.users(id) ON DELETE CASCADE,
  content text NOT NULL,
  created_at timestamptz DEFAULT now(),
  updated_at timestamptz DEFAULT now()
);

-- Auto-update updated_at
CREATE OR REPLACE FUNCTION update_updated_at()
RETURNS TRIGGER AS $$
BEGIN
  NEW.updated_at = now();
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER update_posts_updated_at
  BEFORE UPDATE ON posts
  FOR EACH ROW EXECUTE FUNCTION update_updated_at();
```

**Soft Delete Pattern:**
```sql
ALTER TABLE posts ADD COLUMN deleted_at timestamptz;

CREATE POLICY "Hide deleted" ON posts
  FOR SELECT USING (deleted_at IS NULL);
```

**Full-Text Search:**
```sql
-- Add search vector column
ALTER TABLE posts ADD COLUMN search_vector tsvector;

-- Create GIN index
CREATE INDEX idx_posts_search ON posts USING GIN(search_vector);

-- Update function
CREATE OR REPLACE FUNCTION posts_search_update()
RETURNS TRIGGER AS $$
BEGIN
  NEW.search_vector := to_tsvector('english', COALESCE(NEW.title, '') || ' ' || COALESCE(NEW.content, ''));
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

-- Search query
SELECT * FROM posts
WHERE search_vector @@ plainto_tsquery('english', 'search terms');
```

### 5. Debugging RLS Issues

**Common Problem: Empty Results, No Error**
```sql
-- Check if RLS is enabled
SELECT tablename, rowsecurity FROM pg_tables WHERE schemaname = 'public';

-- List all policies
SELECT * FROM pg_policies WHERE tablename = 'your_table';

-- Test as specific role
SET ROLE anon;
SELECT * FROM your_table LIMIT 1;
RESET ROLE;

-- Test with specific user
SET request.jwt.claims TO '{"sub": "user-uuid-here"}';
SELECT * FROM your_table;
```

**Diagnostic Query:**
```sql
-- Check what the current user can see
SELECT
  auth.uid() as current_user,
  auth.role() as current_role,
  (SELECT count(*) FROM your_table) as visible_rows;
```

## Quick Reference

| Task | Command |
|------|---------|
| Enable RLS | `ALTER TABLE t ENABLE ROW LEVEL SECURITY;` |
| Create policy | `CREATE POLICY "name" ON t FOR action USING (condition);` |
| Drop policy | `DROP POLICY "name" ON t;` |
| Check policies | `SELECT * FROM pg_policies WHERE tablename = 't';` |
| Current user | `SELECT auth.uid();` |
| Force RLS for owner | `ALTER TABLE t FORCE ROW LEVEL SECURITY;` |

## References

See `/references/` for detailed guides:
- `rls-patterns.md` - Advanced RLS policy patterns
- `migration-checklist.md` - Pre-deployment checklist
- `performance-tuning.md` - Query and index optimization
- `social-schema.md` - Schema patterns for social features

© curiositech · MIT · curiositech/some_claude_skills

Similar skills

All skills for Data and databases →

From the same set180

The whole set →
skill-architect skill-architect is a Claude Code skill for designing, auditing, and debugging agent skills. It helps diagnose misactivation and organize expertise into three layers. CX Codex +1 204installs mdx-sanitizer mdx-sanitizer escapes angle brackets, TypeScript generics and Liquid templates in MDX before Docusaurus builds. Use it when pre-commit hooks or builds fail on unexpected token. CX Codex +1 202installs github-actions-pipeline-builder github-actions-pipeline-builder writes GitHub Actions workflows: matrix builds, dependency caching, deployments, automated tests, security scans, release automation. Triggers on "GitHub Actions", "CI/CD", "workflow", "deployment pipeline". CX Codex +1 202installs physics-rendering-expert physics-rendering-expert guides physics implementation for ropes, cables, and cloth using Position-Based Dynamics (PBD) and Verlet integration. Avoids spring instability and Euler gimbal lock. CX Codex +1 201installs playwright-e2e-tester playwright-e2e-tester is a Claude Code skill that generates Playwright test suites, sets up Page Object models, and configures CI/CD for browser automation. CX Codex +1 200installs sober-addict-protector sober-addict-protector is a Claude Code skill for daily recovery check-ins, spotting triggers, assessing risk, and planning ways to protect sobriety before a lapse. CX Codex +1 199installs product-appeal-analyzer product-appeal-analyzer is a Claude Code skill that assesses product appeal, trust, and positioning. It reviews landing pages and product messaging. CX Codex +1 199installs background-job-orchestrator background-job-orchestrator designs background queues with BullMQ, Celery, or cloud tasks. Offloads heavy logic from HTTP handlers, configures retries, and scales worker processes. CX Codex +1 198installs

Project sponsors

Companies that keep this analytics open