SU

supabase-data-handling

Implements data compliance patterns in Supabase, including RLS for isolation and user data deletion workflows.

Install

mkdir -p .claude/skills/supabase-data-handling && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5482" && unzip -o skill.zip -d .claude/skills/supabase-data-handling && rm skill.zip

Installs to .claude/skills/supabase-data-handling

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Implement 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".
517 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • →Enable Row Level Security (RLS) for data isolation
  • →Classify PII columns using an audit and registry
  • →Implement user deletion with cascade purging and audit logging
  • →Export user data for subject access requests
  • →Configure automated data retention policies
  • →Set up point-in-time recovery for backup and restore

How it works

This skill applies RLS for data isolation, uses `supabase.auth.admin.deleteUser()` for right-to-deletion, and employs SQL for data exports and PII detection. It also configures `pg_cron` for automated retention and outlines backup/restore procedures.

Inputs & outputs

You give it
Supabase database schema, user IDs, and PII classification
You get back
RLS policies, PII column registry, user deletion pipeline, data export, audit log, and retention jobs

When to use supabase-data-handling

  • →Implementing GDPR deletion
  • →Configuring RLS for data isolation
  • →Managing PII in database

About this skill

Supabase Data Handling

Overview

Plan data access, erasure, retention, and recovery with explicit authorization and partial-operation receipts. RLS, application cleanup, Storage ownership, Auth administration, and backups are separate boundaries. These examples do not establish legal compliance, complete discovery, atomic erasure, or immediate session revocation.

When to use: Implement GDPR right-to-deletion, respond to data subject access requests (DSARs), audit PII in the database, configure automated retention, set up tenant isolation with RLS, or plan backup/restore procedures.

Prerequisites

  • @supabase/supabase-js v2+ with service role key for admin operations
  • Verify current pg_cron extension availability separately from the project’s backup/PITR plan or add-on entitlement; neither implies the other
  • Understanding of GDPR Articles 15-17 (access, rectification, erasure)
  • Database access via SQL Editor or psql for schema changes

Instructions

Step 1: RLS for Data Isolation and PII Column Management

Enable RLS on every table holding user data, then classify PII columns so later deletion and export steps know what to touch. The RLS skeleton is one USING (auth.uid() = ...) policy per access pattern:

ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;

CREATE POLICY "users_read_own_profile" ON public.profiles
  FOR SELECT USING (auth.uid() = id);

Pair the policies with a PII audit — an information_schema.columns scan by naming pattern, COMMENT ON COLUMN tags, a pii_registry view, and an SDK-side regex scanner for emails, phones, SSNs, and IPs.

See RLS and PII reference for the full multi-tenant policy set, the PII audit SQL, the pii_registry view, and the scanTableForPII() SDK scanner.

Step 2: User Deletion and Data Export

Start with a read-only, user-scoped inventory. The caller supplies a request session, not a target user ID. A public-key client forwards that session and verifies it with Auth; RLS and reviewed table grants still determine access.

import { createClient } from '@supabase/supabase-js';

async function inventoryOwnProfile(request: Request) {
  const authorization = request.headers.get('authorization');
  if (!authorization?.startsWith('Bearer ')) throw new Error('Authentication required');
  const client = createClient(url, publishableKey, {
    global: { headers: { Authorization: authorization } },
    auth: { persistSession: false, autoRefreshToken: false },
  });
  const { data: { user }, error: authError } = await client.auth.getUser();
  if (authError || !user) throw new Error('User verification failed');
  const { data, error } = await client.from('profiles')
    .select('id').eq('id', user.id).limit(1);
  if (error || !Array.isArray(data)) throw new Error('Profile inventory failed');
  return { status: 'partial_inventory', profile_rows: data.length,
    deletion_started: false, complete_export: false };
}

This observes only the reviewed profile projection, not every table, object, backup, or processor. Do not log row contents or credentials; expose results only to the authorized subject with private, no-store responses. A zero-row result does not authorize creating or deleting anything.

Before any erasure, separately review application-owned eligibility, verified subject binding, retention/legal holds, schema cascades, Storage ownership, and ordered cleanup. Persist minimized per-step receipts and retry/idempotency state. Auth finalization is a separate privileged operation only after required cleanup is verified; partial failure remains partial, and existing JWTs may survive until expiry. Export similarly needs an approved table/object inventory, authorization, minimization, and protected delivery rather than a blanket completeness claim.

See deletion and export reference for the bounded plan and partial-receipt limitations. No destructive endpoint is supplied here.

Step 3: Retention Policies and Backup/Restore

See retention policies and backup/restore for pg_cron automated retention schedules (30/90/730-day tiers), SDK-based retention monitoring, pg_dump/pg_restore commands, and point-in-time recovery configuration.

Output

