← ClaudeAtlas

nts-add-authlisted

Add Better Auth to an existing project scaffolded with nextjs-trpc-prisma-starter that initially skipped auth. Use this when the user says 'add auth', 'add login', 'wire Better Auth', 'add user accounts', invokes /nts-add-auth, or starts asking permission/session questions in a project without auth wired. Wires up the Better Auth Prisma adapter, session helper, requirePermission helper, /login page (credentials), the auth route handler at /api/auth/[...all], and the User / Session / Account / Verification Prisma models. Updates the tRPC context to include the session and switches the example router from publicProcedure to protectedProcedure.
juncoding/nextjs-trpc-prisma-starter · ★ 0 · API & Backend · score 70
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