Skip to content
mindrally avatar

Clerk Authentication

Guidance for Clerk authentication in Next.js covering middleware, hooks, server actions, and route protection.

CCM score
52 of 100
skills.sh installs
729
GitHub stars
321
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers provider setup, middleware route matching, server and client auth hooks, and API route protection
  • Includes environment variable setup, clerkMiddleware with createRouteMatcher, and role checks via sessionClaims metadata
  • Enforces per-action authorization in server actions and route handlers, not only in middleware
  • Designed for Next.js App Router applications that need defense-in-depth around protected data and organization roles

Install

$ npx -y skills add mindrally/skills --skill clerk-authentication -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Clerk Authentication

You are an expert in Clerk authentication implementation for Next.js applications. Follow these guidelines when integrating Clerk.

Core Principles

  • Implement defense-in-depth with multiple authentication layers
  • Verify authentication at every data access point, not just middleware
  • Protect server actions individually
  • Use Clerk's built-in security features (HttpOnly cookies, CSRF protection)

Installation and Setup

npm install @clerk/nextjs

Environment Variables

# Required
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...
CLERK_SECRET_KEY=sk_...

# Optional: Custom URLs
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboard

Provider Setup

App Router (app/layout.tsx)

import { ClerkProvider } from '@clerk/nextjs';

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <ClerkProvider>
      <html lang="en">
        <body>{children}</body>
      </html>
    </ClerkProvider>
  );
}

With Custom Appearance

Details

Repository
github.com/mindrally/skills
Categories
Backend & APIs, Frontend & UI Code
First seen
Jun 3, 2026

Questions

What does the clerk-authentication skill do?

The clerk-authentication skill gives Claude guidelines for adding Clerk authentication to Next.js applications, covering middleware, hooks, and security practices. It tells the agent to verify authentication at every data access point and to protect server actions individually.

How do I install the clerk-authentication skill?

Run npx -y skills add mindrally/skills --skill clerk-authentication -y in your project to install clerk-authentication. After that, the agent can follow clerk-authentication's guidance when wiring Clerk into a Next.js app.

What does clerk-authentication need before I use it?

clerk-authentication expects a Next.js project with the @clerk/nextjs package installed. It also needs the Clerk publishable key and secret key set as environment variables, as its setup section describes.

Where does clerk-authentication stand in the Backend & APIs category?

clerk-authentication is listed in the Backend & APIs category on Claude Marketplaces, next to entra-app-registration, neon, firebase-basics, firebase-auth-basics and workers-best-practices. Its focus on Clerk sign-in and route protection in Next.js sets it apart from those skills.

More from mindrally/skills

All 240

Similar to Clerk Authentication

More Backend & APIs