auth-implementation-patterns

auth-implementation-patterns is a skill for Claude Code, Codex from HK-hub/AgentSkills. It costs 46 tokens per session (4,019 once invoked), scanned A, a copy of auth-implementation-patterns, MIT.

A collection of patterns for checking who users are and what they are allowed to do in an application. It covers passwords, login sessions, access tokens, social login, single sign-on, and role-based permissions.

In plain words
What is it for?
It is for securing web and mobile APIs, adding social or enterprise login, managing sessions, restricting features by role, and moving from one authentication system to another.
Why use it?
It helps avoid designing login and permission rules from scratch or mixing up identity checks with access checks. It also provides guidance for finding and fixing authentication problems.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It is for securing web and mobile APIs, adding social or enterprise login, managing sessions, restricting features by role, and moving from one authentication system to another.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hk-hub/agentskills/auth-implementation-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add HK-hub/AgentSkills --skill auth-implementation-patterns
Clone the repo
git clone --depth 1 https://github.com/HK-hub/AgentSkills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for auth-implementation-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/hk-hub/agentskills/auth-implementation-patterns/github.svg)](https://agentmods.dev/skills/hk-hub/agentskills/auth-implementation-patterns)
Your own site
<a href="https://agentmods.dev/skills/hk-hub/agentskills/auth-implementation-patterns"><img src="https://agentmods.dev/badge/skills/hk-hub/agentskills/auth-implementation-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for auth-implementation-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/hk-hub/agentskills/auth-implementation-patterns"><img src="https://agentmods.dev/badge/skills/hk-hub/agentskills/auth-implementation-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 46 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,019 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 84% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00046 $0.04019
Opus 5.5 $0.00018 $0.01608
Sonnet 5.5 $0.00009 $0.00804
Haiku 4.5 $0.00005 $0.00402

Measured 1mo ago against content hash 6a197f111b3c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

auth-implementation-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

84% identical to auth-implementation-patterns — 568 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

auth-implementation-patterns/SKILL.md · 648 lines

How it starts

The opening of the file, as written. The whole thing — 648 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Authentication & Authorization Implementation Patterns

Build secure, scalable authentication and authorization systems using industry-standard patterns and modern best practices.

When to Use This Skill

  • Implementing user authentication systems
  • Securing REST or GraphQL APIs
  • Adding OAuth2/social login
  • Implementing role-based access control (RBAC)
  • Designing session management
  • Migrating authentication systems
  • Debugging auth issues
  • Implementing SSO or multi-tenancy

Core Concepts

1. Authentication vs Authorization

Authentication (AuthN): Who are you?

  • Verifying identity (username/password, OAuth, biometrics)
  • Issuing credentials (sessions, tokens)
  • Managing login/logout

Authorization (AuthZ): What can you do?

  • Permission checking
  • Role-based access control (RBAC)
  • Resource ownership validation
  • Policy enforcement

2. Authentication Strategies

Session-Based:

  • Server stores session state
  • Session ID in cookie
  • Traditional, simple, stateful

Token-Based (JWT):

  • Stateless, self-contained
  • Scales horizontally
  • Can store claims

OAuth2/OpenID Connect:

  • Delegate authentication
  • Social login (Google, GitHub)
  • Enterprise SSO

JWT Authentication

Pattern 1: JWT Implementation

// JWT structure: header.payload.signature
import jwt from "jsonwebtoken";
import { Request, Response, NextFunction } from "express";

interface JWTPayload {
  userId: string;
  email: string;
  role: string;
  iat: number;
  exp: number;
}

// Generate JWT
function generateTokens(userId: string, email: string, role: string) {
  const accessToken = jwt.sign(
    { userId, email, role },
    process.env.JWT_SECRET!,
    { expiresIn: "15m" }, // Short-lived
  );

  const refreshToken = jwt.sign(
    { userId },
    process.env.JWT_REFRESH_SECRET!,
    { expiresIn: "7d" }, // Long-lived
  );

  return { accessToken, refreshToken };
}

// Verify JWT
function verifyToken(token: string): JWTPayload {
  try {
    return jwt.verify(token, process.env.JWT_SECRET!) as JWTPayload;
  } catch (error) {
    if (error instanceof jwt.TokenExpiredError) {
      throw new Error("Token expired");
    }
    if (error instanceof jwt.JsonWebTokenError) {
      throw new Error("Invalid token");
    }
    throw error;
  }
}

// Middleware
function authenticate(req: Request, res: Response, next: NextFunction) {
  const authHeader = req.headers.authorization;
  if (!authHeader?.startsWith("Bearer ")) {
    return res.status(401).json({ error: "No token provided" });
  }

  const token = authHeader.substring(7);
  try {
    const payload = verifyToken(token);
    req.user = payload; // Attach user to request
    next();
  } catch (error) {
    return res.status(401).json({ error: "Invalid token" });
  }
}

// Usage
app.get("/api/profile", authenticate, (req, res) => {
  res.json({ user: req.user });
});

Read the full file on GitHub · 648 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 648 lines · 46 tokens per session scan A 6a197f111b3c

Subscribe to this mod's changes

auth-implementation-patterns is a skill published in the GitHub repository HK-hub/AgentSkills (6 stars, last pushed 2mo ago), licensed MIT. It adds 46 tokens to every session and 4,019 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 84% identical to auth-implementation-patterns, differing in 568 lines, and is treated as a copy.

Related

Other skills, from other repositories

api-tester

A tool for creating and checking API tests from the real API contract and implementation. An API is the agreed way that software sends requests and receives responses.

laolaoshiren/claude-code-skills-zh · 86 tokens

nextjs-supabase-vercel

Set up the current empty folder with the AI App Starter, so the agent builds a Next.js, Supabase and Vercel app with the owner step by step, from idea to launch.

TechNomadCode/AI-Product-Development-Toolkit · 47 tokens

cmux-socket-policy

Socket command threading and focus policy for cmux CLI/socket work. Use when adding or changing socket commands, CLI commands, telemetry commands, focus/select/open/close/send-key behavior, or automation that could steal app focus.

manaflow-ai/cmux · 50 tokens

builder

Implementing robust business logic, API integrations, data models, and reproducible AI image-generation code with type safety. Use for production implementation, Gemini image API pipelines, or interactive pair programming.

simota/agent-skills · 40 tokens

build-a-stripe-integration

Write Stripe code against what the API does today — plan the product shape, confirm every parameter from Stripe's own docs and schemas, and keep the agent in a sandbox. Use when adding checkout, billing, subscriptions, invoicing, or webhooks to a codebase, or when debugging Stripe integration code that compiles but…

superset-sh/superset · 74 tokens

system-and-data-design

Decide whether the system will hold, and where the data lives: requirements and load first, then back-of-the-envelope numbers, building blocks (cache, queue, load balancer, CDN), and the data layer in depth — storage engines, indexes, replication, partitioning, transactions and consistency, batch vs stream. Use when…

AnastasiyaW/codex-claude-code-config · 217 tokens