Agent skill · software engineering · better-auth

better-auth-best-practices

Configure Better Auth server and client, set up database adapters, manage sessions, add plugins, and handle environment variables. Use when users mention Better Auth, betterauth, auth.ts, or need to set up TypeScript authentication with email/password, OAuth, or plugin configuration.

Why this skill is useful

Provides specific commands and configuration patterns for integrating Better Auth with TypeScript applications that the AI wouldn't reliably generate on its own.

What it needs

Requires better-auth installed locally. About 4k tokens when loaded. Last updated 2026-07-11. 206 stars on the source repository.

What this skill does

Better Auth Integration Guide Documentation Version Use documentation that matches the Better Auth version installed in the project. APIs and plugin names can differ across maintained release lines. 1. Prefer a version explicitly named by the user. 2. Otherwise, inspect the resolved better-auth version in the lockfile, falling back to the package manifest when no lockfile is available. 3. When the Better Auth MCP is available, call getdoc with /llms.txt to resolve that package version to a documentation identifier. Pass the identifier to every searchdocs call and pass result paths to getdoc unchanged. 4. Without MCP, start at better-auth.com/llms.txt and follow the matching version index. 5. Use the latest documentation only when the project version cannot be determined or the user explicitly asks about the latest release or an upgrade. When planning an upgrade, separate guidance for the currently installed version from guidance for the target version. --- Setup Workflow 1. Install: npm install better-auth 2. Set env vars: BETTERAUTHSECRET and BETTERAUTHURL 3. Create auth.ts with database + config 4. Create route handler for your framework 5. Run migrations: Built-in adapter: npx auth@latest migrate Drizzle: npx auth@latest generate --output src/db/auth-schema.ts then npx drizzle-kit push (dev) or npx drizzle-kit generate && npx drizzle-kit migrate (prod) Prisma: npx auth@latest generate --output prisma/schema.prisma then npx prisma migrate dev 6. Verify: call GET /api/auth/ok — should return { status: "ok" } --- Quick Reference Environment Variables BETTERAUTHSECRET - Encryption secret (min 32 chars). Generate: openssl rand -base64 32 BETTERAUTHURL - Base URL (e.g., https://example.com) Only define baseURL/secret in config if env vars are NOT set. File Location CLI looks for auth.ts in: ./, ./lib, ./utils, or under ./src. Use --config for custom path. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills better-auth/best-practices

View the source on GitHub

Browse the @skills marketplace