mcpField
B
better-auth

better-auth

github.com/pproencaSecurity220139 installsUpdated 11w ago
Repository

About better-auth

A reference skill with 42 implementation and migration rules for Better Auth, a framework-agnostic TypeScript authentication library. It is intended for developers setting up, extending, securing, troubleshooting, or migrating Better Auth applications.

Key features

  1. 0142 rules across eight categories
  2. 02Setup and adapter guidance
  3. 03Session and cookie configuration
  4. 04Security and plugin recommendations
  5. 05Migration guidance for other auth libraries

Use cases

  1. 01Planning a new Better Auth setup
  2. 02Reviewing auth configuration changes
  3. 03Troubleshooting sessions or CSRF errors
  4. 04Migrating from another authentication library

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pproenca/dot-skills --skill better-auth

After installing, type/better-authin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

AGENTS.md
metadata.json
assets/templates/
_template.md
references/
_sections.md
auth-client-sign-in-helpers.md
auth-infer-additional-fields.md
auth-magic-link-setup.md
auth-oauth-env-vars.md
auth-oauth-redirect-uri.md
auth-require-email-verification.md
db-adapter-selection.md
db-additional-fields.md
db-connection-pooling.md
db-database-hooks.md
db-plugin-schema-customization.md
db-schema-generate.md
migrate-force-allow-id.md
migrate-nextauth-schema-mapping.md
migrate-oauth-account-mapping.md
migrate-parallel-cutover.md
plugins-admin-impersonation.md
plugins-jwt-when-to-use.md
plugins-next-cookies-last.md
plugins-organization-active-context.md
plugins-pair-client-server.md
plugins-shared-access-control.md
plugins-two-factor-issuer.md
route-mount-catchall.md
route-no-body-consumers.md
route-runtime-selection.md

Details

From the project README

Better Auth Best Practices

Implementation and migration guide for Better Auth, the framework-agnostic TypeScript authentication and authorization library. This skill contains 42 rules organized by impact across 8 categories, derived from the official documentation and migration guides.

When to Apply

Reference these guidelines when:

  • Setting up a fresh Better Auth instance (config, adapter, route handler, client)
  • Wiring framework-specific integrations (Next.js App/Pages Router, SvelteKit, Hono, Express, Nuxt, Astro)
  • Configuring sessions, cookies, and security (rate limit, trusted origins, password hashing)
  • Adding plugins: 2FA, organization, admin, magicLink, JWT, passkey, multi-session
  • Migrating from another auth library (NextAuth/Auth.js, Clerk, Auth0, Supabase Auth)
  • Debugging "session is null" / "redirect_uri_mismatch" / 403 CSRF errors
  • Reviewing PRs that touch lib/auth.ts, auth-client.ts, or /api/auth/ route handlers

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Setup & ConfigurationCRITICALsetup-
2Database Adapters & SchemaCRITICALdb-
3API Route HandlersCRITICALroute-
4Session & CookiesHIGHsession-
5Auth Methods & ProvidersHIGHauth-
6Security & HardeningHIGHsecurity-
7Plugins & ExtensionsMEDIUMplugins-
8Migration from Other AuthMEDIUMmigrate-

Quick Reference

1. Setup & Configuration (CRITICAL)
2. Database Adapters & Schema (CRITICAL)
3. API Route Handlers (CRITICAL)
4. Session & Cookies (HIGH)
5. Auth Methods & Providers (HIGH)
6. Security & Hardening (HIGH)
7. Plugins & Extensions (MEDIUM)
8. Migration from Other Auth (MEDIUM)

How to Use

For a fresh implementation, read in priority order: start with all setup- rules, then db-, then route- — these CRITICAL categories must be correct or nothing else works. After the foundation, pick the rules that match your scope: session- for cookie/expiry tuning, auth- for provider configuration, security- for production hardening.

For a migration from another auth library, read migrate-parallel-cutover first (strategy), then security-password-hash-interop (preserve user passwords), then migrate-oauth-account-mapping and migrate-nextauth-schema-mapping (data layout).

Read individual reference files for detailed explanations, incorrect vs. correct code examples, and links to the canonical Better Auth documentation.

Reference Files

FileDescription
references/_sections.mdCategory definitions ordered by impact
assets/templates/_template.mdTemplate for adding new rules
metadata.jsonVersion, references, and discipline metadata

Comments

Markdown supported