user-lifecycle

user-lifecycle is a cursor rule for Cursor from YuDefine/nuxt-supabase-starter. It costs 0 tokens per session (2,089 once invoked), scanned A, original, MIT.

Database guidance for handling a user's suspension or deletion and deciding what happens to related records through foreign-key rules.

In plain words
What is it for?
It helps design soft-delete, suspend-then-delete, or hard-delete behavior, including deletion guards and relationship policies.
Why use it?
It helps prevent broken references, accidental data loss, and incorrect handling of audit, financial, or compliance 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/user-lifecycle
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 user-lifecycle

README.md
[![agentmods](https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/user-lifecycle.svg)](https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/user-lifecycle)
Your own site
<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>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,089 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.1 $0.00000 $0.02089
Opus 5 $0.00000 $0.01045
Sonnet 5 $0.00000 $0.00418
Haiku 4.5 $0.00000 $0.00209

Measured 2d ago against content hash c625ab85378f, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

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.

template/.cursor/rules/user-lifecycle.mdc · 120 lines

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

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

Subscribe to this mod's changes

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.