audit-schema

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

Conventions for a Supabase audit log table, which records who performed an action, what it affected, and whether it succeeded. It also defines a hash chain linking records for each tenant.

In plain words
What is it for?
Use it when designing or checking a Supabase `audit_logs` table for single-tenant or multi-tenant applications, including event fields, idempotency keys, and hash fields.
Why use it?
It provides a consistent database structure for tracking important actions and detecting changes to audit records.

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/audit-schema
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 audit-schema

README.md
[![agentmods](https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/audit-schema.svg)](https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/audit-schema)
Your own site
<a href="https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/audit-schema"><img src="https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/audit-schema.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,301 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.01301
Opus 5 $0.00000 $0.00651
Sonnet 5 $0.00000 $0.00260
Haiku 4.5 $0.00000 $0.00130

Measured 5d ago against content hash aac76424a459, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

audit-schema 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 5d 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.

template/.cursor/rules/audit-schema.mdc · 113 lines

How it starts

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

Audit Schema Conventions(supabase variant)

通用 audit_logs 表名 + D-pattern hash chain 慣例。適用 / / 等 Supabase Cloud / self-hosted 走通用 schema 的 consumer。

表名與基本欄位

預設 audit table 命名為 public.audit_logsMUST 含下列欄位:

欄位 型別 說明
event_id uuid PK audit row primary key
tenant_id uuid per-tenant chain(multi-tenant consumer 必填;single-tenant 可移除)
actor_id uuid 操作者 user.id;nullable 容納 system event
action text 操作動作識別(<verb>.<entity> 格式,例如 data.exportrole.check
target_type text 受影響 entity 類型
target_id text 受影響 entity PK
outcome text success / denied / failure 三選一
reason text denied / failure 時的原因
business_keys jsonb 結構化業務鍵;不可放 PII / raw prompt / large payload
prev_hash text 上一筆同 tenant 的 hash(per-tenant chain)
hash text 本筆 hash(trigger 在 INSERT 時計算)
idempotency_key text 高風險外部 webhook / payment callback 用
span_id uuid 同批操作共用 span id
created_at timestamptz 自動 now()

D-pattern Hash Chain 規約

audit_logs 是 D-pattern canonical truth(DB row 是 source of truth;evlog wide event 是 derived stream)。

  • MUST 用 trigger 計算 prev_hash / hash(SECURITY DEFINER + advisory lock 避免 race)
  • MUST hash payload function 標 STABLE 並用 deterministic 欄位列表
  • MUST RLS 只允許 service insert / service select / tenant select;沒有 UPDATE / DELETE policy
  • MUST 所有 audit row 走 Postgres outbox dispatcher(claim_audit_outbox_batch + mark_audit_evlog_drained),不分 tenant tier 不分流
  • NEVER 在 DB row 寫 ip_address / user_agent / device fingerprint(PII envelope 只放 evlog)

Audit helper 接口

每個 consumer MUSTserver/utils/audit.ts 統一 helper(vendor template 在 clade vendor/snippets/audit-pattern/helper.ts):

Read the full file on GitHub · 113 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. 5d ago First seen · 113 lines · 0 tokens per session scan A aac76424a459

Subscribe to this mod's changes

audit-schema 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,301 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-08-30.