Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Implement authentication and authorization with Better Auth - a framework-agnostic TypeScript authentication framework. Features include email/password authentication with verification, OAuth providers (Google, GitHub, Discord, etc.), two-factor authentication (TOTP, SMS), passkeys/WebAuthn support, session management, role-based access control (RBAC), rate limiting, and database adapters. Use when adding authentication to applications, implementing OAuth flows, setting up 2FA/MFA, managing user
.claude/skills/microck-better-auth/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-21 | ✗→✓ | ▲ Improved | -23% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 99% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 96% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 80% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 61% | 0% |
Better Auth is comprehensive, framework-agnostic authentication/authorization framework for TypeScript with built-in email/password, social OAuth, and powerful plugin ecosystem for advanced features.
bashnpm install better-auth # or pnpm/yarn/bun add better-auth
Create .env:
envBETTER_AUTH_SECRET=<generated-secret-32-chars-min> BETTER_AUTH_URL=http://localhost:3000
Create auth.ts (root, lib/, utils/, or under src/app/server/):
tsimport { betterAuth } from "better-auth"; export const auth = betterAuth({ database: { // See references/database-integration.md }, emailAndPassword: { enabled: true, autoSignIn: true }, socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID!, clientSecret: process.env.GITHUB_CLIENT_SECRET!, } } });
bashnpx @better-auth/cli generate # Generate schema/migrations npx @better-auth/cli migrate # Apply migrations (Kysely only)
Next.js App Router:
ts// app/api/auth/[...all]/route.ts import { auth } from "@/lib/auth"; import { toNextJsHandler } from "better-auth/next-js"; export const { POST, GET } = toNextJsHandler(auth);
Other frameworks: See references/email-password-auth.md#framework-setup
Create auth-client.ts:
tsimport { createAuthClient } from "better-auth/client"; export const authClient = createAuthClient({ baseURL: process.env.NEXT_PUBLIC_BETTER_AUTH_URL || "http://localhost:3000" });
ts// Sign up await authClient.signUp.email({ email: "user@example.com", password: "secure123", name: "John Doe" }); // Sign in await authClient.signIn.email({ email: "user@example.com", password: "secure123" }); // OAuth await authClient.signIn.social({ provider: "github" }); // Session const { data: session } = authClient.useSession(); // React/Vue/Svelte const { data: session } = await authClient.getSession(); // Vanilla JS
| Feature | Plugin Required | Use Case | Reference | |---------|----------------|----------|-----------| | Email/Password | No (built-in) | Basic auth | email-password-auth.md | | OAuth (GitHub, Google, etc.) | No (built-in) | Social login | oauth-providers.md | | Email Verification | No (built-in) | Verify email addresses | email-password-auth.md | | Password Reset | No (built-in) | Forgot password flow | email-password-auth.md | | Two-Factor Auth (2FA/TOTP) | Yes (twoFactor) | Enhanced security | advanced-features.md | | Passkeys/WebAuthn | Yes (passkey) | Passwordless auth | advanced-features.md | | Magic Link | Yes (magicLink) | Email-based login | advanced-features.md | | Username Auth | Yes (username) | Username login | email-password-auth.md | | Organizations/Multi-tenant | Yes (organization) | Team/org features | advanced-features.md | | Rate Limiting | No (built-in) | Prevent abuse | advanced-features.md | | Session Management | No (built-in) | User sessions | advanced-features.md |
Choose Email/Password when:
Choose OAuth when:
Choose Passkeys when:
Choose Magic Link when:
Combine Multiple Methods when:
Better Auth uses client-server architecture:
better-auth): Handles auth logic, database ops, API routesbetter-auth/client): Provides hooks/methods for frontendbetter-auth packagenpx @better-auth/cli generate)scripts/better_auth_init.py - Initialize Better Auth configuration with interactive setup| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | pass→pass | 6,460 | 3,391 | -48% | 1 | 1 | 0% | 1,142 | 2,276 | +99% | 0 | 0 | — |
case-02 | pass→pass | 7,186 | 4,602 | -36% | 1 | 1 | 0% | 1,338 | 2,626 | +96% | 0 | 0 | — |
case-03 | pass→pass | 7,675 | 4,700 | -39% | 1 | 1 | 0% | 1,403 | 2,532 | +80% | 0 | 0 | — |
case-04 | pass→pass | 9,649 | 6,269 | -35% | 1 | 1 | 0% | 1,764 | 2,842 | +61% | 0 | 0 | — |
case-05 | pass→pass | 9,604 | 7,696 | -20% | 1 | 1 | 0% | 1,737 | 3,226 | +86% | 0 | 0 | — |
case-06 | pass→pass | 4,407 | 2,548 | -42% | 1 | 1 | 0% | 706 | 2,120 | +200% | 0 | 0 | — |
case-07 | pass→pass | 5,031 | 4,342 | -14% | 1 | 1 | 0% | 979 | 2,478 | +153% | 0 | 0 | — |
case-08 | pass→pass | 5,055 | 3,422 | -32% | 1 | 1 | 0% | 850 | 2,424 | +185% | 0 | 0 | — |
case-09 | pass→pass | 4,289 | 2,982 | -30% | 1 | 1 | 0% | 716 | 2,246 | +214% | 0 | 0 | — |
case-10 | pass→pass | 3,754 | 3,053 | -19% | 1 | 1 | 0% | 590 | 2,211 | +275% | 0 | 0 | — |
case-11 | pass→pass | 8,414 | 5,346 | -36% | 1 | 1 | 0% | 1,647 | 2,699 | +64% | 0 | 0 | — |
case-12 | pass→pass | 7,291 | 4,803 | -34% | 1 | 1 | 0% | 1,267 | 2,546 | +101% | 0 | 0 | — |
case-13 | pass→pass | 7,984 | 5,249 | -34% | 1 | 1 | 0% | 1,377 | 2,678 | +94% | 0 | 0 | — |
case-14 | pass→pass | 6,918 | 3,898 | -44% | 1 | 1 | 0% | 1,214 | 2,463 | +103% | 0 | 0 | — |
case-15 | pass→pass | 9,479 | 4,340 | -54% | 1 | 1 | 0% | 1,718 | 2,455 | +43% | 0 | 0 | — |
case-16 | pass→pass | 8,492 | 5,573 | -34% | 1 | 1 | 0% | 1,454 | 2,709 | +86% | 0 | 0 | — |
case-17 | pass→pass | 8,245 | 8,373 | +2% | 1 | 1 | 0% | 1,359 | 3,221 | +137% | 0 | 0 | — |
case-18 | pass→pass | 14,073 | 7,178 | -49% | 1 | 1 | 0% | 2,219 | 3,042 | +37% | 0 | 0 | — |
case-19 | pass→pass | 12,713 | 8,833 | -31% | 1 | 1 | 0% | 1,953 | 3,239 | +66% | 0 | 0 | — |
case-20 | pass→pass | 13,661 | 8,557 | -37% | 1 | 1 | 0% | 2,077 | 3,129 | +51% | 0 | 0 | — |
case-21 | fail→pass | 15,002 | 1,741 | -88% | 1 | 1 | 0% | 2,561 | 1,967 | -23% | 0 | 0 | — |
case-22 | pass→pass | 11,287 | 11,343 | +0% | 1 | 1 | 0% | 2,128 | 4,061 | +91% | 0 | 0 | — |
case-23 | pass→pass | 11,890 | 10,325 | -13% | 1 | 1 | 0% | 2,110 | 3,707 | +76% | 0 | 0 | — |
case-24 | pass→pass | 10,733 | 9,872 | -8% | 1 | 1 | 0% | 2,003 | 3,446 | +72% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 24 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 24 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.