/supabase:rls-test-patternsfrom supabase
Automated test patterns for Supabase Row Level Security policies. Covers user isolation, multi-tenant security, role-based access, and anonymous user restrictions.
Ships in supabase. 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; scripts run unread.
Comprehensive testing framework for Row Level Security (RLS) policies in Supabase. Catch security vulnerabilities before production with automated tests for user isolation, multi-tenant security, role-based access, and anonymous user restrictions.
Verify users can only access their own data:
# Test user isolation on specific tables
bash scripts/test-user-isolation.sh conversations messages profiles
# Test with specific user IDs
bash scripts/test-user-isolation.sh documents --user1 "uuid1" --user2 "uuid2"
# Generate detailed report
bash scripts/test-user-isolation.sh --all --report isolation-report.md
What it tests:
Verify organization/team data separation:
# Test organization isolation
bash scripts/test-multi-tenant-isolation.sh organizations projects documents
# Test with specific org IDs
bash scripts/test-multi-tenant-isolation.sh --org1 "org-uuid-1" --org2 "org-uuid-2"
# Test member access patterns
bash scripts/test-multi-tenant-isolation.sh --test-members
What it tests:
Verify role-based access control:
# Test RBAC policies
bash scripts/test-role-permissions.sh admin_panel sensitive_data
# Test specific role hierarchy
bash scripts/test-role-permissions.sh --roles "admin,editor,viewer"
# Test permission escalation prevention
bash scripts/test-role-permissions.sh --test-escalation
What it tests:
Verify anonymous users are properly restricted:
# Test anonymous access on all public tables
bash scripts/test-anonymous-access.sh
# Test specific tables
bash scripts/test-anonymous-access.sh public_posts comments
# Test auth.uid() null handling
bash scripts/test-anonymous-access.sh --test-null-uid
What it tests:
Check all tables have proper RLS policies:
# Audit entire database
bash scripts/audit-rls-coverage.sh
# Audit specific schema
bash scripts/audit-rls-coverage.sh --schema public
# Generate compliance report
bash scripts/audit-rls-coverage.sh --report compliance-report.md --format markdown
What it checks:
Execute all RLS tests:
# Run all tests with default settings
bash scripts/run-all-rls-tests.sh
# Run with custom database URL
bash scripts/run-all-rls-tests.sh --db-url "postgresql://..."
# Run and generate comprehensive report
bash scripts/run-all-rls-tests.sh --report rls-test-results.json --verbose
# Run in CI/CD mode (exit 1 on any failure)
bash scripts/run-all-rls-tests.sh --ci --fail-fast
Test sequence:
Example 1: Testing Chat Application Security
# Test conversation isolation
bash scripts/test-user-isolation.sh conversations messages participants
# Output:
# ✓ User cannot read other user's conversations
# ✓ User cannot send messages to other user's conversations
# ✓ User cannot add participants to other user's conversations
# ✓ All isolation tests passed (12/12)
Example 2: Multi-Tenant SaaS Security Audit
# Full audit of multi-tenant application
bash scripts/test-multi-tenant-isolation.sh organizations projects documents embeddings
# Output:
# ✓ Org A users cannot access Org B projects
# ✓ Removed users lose access immediately
# ✓ Cross-org document access blocked
# ✓ Embeddings respect org boundaries
# ✓ All multi-tenant tests passed (24/24)
Example 3: CI/CD Integration
# In .github/workflows/security-tests.yml
- name: Run RLS Tests
run: |
bash scripts/run-all-rls-tests.sh \
--ci \
--fail-fast \
--report rls-results.json
- name: Upload Test Report
uses: actions/upload-artifact@v3
with:
name: rls-test-results
path: rls-results.json
Example 4: Pre-Production Security Check
# Complete security validation before deploy
bash scripts/audit-rls-coverage.sh --report audit.md
bash scripts/run-all-rls-tests.sh --verbose --report tests.json
# Review both reports before deploying
cat audit.md
cat tests.json
psql) installedRequired in .env file:
# Database connection
SUPABASE_DB_URL="postgresql://postgres:[password]@[host]:5432/postgres"
# API keys for client testing
SUPABASE_URL="https://[project-ref].supabase.co"
SUPABASE_ANON_KEY="eyJ..."
SUPABASE_SERVICE_KEY="eyJ..."
# Test user credentials (optional, for client tests)
TEST_USER_1_EMAIL="[email protected]"
TEST_USER_1_PASSWORD="testpass123"
TEST_USER_2_EMAIL="[email protected]"
TEST_USER_2_PASSWORD="testpass456"
Tests create and clean up their own data, but you can provide:
# Optional: Use existing test users
TEST_USER_1_ID="uuid-for-test-user-1"
TEST_USER_2_ID="uuid-for-test-user-2"
# Optional: Use existing test orgs
TEST_ORG_1_ID="uuid-for-test-org-1"
TEST_ORG_2_ID="uuid-for-test-org-2"
🔒 RLS Test Suite v1.0.0
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Test Summary
Tables tested: 5
Total tests: 48
Passed: 48 ✓
Failed: 0
Duration: 12.3s
✅ All RLS policies working correctly!
🔒 RLS Test Suite v1.0.0
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ SECURITY ISSUE DETECTED
Table: conversations
Test: User isolation - SELECT
Issue: User B could read User A's conversations
Expected: 0 rows
Actual: 5 rows
Recommendation: Add USING clause to SELECT policy:
USING (auth.uid() = user_id)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Test Summary
Total tests: 48
Passed: 43 ✓
Failed: 5 ❌
❌ Critical security issues found. Do not deploy.
Integration Points:
/supabase:test-rls commandsupabase-security-auditor agentrls-templates skill (creates policies, this tests them)Best Practices:
README.md (opens in a new tab)examples/ci-integration.md (opens in a new tab)examples/common-vulnerabilities.md (opens in a new tab)examples/testing-workflow.md (opens in a new tab)scripts/audit-rls-coverage.sh (opens in a new tab)scripts/run-all-rls-tests.sh (opens in a new tab)scripts/test-anonymous-access.sh (opens in a new tab)scripts/test-multi-tenant-isolation.sh (opens in a new tab)scripts/test-role-permissions.sh (opens in a new tab)scripts/test-user-isolation.sh (opens in a new tab)templates/rls-test-suite.ts (opens in a new tab)templates/security-checklist.md (opens in a new tab)templates/test-scenarios.json (opens in a new tab)templates/user-isolation-tests.sql (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
8 skills in this plugin
/agentic-platform-schemaAgentic Platform Contract tables for AI agent applications - runs, events, artifacts, and tool calls tracking. Use when building AI agent backends that need structured run/event storage./auth-configsConfigure Supabase authentication providers (OAuth, JWT, email). Use when setting up authentication, configuring OAuth providers (Google/GitHub/Discord), implementing auth flows, configuring JWT settings, or when user mentions Supabase auth, social login, authentication setup, or auth configuration./e2e-test-scenariosEnd-to-end testing scenarios for Supabase - complete workflow tests from project creation to AI features, validation scripts, and comprehensive test suites. Use when testing Supabase integrations, validating AI workflows, running E2E tests, verifying production readiness, or when user mentions Supabase testing, E2E tests, integration testing, pgvector testing, auth testing, or test automation.npx claudepluginhub vanman2024/ai-dev-marketplace --plugin supabaseOther plugins' skills for the same job