multitenancy-billing
Build SaaS tenancy and monetization: orgs/teams/roles, tenant isolation, Stripe billing, metering, entitlements, audit logs. Use for any multi-tenant or paid feature.
SKILL.mdskills/saas/multitenancy-billing/SKILL.md
GitHubmultitenancy-billing
Tenants isolated by construction, money handled by Stripe, every grant auditable.
Activate when
- Adding organizations, seats, roles, trials, subscriptions, usage limits, or per-tenant data.
Do NOT activate for
- Single-tenant internals (see architecture/modularity).
Procedure
- Model: org → team → user → role → permission; tenant id on every row or separate schema per isolation tier (shared-schema with tenant id, or separate schema per isolation tier).
- Enforce: server-side tenant scoping on every query; cross-tenant tests for each new endpoint; support access is impersonation-audited, never silent.
- Bill: Stripe for subscriptions/invoices/trials; webhook handling idempotent with signature verification; metering pipeline decoupled from request path.
- Gate: entitlements checked server-side; feature flags per plan; quotas with clear 429/upgrade paths; audit log for permission and billing events.
- Operate: background jobs for email/notifications/dunning; data-export and tenant-deletion runbooks.
- Verify: cross-tenant access tests fail closed, webhook replay is safe, trial→paid→cancel flows exercised end to end.
References
- Related:
../../backend/authorization/,../../backend/api-security/.