The reviewed output is an access-policy and PII inventory, a partial user-scoped observation, and an explicit erasure/export/retention/recovery plan. Pattern scans can miss sensitive values. Record which tables, objects, identities, operations, and failure paths were actually covered; do not label a partial result compliant, complete, immutable, or successfully erased without independent evidence.

Error Handling

ErrorCauseSolution
auth.admin.deleteUser() returns 404User already deleted or wrong IDCheck auth.users table; may have been deleted by another process
violates foreign key constraint during deletionChild rows reference userDelete in cascade order (comments → orders → profiles) or use ON DELETE CASCADE
permission denied for function cron.scheduleExtension or caller privilege mismatchVerify current extension availability and approved scheduling role separately from PITR entitlement
pg_dump: connection refusedUsing wrong port or pooler URLUse direct connection (port 5432), not pooler (port 6543) for pg_dump
Approved operation deniedGrants, identity, policy, or eligibility mismatchInspect the actual boundary; do not switch to a service-role client to silence the denial
Audit receipt missingWrite failed or logging design incompletePreserve partial status and investigate approved receipt authorization; do not broaden privileges blindly
Retention job not runningpg_cron job disabled or erroredCheck cron.job_run_details for error messages

Examples

Example 1 — Review an erasure request:

Run the authenticated read-only inventory above, then record the requested scope and review eligibility, required cleanup, partial-failure recovery, and protected evidence delivery before approving any mutation. Applicable legal obligations and deadlines require the organization’s qualified review; this skill does not determine them.

Example 2 — Quick PII audit:

-- Count rows with email-like patterns in unexpected columns
SELECT 'profiles' AS table_name, 'bio' AS column_name, count(*) AS rows_with_email
FROM public.profiles
WHERE bio ~ '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}';

Example 3 — Verify retention job execution:

-- Separately approved operator metadata observation; inspect only reviewed jobs.
-- Run only if pg_cron is installed and the operator is authorized to read it.
SELECT jobid, status, start_time, end_time
FROM cron.job_run_details
ORDER BY start_time DESC
LIMIT 20;

A scheduler receipt alone does not establish successful cleanup or policy compliance. Inspect approved operation receipts and errors separately.

Resources

Next Steps

  • For enterprise role-based access control, see supabase-enterprise-rbac
  • For security hardening and API key scoping, see supabase-security-basics
  • For observability and audit trail monitoring, see supabase-observability

When not to use it

  • →When a Supabase project is not on a Pro plan for pg_cron and point-in-time recovery
  • →When the service role key is not available for admin operations

Prerequisites

@supabase/supabase-js v2+ with service role key for admin operationsSupabase project on Pro plan (for pg_cron and point-in-time recovery)Understanding of GDPR Articles 15-17 (access, rectification, erasure)Database access via SQL Editor or psql for schema changes

Limitations

  • →Requires Supabase Pro plan for pg_cron and point-in-time recovery
  • →Deletion requires careful cascade ordering or ON DELETE CASCADE to avoid foreign key violations
  • →RLS policies can block admin operations if a service role key is not used

How it compares

This workflow provides a structured, Supabase-specific approach to GDPR/CCPA compliance, unlike generic data handling methods.

Compared to similar skills

supabase-data-handling side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
supabase-data-handling (this skill)14moReviewAdvanced
supabase-rls-policy-generator111yNo flagsAdvanced
sqlmap-database-penetration-testing410moReviewAdvanced
data-safety-auditor311moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore →

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

supabase-rls-policy-generator

hopeoverture

This skill should be used when the user requests to generate, create, or add Row-Level Security (RLS) policies for Supabase databases in multi-tenant or role-based applications. It generates comprehensive RLS policies using auth.uid(), auth.jwt() claims, and role-based access patterns. Trigger terms include RLS, row level security, supabase security, generate policies, auth policies, multi-tenant security, role-based access, database security policies, supabase permissions, tenant isolation.

11109

sqlmap-database-penetration-testing

davila7

This skill should be used when the user asks to "automate SQL injection testing," "enumerate database structure," "extract database credentials using sqlmap," "dump tables and columns from a vulnerable database," or "perform automated database penetration testing." It provides comprehensive guidance for using SQLMap to detect and exploit SQL injection vulnerabilities.

449

data-safety-auditor

ananddtyagi

Comprehensive data safety auditor for Vue 3 + Pinia + IndexedDB + PouchDB applications. Detects data loss risks, sync issues, race conditions, and browser-specific vulnerabilities with actionable remediation guidance.

38

row-level-security

dadbodgeoff

Implement PostgreSQL Row Level Security (RLS) for multi-tenant SaaS applications. Use when building apps where users should only see their own data, or when implementing organization-based data isolation.

15

branch-isolation

Peadarpol

Expert review of multi-tenant and branch isolation safety, ensuring no query data leaks or cross-tenant access.

00

supabase-postgres-best-practices

davila7

Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.

439

Search skills

Search the agent skills registry