authentication
Installation
SKILL.md
Authentication (Better Auth)
When to use: Sessions, sign-in/sign-up flows, OAuth, magic links, or organization context on the session.
Stack
@platform/db-postgresexposescreateBetterAuth()inpackages/platform/db-postgres/src/create-better-auth.ts, wiring better-auth with the Drizzle adapter against the shared Postgres client.- Sessions:
auth.api.getSession({ headers })→{ user, session }with typed fields. Userincludesid,email,name— use those fields directly (no assertions).
Web app helpers
- Session helpers:
apps/web/src/domains/sessions/session.functions.ts(getSession,ensureSession, etc.). - Organization context is added via the
customSessionplugin (multi-tenant product behavior).
Domain alignment
- Auth intent flows (login/signup completion) use use-cases from
@domain/authcomposed with Postgres repositories — keep policy in domain, wiring in apps.