Skip to main content
skill CX Codex

auth-module-builder — Claude Code skill: login, JWT, sessions

auth-module-builder lays out a full authentication module: login and registration routes, JWT signing, bcrypt hashing, Redis sessions and a threat model. Useful when the login flow starts from an empty file.

MIT 263 installs ★ 64 updated 2026-01-12

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add patricio0312rev/skills --skill auth-module-builder -a claude-code
Open on GitHub

What auth-module-builder does

The skill maps the pieces of an auth module: routes for POST /login, /register, /logout, /refresh and /forgot-password, plus authenticate, requireAuth and optionalAuth middleware. Token verification pulls the value from the Authorization header and then loads the user by the id stored in the payload. Code samples are TypeScript, with a 15-minute access token and a 7-day refresh token.

Sessions have their own pattern: express-session on a Redis store, httpOnly cookies, sameSite: lax, and the secure flag turned on in production. A checklist and a threat model sit alongside — brute force, token theft, CSRF, session fixation, XSS, each paired with a mitigation.

Three secrets come from the environment: JWT_SECRET, JWT_REFRESH_SECRET, SESSION_SECRET. Set them before asking an agent to wire anything up, since the signing and session code reads only from there. The checklist puts the bcrypt cost floor at 10, and the sample sits exactly on that number — a lower value fails the check.

What it helps with

  • scaffold login and registration with hashed passwords
  • issue access and refresh tokens with separate lifetimes
  • keep sessions in Redis behind httpOnly cookies
  • block brute force and CSRF on the auth routes
  • hand reviewers a threat model for the login flow

Example prompts for the agent

  • Build the auth module: login, registration, logout and token refresh routes
  • Add requireAuth middleware that checks the JWT from the Authorization header
  • Set up Redis-backed sessions with httpOnly cookies and CSRF protection

How to install auth-module-builder

1Skills CLI (Vercel)

npx skills add patricio0312rev/skills --skill auth-module-builder -a claude-code

2Manually: put the files in place

~/.claude/skills/auth-module-builder/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/auth-module-builder/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about auth-module-builder

How do I install auth-module-builder in Claude Code?

Run npx skills add patricio0312rev/skills --skill auth-module-builder -a claude-code. The skill lands in ~/.claude/skills/auth-module-builder/SKILL.md.

What does auth-module-builder do?

It describes login, registration and password-reset routes, JWT middleware, bcrypt hashing, cookie settings and CSRF handling. It also ships a security checklist and a write-up of common attacks with mitigations.

Which environment variables does it need?

JWT_SECRET and JWT_REFRESH_SECRET for signing tokens, SESSION_SECRET for sessions. All three are read from the environment rather than hardcoded.

Source text

SKILL.md · MIT
---
name: auth-module-builder
description: Implements secure authentication patterns including login/registration, session management, JWT tokens, password hashing, cookie settings, and CSRF protection. Provides auth routes, middleware, security configurations, and threat model documentation. Use when building "authentication", "login system", "JWT auth", or "session management".
---

# Auth Module Builder

Implement secure, production-ready authentication systems.

## Core Components

**Routes**: POST /login, /register, /logout, /refresh, /forgot-password
**Middleware**: authenticate, requireAuth, optionalAuth
**Security**: bcrypt hashing, JWT signing, secure cookies, CSRF tokens
**Session**: Redis/DB storage, expiration, refresh tokens
**Threats**: Document common attacks and mitigations

## JWT Pattern

```typescript
// Generate tokens
const accessToken = jwt.sign(
  { userId: user.id, email: user.email },
  process.env.JWT_SECRET,
  { expiresIn: "15m" }
);

const refreshToken = jwt.sign(
  { userId: user.id, type: "refresh" },
  process.env.JWT_REFRESH_SECRET,
  { expiresIn: "7d" }
);

// Verify middleware
export const authenticate = async (req, res, next) => {
  const token = req.headers.authorization?.split(" ")[1];
  if (!token) return res.status(401).json({ error: "No token" });

  try {
    const decoded = jwt.verify(token, process.env.JWT_SECRET);
    req.user = await User.findById(decoded.userId);
    next();
  } catch (err) {
    res.status(401).json({ error: "Invalid token" });
  }
};
```

## Session Pattern

```typescript
// Express session with Redis
app.use(
  session({
    store: new RedisStore({ client: redisClient }),
    secret: process.env.SESSION_SECRET,
    resave: false,
    saveUninitialized: false,
    cookie: {
      secure: process.env.NODE_ENV === "production",
      httpOnly: true,
      maxAge: 1000 * 60 * 60 * 24 * 7, // 7 days
      sameSite: "lax",
    },
  })
);
```

## Password Security

```typescript
import bcrypt from "bcrypt";

// Hash password
const hashedPassword = await bcrypt.hash(password, 10);

// Verify password
const isValid = await bcrypt.compare(password, user.hashedPassword);
```

## Security Checklist

- [ ] Passwords hashed with bcrypt (cost ≥10)
- [ ] JWT secrets from environment, rotated regularly
- [ ] HTTPS only in production
- [ ] httpOnly, secure cookies
- [ ] CSRF protection enabled
- [ ] Rate limiting on auth routes
- [ ] Account lockout after failed attempts
- [ ] Password reset tokens expire
- [ ] Email verification for new accounts

## Threat Model

**Brute Force**: Rate limit + account lockout
**Token Theft**: Short expiry, httpOnly cookies, HTTPS only
**CSRF**: SameSite cookies + CSRF tokens
**Session Fixation**: Regenerate session ID on login
**XSS**: Sanitize inputs, CSP headers

© patricio0312rev · MIT · patricio0312rev/skills

Similar skills

All skills for Backend and APIs →

From the same set148

The whole set →
state-ux-flow-builder The state-ux-flow-builder skill structures loading, error, empty, and success states for data-driven screens. Use it when a UI flow has several views or state transitions. CX Codex +1 264installs zustand-state-builder zustand-state-builder — a skill for managing app state with Zustand: minimal API, full TypeScript support, persistence, and devtools. Runs on Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode. CX Codex +1 264installs monorepo-ci-optimizer monorepo-ci-optimizer — a CI skill for monorepos: it works out which packages a change touches and runs builds and tests only for those. Useful when every PR runs the whole workspace. CX Codex +1 264installs coverage-strategist The coverage-strategist skill helps set test priorities and coverage goals across a project. Use it when deciding which paths need tests and which code can be left out. CX Codex +1 263installs kubernetes-manifest-generator kubernetes-manifest-generator produces production-grade Kubernetes YAML manifests with hardening, autoscaling, and networking defaults. Useful when preparing workloads for cluster deployment. CX Codex +1 262installs caching-cdn-strategy-planner caching-cdn-strategy-planner is a Claude Code skill for planning CDN and server-side caching, response headers, and invalidation. Use it in API design. CX Codex +1 262installs dependency-doctor dependency-doctor scans your manifests, flags outdated and duplicated packages, known CVEs and risky version pairs, then hands back a report with a step-by-step upgrade plan. CX Codex +1 261installs db-performance-watchlist db-performance-watchlist is a Claude Code skill that tracks PostgreSQL metrics, including slow queries, connection pools, and unused indexes through Prisma. CX Codex +1 260installs

Project sponsors

Companies that keep this analytics open