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/user-lifecyclegit 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/user-lifecycle)<a href="https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/user-lifecycle"><img src="https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/user-lifecycle.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.02089 |
| Opus 5 | $0.00000 | $0.01045 |
| Sonnet 5 | $0.00000 | $0.00418 |
| Haiku 4.5 | $0.00000 | $0.00209 |
Grade A, and why
user-lifecycle 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 — 120 lines — stays where its author put it; the contents beside it link to each section on GitHub.
User Lifecycle
Consumer 刪除或停用使用者時,FK 策略與 guard pattern 的標準治理。三種 variant 任選其一,FK 策略矩陣與 delete guard 跨 variant 共用。
Reference: vendor/snippets/user-lifecycle/README.md(variant 決策樹 + 範本安裝 SOP)
三種 Variant
| Variant | 語意 | 適用場景 |
|---|---|---|
| status-based | suspended_at / status 欄,使用者永不從表消失 |
SaaS、校務、多角色平台(大多數 consumer) |
| suspend-and-delete | 先 suspend 冷卻期,到期 hard delete(scheduler / cron) | GDPR right-to-erasure、資料保留政策有硬限 |
| hard-delete-explicit | 無 suspend,直接 hard delete + cascade | 單租戶 internal tool、無合規需求 |
FK Strategy Decision Matrix
設計 user 相關 FK 時,依被引用表的語意選 ON DELETE 行為:
| 被引用資料類型 | ON DELETE 行為 | 理由 |
|---|---|---|
| User-owned data(profile / settings / preference) | CASCADE |
屬使用者私有,人刪資料跟著刪 |
| Membership / role assignment | CASCADE |
成員關係隨人消失 |
created_by / updated_by / assigned_to |
SET NULL |
保留資料但去除人員連結 |
| Audit trail / operation log | No FK or SET NULL |
Audit canonical 不可因刪人斷鏈(見 audit-pattern.md) |
| Financial / compliance record | RESTRICT |
有帳務 / 合規紀錄的使用者不可刪 |
| Manager / supervisor reference | SET NULL |
組織樹不因離職斷裂 |
MUST 在 migration PR 對每個新 FK 標註選用的行為與理由。
Delete Guard Pattern
不論哪個 variant,刪除 / 停用 endpoint MUST 實作以下 5 道 guard(順序即優先序):
| # | Guard | 拒絕條件 | 錯誤碼 |
|---|---|---|---|
| 1 | No self-delete | actor.id === target.id |
403 |
| 2 | No delete/suspend admin | target 有 admin role(須先 demote) | 403 |
| 3 | No delete owner | target 是 org/tenant owner(須先 transfer) | 403 |
| 4 | No delete last admin | org/tenant 內只剩一個 admin | 403 |
| 5 | Session invalidation | 依 session-store 類型 — revocable store 即時 revoke;stateless cookie 走 per-request 重驗(見 § Session 失效策略) | — |
Guard 5 非 pre-check 而是 post-action side-effect;其餘 4 道在 mutation 前 fail-fast。
Template: vendor/snippets/user-lifecycle/delete-guard.ts.template
Auth Layer Enforcement
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 · 120 lines · 0 tokens per session scan A c625ab85378f
user-lifecycle 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,089 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
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.
angular-20
This rule provides comprehensive best practices and coding standards for Angular development, focusing on modern TypeScript, standalone components, signals, and performance optimizations.