agentleFS
NikoxkxNikoxkx/Agent-Skills/skills/web-development/auth-flow-builder/SKILL.md

auth-flow-builder

Skill1 starsChanged 5 months agoApache-2.0View on GitHub

Implements authentication flows including login, registration, password reset, and session management. Use when adding auth to a web app using JWT, sessions, or OAuth.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always httpOnly + SameSite=Strict/Lax + Secure cookies.

    line 39
  2. Distinctive:

    Never store tokens in localStorage or sessionStorage.

    line 40
  3. Distinctive:

    CSRF protection: Use SameSite + double-submit cookie or framework built-in.

    line 49

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Overview

Implements secure authentication flows (login, register, forgot password, reset, logout, session refresh) using modern best practices: httpOnly cookies for tokens (never localStorage), PKCE for OAuth, CSRF protection, refresh token rotation, and clear guidance on JWT vs session vs OAuth tradeoffs. Provides complete flows for NextAuth.js / Auth.js, custom JWT, and session-based approaches.

When to Use This Skill

  • Adding authentication to a new or existing web application.
  • User requests "login page", "sign up", "protected route", "OAuth", or "session management".
  • You need to choose between JWT, sessions, or OAuth and implement it securely.

Prerequisites

  • Backend framework (Next.js, Express, etc.).
  • Database or user store (Prisma, Drizzle, or auth provider).
  • For OAuth: provider credentials (Google, GitHub, etc.).
  • HTTPS in production (mandatory for cookies and OAuth).

Steps

  1. Choose auth strategy:
    • Sessions + httpOnly cookie: Simplest, good for traditional apps.
    • JWT in httpOnly cookie + refresh rotation: Stateless, good for APIs and microservices.
    • OAuth 2.1 + PKCE: For third-party login (recommended when possible).
    • Compare pros/cons in the output.
  2. Secure token storage:
    • Always httpOnly + SameSite=Strict/Lax + Secure cookies.
    • Never store tokens in localStorage or sessionStorage.
  3. Implement flows:
    • Login: validate credentials → issue tokens/cookie → redirect.
    • Register: validate, hash password (bcrypt/argon2), create user.
    • Password reset: time-limited token via email, one-time use.
    • Refresh: short-lived access token + rotating refresh token.
    • Logout: clear cookies, invalidate refresh token on server.
  4. CSRF protection: Use SameSite + double-submit cookie or framework built-in.
  5. Protected routes / middleware:
    • Next.js middleware example that checks for valid session/JWT.
    • Redirect unauthenticated users to /login with return URL.
  6. NextAuth.js / Auth.js integration (recommended for most Next.js apps):
    • Full config with credentials provider + Google/GitHub.
    • Custom pages.
    • Session callback to enrich user object.
  7. Output:
    • Complete auth service functions.
    • Route handlers or API routes for each flow.
    • Middleware.
    • Frontend login/register forms (or point to form-validator skill).
    • Environment variable list.
    • Security checklist.

Examples

Full NextAuth config, custom JWT login/register handlers with httpOnly cookies, password reset flow with email token, and protected route middleware are included.

Edge Cases & Error Handling

  • Invalid/expired refresh token: Force re-login, clear all cookies.
  • Brute force: Rate limit login attempts per email/IP.
  • Email verification: Optional but recommended step after registration.
  • Account linking: For OAuth + credentials.
  • Session fixation: Regenerate session on login.

Verification

  1. Register a new user.
  2. Login — verify httpOnly cookie is set (inspect in DevTools → Application → Cookies).
  3. Access a protected page while logged out — redirected to login.
  4. Refresh the page while logged in — session persists.
  5. Logout — cookie cleared.
  6. Attempt password reset end-to-end.
  7. Success: All flows work, no tokens in localStorage, cookies are httpOnly and secure-flagged in production.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.