Clerk Webhooks EventsSAFE
Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.
Overview
Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.
4f83675ca38aOBSERVED · 2026-10-08Install
Commands as the repository documents them. They are shown, not run.
npm install svix
npm install svix
Host compatibility
What the documentation claims. We have not run a compatibility test.
| Host | Status | Notes |
|---|---|---|
| claude-code | mentioned |
What it tells the agent
The instruction file, verbatim from the audited commit — this is the text the model reads, and the surface the audit's instruction layer examines. Quoted here so you can judge it without cloning anything.
--- name: clerk-webhooks-events description: 'Configure Clerk webhooks and handle authentication events. Use when setting up user sync, handling auth events, or integrating Clerk with external systems via Svix webhooks. Trigger with phrases like "clerk webhooks", "clerk events", "clerk user sync", "clerk svix", "clerk event handling". ' allowed-tools: Read, Write, Edit, Bash(npm:*), Grep version: 1.15.0 license: MIT author: Jeremy Longshore <[email protected]> tags: - saas - clerk - authentication - webhooks compatibility: Designed for Claude Code --- # Clerk Webhooks & Events ## Overview Configure and handle Clerk webhooks for user lifecycle events and data synchronization. Clerk uses Svix for webhook delivery with HMAC-SHA256 signature verification. As of 2025, Clerk provides a built-in `verifyWebhook()` helper in `@clerk/backend` alongside the manual Svix approach. ## Prerequisites - Clerk account with webhook endpoint configured in Dashboard - HTTPS endpoint (use `ngrok` for local dev) - `CLERK_WEBHOOK_SECRET` environment variable (starts with `whsec_`) ## Instructions ### Step 1: Install Dependencies ```bash # Option A: Use @clerk/backend's built-in verifyWebhook() (recommended) # Already included with @clerk/nextjs — no extra install needed # Option B: Manual Svix verification npm install svix ``` ### Step 2: Create Webhook Endpoint (verifyWebhook — Recommended) ```typescript // app/api/webhooks/clerk/route.ts import { verifyWebhook } from '@clerk/backend/webhooks' import type { WebhookEvent } from '@clerk/nextjs/server' export async function POST(req: Request) { let evt: WebhookEvent try { evt = await verifyWebhook(req) } catch (err) { console.error('Webhook verification failed:', err) return new Response('Invalid signature', { status: 400 }) } return handleWebhookEvent(evt) } ``` ### Step 2 (Alternative): Manual Svix Verification ```typescript // app/api/webhooks/clerk/route.ts import { Webhook } from 'svix' import { headers } from 'next/headers' import type { WebhookEvent } from '@clerk/nextjs/server' export async function POST(req: Request) { const WEBHOOK_SECRET = process.env.CLERK_WEBHOOK_SECRET if (!WEBHOOK_SECRET) { throw new Error('Missing CLERK_WEBHOOK_SECRET env variable') } const headerPayload = await headers() const svixHeaders = { 'svix-id': headerPayload.get('svix-id') || '', 'svix-timestamp': headerPayload.get('svix-timestamp') || '', 'svix-signature': headerPayload.get('svix-signature') || '', } if (!svixHeaders['svix-id'] || !svixHeaders['svix-signature']) { return new Response('Missing svix headers', { status: 400 }) } // CRITICAL: Use req.text(), NOT req.json() — JSON parsing alters the payload // and breaks signature verification const body = await req.text() const wh = new Webhook(WEBHOOK_SECRET) let evt: WebhookEvent try { evt = wh.verify(body, svixHeaders) as WebhookEvent } catch (err) { console.error('Webhook verification failed:', err) return new Response('Invalid signature', { status: 400 }) } return handleWebhookEvent(evt) } ``` ### Step 3: Implement Event Handlers ```typescript async function handleWebhookEvent(evt: WebhookEvent) { const eventType = evt.type switch (eventType) { case 'user.created': { const { id, email_addresses, first_name, last_name, image_url } = evt.data const primaryEmail = email_addresses.find(e => e.id === evt.data.primary_email_address_id) await db.user.create({ data: { clerkId: id, email: primaryEmail?.email_address || email_addresses[0]?.email_address, firstName: first_name, lastName: last_name, avatarUrl: image_url, }, }) console.log(`[Webhook] User created: ${id}`) break } case 'user.updated': { const { id, email_addresses, first_name, last_name, image_url } = evt.data const primaryEmail = email_addresses.find(e => e.id === evt.data.primary_email_address_id) await db.user.upsert({ where: { clerkId: id }, update: { email: primaryEmail?.email_address, firstName: first_name, lastName: last_name, avatarUrl: image_url, }, create: { clerkId: id, email: primaryEmail?.email_address || '', firstName: first_name, lastName: last_name, avatarUrl: image_url, }, }) break } case 'user.deleted': { if (evt.data.id) { // Soft-delete or hard-delete based on your data retention policy await db.user.update({ where: { clerkId: evt.data.id }, data: { deletedAt: new Date() }, }) } break } case 'organization.created': { const { id, name, slug, created_by } = evt.data await db.organization.create({ data: { clerkOrgId: id, name, slug: slug || '', createdBy: created_by }, }) break } case 'organizationMembership.created': { const { organization, public_user_data, role } = evt.data await db.orgMembership.create({ data: { orgId: organization.id, userId: public_user_data.user_id, role, }, }) break } case 'session.created': console.log(`[Webhook] Session created for user: ${evt.data.user_id}`) break default: console.log(`[Webhook] Unhandled event: ${eventType}`) } return new Response('OK', { status: 200 }) } ``` ### Step 4: Idempotency Protection ```typescript // lib/webhook-idempotency.ts // Clerk/Svix may retry failed deliveries — prevent duplicate processing export async function processIdempotently( svixId: string, eventType: string, handler: () => Promise<void> ): Promise<{ processed: boolean; duplicate: boolean }> { // Check if already processed (use your DB or Redis) const existing = await db.webhookEvent.
Trust audit
SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | PASS |
| L1 | Static analysis of the code | PASS |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | PASS |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- none-observed
- Network
- none-observed
- Shell
- none-observed
- Dependencies
- pinned
- Secrets in source
- none-found
Findings (0)
No findings outside the package's declared scope.
Gates applied: no_behavioural_pass.
4f83675ca38afull audit observations/trust-audit/skill/jeremylongshore__clerk-webhooks-events.json · Report an issue / request a re-scanAudit history
Every audit this skill has had.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-08 | 4f83675ca38a | SAFE | B | 89 | first audit |
Questions
What does the Clerk Webhooks Events skill do?
Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.
Is Clerk Webhooks Events safe to install?
The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean skill reads B.
What can Clerk Webhooks Events access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
Which assistants does Clerk Webhooks Events work with?
Its documentation mentions claude-code. That is what the text claims, not a compatibility test we ran.
How current is this page?
The grade is for one exact copy of the source (4f83675ca38a), read on 2026-10-08. The repository is watched, and a new audit runs when it changes — this is the first audit.