claude-workspace: Skill for Claude Code

.claude/skills/auth-patterns/SKILL.md

auth-patterns is a skill for Claude Code from Piyush8296/claude-workspace. It costs 53 tokens per session (1,542 once invoked), scanned A, original, MIT.

A guide to handling user login, permissions, and sessions in React and Next.js applications. It covers Auth.js, custom JSON Web Tokens, cookies, OAuth sign-in, protected routes, token refresh, and role-based interface elements.

In plain words
What is it for?
Use it to add login and logout flows, connect OAuth providers, protect pages with middleware, manage sessions and token refresh, and show interface options based on user roles.
Why use it?
It helps keep authentication logic in one place and prevents common mistakes such as exposing login tokens in browser storage or leaving private routes unprotected.

Skill for Claude Code

Written for Claude Code: installed under .claude/.

This is Piyush8296/claude-workspace's own configuration. It tells Claude Code how to work on claude-workspace itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-workspace configures →

Reuse

Borrowing it

Nothing to install: this file belongs to Piyush8296/claude-workspace. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/Piyush8296/claude-workspace/main/.claude/skills/auth-patterns/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/Piyush8296/claude-workspace

Made for: Claude Code.

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-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/piyush8296/claude-workspace/auth-patterns.svg)](https://agentmods.dev/skills/piyush8296/claude-workspace/auth-patterns)
Your own site
<a href="https://agentmods.dev/skills/piyush8296/claude-workspace/auth-patterns"><img src="https://agentmods.dev/badge/skills/piyush8296/claude-workspace/auth-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 53 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,542 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 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.1 $0.00053 $0.01542
Opus 5 $0.00026 $0.00771
Sonnet 5 $0.00011 $0.00308
Haiku 4.5 $0.00005 $0.00154

Measured 6d ago against content hash 73ae4b1df99c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

auth-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 6d 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.

.claude/skills/auth-patterns/SKILL.md · 228 lines

How it starts

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

Auth Patterns

Architecture Decision

Approach Best For Session Storage
NextAuth / Auth.js Next.js apps, OAuth providers Server-side (JWT or database)
Custom JWT React SPAs, custom backends httpOnly cookie (server-set)
Session cookie Traditional server-rendered httpOnly cookie

Rule: Never store auth tokens in localStorage or sessionStorage. Always use httpOnly cookies.

Next.js Middleware Protection

// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { getToken } from 'next-auth/jwt';

const PUBLIC_ROUTES = ['/', '/login', '/register', '/forgot-password'];
const AUTH_ROUTES = ['/login', '/register'];  // Redirect away if already logged in

export async function middleware(req: NextRequest) {
  const token = await getToken({ req });
  const { pathname } = req.nextUrl;

  // Already authenticated → redirect away from auth pages
  if (token && AUTH_ROUTES.some((r) => pathname.startsWith(r))) {
    return NextResponse.redirect(new URL('/dashboard', req.url));
  }

  // Not authenticated → redirect to login (except public routes)
  if (!token && !PUBLIC_ROUTES.some((r) => pathname === r || pathname.startsWith('/api/auth'))) {
    const loginUrl = new URL('/login', req.url);
    loginUrl.searchParams.set('callbackUrl', pathname);
    return NextResponse.redirect(loginUrl);
  }

  return NextResponse.next();
}

export const config = {
  matcher: ['/((?!_next/static|_next/image|favicon.ico|public/).*)'],
};

NextAuth Setup

// lib/auth.ts
import NextAuth from 'next-auth';
import Google from 'next-auth/providers/google';
import Credentials from 'next-auth/providers/credentials';
import { env } from '@/lib/env';

export const { handlers, auth, signIn, signOut } = NextAuth({
  providers: [
    Google({
      clientId: env.GOOGLE_CLIENT_ID,
      clientSecret: env.GOOGLE_CLIENT_SECRET,
    }),
    Credentials({
      credentials: {
        email: { label: 'Email', type: 'email' },
        password: { label: 'Password', type: 'password' },
      },
      authorize: async (credentials) => {
        const user = await verifyCredentials(credentials);
        if (!user) return null;
        return { id: user.id, email: user.email, name: user.name, role: user.role };
      },
    }),
  ],
  callbacks: {
    jwt({ token, user }) {
      if (user) {
        token.id = user.id;
        token.role = user.role;
      }
      return token;
    },
    session({ session, token }) {
      session.user.id = token.id as string;
      session.user.role = token.role as string;
      return session;
    },
  },
  pages: {
    signIn: '/login',
    error: '/login',
  },
});

Read the full file on GitHub · 228 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. 6d ago First seen · 228 lines · 53 tokens per session scan A 73ae4b1df99c

Subscribe to this mod's changes

auth-patterns is a skill published in the GitHub repository Piyush8296/claude-workspace (2 stars, last pushed 4mo ago), licensed MIT. It adds 53 tokens to every session and 1,542 once invoked, about $0.0003 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

pagination

Generates pagination infrastructure with offset or cursor-based patterns, infinite scroll, and search support. Use when user wants to add paginated lists, infinite scrolling, or load-more functionality.

rshankras/claude-code-apple-skills · 38 tokens

unfold-admin

Django Unfold admin theme - build, configure, and enhance modern Django admin interfaces with Unfold. Use when working with: (1) Django admin UI customisation or theming, (2) Unfold ModelAdmin, inlines, actions, filters, widgets, or decorators, (3) Admin dashboard components and KPI cards, (4) Sidebar navigation…

0xDarkMatter/claude-mods · 146 tokens

senior-dev

Activates the SeniorDev agent for full-stack software engineering. Use this skill when you need production-ready code: Next.js 14 frontends, FastAPI backends, TypeScript strict-mode components, PostgreSQL schemas, Redis caching, authentication flows, or complete REST/GraphQL APIs. SeniorDev always outputs complete…

vignesh2027/Claude-Agentic-Skills2.0-version · 86 tokens

fullstack-developer

Modern web development expertise covering React, Node.js, databases, and full-stack architecture. Use when: building web applications, developing APIs, creating frontends, setting up databases, deploying web apps, or when user mentions React, Next.js, Express, REST API, GraphQL, MongoDB, PostgreSQL, or full-stack…

medy-gribkov/arcana · 0 tokens

web-push-notifications

VAPID-signed Web Push (RFC 8030, 8291, 8292) — subscribe lifecycle, endpoint hashing, payload size cap, pushsubscriptionchange routing, and how to wire alarms / notifications across browser + service worker.

Nmor/the-claude-council · 56 tokens

remix

Build and review Remix 3 applications using the remix npm package and subpath imports. Use when working on Remix app structure, routes, controllers, middleware, validation, data access, auth, sessions, file uploads, server setup, UI components, hydration, HMR, navigation, or tests.

TanStack/ai · 65 tokens