Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
pproenca avatar

Better Auth Scaffold

  • 82 installs
  • 191 repo stars
  • Updated July 24, 2026
  • pproenca/dot-skills

better-auth-scaffold is a Claude Code skill for security.

About

better-auth-scaffold is a Claude Code skill for security. It helps solo builders move faster with AI-assisted coding.

  • better-auth-scaffold
  • Security
  • AI-coding skill

Better Auth Scaffold by the numbers

  • 82 all-time installs (skills.sh)
  • +6 installs in the week ending Aug 4, 2026 (Skillselion tracking)
  • Ranked #1,081 of 2,203 Security skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/pproenca/dot-skills --skill better-auth-scaffold

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs82
repo stars191
Last updatedJuly 24, 2026
Repositorypproenca/dot-skills

How do I helps with security tasks during AI-assisted development.?

Helps with security tasks during AI-assisted development.

Who is it for?

Best when you're working on security and need structured help with better auth scaffold.

Skip if: Teams with no security needs, or anyone wanting a generic chat assistant without this specific workflow.

When should I use this skill?

When you need to helps with security tasks during AI-assisted development., or when better-auth-scaffold is a claude code skill for security.

What you get

Structured output aligned to better-auth-scaffold: better-auth-scaffold, Security.

Files

SKILL.mdMarkdownGitHub ↗

Better Auth Scaffold (Next.js + Drizzle)

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.

When to Apply

Reference these templates when:

  • Starting a new Next.js project that needs authentication
  • Adding Better Auth to an existing Next.js + Drizzle codebase
  • Refactoring a partial Better Auth setup that's missing the catch-all route, middleware, or nextCookies() ordering
  • Generating a per-feature variant (minimal, social, advanced) on top of an existing project

Setup

Required parameters

ParameterRequiredDefaultDescription
presetnominimalminimal (email+password) \
db_provideryespg \
app_nameyesDisplay name (becomes 2FA issuer in authenticator apps when preset=advanced)

Optional parameters

ParameterDefaultDescription
auth_pathlib/auth.tsServer auth module path
client_pathlib/auth-client.tsClient module path
api_route_pathapp/api/auth/[...all]/route.tsCatch-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.

Available Templates

TemplateOutput FileWhen to emit
`auth.ts.template`lib/auth.tsAlways
`auth-client.ts.template`lib/auth-client.tsAlways
`route.ts.template`app/api/auth/[...all]/route.tsAlways
`middleware.ts.template`middleware.tsWhen protected_paths is non-empty
`env.template`.env.exampleAlways
`db-schema-better-auth.ts.template`db/schema/auth.tsAlways (stub — replace with output of better-auth generate)
`db-index.ts.template`db/index.tsWhen the project has no Drizzle client yet
`email.ts.template`lib/email.tsWhen preset=advanced (and the file doesn't already exist)
`sign-in-page.tsx.template`app/sign-in/page.tsxWhen the project has no sign-in page (closes the middleware redirect loop)
`permissions.ts.template`lib/permissions.tsOptional starter for org/admin plugin work

How to Use

1. Resolve parameters. Read config.json first; for any missing required parameter (db_provider, app_name), ask the user via AskUserQuestion.

2. Render each template. For each template file:

  • Read the template.
  • Substitute {{placeholder}} values ({{app_name}}, {{db_provider}}, etc.) with the resolved parameter values.
  • Apply PRESET[...] conditional blocks using these rules:

1. Find every pair of marker lines matching // PRESET[<tags>] and // /PRESET[<tags>] (or /* PRESET[...] */ / # PRESET[...] for non-JS files — same syntax, different comment style). 2. Parse <tags> as a comma-separated list (e.g. social,advanced). 3. If the chosen preset value is in <tags> → remove ONLY the two marker lines; keep the lines between them. 4. If the chosen preset value is NOT in <tags> → remove the ENTIRE block including both marker lines. 5. Markers may be nested (e.g. PRESET[advanced] inside PRESET[minimal,social,advanced]); process from inside out.

  • For Mustache-style iteration in middleware.ts.template (// {{#protected_paths}} ... // {{/protected_paths}}), repeat the lines between the markers once per item in the list, substituting {{path}} with each value.

3. Write output files. Before writing, check if the target file already exists:

  • If it doesn't exist → write it.
  • If it exists and is identical → no-op.
  • If it exists and differs → show a diff and ask the user (overwrite / merge / skip).

4. 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.

5. Print next steps. Tell the user to:

  • Fill in .env.local (copy from .env.example)
  • Generate a secret: openssl rand -base64 32
  • Register OAuth redirect URIs with each provider console (for social/advanced presets)
  • Implement lib/email.ts to wire transactional email (for advanced preset)

Conventions

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 array
  • Middleware does a cookie-presence check only; real validation in pages
  • All secrets via process.env.*, never inline
  • Sliding-window sessions with cookieCache enabled

Related Skills

  • `better-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.

Gotchas

See `gotchas.md` — initialized empty, populated as we discover them.

Related skills

FAQ

What does better-auth-scaffold do?

better-auth-scaffold is a Claude Code skill for security.

When should I use better-auth-scaffold?

When you need to helps with security tasks during AI-assisted development., or when better-auth-scaffold is a claude code skill for security.

What are the main capabilities?

better-auth-scaffold; Security; AI-coding skill.

Securityappsec

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.