nts-add-authlisted
Install: claude install-skill juncoding/nextjs-trpc-prisma-starter
# Add Better Auth to an existing project
For projects scaffolded without auth that now need it. This is a substantial change — every tRPC procedure becomes auth-gated, and the schema gains four new tables.
## Use when
- User wants user accounts / login / sessions.
- User says "add auth" / "wire Better Auth" / "we need permissions now".
- User invokes `/nts-add-auth`.
## Confirmation flow
Auth is a meaningful schema change. Before writing:
1. Verify project structure (`prisma/schema.prisma`, `src/server/`, `package.json` exist).
2. Confirm auth strategy:
- **Credentials only (recommended)** — email + password.
- **Credentials + magic-link** — adds Resend dependency.
- **Credentials + OAuth providers** (Google, GitHub, etc.) — adds provider configuration.
3. Confirm the user has a place to put the bootstrap admin (sysadmin) — usually the seed script.
4. Show all file changes. Confirm.
## What this skill does
1. Adds `better-auth` to `package.json`.
2. Adds Better Auth's required Prisma models — `User`, `Session`, `Account`, `Verification`.
3. Creates a migration.
4. Creates `src/server/auth/index.ts` with the Better Auth config.
5. Creates `src/server/auth/session.ts` with `requireSession()` and `getSession()` helpers.
6. Creates `src/server/auth/permissions.ts` with `requirePermission()` (RBAC). Adds `Role`, `Permission`, `UserRole`, `RolePermission` Prisma models.
7. Creates `src/app/api/auth/[...all]/route.ts` — Better Auth's catch-all handler.
8. Creates `s