Agent skill
auth-patterns
Better-auth integration for authentication. Use when implementing login, registration, protected routes, or email verification.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/testing/auth-patterns
SKILL.md
Auth Patterns
Quick Pattern
// Login form
export const login = form(schema, async ({ email, password }) => {
const event = getRequestEvent();
await auth.api.signInEmail({
body: { email, password },
headers: event.request.headers,
});
redirect(303, '/dashboard'); // Outside try/catch
});
// Protected query
export const get_data = guarded_query(() => {
return { message: 'Protected data' };
});
Core Principles
- Use
getRequestEvent()for headers (cookie access) - Redirect MUST be outside try/catch (throws error)
- Use
guarded_query/form/commandfor protected endpoints - Email verification required before login
- Commands cannot redirect - use client-side
goto()
Reference Files
- auth-setup.md - Complete better-auth configuration
- auth-usage.md - All auth patterns and examples
- email-verification.md - Email verification flow
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?