Scaffolds Better Auth in Next.js (App Router) + Drizzle projects. Generates auth files, route handler, middleware, env example, and permissions module with presets for minimal, social, or advanced (2FA + magic link).
How this skill is triggered — by the user, by Claude, or both
Slash command
/pproenca-dot-skills-1:better-auth-scaffoldThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Parameterized templates for bootstrapping a Better Auth setup in a Next.js App Router project using the Drizzle adapter. Each template enforces the conventions documented in [`references/conventions.md`](references/conventions.md) — file layout, plugin ordering, env handling, runtime selection.
Parameterized templates for bootstrapping a Better Auth setup in a Next.js App Router project using the Drizzle adapter. Each template enforces the conventions documented in references/conventions.md — file layout, plugin ordering, env handling, runtime selection.
Reference these templates when:
nextCookies() ordering| Parameter | Required | Default | Description |
|---|---|---|---|
preset | no | minimal | minimal (email+password) | social (adds Google + GitHub) | advanced (social + twoFactor + magicLink) |
db_provider | yes | — | pg | mysql | sqlite (Drizzle provider) |
app_name | yes | — | Display name (becomes 2FA issuer in authenticator apps when preset=advanced) |
| Parameter | Default | Description |
|---|---|---|
auth_path | lib/auth.ts | Server auth module path |
client_path | lib/auth-client.ts | Client module path |
api_route_path | app/api/auth/[...all]/route.ts | Catch-all route handler path |
protected_paths | ["/dashboard"] | Routes the middleware guards |
If config.json already exists with values, the skill uses those; otherwise it asks the user.
| Template | Output File | When to emit |
|---|---|---|
auth.ts.template | lib/auth.ts | Always |
auth-client.ts.template | lib/auth-client.ts | Always |
route.ts.template | app/api/auth/[...all]/route.ts | Always |
middleware.ts.template | middleware.ts | When protected_paths is non-empty |
env.template | .env.example | Always |
db-schema-better-auth.ts.template | db/schema/auth.ts | Always (stub — replace with output of better-auth generate) |
db-index.ts.template | db/index.ts | When the project has no Drizzle client yet |
email.ts.template | lib/email.ts | When preset=advanced (and the file doesn't already exist) |
sign-in-page.tsx.template | app/sign-in/page.tsx | When the project has no sign-in page (closes the middleware redirect loop) |
permissions.ts.template | lib/permissions.ts | Optional starter for org/admin plugin work |
Resolve parameters. Read config.json first; for any missing required parameter (db_provider, app_name), ask the user via AskUserQuestion.
Render each template. For each template file:
{{placeholder}} values ({{app_name}}, {{db_provider}}, etc.) with the resolved parameter values.PRESET[...] conditional blocks using these rules:
// PRESET[<tags>] and // /PRESET[<tags>] (or /* PRESET[...] */ / # PRESET[...] for non-JS files — same syntax, different comment style).<tags> as a comma-separated list (e.g. social,advanced).<tags> → remove ONLY the two marker lines; keep the lines between them.<tags> → remove the ENTIRE block including both marker lines.PRESET[advanced] inside PRESET[minimal,social,advanced]); process from inside out.middleware.ts.template (// {{#protected_paths}} ... // {{/protected_paths}}), repeat the lines between the markers once per item in the list, substituting {{path}} with each value.Write output files. Before writing, check if the target file already exists:
Run the CLI sequence. After all files are written:
npx @better-auth/cli@latest generate
npx drizzle-kit generate
npx drizzle-kit migrate
These commands replace the placeholder db/schema/auth.ts with the real schema and apply migrations.
Print next steps. Tell the user to:
.env.local (copy from .env.example)openssl rand -base64 32social/advanced presets)lib/email.ts to wire transactional email (for advanced preset)Read references/conventions.md for the rationale behind every convention these templates encode. Highlights:
lib/auth.ts is server-only (import "server-only")nextCookies() is ALWAYS the last plugin in the arrayprocess.env.*, never inlinecookieCache enabledbetter-auth — Library/API Reference with 42 rules covering setup, sessions, security, plugins, and migration. The templates here are one canonical realization of those rules; read the rule for the underlying reasoning when you need to deviate.See gotchas.md — initialized empty, populated as we discover them.
npx claudepluginhub joshuarweaver/cascade-code-general-misc-1 --plugin pproenca-dot-skills-1Integrates Better Auth with NestJS backends and Next.js App Router frontends using Drizzle ORM and PostgreSQL. Covers database setup, social logins, 2FA, organizations, passkeys, and protected routes.
Better Auth in TypeScript — setting up the auth instance, picking adapters, wiring framework route handlers, configuring sessions and cookies, adding plugins (2FA, organization, admin, magicLink, JWT), or porting from NextAuth/Auth.js, Clerk, Auth0, or Supabase Auth. Covers Next.js, SvelteKit, Hono, Express, Nuxt, Astro, and React/Vue/Svelte clients. Trigger when writing, reviewing, or migrating Better Auth code — and even when the user doesn't explicitly mention Better Auth but is working on TypeScript authentication, session cookies, OAuth providers, or auth-library migration. Contains 42 rules organized by impact across 8 categories.
Sets up Neon Auth in Next.js, React SPA, or Node.js apps. Configures auth routes, session management, social providers, and generates UI components.