Token导航 LogoToken导航TokenDH.com
待分类只读github未标认证来源可访问许可证需确认审计通过

supabase-rls-policy-generatorSupabase RLS policy 生成器

Agent Skill

supabase-rls-policy-generator 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

303

周安装

13

GitHub Stars

3

下载量

106
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:supabase-rls-policy-generator(Supabase RLS policy 生成器)
来源仓库:https://github.com/hopeoverture/worldbuilding-app-skills
仓库路径:skills/supabase-rls-policy-generator
安装命令:
npx skills add https://github.com/hopeoverture/worldbuilding-app-skills --skill supabase-rls-policy-generator
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/hopeoverture/worldbuilding-app-skills --skill supabase-rls-policy-generator

简介

用于自动生成 Supabase RLS 策略代码,适合快速构建安全的数据访问规则。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 等宿主环境,支持策略模板与逻辑生成。
  • 通过 npx 命令从指定 GitHub 仓库安装,需结合原始 README 核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网或文件写入操作。
  • supabase-rls-policy-generator 属于待分类类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Supabase RLS Policy Generator

To generate comprehensive Row-Level Security policies for Supabase databases, follow these steps systematically.

Step 1: Analyze Current Schema

Before generating policies:

  1. Ask user for the database schema file path or table names
  2. Read the schema to understand table structures, foreign keys, and relationships
  3. Identify tables that need RLS protection
  4. Determine the security model: multi-tenant, role-based, or hybrid

Step 2: Identify Security Requirements

Determine access patterns by asking:

  • Is this a multi-tenant application? (tenant_id isolation)
  • What roles exist in the system? (admin, user, viewer, etc.)
  • Are there public vs private resources?
  • Do users need to share resources across accounts?
  • Are there hierarchical permissions? (organization > team > user)

Consult references/rls-patterns.md for common security patterns.

Step 3: Generate RLS Policies

For each table requiring protection, generate policies following this structure:

Enable RLS

ALTER TABLE table_name ENABLE ROW LEVEL SECURITY;

Policy Types to Generate

SELECT Policies - Control read access:

  • User can view their own records
  • User can view records in their tenant
  • Role-based viewing (admins see all)
  • Public records accessible to all authenticated users

INSERT Policies - Control creation:

  • User can create records with their own user_id
  • User can create records in their tenant
  • Role-based creation restrictions

UPDATE Policies - Control modifications:

  • User can update their own records
  • Admins can update all records
  • Tenant-scoped updates

DELETE Policies - Control deletion:

  • User can delete their own records
  • Admin-only deletion
  • Tenant-scoped deletion

Policy Templates

Use templates from assets/policy-templates.sql:

Basic User Ownership:

CREATE POLICY "Users can view own records"
  ON table_name FOR SELECT
  USING (auth.uid() = user_id);

Multi-Tenant Isolation:

CREATE POLICY "Tenant isolation"
  ON table_name FOR ALL
  USING (
    tenant_id IN (
      SELECT tenant_id FROM user_tenants
      WHERE user_id = auth.uid()
    )
  );

Role-Based Access:

CREATE POLICY "Admins have full access"
  ON table_name FOR ALL
  USING (
    auth.jwt() ->> 'role' = 'admin'
  );

JWT Claims:

CREATE POLICY "Organization access"
  ON table_name FOR SELECT
  USING (
    organization_id = (auth.jwt() -> 'app_metadata' ->> 'organization_id')::uuid
  );

Step 4: Generate Helper Functions

Create PostgreSQL functions to support complex policies:

-- Function to check user role
CREATE OR REPLACE FUNCTION auth.user_has_role(required_role TEXT)
RETURNS BOOLEAN AS $$
BEGIN
  RETURN (auth.jwt() ->> 'role') = required_role;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

-- Function to check tenant membership
CREATE OR REPLACE FUNCTION auth.user_in_tenant(target_tenant_id UUID)
RETURNS BOOLEAN AS $$
BEGIN
  RETURN EXISTS (
    SELECT 1 FROM user_tenants
    WHERE user_id = auth.uid()
    AND tenant_id = target_tenant_id
  );
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

Step 5: Generate Testing Queries

Create test queries to verify policies work correctly:

-- Test as authenticated user
SET request.jwt.claim.sub = 'user-uuid';
SELECT * FROM table_name; -- Should see only accessible records

-- Test as admin
SET request.jwt.claim.role = 'admin';
SELECT * FROM table_name; -- Should see all records

-- Test as different tenant
SET request.jwt.claim.sub = 'other-user-uuid';
SELECT * FROM table_name; -- Should see different tenant's records

Step 6: Create Migration File

Generate a migration file with proper structure:

-- Migration: Add RLS policies
-- Created: [timestamp]

-- Enable RLS on tables
ALTER TABLE users ENABLE ROW LEVEL SECURITY;
ALTER TABLE items ENABLE ROW LEVEL SECURITY;

-- Drop existing policies if any
DROP POLICY IF EXISTS "policy_name" ON table_name;

-- Create new policies
[Generated policies here]

-- Create helper functions
[Generated functions here]

-- Grant necessary permissions
GRANT SELECT, INSERT, UPDATE, DELETE ON table_name TO authenticated;
GRANT SELECT ON table_name TO anon; -- If public read needed

Step 7: Document Generated Policies

Create documentation explaining:

  • What each policy does
  • Which users/roles have what access
  • Any special cases or exceptions
  • How to test the policies
  • Common troubleshooting tips

Use template from assets/policy-documentation-template.md.

Implementation Guidelines

Security Best Practices

  • Always enable RLS on tables with user data
  • Use auth.uid() for user-owned records
  • Use JWT claims for role-based access
  • Prefer SECURITY DEFINER functions for complex logic
  • Test policies with different user roles
  • Use USING clause for read access, WITH CHECK for write validation

Performance Considerations

  • Add indexes on columns used in policies (user_id, tenant_id, role)
  • Keep policy logic simple for better performance
  • Use helper functions for reusable complex logic
  • Avoid subqueries in policies when possible

Common Patterns

Consult references/rls-patterns.md for detailed examples of:

  • Multi-tenant isolation
  • Role-based access control (RBAC)
  • Attribute-based access control (ABAC)
  • Hierarchical permissions
  • Public/private resource splitting
  • Shared resource access

Output Format

Generate files in the following structure:

migrations/
  [timestamp]_add_rls_policies.sql
docs/
  rls-policies.md (documentation)
tests/
  rls_tests.sql (test queries)

Verification Checklist

Before completing:

  • RLS enabled on all sensitive tables
  • Policies cover all operations (SELECT, INSERT, UPDATE, DELETE)
  • Policies tested with different user roles
  • Indexes added for policy columns
  • Helper functions created for complex logic
  • Documentation generated
  • Test queries provided
  • No policies accidentally grant excessive access

Consulting References

Throughout generation:

  • Consult references/rls-patterns.md for security patterns
  • Consult references/supabase-auth.md for auth.uid() and JWT structure
  • Use templates from assets/policy-templates.sql

Completion

When finished:

  1. Display the generated migration file
  2. Summarize the policies created
  3. Provide testing instructions
  4. Offer to generate additional policies or modify existing ones

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.62%
按下载量换算39

Claude

27%
按下载量换算29

Cursor

17.26%
按下载量换算18

Gemini CLI

9.99%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills