database-access

database-access is a cursor rule for Cursor from YuDefine/nuxt-supabase-starter. It costs 0 tokens per session (1,831 once invoked), scanned A, original, MIT.

A database access pattern that separates browser reads from server-side reads and writes when using Supabase. Supabase is a hosted PostgreSQL service with rules that can restrict which users may access rows.

In plain words
What is it for?
It is for choosing Supabase clients, API routes, row-level security, privileged background tasks, and optional service-layer queries.
Why use it?
It reduces accidental exposure of privileged database access and keeps authorization checks in the appropriate server or database layer.

Cursor rule for Cursor

Install

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.

agentmods
npx agentmods add rules/yudefine/nuxt-supabase-starter/database-access
Clone the repo
git clone --depth 1 https://github.com/YuDefine/nuxt-supabase-starter

Made for: Cursor.

Wrote 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.

agentmods badge for database-access

README.md
[![agentmods](https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/database-access.svg)](https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/database-access)
Your own site
<a href="https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/database-access"><img src="https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/database-access.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,831 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01831
Opus 5 $0.00000 $0.00915
Sonnet 5 $0.00000 $0.00366
Haiku 4.5 $0.00000 $0.00183

Measured yesterday against content hash 4725b4865dd5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

database-access 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 yesterday.

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.

template/.cursor/rules/database-access.mdc · 121 lines

How it starts

The opening of the file, as written. The whole thing — 121 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Database Access Pattern

  • Client(預設): READ only via useSupabaseClient<Database>()僅限 RLS SELECT TO public 的表
  • Server(預設): request-scoped 讀寫一律經 /api/v1/* + getSupabaseWithContext(event)

Helper 名依 modules.auth 而異:本檔以 getSupabaseWithContext(event) 為 canonical 名。當 consumer 的 .claude/hub.json modules.authbetter-authnuxt-auth-utils 時,等價 helper 是 getAuthedSupabase(event) —— 那些 auth stack 下 Supabase 不簽 JWT,auth.uid() 恆 null,helper 只驗 session 不做授權,名字必須說實話。兩者回傳形狀相同({ client, user })。見 [[auth-data-path-consistency]] § Server 側:RLS policy 的前提條件。

  • Privileged system tasks: getServerSupabaseClient() 僅用於 audit logging、backfill、資料修復、背景工作
  • Optional transactional query layer: server/utils/drizzle.ts 僅用於 service 層 / 系統任務;NEVER 讓 Drizzle 接管 migration、RLS、trigger
  • Client-side writes are architecture exceptions — 只有在 proposal / ADR 明確記錄並同時滿足下列條件時,才可從 client 使用 .insert() / .update() / .delete() / .upsert()
    • RLS policy 能完整表達 tenant / user scope 與所有授權規則
    • GRANT 只開必要 schema / table / operation,不給寬權限
    • 不需要 service_role、server-only secret、跨表 transaction、workflow transition、audit-chain、storage upload 或外部 API
    • 不涉及角色 / 權限、薪資、簽核、出勤、稽核、批次修復等敏感流程
    • 有 focused tests 驗證 allow path、deny path、tenant isolation 與 RLS 失敗時的 UI/錯誤處理
  • NEVER client 直讀 RLS TO authenticated 的表 — anon 角色會靜默回傳 0 筆(見 supabase-rls skill)

MCP 存取

  • Dev 查詢用 dev-supabase MCP(local Supabase instance)
  • NEVER 使用 Kong port 8001 — Studio introspection 會觸發 PostgREST pool 重建,導致 REST API 中斷
  • NEVER 在上班時間 docker restart 任何 Supabase 容器

Seed 資料

seed.sql 使用 INSERT 格式(非 COPY FROM stdin),加 SET session_replication_role = replica;TRUNCATE CASCADE

本檔是 clade 投影,NEVER 就地編輯。專案特化寫進自家 .cursor/rules/local/;要改本檔請回 clade 源檔並 propagate。

Read the full file on GitHub · 121 lines

Changes

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.

  1. yesterday First seen · 121 lines · 0 tokens per session scan A 4725b4865dd5

Subscribe to this mod's changes

database-access is a cursor rule published in the GitHub repository YuDefine/nuxt-supabase-starter (45 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,831 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.