better-auth/better-auth-security-best-practices

Mejores prácticas de seguridad para better-auth — una skill instalable para agentes de IA.

¿Qué es better-auth-security-best-practices?

Esta skill proporciona un conjunto de mejores prácticas de seguridad para implementar y mantener la autenticación con better-auth en aplicaciones web. Incluye pautas sobre almacenamiento seguro de tokens, manejo de sesiones, protección contra ataques comunes (como XSS y CSRF), y configuración segura de proveedores OAuth. Está diseñada para desarrolladores que utilizan AI agents como Claude Code, Cursor y Codex, permitiendo que el agente aplique automáticamente configuraciones de seguridad robustas al generar o revisar código. La skill se basa en la documentación oficial de better-auth y ofrece recomendaciones específicas sobre cifrado, expiración de tokens, validación de entradas y uso de cabeceras HTTP de seguridad.

Compatible con~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/better-auth/skills/tree/main/skills/better-auth-security-best-practices

Installed? Explore more Productividad y colaboración skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

¿Qué hace better-auth-security-best-practices?

better-auth-security-best-practices — una skill instalable para agentes de IA.

Esta skill ayuda a los agentes de IA a aplicar las mejores prácticas de seguridad al trabajar con better-auth. Incluye pautas para:

  • Almacenamiento seguro de tokens (JWT, sesiones)
  • Protección contra ataques XSS, CSRF y otros
  • Configuración segura de OAuth y proveedores sociales
  • Manejo correcto de sesiones y expiración
  • Uso de variables de entorno para secretos
  • Validación y sanitización de entradas

Plataformas compatibles: Claude Code, Cursor, Codex y otros agentes de IA que soporten skills instalables.

Uso básico

Para instalar esta skill, usa el comando correspondiente según tu agente:

# Claude Code
claude install better-auth/better-auth-security-best-practices

# Cursor
cursor install better-auth/better-auth-security-best-practices

# Codex
codex install better-auth/better-auth-security-best-practices

Contenido

La skill proporciona:

  1. Lista de verificación de seguridad - Una guía paso a paso para asegurar tu implementación de better-auth.
  2. Ejemplos de configuración - Fragmentos de código con configuraciones seguras.
  3. Buenas prácticas - Explicaciones detalladas de cada recomendación.

Ejemplos de código

Configuración segura de JWT:

import { createAuth } from 'better-auth'

const auth = createAuth({
  secret: process.env.BETTER_AUTH_SECRET,
  jwt: {
    issuer: 'tu-app',
    audience: 'tu-app',
    expiresIn: '15m',
    algorithm: 'RS256' // Usa RSA en lugar de HS256 para mayor seguridad
  }
})

Protección CSRF:

// Configuración recomendada para CSRF
const auth = createAuth({
  csrf: {
    enabled: true,
    allowedOrigins: [process.env.ALLOWED_ORIGIN]
  }
})

Más información

Para más detalles, consulta la documentación oficial de better-auth y el repositorio de la skill.

Individual skills in this repo

This repo contains 5 individual skills — each has its own dedicated page.

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.

better-auth/create-auth-skill

Scaffold and implement authentication in TypeScript/JavaScript apps using Better Auth. Detect frameworks, configure database adapters, set up route handlers, add OAuth providers, and create auth UI pages. Use when users want to add login, sign-up, or authentication to a new or existing project with Better Auth.

better-auth/email-and-password-best-practices

Configure email verification, implement password reset flows, set password policies, and customise hashing algorithms for Better Auth email/password authentication. Use when users need to set up login, sign-in, sign-up, credential authentication, or password security with Better Auth.

better-auth/organization-best-practices

Configure multi-tenant organizations, manage members and invitations, define custom roles and permissions, set up teams, and implement RBAC using Better Auth's organization plugin. Use when users need org setup, team management, member roles, access control, or the Better Auth organization plugin.

better-auth/two-factor-authentication-best-practices

Configure TOTP authenticator apps, send OTP codes via email/SMS, manage backup codes, handle trusted devices, and implement 2FA sign-in flows using Better Auth's twoFactor plugin. Use when users need MFA, multi-factor authentication, authenticator setup, or login security with Better Auth.

Skills relacionados