Introduction¶
In TypeScript or JavaScript projects, integrating login, registration, and sessions often requires touching database adapters, framework routes, OAuth callbacks, client-side SDKs, and migration scripts—scattered across multiple files and easy to miss steps. Better Auth itself consolidates authentication capabilities into a single configuration, but wiring it up from scratch still demands consulting the documentation and editing code in several places. create-auth is an Agent Skill designed for coding assistants that turns the workflow of “scan the project first, decide on the plan, then implement according to the framework” into a fixed process suitable for new projects, existing codebases, or migrations from other authentication libraries.
What Is This¶
create-auth is provided by the Better Auth official skills repository and categorized as an official development Skill on officialskills.sh. Its purpose is to scaffold authentication in TS/JS applications with Better Auth—automatically detecting the framework and database, configuring adapters and route handlers, integrating OAuth, and generating authentication-related UI pages. For exact syntax and APIs, refer to better-auth.com/docs.
Core Features¶
The Skill splits the work into two phases, and the Phase 1 planning must be completed before writing any implementation code.
Project Scan (Automatically Infer Defaults)¶
The assistant analyzes the codebase and infers as many defaults as possible from existing files:
- Framework: e.g.
next.config,svelte.config,nuxt.config,astro.config,vite.config, or Express / Hono entry points. - Database & ORM: e.g.
prisma/schema.prisma,drizzle.config.ts(with itsdialect), dependencies such aspg,postgres,mysql2,better-sqlite3,mongooseinpackage.json; Drizzle driver packages allow finer distinction between Postgres setups. - Existing authentication:
next-auth,lucia,clerk,supabase/auth,firebase/auth, etc., either inpackage.jsonor via imports. - Package manager:
pnpm-lock.yaml,yarn.lock,bun.lockb,package-lock.json.
Items that can be determined are pre-filled into options to minimize redundant questions.
Structured Planning (AskQuestion)¶
The assistant asks all applicable questions in a single batch (skipping any already answered by the scan), using a title like “Auth Setup Planning”. Coverage includes:
- Project type: brand-new project / add auth to an existing project / migrate from another library.
- Framework: Next.js (App or Pages Router), SvelteKit, Nuxt, Astro, Express, Hono, SolidStart, etc.
- Database & ORM: PostgreSQL / MySQL / SQLite / MongoDB with Prisma, Drizzle, or a native driver.
- Login methods (multi-select): email & password, social OAuth, magic link, passkey, phone number.
- Social providers (follow-up if OAuth is chosen): Google, GitHub, Apple, Microsoft, Discord, Twitter/X.
- Email verification (if email & password is chosen).
- Email sending method (needed for verification or password reset): Resend or temporary Mock (console).
- Extended capabilities (multi-select): 2FA, organizations/teams, admin dashboard, API Bearer Token, password reset, etc.
- Required auth pages: login, registration, plus forgot password, reset password, email verification, etc. (dependent on previous answers).
- Auth page UI style: minimal, centered card, split layout, glassmorphism, or custom description.
After collecting the answers, the assistant outputs a checklist-style Auth Implementation Plan in Markdown and asks the user to confirm before proceeding to implementation.
Implementation Path (Phase 2)¶
Once the user confirms the plan, follow this decision tree:
- New project: Install
better-authand any scoped packages from the plan → createauth.ts/auth-client.ts→ add route handlers → set environment variables → run CLI migrate/generate → add plugins & UI pages. - Migration: Audit existing authentication, migrate incrementally, install the new library alongside the old one, wire routes then sessions then UI, and finally remove the old library (see documentation for migration guidance).
- Adding auth to an existing project: Analyze the structure, install & configure, add route handlers & schema migrations, integrate into existing pages & plugins.
After implementation, the Skill guides the user through follow-up steps such as OAuth credentials, deployment environment variables, and end-to-end testing.
Dependencies & Environment Variables (Used During Implementation)¶
Core package:
npm install better-auth
Optional scoped packages (examples): @better-auth/passkey, @better-auth/sso, @better-auth/stripe, @better-auth/scim, @better-auth/expo.
Common environment variables:
BETTER_AUTH_SECRET=<32+ chars, generate with: openssl rand -base64 32>
BETTER_AUTH_URL=http://localhost:3000
DATABASE_URL=<your database connection string>
OAuth requires additional configuration such as GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET, GOOGLE_CLIENT_ID, etc.
Server-side configuration usually lives in lib/auth.ts or src/lib/auth.ts and must include at least database and emailAndPassword: { enabled: true }. Standard setups also configure socialProviders, email verification, and password reset callbacks. Schema generation and migrations mentioned in the plan can be handled via the CLI (example: npx auth@latest; the auth package is used by the CLI and does not need to be installed globally) together with framework route handlers (e.g. app/api/auth/[...all]/route.ts in Next.js App Router).
Installation & Activation¶
In assistants that support Agent Skills, you can add this Skill as instructed on officialskills.sh:
npx skills add https://github.com/better-auth/skills --skill better-auth-create-auth
You can also provide the Skill directory link directly to your assistant and request installation:
https://github.com/better-auth/skills/tree/main/better-auth/create-auth
After installation, simply mention that you want to add login/registration or migrate authentication in your project to trigger the Skill’s workflow. Installation entries may differ in Cursor, Codex CLI, Claude Code, etc., but the Skill itself is the SKILL.md instructions in the repository; differences among clients not listed on the official page are beyond the scope of this article.
Typical Usage¶
The following scenarios come from the official Skill page’s “When to use it” section. In a session with the Skill installed, describe similar needs in natural language; the assistant will run Phase 1 scanning & questioning and, once you confirm the plan, implement the code.
- Add email & password login to a Next.js App Router + Prisma project.
- Configure Google and GitHub OAuth in SvelteKit.
- Migrate from NextAuth or Lucia to Better Auth with minimal interruption.
- Enable 2FA, organizations, and other plugins on a Drizzle schema.
- Generate login/registration pages with session protection for a Hono API and wire up the route handlers.
The planning phase produces an example plan (framework, database, login methods, plugins, UI step list) that matches the checklist in the reference material; the implementation phase then generates the auth-client (e.g. a React client) and corresponding route handlers for your chosen framework.
Suitable Scenarios & Caveats¶
Suitable for: TypeScript/JavaScript full-stack or front-end/back-end separated projects; scenarios that require combinations of email & password, OAuth, 2FA, organizations, etc.; when you want the assistant to string together adapters, routes, migrations, and pages in one go according to the repository’s conventions instead of piecing together documentation snippets yourself.
Caveats:
- Complete planning and user confirmation before writing any implementation to avoid mismatches with the project stack.
- If the project already has another authentication library, follow a step-by-step parallel migration; do not remove the old dependencies before auditing.
- Passkey, enterprise SSO, Stripe, SCIM, Expo, etc., require additional scoped packages and must be explicitly selected in the plan.
- Email-related features need a real sending service (e.g. Resend) or acceptance of development-time Mock.
- Code details are subject to the official Better Auth documentation; the Skill provides workflow and decision trees and does not replace reading OAuth provider consoles or managing production secrets.
Conclusion¶
create-auth breaks Better Auth integration into “scan → Q&A planning → confirm checklist → scenario-based implementation,” covering multiple frameworks, databases, and migrations from legacy libraries. If you’re using an AI coding assistant to build a login system, install the Skill from the official repository and describe your target stack and login methods directly in the conversation.
Official repository: https://github.com/better-auth/skills/tree/main/better-auth/create-auth