clerk
Skill2 starsChanged 4 months agoMITView on GitHub
Use to add drop-in authentication (sign-in/up, sessions, orgs, user button) to a Next.js/React app and protect server code.
- Reads credentials
- Installs packages
5 other projects use a version of this.
Adopted by
Most recently taken up by
- delorenj/skillstheir own version, first seen Oct 2, 2026
- Aymenjdily/biblion-testing-agentic-ai-skillstheir own version, first seen Sep 4, 2026
- clerk/skillstheir own version, first seen May 8, 2026
- elpiarthera/vantage-startertheir own version, first seen Mar 26, 2026
- wrsmith108/clerk-claude-skilltheir own version, first seen Dec 27, 2025
Used with
Projects with it also use clerk-custom-ui, clerk-nextjs-patterns and 4 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
elpiartheraSkillclerk-custom-ui
Customize Clerk component appearance - themes, layout, colors, fonts, CSS. Use for appearance styling, visual customization, branding.
Also in 3 projects that use this
elpiartheraSkillclerk-nextjs-patterns
Advanced Next.js patterns - middleware, Server Actions, caching with Clerk.
Also in 3 projects that use this
Harmeet10000Skillclerk-setup
Add Clerk authentication to any project by following the official quickstart guides.
Also in 3 projects that use this
- +3 more from elpiarthera
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- clerk/skills★ 86same name
- delorenj/skills★ 15same name
- wrsmith108/clerk-claude-skill★ 5same name
- Aymenjdily/biblion-testing-agentic-ai-skills★ 2same name
- elpiarthera/vantage-starter★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository20 other files it gives its agents.
- anthropicSkill
- cloudflare-workersSkill
- dockerSkill
- fly-ioSkill
- github-actionsSkill
- neonSkill
- netlifySkill
- nextjsSkill
- openaiSkill
- prismaSkill
- railwaySkill
- renderSkill
- resendSkill
- sentrySkill
- stripeSkill
- supabaseSkill
- tailwindcssSkill
- terraformSkill
- upstash-redisSkill
- vercelSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Use when: you want auth working in minutes with prebuilt UI (<SignIn/>, <UserButton/>).
- Distinctive: line 22
Use when: you need organizations/teams, roles, or B2B multi-tenant auth.
- Very specific: line 23
Don't use for: cases where you must fully own the auth tables/DB (use Auth.js/Lucia or Supabase Auth).
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Clerk — Skillship
Drop-in authentication and user management: prebuilt UI components, hosted sign-in/up, sessions, and organizations, wired into Next.js middleware and server helpers.
🧭 When to use this skill
- Use when: you want auth working in minutes with prebuilt UI (
<SignIn/>,<UserButton/>). - Use when: you need organizations/teams, roles, or B2B multi-tenant auth.
- Don't use for: cases where you must fully own the auth tables/DB (use Auth.js/Lucia or Supabase Auth).
⚡ Quickstart
1. Scaffold with the CLI (recommended — wires provider, middleware, and env keys)
npx -y clerk@latest init
# writes NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY to .env.local2. Or set up manually
npm install @clerk/nextjs# .env.local
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_... # SERVER ONLY — never expose in client code3. Middleware
// Next.js 16+: name the file proxy.ts | Next.js <=15: name it middleware.ts (contents identical)
import { clerkMiddleware } from "@clerk/nextjs/server";
export default clerkMiddleware();
export const config = {
matcher: [
"/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)",
"/(api|trpc)(.*)",
"/__clerk/(.*)",
],
};4. Wrap the app (ClerkProvider goes INSIDE <body>)
// app/layout.tsx
import { ClerkProvider, SignInButton, SignUpButton, Show, UserButton } from "@clerk/nextjs";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<ClerkProvider>
<header>
<Show when="signed-out">
<SignInButton />
<SignUpButton />
</Show>
<Show when="signed-in">
<UserButton />
</Show>
</header>
{children}
</ClerkProvider>
</body>
</html>
);
}🧩 Common recipes
Recipe: Read the user on the server (auth() is async — always await)
import { auth, currentUser } from "@clerk/nextjs/server";
export default async function Page() {
const { userId } = await auth(); // fast: just the ID / claims
if (!userId) return <p>Sign in first.</p>;
const user = await currentUser(); // full user object (extra fetch)
return <p>Hello {user?.firstName}</p>;
}Recipe: Protect a Route Handler / server action (protect close to the data)
import { auth } from "@clerk/nextjs/server";
export async function POST() {
const { userId } = await auth();
if (!userId) return new Response("Unauthorized", { status: 401 });
// ...do the protected work
}Recipe: Client-side user state
"use client";
import { useUser, useAuth } from "@clerk/nextjs";
export function Profile() {
const { isLoaded, isSignedIn, user } = useUser();
if (!isLoaded) return null;
return isSignedIn ? <span>{user.fullName}</span> : <span>Signed out</span>;
}🚀 Ship to production
- Create a production instance in the Clerk Dashboard and use its live keys as host secrets.
- Configure your production domain + set
CLERK_SECRET_KEY/NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYin the host. - Middleware file named correctly for your Next.js version (
proxy.ts16+,middleware.ts≤15). - Enforce authorization at the data layer (route handlers/actions), not only in middleware.
- Set
CLERK_ENCRYPTION_KEY(openssl rand --hex 32) if you pass a dynamicsecretKeyto middleware. - Use
@clerk/nextjs(not@clerk/clerk-react) in Next.js apps.
🔐 Security & secrets
CLERK_SECRET_KEYauthenticates your backend to Clerk — never expose it in client code orNEXT_PUBLIC_*.- Protect resources as close to the data as possible; middleware alone is not a sufficient auth boundary.
- Set
authorizedPartiesin middleware to defend against subdomain cookie-leak attacks.
🐛 Common errors & fixes
| Symptom | Likely cause | Fix | |
auth() ... Promise / undefined userId | Forgot to await | const { userId } = await auth() | |
| Auth not applied on some routes | Middleware matcher too narrow | Use the recommended matcher incl. `/(api | trpc)(.*)` |
ClerkProvider errors / hydration issues | Provider wrapping <html> | Put <ClerkProvider> inside <body> | |
| Works in dev, breaks in prod | Still using dev keys / domain | Create prod instance, set live keys + domain | |
| Secret key leaked to client | Used NEXT_PUBLIC_ for secret | Keep secret server-side only |
📚 Sources
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

