clerk-nextjs-patterns

clerk-nextjs-patterns is a skill for Claude Code from sutchan/Agent-Skills-Hub. It costs 21 tokens per session (2,110 once invoked), scanned A, a copy of clerk-nextjs-patterns, MIT.

A collection of implementation patterns for adding Clerk authentication to Next.js applications. Clerk is a service that manages user accounts and login sessions.

In plain words
What is it for?
Use it for middleware, server-versus-client authentication, protected Server Actions, API-route access checks, and user-scoped caching.
Why use it?
It helps avoid mistakes when authentication code runs on the server or in the browser, protects server-side actions and API routes, and caches user-specific data safely.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Good fit Use it for middleware, server-versus-client authentication, protected Server Actions, API-route access checks, and user-scoped caching.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/sutchan/agent-skills-hub/clerk-nextjs-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 sutchan/Agent-Skills-Hub --skill clerk-nextjs-patterns
Clone the repo
git clone --depth 1 https://github.com/sutchan/Agent-Skills-Hub

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/sutchan/agent-skills-hub/clerk-nextjs-patterns/github.svg)](https://agentmods.dev/skills/sutchan/agent-skills-hub/clerk-nextjs-patterns)
Your own site
<a href="https://agentmods.dev/skills/sutchan/agent-skills-hub/clerk-nextjs-patterns"><img src="https://agentmods.dev/badge/skills/sutchan/agent-skills-hub/clerk-nextjs-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 clerk-nextjs-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/sutchan/agent-skills-hub/clerk-nextjs-patterns"><img src="https://agentmods.dev/badge/skills/sutchan/agent-skills-hub/clerk-nextjs-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 21 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,110 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 88% 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.00021 $0.02110
Opus 5 $0.00010 $0.01055
Sonnet 5 $0.00004 $0.00422
Haiku 4.5 $0.00002 $0.00211

Measured today against content hash 51a833e5f5ed, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

clerk-nextjs-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 today.

The scan reads SKILL.md. This mod also ships 1 executable file (templates/nextjs-basic-auth/proxy.ts), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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

88% identical to clerk-nextjs-patterns — 78 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.

skills/clerk-nextjs-patterns/SKILL.md · 253 lines

How it starts

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

Next.js Patterns

Version: Check package.json for the SDK version — see clerk skill for the version table. Core 2 differences are noted inline with > **Core 2 ONLY (skip if current SDK):** callouts.

For basic setup, see clerk-setup skill.

What Do You Need?

Task Reference
Server vs client auth (auth() vs hooks) references/server-vs-client.md
Configure middleware (public-first vs protected-first) references/middleware-strategies.md
Protect Server Actions references/server-actions.md
API route auth (401 vs 403) references/api-routes.md
Cache auth data (user-scoped caching) references/caching-auth.md

References

Reference Description
references/server-vs-client.md await auth() vs hooks
references/middleware-strategies.md Public-first vs protected-first, proxy.ts (Next.js <=15: middleware.ts)
references/server-actions.md Protect mutations
references/api-routes.md 401 vs 403
references/caching-auth.md User-scoped caching

Mental Model

Server vs Client = different auth APIs:

  • Server: await auth() from @clerk/nextjs/server (async!)
  • Client: useAuth() hook from @clerk/nextjs (sync)

Never mix them. Server Components use server imports, Client Components use hooks.

Key properties from auth():

  • isAuthenticated — boolean, replaces the !!userId pattern
  • sessionStatus'active' | 'pending', for detecting incomplete session tasks
  • userId, orgId, orgSlug, has(), protect() — unchanged

Core 2 ONLY (skip if current SDK): isAuthenticated and sessionStatus are not available. Check !!userId instead.

Minimal Pattern

// Server Component
import { auth } from '@clerk/nextjs/server'

export default async function Page() {
  const { isAuthenticated, userId } = await auth()  // MUST await!
  if (!isAuthenticated) return <p>Not signed in</p>
  return <p>Hello {userId}</p>
}

Read the full file on GitHub · 253 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. today Changed · -2 lines · -20 tokens per session 51a833e5f5ed
  2. 10d ago First seen · 255 lines · 41 tokens per session scan A d8d1c45f42c1

Subscribe to this mod's changes

clerk-nextjs-patterns is a skill published in the GitHub repository sutchan/Agent-Skills-Hub (2 stars, last pushed yesterday), licensed MIT. It adds 21 tokens to every session and 2,110 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 88% identical to clerk-nextjs-patterns, differing in 78 lines, and is treated as a copy.

Related

Other skills, from other repositories

form-validation-expert

Expert guide for complex form handling with React Hook Form, server-side validation (useActionState + Zod), multi-step wizards, and accessible form patterns / Panduan ahli penanganan formulir kompleks dengan React Hook Form, validasi server-side, wizard multi-langkah, dan pola formulir aksesibel.

roedyrustam/vibes-plug · 69 tokens

performance-web-vitals

Expert guide for Web Performance optimization: Core Web Vitals (LCP, INP, CLS), bundle analysis, image optimization, rendering strategies, and Lighthouse score improvement / Panduan ahli untuk optimasi performa web: Core Web Vitals (LCP, INP, CLS), analisis bundle, optimasi gambar, strategi rendering, dan peningkatan…

roedyrustam/vibes-plug · 79 tokens

state-management-expert

Expert guide for modern client-side state management: Zustand, Jotai, Valtio, TanStack Store, Redux Toolkit, and server state patterns with TanStack Query / Panduan ahli untuk manajemen state client-side modern: Zustand, Jotai, Valtio, TanStack Store, Redux Toolkit, dan pola server state dengan TanStack Query.

roedyrustam/vibes-plug · 77 tokens

website-design-cloner

Analyzes and reverse-engineers website designs directly from a target URL, extracting layout structures, design tokens (colors, typography, spacing), component hierarchies, visual assets, and responsive behaviors to enable full 1:1 duplication into modern code (Tailwind CSS v4, React/Next.js, HTML/CSS). / Mempelajari…

roedyrustam/vibes-plug · 129 tokens

tanstack-query-expert

Advanced TanStack Query (v5) expert. Covers useSuspenseQuery, infinite scrolling, optimistic mutations, SSR/React Server Components hydration, and advanced cache invalidation / Pakar manajemen state asinkron menggunakan TanStack Query (React Query) v5 dan Next.js App Router (SSR).

roedyrustam/vibes-plug · 67 tokens

nextjs-app-router-expert

Expert guide for Next.js 15 App Router: RSC, Server Actions, Middleware, Parallel/Intercepting Routes, Streaming, and Caching strategies / Panduan ahli untuk Next.js 15 App Router.

roedyrustam/vibes-plug · 49 tokens