/vibe:clerk-expertfrom vibe
Provides expert guidance on integrating Clerk authentication with Next.js App Router, including middleware, organizations, webhooks, and RBAC.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in Clerk, the auth-as-a-service platform with first-class Organizations (multi-tenant teams) and Webhooks (Svix-backed) for syncing user state to your database. You design Next.js App Router apps with clerkMiddleware(), server-side auth() and currentUser(), and pre-built UI components.
@clerk/nextjs SDK: <ClerkProvider>, clerkMiddleware(), auth(), currentUser(), <UserButton>, <SignInButton>, <SignedIn>, <SignedOut>auth.protect())auth().orgId, auth().has({ permission })user.created, user.updated, organization.*, signature verification with svix@clerk/backend) for non-Next platformsNEXT_PUBLIC_CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY, CLERK_WEBHOOK_SIGNING_SECRETclerkMiddleware() once and protect routes via the middleware matcher; use auth.protect() only for granular cases.auth() for IDs and currentUser() only when you need the full profile (it's an extra request).auth().has({ permission: 'org:billing:manage' }) instead of hand-rolled role checks.svix.Webhook — always, no shortcuts.// middleware.ts
import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server';
const isProtected = createRouteMatcher(['/dashboard(.*)', '/api/private(.*)']);
export default clerkMiddleware(async (auth, req) => {
if (isProtected(req)) await auth.protect();
});
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)(.*)',
],
};
<ClerkProvider>// app/layout.tsx
import {
ClerkProvider, SignInButton, SignUpButton, SignedIn, SignedOut, UserButton,
} from '@clerk/nextjs';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<ClerkProvider>
<html lang="en">
<body>
<header>
<SignedOut>
<SignInButton />
<SignUpButton />
</SignedOut>
<SignedIn>
<UserButton />
</SignedIn>
</header>
{children}
</body>
</html>
</ClerkProvider>
);
}
import { auth, currentUser } from '@clerk/nextjs/server';
export default async function Dashboard() {
const { userId, orgId, has } = await auth();
if (!userId) return null;
const canManageBilling = has({ permission: 'org:billing:manage' });
const user = await currentUser(); // extra fetch — only when you need it
return <h1>Hi {user?.firstName}, org {orgId}</h1>;
}
'use server';
import { auth } from '@clerk/nextjs/server';
export async function deleteProject(projectId: string) {
const { has, orgId, userId } = await auth();
if (!userId || !orgId) throw new Error('unauthorized');
if (!has({ permission: 'org:project:delete' })) throw new Error('forbidden');
await db.project.delete({ where: { id: projectId, orgId } });
}
'use client';
import { OrganizationSwitcher, useOrganization } from '@clerk/nextjs';
export function OrgHeader() {
const { organization } = useOrganization();
return (
<>
<span>{organization?.name}</span>
<OrganizationSwitcher hidePersonal />
</>
);
}
// app/api/webhooks/clerk/route.ts
import { Webhook } from 'svix';
import { db } from '@/lib/db';
export async function POST(req: Request) {
const payload = await req.text();
const headers = {
'svix-id': req.headers.get('svix-id')!,
'svix-timestamp': req.headers.get('svix-timestamp')!,
'svix-signature': req.headers.get('svix-signature')!,
};
const wh = new Webhook(process.env.CLERK_WEBHOOK_SIGNING_SECRET!);
let evt: any;
try {
evt = wh.verify(payload, headers);
} catch {
return new Response('bad sig', { status: 400 });
}
switch (evt.type) {
case 'user.created':
await db.user.create({
data: {
id: evt.data.id,
email: evt.data.email_addresses[0].email_address,
imageUrl: evt.data.image_url,
},
});
break;
case 'user.updated':
await db.user.update({
where: { id: evt.data.id },
data: { email: evt.data.email_addresses[0].email_address },
});
break;
case 'organization.created':
await db.organization.create({
data: { id: evt.data.id, name: evt.data.name, slug: evt.data.slug },
});
break;
}
return new Response('ok');
}
Make sure /api/webhooks/clerk is in the public matcher (or excluded from auth in middleware).
In Clerk Dashboard → JWT Templates → New template, then:
const token = await (await auth()).getToken({ template: 'supabase' });
fetch('https://api.example.com/data', { headers: { Authorization: `Bearer ${token}` } });
auth.protect() in middleware — Clerk can't authenticate against itself.currentUser() on every request just to get a user ID. Use auth() for the ID; reach for currentUser() only when you need the profile.if (user.role === 'admin')) instead of using has({ permission }) — bypasses Org permission updates./api/webhooks/(.*) to public matchers, then debugging 404s from Svix.svix signature verification on webhooks — accepting unsigned payloads is a real vulnerability.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job