Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/yudefine/nuxt-supabase-starter/rls-policygit clone --depth 1 https://github.com/YuDefine/nuxt-supabase-starterWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/rls-policy)<a href="https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/rls-policy"><img src="https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/rls-policy.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.02163 |
| Opus 5 | $0.00000 | $0.01081 |
| Sonnet 5 | $0.00000 | $0.00433 |
| Haiku 4.5 | $0.00000 | $0.00216 |
Grade A, and why
rls-policy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 100 lines — stays where its author put it; the contents beside it link to each section on GitHub.
RLS Policy
- NEVER 在 write policy 加
(SELECT auth.role()) = 'service_role'當 bypass 條件 — Supabaseservice_role具備 PostgreSQLBYPASSRLS,本來就略過所有 RLS,policy 內加這條件對 service role 沒有任何實際保護作用,只會讓後續 agent 誤以為 privileged write path 由 policy 控制。privileged 寫入的安全邊界見下方「service_role 與 privileged client isolation」。 - SELECT:
TO publicfor client reads,TO authenticatedfor server-only - UPDATE policy 需要搭配 SELECT policy — Postgres RLS 的 UPDATE 必須先 SELECT row,缺少 SELECT policy 會靜默回傳 0 rows(無報錯)
- Storage upsert 需要 INSERT + SELECT + UPDATE 三個 policy — 只有 INSERT 時新上傳正常,但覆蓋(upsert)會靜默失敗
- NEVER use
user_metadata(raw_user_meta_data)in RLS policies — 使用者可自行修改,改用app_metadata - See
supabase-rlsskill for policy templates andTO public陷阱
本檔是 clade 投影,NEVER 就地編輯。專案特化寫進自家
.cursor/rules/local/;要改本檔請回 clade 源檔並 propagate。
GRANT 先於 RLS——table privilege 驗證
PostgreSQL 先檢查 table-level privilege(GRANT)再評估 RLS policy。只建 CREATE POLICY ... TO authenticated 但沒有對應的 GRANT SELECT ON <table> TO authenticated,結果是 42501(permission denied),RLS policy 完全不被評估。
Migration 新增 RLS policy 時 MUST:
- 同一支 migration 內顯式
GRANT <privilege> ON <table> TO <role>,或 - 註明 table 已有既存 GRANT(引用授予 GRANT 的 migration 編號)
驗證方式——在 dev DB 查 pg_catalog:
SELECT grantee, privilege_type
FROM information_schema.role_table_grants
WHERE table_schema = '<schema>' AND table_name = '<table>';
若目標 role 不在結果中,RLS policy 寫再多都是死的。
靜默失敗陷阱
auth.uid() IS NULL陷阱 — 未認證時auth.uid()回傳 null,null = user_id永遠 false,policy 靜默拒絕。要明確區分「沒登入」與「沒權限」,在 policy 開頭寫auth.uid() IS NOT NULL AND ...- DELETE 同理 UPDATE — 沒有 SELECT policy 時 DELETE 也靜默成功但不刪除任何 row
- 缺
TOrole 指定的 policy 會對所有 role 執行 — 明確指定TO authenticated或TO public,避免anon不必要地觸發 policy 評估 - Views 預設繞過 RLS —
CREATE VIEW必須加WITH (security_invoker = true),見migration.md
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 100 lines · 0 tokens per session scan A af31f4c08835
rls-policy is a cursor rule published in the GitHub repository YuDefine/nuxt-supabase-starter (45 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,163 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other cursor rules, from other repositories
demeter
Database specialist — SQLAlchemy 2.0, Alembic, query optimization, N+1 prevention, TDD migrations, modern DB libs. Calls apollo for discovery, sends to themis.
viberaven-supabase-rls
Apply when editing Supabase migrations, RLS policies, or auth SQL.
sveltekit-spa
You are an expert SvelteKit engineer. Follow these rules ALWAYS when generating or editing code.
supabase
Supabase development guidelines, commands, and database patterns.
cache-optimization
Fantasy402 cache optimization patterns and performance guidelines.
ponytail
Ponytail, lazy senior dev mode. Always pick the simplest solution that works.