betterauth
Better Auth Integration Skill
This skill provides the source of truth for integrating Better Auth into a polyglot stack (Go backend + React frontend). It ensures secure session management, type-safe API calls, and seamless TanStack Query integration.
Architectural Standards
1. Unified Auth Schema & Plugins
- Database: Use the Better Auth standard schema. Standardize table names to
user,session,account,verification. - Plugins: Enable and configure:
organization: For multi-tenant isolation.sso: For SAML/OIDC enterprise login.two-factor: For TOTP/Email/SMS MFA.admin: For user impersonation and management.
2. Go Backend Integration (The Bridge)
- Middleware: Implement a robust middleware that:
- Extracts the
better-auth.session_tokencookie. - Validates it against the
sessiontable. - Handles Token Refresh by checking the
expiresAtand performing a silent refresh via the Better Auth API if needed.
- Extracts the
- Context: Store the full
UserandOrganizationobjects in the request context for downstream RBAC.
More from inselfcontroll/ai-agent-skills
rust_dioxus_framework
Acts as a Rust Dioxus Framework Specialist for building cross-platform UIs. Use when building desktop, web, or mobile apps using the Dioxus framework.
15clerk
Expert for Clerk authentication integration. Use when setting up Clerk in React, implementing Clerk Go middleware for session validation, or managing Clerk user profiles.
2testing_qa
Acts as a Testing and QA Agent. Use when writing unit, integration, or E2E tests, or when auditing code for test coverage.
2code-review
Expert for codebase-wide code reviews. Use when auditing Pull Requests, refactoring complex logic, or enforcing architectural and security standards across the ecosystem.
2principal_architect
Acts as a Principal Software Architect to design blueprints and enforce architectural rules. Use when designing system architecture, defining API contracts, or planning data flows.
2requirements_analyst
Acts as a Requirements Analyst to translate requests into specifications. Use when gathering user requirements, defining user stories, or creating technical specifications.
2