clerk-setup
Skill16 starsChanged 24 days agoMITView on GitHub
Set up Clerk authentication in any project with the Clerk CLI and official framework quickstarts. Use when adding Clerk, initializing Clerk, scaffolding a new app with Clerk, or migrating an existing authentication system to Clerk.
- Reads credentials
We split this skill into the rules it gives an agent
17 rules. 0 are common, 6 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
6
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Use the Clerk CLI to add authentication.
- Very specific: line 32
Before init, inspect auth dependencies, routes, middleware, sessions, and user records — never environment files.
- Distinctive: line 37
Do not modify or remove existing auth without approval.
- Distinctive: line 55
Follow this branch when the user asks to use an existing Clerk application or an existing Clerk project needs its keys restored.
- Very specific: line 61
If they supplied an application ID, keep it for init or link as appropriate.
- Very specific: line 79
Only when the user needs production keys, use npx -y clerk@latest env pull --instance prod instead.
- Very specific: line 93
Ask which framework and package manager to use, defaulting to Next.js and npm:
- Very specific: line 111
If init reports the framework is unsupported or undetected, follow the quickstart instead.
- Distinctive: line 117
Use the matching direct quickstart:
- Very specific: line 172
If components.json exists in the project root, add @clerk/ui with the project's package manager.
- Distinctive: line 182
Add to global CSS:
- Very specific: line 190
Use Node.js 20.9.0 or later for current Clerk SDKs.
- Very specific: line 193
Never expose CLERK_SECRET_KEY in client code.
- Distinctive: line 195
Do not read or print existing environment variable files.
- Very specific: line 203
Before production, have the user claim the app with npx -y clerk@latest auth login, then configure production with npx -y clerk@latest …
- Very specific: line 210
Add <OrganizationSwitcher /> next to the existing <UserButton />, or the framework equivalent.
- Distinctive: line 213
If no, point them to Organizations, Components, and the Clerk Dashboard.
“Common” is measured: kept by at least 6 in 10 of the 8 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
Set up Clerk
Use the Clerk CLI to add authentication. In agent environments, supported frameworks default to accountless setup: npx -y clerk@latest init provisions a claimable application and writes temporary development keys without requiring a Clerk account.
Before you start
Show the user this checklist and wait for a yes:
Here's what I'll do to get you set up with Clerk.
1. Set up Clerk in this project, or scaffold a new app if this directory is empty.
2. Install Clerk's agent skills for the coding agents on this machine, if they aren't installed yet.
3. Start your app with Clerk installed.
Shall I proceed?Existing authentication
Before init, inspect auth dependencies, routes, middleware, sessions, and user records — never environment files. If a different auth provider exists, stop and get approval for a migration plan covering:
- Backend API user import, stable external IDs, compatible password hashes, and OAuth continuity.
- Protected routes, tokens, session cutover, and rollout strategy.
Do not modify or remove existing auth without approval.
See the migration guide.
Existing Clerk projects
If the project already uses Clerk, skip init in Steps 1a and 1b: a signed-out agent run could create another application and replace the project's Clerk keys. If Clerk already works and the user asked for setup, report that no setup is needed. If the user reports missing keys, restore them through the existing-application branch below. If inspection finds missing provider, middleware, or auth routes, add only those pieces from the matching quickstart in Step 2. Never create a replacement application.
Inspect its Clerk package versions before changing anything and use the version table in the clerk skill to identify its SDK generation. Preserve that generation unless the user asks to upgrade it, and apply these differences in every step below for Core 2 projects:
- React and Expo use
@clerk/clerk-reactand@clerk/clerk-expoinstead of@clerk/reactand@clerk/expo. - Control components are
<SignedIn>and<SignedOut>instead of<Show>. - Next.js
ClerkProvidercan wrap<html>instead of going inside<body>. - The minimum Node.js version is 18.17.0 instead of 20.9.0.
- Themes come from
@clerk/themesand@clerk/themes/shadcn.cssinstead of@clerk/ui.
Use an existing Clerk application (optional)
Follow this branch when the user asks to use an existing Clerk application or an existing Clerk project needs its keys restored. Have them authenticate from their host terminal before targeting account-level resources:
npx -y clerk@latest auth loginIf they supplied an application ID, keep it for init or link as appropriate. Otherwise, list the applications:
npx -y clerk@latest apps list --jsonShow the names and IDs and ask which application to use. Never choose an application for them. For a new Clerk integration, pass the selected ID as --app <application_id> to init. For a project already using Clerk, do not run init. If it is not already linked to the selected application, link it:
npx -y clerk@latest link --app <application_id>For missing development keys, pull them:
npx -y clerk@latest env pullOnly when the user needs production keys, use npx -y clerk@latest env pull --instance prod instead. Do not replace working keys or switch applications without the user's confirmation.
Step 1a: Existing project without Clerk
For a project that does not already use Clerk, run from the project root:
npx -y clerk@latest initinit detects the framework and package manager, installs the SDK, and configures the provider, middleware, auth routes, and environment. It also installs Clerk's agent skills globally. If the user declined them, or they're already available to you, such as when you loaded this as the clerk-setup skill, add --no-skills to skip that step. Don't pass --framework or --pm unless asked. Add --app <application_id> only when the user selected an application in the optional branch above.
Step 1b: Empty directory
Ask which framework and package manager to use, defaulting to Next.js and npm:
npx -y clerk@latest init --framework <framework> --pm <package-manager>init creates the app in a new subdirectory, such as my-clerk-next-app, not in the current directory. Run the remaining steps from that subdirectory. As in Step 1a, add --no-skills if Clerk's skills are already available to you or the user declined them.
init can create Next.js, React Router, Astro, Nuxt, TanStack Start, React, Vue, JavaScript/Vite, and Expo apps. For Express, Fastify, iOS, or Android, create the project with that platform's own tooling first, then follow Step 1a.
Step 1c: Accountless development keys
For a signed-out user on a framework with accountless support (Next.js, React Router, Astro, Nuxt, or TanStack Start), init provisions a claimable application and writes temporary keys to the detected environment file. Relay the filename and claim instruction printed by the CLI. The app stays unclaimed until the user runs npx -y clerk@latest auth login; don't run it unless asked. Use --accountless only to force this flow while signed in.
Frameworks without accountless support need real API keys. There, init applies what setup it can and prints the remaining steps.
Step 2: Fall back to docs when init is incomplete
If init reports the framework is unsupported or undetected, follow the quickstart instead. If it finishes but prints remaining steps, follow those, and use the matching quickstart for anything they don't cover.
For an existing Clerk project with missing integration files, use that quickstart to add only the missing pieces without running init.
init configures Next.js, React, React Router, Nuxt, TanStack Start, Astro, Vue, JavaScript/Vite, Expo, Express, and Fastify projects. For iOS and Android, it only prints setup steps, so follow the quickstart.
Use the matching direct quickstart:
- Next.js
- React
- React Router
- Nuxt
- TanStack Start
- Astro
- Vue
- JavaScript or Vite
- Expo
- Express
- Fastify
- iOS
- Android
- Chrome extension
For everything else, use Clerk's llms.txt.
Step 3: Add visible auth controls
Skip this step for backend-only projects, such as Express or Fastify APIs. For Expo, iOS, and Android, use the native components from the matching quickstart instead.
A web app needs sign-in, sign-up, and signed-in user controls, worked into the existing layout or navigation. If they already exist, adapt them instead of duplicating.
For Next.js App Router:
import { SignInButton, SignUpButton, Show, UserButton } from '@clerk/nextjs'
<>
<Show when="signed-out">
<SignInButton />
<SignUpButton />
</Show>
<Show when="signed-in">
<UserButton />
</Show>
</>Astro imports from @clerk/astro/components. Nuxt auto-imports the components; explicit imports come from @clerk/nuxt/components. Other frameworks use the same names from their Clerk package, such as @clerk/vue or @clerk/react.
Step 4: Verify
npx -y clerk@latest doctorThen start the app, confirm the auth controls render, and fix anything the CLI reports.
Bot protection can block sign-ups in browsers you automate. If you test a new accountless app in one, run npx -y clerk@latest users create --email <unique>+clerk_test@example.com --password <random-16-char-alphanumeric> --yes, then sign in. If asked for a verification code, enter 424242. Tell the user you created this test user. For an existing app, ask the user before creating users. To test sign-up, use @clerk/testing.
Step 5: If using shadcn/ui
If components.json exists in the project root, add @clerk/ui with the project's package manager. Match the lockfile: pnpm-lock.yaml → pnpm add, yarn.lock → yarn add, bun.lock or bun.lockb → bun add, package-lock.json → npm install.
Apply the theme in your provider:
import { shadcn } from '@clerk/ui/themes'
<ClerkProvider appearance={{ theme: shadcn }}>{children}</ClerkProvider>Add to global CSS:
@import '@clerk/ui/themes/shadcn.css';Critical rules
- Use Node.js 20.9.0 or later for current Clerk SDKs.
- Next.js 15+:
auth()is async. Alwaysawait auth(). - For current Next.js SDKs,
ClerkProvidergoes inside<body>, not around<html>. - Never expose
CLERK_SECRET_KEYin client code. - For fresh setups, use the current framework package, such as
@clerk/nextjs,@clerk/react,@clerk/expo,@clerk/react-router, or@clerk/tanstack-react-start. - Do not read or print existing environment variable files; ask the user for any missing non-sensitive configuration.
After setup
Have the user sign up as their first test user. Congratulate them once the profile icon appears in the nav.
Then ask how they want users to sign up and sign in — identifiers (email, phone, username) and social providers. Changing these needs a claimed application: have the user run npx -y clerk@latest auth login first, then review with npx -y clerk@latest config pull and change with npx -y clerk@latest config patch (supports --dry-run), or use the Clerk Dashboard. See sign-up and sign-in options for details.
Before production, have the user claim the app with npx -y clerk@latest auth login, then configure production with npx -y clerk@latest deploy. Unclaimed apps and temporary keys aren't production-ready.
Then offer Organizations — multi-tenancy, team invitations, roles and permissions, and enterprise SSO.
If yes:
- Run
npx -y clerk@latest enable orgs. - Add
<OrganizationSwitcher />next to the existing<UserButton />, or the framework equivalent. - Have them create an organization from the switcher and invite a teammate.
If no, point them to Organizations, Components, and the Clerk Dashboard.
Other versions8 projects use a version of this.
Word for word · 0
None found.
Edited · 3
- clerk/skills★ 8965% same
- HamedMP/matrix-os★ 8511% same
- elpiarthera/vantage-starter★ 011% same
Wrote their own version · 5
- adrianhajdin/ghost-ai★ 332same name
- delorenj/skills★ 18same name
- Aymenjdily/biblion-testing-agentic-ai-skills★ 2same name
- sanketbodke/skew-ai★ 0same name
- Visitha2001/ghost-ai-sse★ 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.
Used alongsideProjects with it also use clerk-billing.
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.
sanketbodkeSkillclerk-billing
Clerk Billing for subscription management - render Clerk's PricingTable
Also in 3 projects that use this
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- clerk-backend-apiSkill
- clerk-cliSkill
- clerk-custom-uiSkill
- clerk-expoSkill
- clerk-orgsSkill
- clerk-testingSkill
- clerk-webhooksSkill
- create-agent-with-sanity-contextSkill
- dial-your-contextSkill
- expo-animationSkill
- expo-data-fetchingSkill
- expo-design-systemSkill
- expo-project-structureSkill
- expo-routerSkill
- shape-your-agentSkill
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.

