Better Auth Patterns

Better Auth Patterns is a skill for Claude Code, Codex from smicolon/ai-kit. It costs 34 tokens per session (2,935 once invoked), scanned A, original, MIT.

A set of Better Auth patterns for adding authentication to React applications, including providers, forms, and sessions.

In plain words
What is it for?
Use it when setting up sign-in, configuring authentication providers, building auth forms, or managing logged-in user sessions.
Why use it?
It helps keep common authentication work consistent and reduces the need to decide how each part should be implemented.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/smicolon/ai-kit/better-auth-patterns
Any agent
npx skills add smicolon/ai-kit --skill better-auth-patterns
Clone the repo
git clone --depth 1 https://github.com/smicolon/ai-kit

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for Better Auth Patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/smicolon/ai-kit/better-auth-patterns.svg)](https://agentmods.dev/skills/smicolon/ai-kit/better-auth-patterns)
Your own site
<a href="https://agentmods.dev/skills/smicolon/ai-kit/better-auth-patterns"><img src="https://agentmods.dev/badge/skills/smicolon/ai-kit/better-auth-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 34 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,935 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin unknown No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00034 $0.02935
Opus 5 $0.00017 $0.01468
Sonnet 5 $0.00007 $0.00587
Haiku 4.5 $0.00003 $0.00294

Measured today against content hash 09dffc36079d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

Better Auth Patterns scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

return fetch(url, {
packs/better-auth/skills/better-auth-patterns/SKILL.md · 526 lines

How it starts

The opening of the file, as written. The whole thing — 526 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Better Auth Patterns

This skill enforces Better Auth best practices for authentication in React applications.

Server Configuration

Basic Setup

// lib/auth.ts
import { betterAuth } from 'better-auth'
import { prismaAdapter } from 'better-auth/adapters/prisma'
import { prisma } from './prisma'

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: 'postgresql',
  }),

  emailAndPassword: {
    enabled: true,
    requireEmailVerification: true,
  },

  session: {
    expiresIn: 60 * 60 * 24 * 7, // 7 days
    updateAge: 60 * 60 * 24,     // Extend daily
  },
})

export type Auth = typeof auth

Social Providers

import { betterAuth } from 'better-auth'

export const auth = betterAuth({
  // ... database config

  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID!,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
      scopes: ['email', 'profile'],
    },
    github: {
      clientId: process.env.GITHUB_CLIENT_ID!,
      clientSecret: process.env.GITHUB_CLIENT_SECRET!,
      scopes: ['user:email'],
    },
    discord: {
      clientId: process.env.DISCORD_CLIENT_ID!,
      clientSecret: process.env.DISCORD_CLIENT_SECRET!,
    },
  },
})

Two-Factor Authentication

import { twoFactor } from 'better-auth/plugins/two-factor'

export const auth = betterAuth({
  // ... base config

  plugins: [
    twoFactor({
      issuer: 'MyApp',
      totpWindow: 1,
      backupCodes: {
        enabled: true,
        count: 10,
      },
    }),
  ],
})

Passkeys (WebAuthn)

import { passkey } from 'better-auth/plugins/passkey'

export const auth = betterAuth({
  // ... base config

  plugins: [
    passkey({
      rpId: 'myapp.com',
      rpName: 'My App',
      origin: 'https://myapp.com',
      attestation: 'none',
      authenticatorSelection: {
        authenticatorAttachment: 'platform',
        userVerification: 'preferred',
        residentKey: 'preferred',
      },
    }),
  ],
})

Read the full file on GitHub · 526 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed · +70 lines 09dffc36079d
  2. 4d ago First seen · 456 lines · 34 tokens per session scan A fde91229df4b

Subscribe to this mod's changes

Better Auth Patterns is a skill published in the GitHub repository smicolon/ai-kit (6 stars, last pushed today), licensed MIT. It adds 34 tokens to every session and 2,935 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.