Clerk Migration Deep DiveSAFE
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-08Host 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-migration-deep-dive description: 'Migrate from other authentication providers to Clerk. Use when migrating from Auth0, Firebase, Supabase Auth, NextAuth, or custom authentication solutions. Trigger with phrases like "migrate to clerk", "clerk migration", "switch to clerk", "auth0 to clerk", "firebase auth to clerk". ' allowed-tools: Read, Write, Edit, Bash(npm:*), Grep version: 1.15.0 license: MIT author: Jeremy Longshore <[email protected]> tags: - saas - clerk - migration - authentication compatibility: Designed for Claude Code --- # Clerk Migration Deep Dive ## Current State !`npm list @auth0/nextjs-auth0 next-auth @supabase/auth-helpers-nextjs firebase 2>/dev/null | grep -E "auth0|next-auth|supabase|firebase" || echo 'No auth providers detected'` ## Overview Comprehensive guide to migrating from Auth0, Firebase Auth, Supabase Auth, or NextAuth to Clerk. Covers user data export, bulk import, parallel running, and phased migration. ## Prerequisites - Current auth provider access with admin/export permissions - Clerk account with API keys - Git repository with clean working state - Migration timeline planned (recommend 2-4 weeks) ## Instructions ### Step 1: Export Users from Current Provider **Auth0 Export:** ```bash # Export users via Auth0 Management API curl -s -H "Authorization: Bearer $AUTH0_TOKEN" \ "https://$AUTH0_DOMAIN/api/v2/users?per_page=100&page=0" \ | jq '[.[] | {email: .email, name: .name, picture: .picture, created_at: .created_at}]' \ > auth0-users.json ``` **NextAuth (Prisma) Export:** ```typescript // scripts/export-nextauth-users.ts const users = await prisma.user.findMany({ include: { accounts: true }, }) const exported = users.map((u) => ({ email: u.email, name: u.name, image: u.image, provider: u.accounts[0]?.provider, createdAt: u.createdAt, })) await fs.writeFile('nextauth-users.json', JSON.stringify(exported, null, 2)) ``` ### Step 2: Import Users to Clerk ```typescript // scripts/import-to-clerk.ts import { createClerkClient } from '@clerk/backend' import users from './auth0-users.json' const clerk = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY! }) interface MigrationResult { email: string status: 'created' | 'exists' | 'error' clerkId?: string error?: string } async function importUsers(): Promise<MigrationResult[]> { const results: MigrationResult[] = [] for (const user of users) { try { const created = await clerk.users.createUser({ emailAddress: [user.email], firstName: user.name?.split(' ')[0], lastName: user.name?.split(' ').slice(1).join(' '), skipPasswordRequirement: true, // User will set password on first sign-in }) results.push({ email: user.email, status: 'created', clerkId: created.id }) console.log(`Created: ${user.email} -> ${created.id}`) } catch (err: any) { if (err.status === 422) { results.push({ email: user.email, status: 'exists' }) } else { results.push({ email: user.email, status: 'error', error: err.message }) } } // Respect rate limits await new Promise((resolve) => setTimeout(resolve, 100)) } return results } importUsers().then((results) => { const summary = { total: results.length, created: results.filter((r) => r.status === 'created').length, exists: results.filter((r) => r.status === 'exists').length, errors: results.filter((r) => r.status === 'error').length, } console.log('Migration summary:', summary) fs.writeFileSync('migration-results.json', JSON.stringify(results, null, 2)) }) ``` ### Step 3: Update Database References ```typescript // scripts/update-db-references.ts import { createClerkClient } from '@clerk/backend' const clerk = createClerkClient({ secretKey: process.env.CLERK_SECRET_KEY! }) async function updateDatabaseReferences() { // Get all users from your database const dbUsers = await db.user.findMany() for (const dbUser of dbUsers) { // Find corresponding Clerk user by email const clerkUsers = await clerk.users.getUserList({ emailAddress: [dbUser.email], }) if (clerkUsers.totalCount > 0) { const clerkUser = clerkUsers.data[0] await db.user.update({ where: { id: dbUser.id }, data: { clerkId: clerkUser.id, // Keep old auth ID for rollback legacyAuthId: dbUser.authProviderId, }, }) console.log(`Mapped: ${dbUser.email} -> ${clerkUser.id}`) } } } ``` ### Step 4: Replace Auth Code (NextAuth to Clerk Example) ```typescript // BEFORE: NextAuth // import { getServerSession } from 'next-auth' // import { authOptions } from '@/lib/auth' // const session = await getServerSession(authOptions) // const userId = session?.user?.id // AFTER: Clerk import { auth } from '@clerk/nextjs/server' const { userId } = await auth() ``` ```typescript // BEFORE: NextAuth client hook // import { useSession } from 'next-auth/react' // const { data: session } = useSession() // AFTER: Clerk client hook import { useUser } from '@clerk/nextjs' const { user, isLoaded } = useUser() ``` ```typescript // BEFORE: NextAuth middleware // export { default } from 'next-auth/middleware' // export const config = { matcher: ['/dashboard(.*)'] } // AFTER: Clerk middleware import { clerkMiddleware, createRouteMatcher } from '@clerk/nextjs/server' const isProtected = createRouteMatcher(['/dashboard(.*)']) export default clerkMiddleware(async (auth, req) => { if (isProtected(req)) await auth.protect() }) ``` ### Step 5: Parallel Running (Optional Safety Net) ```typescript // lib/auth-bridge.ts — run both auth systems during transition import { auth as clerkAuth } from '@clerk/nextjs/server' export async function getAuthUser() { // Try Clerk first (new system) const { userId: clerkUserId } = await clerkAuth() if (clerkUserId) { return { provider: 'clerk', userId: clerkUserId } } // Fall
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-migration-deep-dive.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 Migration Deep Dive 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 Migration Deep Dive 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 Migration Deep Dive access on my machine?
The audit observed no filesystem, network or shell use at all in its source.
Which assistants does Clerk Migration Deep Dive 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.