better-auth-security-best-practices

better-auth-security-best-practices is a skill for Claude Code, Codex from krivoox/agent-stack-template. It costs 70 tokens per session (2,628 once invoked), scanned A, a copy of better-auth-security-best-practices, MIT.

Security guidance for Better Auth, a library for adding sign-in and user authentication to applications.

In plain words
What is it for?
Configuring rate limits, secrets, CSRF protection, trusted origins, secure cookies and sessions, OAuth token encryption, IP tracking, and audit logs.
Why use it?
It helps prevent common authentication problems, such as weak secrets, brute-force login attempts, unsafe sessions, and missing request protections.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents).

Good fit Configuring rate limits, secrets, CSRF protection, trusted origins, secure cookies and sessions, OAuth token encryption, IP tracking, and audit logs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/krivoox/agent-stack-template/better-auth-security-best-practices
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.

Any agent
npx skills add krivoox/agent-stack-template --skill better-auth-security-best-practices
Clone the repo
git clone --depth 1 https://github.com/krivoox/agent-stack-template

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-security-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/krivoox/agent-stack-template/better-auth-security-best-practices.svg)](https://agentmods.dev/skills/krivoox/agent-stack-template/better-auth-security-best-practices)
Your own site
<a href="https://agentmods.dev/skills/krivoox/agent-stack-template/better-auth-security-best-practices"><img src="https://agentmods.dev/badge/skills/krivoox/agent-stack-template/better-auth-security-best-practices.svg" alt="Measured on agentmods" height="20"></a>
Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,628 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod 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.1 $0.00070 $0.02628
Opus 5 $0.00035 $0.01314
Sonnet 5 $0.00014 $0.00526
Haiku 4.5 $0.00007 $0.00263

Measured 8d ago against content hash 042f01c76b63, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

better-auth-security-best-practices scanned grade A with 0 findings 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 8d ago.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to better-auth-security-best-practices — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/better-auth-security-best-practices/SKILL.md · 433 lines

How it starts

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

Secret Management

Configuring the Secret

import { betterAuth } from "better-auth";

export const auth = betterAuth({
  secret: process.env.BETTER_AUTH_SECRET, // or via `BETTER_AUTH_SECRET` env
});

Better Auth looks for secrets in this order:

  1. options.secret in your config
  2. BETTER_AUTH_SECRET environment variable
  3. AUTH_SECRET environment variable

Secret Requirements

  • Rejects default/placeholder secrets in production
  • Warns if shorter than 32 characters or entropy below 120 bits
  • Generate: openssl rand -base64 32
  • Never commit secrets to version control

Rate Limiting

Enabled in production by default. Applies to all endpoints. Plugins can override per-endpoint.

Default Configuration

import { betterAuth } from "better-auth";

export const auth = betterAuth({
  rateLimit: {
    enabled: true, // Default: true in production
    window: 10, // Time window in seconds (default: 10)
    max: 100, // Max requests per window (default: 100)
  },
});

Storage Options

Options: "memory" (resets on restart, avoid on serverless), "database" (persistent), "secondary-storage" (Redis, default when available).

rateLimit: {
  storage: "database",
}

Custom Storage

Implement your own rate limit storage:

rateLimit: {
  customStorage: {
    get: async (key) => {
      // Return { count: number, expiresAt: number } or null
    },
    set: async (key, data) => {
      // Store the rate limit data
    },
  },
}

Per-Endpoint Rules

Sensitive endpoints default to 3 requests per 10 seconds (/sign-in, /sign-up, /change-password, /change-email). Override:

rateLimit: {
  customRules: {
    "/api/auth/sign-in/email": {
      window: 60, // 1 minute window
      max: 5, // 5 attempts
    },
    "/api/auth/some-safe-endpoint": false, // Disable rate limiting
  },
}

CSRF Protection

Multi-layer protection: origin header validation, Fetch Metadata checks, and first-login protection.

Read the full file on GitHub · 433 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. 8d ago First seen · 433 lines · 70 tokens per session scan A 042f01c76b63

Subscribe to this mod's changes

better-auth-security-best-practices is a skill published in the GitHub repository krivoox/agent-stack-template (31 stars, last pushed 18d ago), licensed MIT. It adds 70 tokens to every session and 2,628 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to better-auth-security-best-practices, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

mtg-commander-analysis

Expert Magic: The Gathering Commander (EDH) deck analysis, optimization, and building assistant. Use this skill whenever the user asks about Commander decks, EDH optimization, power level assessment, bracket placement, mana base construction, card cuts/additions, deck building, commander selection, synergy analysis…

KaelSensei/MagicAIBuilder · 208 tokens

typescript-craftsmanship

Professional TypeScript + React + Next.js coding standards enforcer. Use this skill whenever writing, reviewing, or refactoring TypeScript code in any project — whether it's a new feature, a bug fix, a refactoring pass, or a code review. Trigger on: any TypeScript or TSX file creation/editing, "clean up this code"…

KaelSensei/MagicAIBuilder · 218 tokens

clean-architecture

Clean / Hexagonal Architecture adapted to this Next.js 15 App Router + Prisma + React 19 project. Use when designing a new feature, adding a module, debating where code should live, reviewing a PR that crosses layers, or when the domain logic starts leaking into UI / routes.

KaelSensei/MagicAIBuilder · 62 tokens

clean-code

Clean Code principles applied to this TypeScript / Next.js / React project, with a strong emphasis on eliminating duplication (DRY). Use before writing new code, during refactors, after Sonar flags duplicatedlines, or when reviewing a PR that adds similar-looking code to existing modules.

KaelSensei/MagicAIBuilder · 60 tokens

mtg-rules

Magic: The Gathering comprehensive rules reference and rules engine. Use this skill whenever the user asks about MTG rules, card interactions, game mechanics, timing, priority, layers, state-based actions, combat, stack resolution, or any rules question about Magic: The Gathering. Also trigger on: 'how does X work in…

KaelSensei/MagicAIBuilder · 162 tokens

web-performance

PageSpeed and Core Web Vitals checklist for web projects. Use when building UI, shipping a page, reviewing front-end code, or running /audit-code or /beautify on a web target.

KaelSensei/MagicAIBuilder · 43 tokens