Agent skill · software engineering · secondsky
better-auth
Skill for integrating Better Auth - comprehensive TypeScript authentication framework for Cloudflare D1, Next.js, Nuxt, and 15+ frameworks. Use when adding auth, encountering D1 adapter errors, or implementing OAuth/2FA/RBAC features.
Why this skill is useful
Adds executable scripts and specific integration patterns for authentication in Cloudflare D1 and various frameworks that the AI wouldn't reliably generate on its own.
What it needs
Requires bun, drizzle-orm, kysely installed locally. About 10k tokens when loaded. Last updated 2026-08-06. 204 stars on the source repository.
What this skill does
better-auth Status: Production Ready Last Updated: 2026-04-08 Package: better-auth@1.6.0 (ESM-only) Dependencies: Drizzle ORM or Kysely (required for D1 complex use cases; D1 native support available in v1.5+) --- Quick Start (5 Minutes) Installation Option 1: Drizzle ORM (Recommended) Option 2: Kysely ⚠️ v1.4.0+ Requirements better-auth v1.4.0+ is ESM-only. Ensure: package.json: Upgrading from v1.3.x? Load references/migration-guide-1.4.0.md Upgrading from v1.4.x? Load references/migration-guide-1.5.0.md ⚠️ CRITICAL: D1 Adapter Requirements v1.5.0+: D1 is now natively supported. Pass your D1 binding directly: For complex schemas, use Drizzle ORM: Minimal Setup (Cloudflare Workers + Drizzle) 1. Create D1 Database: 2. Define Schema (src/db/schema.ts): 3. Initialize Auth (src/auth.ts): 4. Create Worker (src/index.ts): 5. Deploy: --- Decision Tree For code examples and syntax, always consult better-auth.com/docs. --- Critical Rules MUST DO ✅ Use better-auth/minimal + adapter packages for smallest bundle (v1.5+) ✅ Use npx auth migrate and npx auth generate for CLI commands (v1.5+) ✅ Set BETTERAUTHSECRET via wrangler secret put ✅ Configure CORS with credentials: true ✅ Match OAuth callback URLs exactly (no trailing slash) ✅ Apply migrations to local D1 before wrangler dev ✅ Use camelCase column names in schema NEVER DO ❌ Use d1Adapter (doesn't exist) ❌ Forget CORS credentials or mismatch OAuth URLs ❌ Use snakecase columns without CamelCasePlugin ❌ Skip local migrations or hardcode secrets ❌ Leave sendVerificationEmail unimplemented ⚠️ v1.5.0 Breaking Changes API Key Plugin Moved: Schema: userId → referenceId, new configId field. After Hooks: Database after-hooks now run post-transaction (not inside it). Deprecated APIs Removed: Adapter → DBAdapter, InferUser/InferSession removed, @better-auth/core/utils split into subpath exports. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills secondsky/better-auth