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, original, 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

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.

agentmods
npx agentmods add skills/hk-hub/agentskills/auth-implementation-patterns
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.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.svg" alt="Measured on agentmods" 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. Scan, not verified.
Origin original No closer match found 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 $0.00046 $0.04019
Opus 5 $0.00023 $0.02010
Sonnet 5 $0.00009 $0.00804
Haiku 4.5 $0.00005 $0.00402

Measured 3d ago against content hash 6a197f111b3c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 3d 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.

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. 3d 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 16d ago), licensed MIT. It adds 46 tokens to every session and 4,019 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

minimax-h3-reference-video-prompt

Default downstream MiniMax H3 specialist for every image-based request unless the user explicitly declares boundary-only first/last frames with no reusable reference role. Use the official six-section full-reference format for character/person/object consistency, scene/style/action/camera/storyboard/voice/audio…

unknowlei/minimax-h3-opencode-skills · 89 tokens

minimax-h3-keyframe-video-prompt

Narrow downstream MiniMax H3 specialist for pure I2VA, FL2VA, and L2VA boundary-frame prompts. Use only after minimax-h3-creative-director verifies that the user explicitly declared the images as literal first/last frames and that they have no character, identity, person, object, costume, scene, style, voice, action…

unknowlei/minimax-h3-opencode-skills · 108 tokens

minimax-h3-multishot-planner

Non-skippable planning-only MiniMax H3 subskill used by minimax-h3-creative-director before final prompt formatting. Invoke when the user explicitly requests multiple shots, scenes, cuts, montage, or shot-by-shot design, or when a video of at least 10 seconds has no declared single-shot/multishot preference and the…

unknowlei/minimax-h3-opencode-skills · 120 tokens

minimax-h3-text-video-prompt

Downstream MiniMax H3 specialist for professional text-to-video (T2VA) prompts using the official three-field format. Use after minimax-h3-creative-director routes a request with no image, video, or audio reference asset, or when this skill is explicitly invoked for a text-only idea, script, or storyboard requiring an…

unknowlei/minimax-h3-opencode-skills · 83 tokens

minimax-h3-creative-director

Primary mandatory entrypoint for every MiniMax H3 video-generation request. Use before any other H3 skill for creation, animation, extension, editing, restyling, reference, or prompt review. It reads the official h3-prompt-writing specification, defaults image-based work to full-reference consistency, permits pure…

unknowlei/minimax-h3-opencode-skills · 116 tokens

minimax-h3-prompt-reviewer

Downstream MiniMax H3 specialist that audits, repairs, and rewrites T2VA, I2VA, FL2VA, L2VA, and full-reference prompts into an official structured format. Use after minimax-h3-creative-director routes an existing prompt for diagnosis or repair, or when explicitly invoked for formatting, timeline, camera, dialogue…

unknowlei/minimax-h3-opencode-skills · 101 tokens