auth

auth is a skill for Claude Code, Codex from AbdulmalekAlshugaa/claude-agents-fullstack. It costs 52 tokens per session (590 once invoked), scanned A, original, MIT.

A guide for adding login, user sessions, route protection, and role-based permissions to a Next.js app that uses MongoDB.

In plain words
What is it for?
Use it when building signup, login, session checks, protected routes, or permissions for different user roles.
Why use it?
It helps prevent unauthorized users from reaching pages, actions, or request handlers, while providing a clear setup for common account features.

Skill for Claude CodeCodex

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

Good fit Use it when building signup, login, session checks, protected routes, or permissions for different user roles.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/abdulmalekalshugaa/claude-agents-fullstack/auth
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 AbdulmalekAlshugaa/claude-agents-fullstack --skill auth
Clone the repo
git clone --depth 1 https://github.com/AbdulmalekAlshugaa/claude-agents-fullstack

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/abdulmalekalshugaa/claude-agents-fullstack/auth/github.svg)](https://agentmods.dev/skills/abdulmalekalshugaa/claude-agents-fullstack/auth)
Your own site
<a href="https://agentmods.dev/skills/abdulmalekalshugaa/claude-agents-fullstack/auth"><img src="https://agentmods.dev/badge/skills/abdulmalekalshugaa/claude-agents-fullstack/auth/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

Your own site · 80×15
<a href="https://agentmods.dev/skills/abdulmalekalshugaa/claude-agents-fullstack/auth"><img src="https://agentmods.dev/badge/skills/abdulmalekalshugaa/claude-agents-fullstack/auth.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 52 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 590 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.00052 $0.00590
Opus 5.5 $0.00021 $0.00236
Sonnet 5.5 $0.00010 $0.00118
Haiku 4.5 $0.00005 $0.00059

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

Security

Grade A, and why

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

skills/auth/SKILL.md · 53 lines

How it starts

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

Auth (Auth.js / NextAuth v5)

Setup

  • Use Auth.js (next-auth v5) with the adapter matching the project's DB:
    # Postgres (default)
    pnpm add next-auth@beta @auth/drizzle-adapter
    # Mongo
    pnpm add next-auth@beta @auth/mongodb-adapter mongodb
    
  • Config in src/lib/auth.ts exporting { handlers, auth, signIn, signOut }; route handler at src/app/api/auth/[...nextauth]/route.ts re-exports handlers.
  • Prefer OAuth providers (Google/GitHub) first; credentials provider only when required — then hash with bcrypt (cost ≥ 12) and never store or log the plain password.
  • AUTH_SECRET in .env.local (npx auth secret), validated in lib/env.ts.

The one rule that matters

Check the session at every entry point that does anything private. Middleware is UX (redirects), not security. Each of these independently verifies:

  • Server component / page: const session = await auth() → redirect if null.
  • Server action: first line const session = await auth(); if (!session) return { ok: false, error: 'unauthenticated' } — actions are public HTTP endpoints.
  • Route handler: same check, return 401.
  • Service layer: takes userId as an explicit parameter — services never read the session themselves, callers pass identity in.

Authorization (roles/ownership)

  • Store role on the user row/document; put it in the JWT/session via callbacks so checks don't hit the DB.
  • Ownership checks happen in the service, in the query itself: where(and(eq(t.id, id), eq(t.userId, userId))) in Drizzle, or Model.findOne({ _id: id, userId }) in Mongoose — not a post-fetch if (avoids TOCTOU and leaking existence via 403 vs 404; return 404 for both).
  • Never trust a userId, role, or orgId from the request body — always from the session.

Session strategy

  • JWT sessions (default) for simplicity; database sessions if you need instant revocation.
  • Keep the session payload small: id, email, role. Everything else is a DB read.

Read the full file on GitHub · 53 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 Changed · +3 lines · +7 tokens per session 515ebf738a82
  2. 1mo ago First seen · 50 lines · 45 tokens per session scan A 4eecbb3e3e2c

Subscribe to this mod's changes

auth is a skill published in the GitHub repository AbdulmalekAlshugaa/claude-agents-fullstack (4 stars, last pushed 1mo ago), licensed MIT. It adds 52 tokens to every session and 590 once invoked, about $0.0002 per session on Opus 5.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

dynamic

Fullstack development with bkend.ai BaaS — authentication, database, API integration. Triggers: fullstack, BaaS, login, signup, database, web app.

ww-w-ai/bkit-claude-code · 38 tokens

ring:mapping-service-resources

Mapping a Go service's Service -> Module -> Resource hierarchy for dispatch-layer registration: detects modules and per-module PostgreSQL/MongoDB/RabbitMQ resources, database names, and shared databases, generates MongoDB index migration pairs (.up.json/.down.json), detects existing Postgres migrations, emits an HTML…

LerianStudio/ring · 97 tokens

fastapi-init-skill

A tool that creates a complete FastAPI web-service starting point, including database choices, login protection, file uploads, streaming responses, API documentation, and start or restart scripts.

jiushiwon/wg-skills · 229 tokens

nodejs-init-skill

A setup assistant for creating Node.js web services with the Express framework. It checks the environment, installs needed tools, and generates a ready-to-run project with authentication, file uploads, API documentation, and database choices.

jiushiwon/wg-skills · 219 tokens

mongodb-development

MongoDB development guidelines with Payload CMS, Mongoose, aggregation pipelines, and TypeScript best practices.

Mindrally/skills · 23 tokens

nest-data-layer

ORM patterns for NestJS: TypeORM, Prisma, Mongoose. Covers entities, repositories, transactions, migrations, common pitfalls (N+1, cascade deletes, transaction boundaries). Use this skill to: Detect which ORM the project uses and apply matching patterns. Define entities/schemas with the right decorators. Inject…

AratKruglik/claude-sdlc · 137 tokens