Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问clear审计未展示

supabase-rls-policySupabase RLS policy 命令行

Agent Skill

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

总安装

376

周安装

16

GitHub Stars

4

下载量

132
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/linehaul-ai/linehaulai-claude-marketplace --skill supabase-rls-policy

简介

用于处理 Supabase RLS(行级安全)策略相关的代码协作信息,适合审查策略变更。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 等宿主环境,支持 Issue 和 PR 分析。
  • 通过 npx 命令从指定 GitHub 仓库安装,需结合原始 README 核验具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网或命令执行。
  • supabase-rls-policy 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Supabase RLS Policy Expert

Generate production-ready row-level security policies for Supabase PostgreSQL databases following best practices and Supabase-specific conventions.

Core Policy Syntax

Policy Structure

All policies follow this structure:

CREATE POLICY "Policy description" ON table_name
FOR operation
TO role
USING (condition)
WITH CHECK (condition);

Operations and Conditions

  • SELECT: Use USING only, no WITH CHECK
  • INSERT: Use WITH CHECK only, no USING
  • UPDATE: Use both USING and WITH CHECK
  • DELETE: Use USING only, no WITH CHECK

Never use FOR ALL - always create separate policies for each operation (SELECT, INSERT, UPDATE, DELETE).

Supabase-Specific Features

Authentication Roles

Supabase maps requests to two built-in roles:

  • anon: Unauthenticated users (not logged in)
  • authenticated: Authenticated users (logged in)

Apply roles with the TO clause, which must come after the operation:

-- CORRECT
CREATE POLICY "policy name" ON profiles
FOR select
TO authenticated
USING (true);

-- INCORRECT - TO must come after FOR
CREATE POLICY "policy name" ON profiles
TO authenticated
FOR select
USING (true);

Helper Functions

auth.uid() - Returns the ID of the authenticated user making the request

auth.jwt() - Returns the JWT with access to user metadata:

  • raw_user_meta_data: User-updatable, not secure for authorization
  • raw_app_meta_data: Cannot be updated by user, use for authorization

Example using JWT for team membership:

CREATE POLICY "User is in team" ON my_table
TO authenticated
USING (team_id IN (
  SELECT auth.jwt() -> 'app_metadata' -> 'teams'
));

MFA Requirements

Check for multi-factor authentication using AAL (Assurance Level):

CREATE POLICY "Restrict updates" ON profiles
AS restrictive
FOR update
TO authenticated
USING ((SELECT auth.jwt()->>'aal') = 'aal2');

Performance Optimization

Critical Optimizations

  1. Add indexes on columns used in policies:
CREATE INDEX userid ON test_table USING btree (user_id);
  1. Wrap functions in SELECT to enable caching:
-- OPTIMIZED - uses initPlan caching
CREATE POLICY "policy" ON test_table
TO authenticated
USING ((SELECT auth.uid()) = user_id);

-- SLOWER - calls function on every row
CREATE POLICY "policy" ON test_table
TO authenticated
USING (auth.uid() = user_id);
  1. Minimize joins - fetch criteria into sets instead:
-- SLOW - joins on each row
CREATE POLICY "Team access" ON test_table
TO authenticated
USING (
  (SELECT auth.uid()) IN (
    SELECT user_id FROM team_user
    WHERE team_user.team_id = team_id -- JOIN
  )
);

-- FAST - no join
CREATE POLICY "Team access" ON test_table
TO authenticated
USING (
  team_id IN (
    SELECT team_id FROM team_user
    WHERE user_id = (SELECT auth.uid()) -- no join
  )
);
  1. Always specify roles with TO clause:
-- OPTIMIZED
CREATE POLICY "policy" ON rls_test
TO authenticated
USING ((SELECT auth.uid()) = user_id);

Syntax Rules

String Handling

Always use double apostrophes in SQL strings:

-- CORRECT
name = 'Night''s watch'

-- INCORRECT
name = 'Night\'s watch'

Multiple Operations

Create separate policies for each operation - PostgreSQL doesn't support multiple operations per policy:

-- INCORRECT
CREATE POLICY "policy" ON profiles
FOR insert, delete  -- NOT SUPPORTED
TO authenticated
WITH CHECK (true)
USING (true);

-- CORRECT
CREATE POLICY "Can create profiles" ON profiles
FOR insert
TO authenticated
WITH CHECK (true);

CREATE POLICY "Can delete profiles" ON profiles
FOR delete
TO authenticated
USING (true);

Policy Patterns

Owner-Based Access

-- Users can view their own records
CREATE POLICY "Users view own records" ON test_table
FOR select
TO authenticated
USING ((SELECT auth.uid()) = user_id);

-- Users can update their own records
CREATE POLICY "Users update own records" ON test_table
FOR update
TO authenticated
USING ((SELECT auth.uid()) = user_id)
WITH CHECK ((SELECT auth.uid()) = user_id);

Team-Based Access

-- Users can access team records
CREATE POLICY "Team member access" ON test_table
FOR select
TO authenticated
USING (
  team_id IN (
    SELECT team_id FROM team_user
    WHERE user_id = (SELECT auth.uid())
  )
);

Public Read, Authenticated Write

-- Anyone can read
CREATE POLICY "Public read" ON profiles
FOR select
TO anon, authenticated
USING (true);

-- Only authenticated can insert
CREATE POLICY "Authenticated insert" ON profiles
FOR insert
TO authenticated
WITH CHECK (true);

Policy Types

PERMISSIVE (Default, Recommended)

Policies are combined with OR - if any policy grants access, it's allowed. Always prefer PERMISSIVE unless you have a specific need for RESTRICTIVE.

RESTRICTIVE (Use Sparingly)

All RESTRICTIVE policies must pass (AND logic). Use only for additional security layers like MFA requirements. Discourage use because:

  • More complex to reason about
  • Can accidentally lock out users
  • Harder to debug access issues

Output Format

Always wrap SQL in markdown code blocks with language tag:

CREATE POLICY "Descriptive policy name" ON books
FOR insert
TO authenticated
WITH CHECK ((SELECT auth.uid()) = author_id);

Policy naming: Use descriptive sentences in double quotes explaining what the policy does.

Explanations: Provide as separate text, never inline SQL comments.

Validation Checklist

Before finalizing policies, verify:

  • ✓ Used auth.uid() instead of current_user
  • ✓ Wrapped functions in SELECT for performance
  • ✓ Added indexes on policy columns
  • ✓ Specified roles with TO clause
  • ✓ Minimized joins in policy logic
  • ✓ Used correct USING/WITH CHECK for operation type
  • ✓ Created separate policies per operation (no FOR ALL)
  • ✓ Used double apostrophes in strings
  • ✓ Used PERMISSIVE unless RESTRICTIVE required
  • ✓ Provided clear policy descriptions

Out of Scope

If user requests anything not related to RLS policies, explain that this skill only assists with Supabase row-level security policy creation and suggest they rephrase their request or use other tools.

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

补充不同宿主或平台的使用分布数据

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

平台分布

Antigravity

30.23%
按下载量换算40

Claude Code

22.32%
按下载量换算29

Gemini CLI

15.53%
按下载量换算20

Codex

11.44%
按下载量换算15

OpenCode

7.37%
按下载量换算10

Cursor

3.66%
按下载量换算5

安全审计

暂无安全审计结果可展示。

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills