---
name: "lucia-auth-sessions-framework"
description: "Implement complete session-based authentication in Next.js/SvelteKit/Astro using Lucia Auth."
metadata:
  author: "Lucia"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup lucia auth sessions"
  - "validate session cookie lucia"
  - "create session lucia"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Lucia Auth Lightweight Database Session Management

Configures Lucia Auth: setting up database adapters (Prisma, Drizzle, SQLite), creating sessions, managing HttpOnly session cookies, session validation in middleware, and handling user sign-out safely.

## When to Invoke
Invoke this skill whenever you need to:
- setup lucia auth sessions
- validate session cookie lucia
- create session lucia

## Execution SOP & Rules
1. Initialize: const lucia = new Lucia(adapter, { sessionCookie: { attributes: { secure: !dev } } }).
2. Create session upon login: const session = await lucia.createSession(userId, {});
3. Set cookie in response: cookies().set(lucia.createSessionCookie(session.id));
4. Validate in middleware: const { session, user } = await lucia.validateSession(sessionId).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
