supabase-add-tenant-user
Installation
SKILL.md
Add a new multi-tenant user: $ARGUMENTS
$ARGUMENTS can include any of:
- email (required)
- display name / full name
- role preference (
user|author|creator|editor|subscriber|admin) — defaultuser - organization slug if joining an existing tenant (no new org created)
- membership role (
owner|admin|member) — defaultownerif new org,memberif joining - Supabase project id / ref if not inferrable
Operating principles
- Never grant
role = 'admin'inuser_profilesunless the user is explicitly the Movemental platform account. Platform admin is reserved for the operator of the SaaS. Creators on the platform areauthororcreator, notadmin. - One auth user = one owned organization. The
handle_new_usertrigger provisions a personal org automatically. Only bypass when joining an existing tenant. - Never insert an
organization_membershipsrow pointing to a non-existent org or user. Verify both exist first. - Never commit plaintext passwords to the repo. Prefer magic-link invites (
supabase.auth.admin.inviteUserByEmail) or passwordless OTP. If a password is required, print it once to the operator and do not persist. - Always prefer the DB trigger over manual inserts.
handle_new_useris idempotent (ON CONFLICT DO NOTHING/ existence checks) and will filluser_profiles,organizations, andorganization_membershipsautomatically.