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.
npx skills add krivoox/agent-stack-template --skill better-auth-security-best-practicesgit clone --depth 1 https://github.com/krivoox/agent-stack-templateWrote 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.
[](https://agentmods.dev/skills/krivoox/agent-stack-template/better-auth-security-best-practices)<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>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.
| Model | Per session | Once 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 |
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.
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.
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:
options.secretin your configBETTER_AUTH_SECRETenvironment variableAUTH_SECRETenvironment 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.
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.
- 8d ago First seen · 433 lines · 70 tokens per session scan A 042f01c76b63
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.
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…
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"…
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.
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.
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…
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.