auth-handler
Manage authentication, authorization, and user sessions. Use when dealing with login, sign-up, API protection, middleware, or user data fetching.
model: inherit
$ Installieren
git clone https://github.com/majiayu000/claude-skill-registry /tmp/claude-skill-registry && cp -r /tmp/claude-skill-registry/skills/data/auth-handler ~/.claude/skills/claude-skill-registry// tip: Run this command in your terminal to install the skill
SKILL.md
name: auth-handler description: Manage authentication, authorization, and user sessions. Use when dealing with login, sign-up, API protection, middleware, or user data fetching. tools: Read, Write, Edit model: inherit
Auth Handler
Instructions
1. API Route Protection
- Standard Routes: Use
withAuthRequired.export default withAuthRequired(async (req, { session, getUser }) => { ... }) - Super Admin Routes: Use
withSuperAdminAuthRequired. - Cron Jobs: Use
cronAuthRequired. - Defense in Depth: Do NOT rely solely on middleware. Always implement individual route protection.
2. Frontend Data Access
- Client Components: Use
useUser()hook (SWR). - Restriction: NEVER use
useSessionfromnext-auth/react.
3. Server-Side Data Access
- Check Auth: Import
authfrom@/auth. - Get Plan: Use
getUserPlan(session.user.id).session.useris minimal.
Reference
For architecture details, key files, and debugging tips, see reference.md.
Repository

majiayu000
Author
majiayu000/claude-skill-registry/skills/data/auth-handler
0
Stars
0
Forks
Updated1d ago
Added1w ago