The Clerk CLI is a command-line tool for you and your agents to set up and manage Clerk authentication directly from the terminal. It supports 10+ frameworks.
Run clerk init in your project directory to get started:
terminal
clerkinit
This command auto-detects your framework, installs the appropriate Clerk SDK, and applies framework-specific setup such as auth pages, middleware, and providers. If you're authenticated with clerk auth login, it also links your project to a Clerk application and pulls your environment variables automatically.
You can also use clerk init --starter to bootstrap a brand new project from a starter template, or run clerk init without an account to get started immediately with temporary development keys.
Create an iOS or macOS SwiftUI app in Xcode with File > New > Project and the App template, or use an app you already have. In your terminal, open the folder containing its Xcode project or workspace, then run:
terminal
clerkinit
This command detects your app, guides you through selecting or creating a Clerk application, installs the SDK, and configures supported capabilities and native registration. It also offers to enable native Sign in with Apple. Xcode is required.
For an unchanged SwiftUI app created from Xcode's App template, it also initializes Clerk and offers to add a prebuilt sign-in screen. For an app you've already customized, finish the Swift integration yourself or with your agent using the iOS Quickstart, then build and test sign-in.
To create a new app without opening Xcode, run clerk init --starter and choose iOS (SwiftUI) or macOS (SwiftUI). The CLI asks for an app name, Bundle ID, and Apple Developer team, then creates the Xcode project and configures Clerk.
Create an Android app in Android Studio with the Empty Activity template, or use an app you already have. In your terminal, open the project's root folder (the one containing settings.gradle.kts or settings.gradle), then run:
terminal
clerkinit
This command finds your app module and guides you through selecting or creating a Clerk application. For supported project layouts, it adds the Clerk Android SDK to your Gradle build and initializes Clerk in an Application class with your development Publishable Key. It registers your app's package name and debug signing certificate fingerprint when available, and reports any setup it can't complete. It also offers to enable native Sign in with Google. It reads your Gradle files as text and never runs Gradle, so it works on any operating system.
If the CLI needs a debug signing fingerprint it can't find, build the app once and retry, or pass the certificate's SHA-256 with --android-fingerprint.
For an unchanged Empty Activity app that matches the CLI's template, it also offers to add a prebuilt sign-in screen. Otherwise, finish the Kotlin integration yourself or with your agent using the Android QuickstartAndroid Icon, then build and test sign-in.
To create a new app without opening Android Studio, run clerk init --starter and choose Android (Jetpack Compose). The CLI asks for an app name and package name, then creates the Gradle project and configures Clerk. Building the app still requires the Android SDK and a JDK 17 or later.
Note
clerk init doesn't currently support scaffolding for this SDK. You can still use the CLI for app and environment management.
Set up authentication — clerk init detects your framework, installs the SDK, and applies supported authentication setup.
Manage your account and project link — clerk auth login and clerk auth logout manage your CLI session, clerk whoami shows the current account and linked application, and clerk link / clerk unlink connect or disconnect a project.
Manage environment variables for projects that use environment files — clerk env pull pulls your Clerk API keys into your project's env file. Pass --print to print them instead, for example, to add production keys to your hosting provider.
Configure your instance — clerk config pull and clerk config patch let you manage your Clerk instance's auth settings as code.
Audit your instance's security — clerk security grades your instance against Clerk's security recommendations, such as bot protection, breached password detection, user lockout, and multi-factor authentication. clerk security fix applies the recommendations you pick as a single config change, and --dry-run previews the diff first. Run clerk security checks to list every recommendation.
Deploy to production — clerk deploy walks you through promoting a Clerk app from development to production: registering your domain, configuring DNS, and gathering OAuth credentials. Pass --domain <domain> to skip the domain prompt and --yes to skip the confirmations before the production instance is created. Use clerk deploy status to verify deploy completeness.
Access the Clerk API — clerk api is an authenticated client for Clerk's Backend API. Target the Platform API with --platform, or query the public, unauthenticated Frontend API with --fapi. Run clerk api ls to explore available endpoints.
Run diagnostics — clerk doctor validates your project's Clerk integration and flags common issues, including whether your configured Clerk MCP server is reachable. Pass --fix to attempt automatic fixes.
Connect AI clients to Clerk's MCP server — clerk mcp install registers Clerk's MCP server in the AI clients detected on your machine, such as Claude Code, Cursor, and VS Code. clerk mcp list shows what's registered, and clerk mcp uninstall removes it.
Manage applications — clerk apps list and clerk apps create let you view and create Clerk applications from the terminal.
Manage users — clerk users list, clerk users create, and clerk users open work with Clerk users directly. For anything the curated commands don't cover, use clerk api /users.
Migrate users from another provider — clerk migrate export pulls users out of Auth0, Auth.js, Better Auth, Firebase, Supabase, WorkOS, or another Clerk instance, and clerk migrate import creates them in Clerk. clerk migrate runs shows what each run did, and clerk migrate undo deletes the users an import created. For any other platform, write a custom source, check it with clerk migrate sources ./my-platform.ts, and import with clerk migrate import users.json --source ./my-platform.ts. See the migration guides.
Query Application Logs — clerk logs lists your instance's Application Logs, with filters for time range, user, event type, and payload fields. clerk logs --follow prints recent logs before streaming new arrivals, and clerk logs get shows the logs of one sign-in or sign-up.
Impersonate a user — clerk impersonate (alias clerk imp) mints a short-lived sign-in link so you can sign in as one of your users to reproduce an issue. Every session is traceable to your logged-in account, and you can revoke a pending token with clerk imp revoke.
Test webhooks locally — clerk webhooks listen opens a relay tunnel that forwards Clerk webhook deliveries to your local server, and clerk webhooks verify checks a delivery's signature offline. Neither requires a linked project.
Toggle features — clerk enable and clerk disable turn features like organizations and billing on or off for your instance.
Open the Dashboard — clerk open launches the Clerk Dashboard in your browser from the terminal.
Maintain the CLI — clerk update updates the CLI to the latest version, and clerk completion generates shell autocompletion for bash, zsh, fish, and PowerShell.
New commands can ship as experimental first. They stay off until you turn them on with the CLERK_EXPERIMENTAL environment variable, and they may change or be removed without notice. While a command is off, clerk --help and shell completion leave it out. If you run it, the CLI returns an experiment_disabled error that tells you what to set.
To turn on an experimental command, set CLERK_EXPERIMENTAL to its name:
That turns it on for one run. To keep it on for your shell session, export the variable with export CLERK_EXPERIMENTAL=<experimental_command>. To turn on more than one, separate the names with commas, such as CLERK_EXPERIMENTAL=<first_command>,<second_command>. Names are case-insensitive, and the CLI ignores ones it doesn't recognize.
The CLI is designed to work with AI coding agents:
Automatic agent detection — The CLI auto-detects agent vs. human mode. Non-TTY environments default to agent mode, or you can set it explicitly with --mode agent.
Agent-friendly setup — For supported projects, clerk init -y applies setup non-interactively. For native iOS and macOS apps, follow the iOS setup promptiOS Icon, and for native Android apps, the Android setup promptAndroid Icon. Both existing projects and new --starter projects support --json for missing inputs, recovery steps, and remaining Swift or Kotlin integration tasks.
Application link protection — Agents can pass --app <application_id> to select a Clerk application. In agent mode, if setup would replace an existing link, the CLI stops and requires --relink to confirm the switch. Inside a Git repository, that link is shared across its projects.
Structured input — Pass command options as a JSON string with --input-json (inline, @file.json, or - for stdin) instead of individual flags.
Security audits — In agent mode, clerk security audit returns JSON with each finding's status and severity, plus the exact config patch for findings that a config change can fix. clerk security fix requires the recommendation IDs or --all, plus --yes to apply them. Recommendations that need a product decision take --factors (multi-factor authentication) or --strategy (passwordless sign-in).
Production deploys — clerk deploy --domain <domain> --mode agent creates or resumes the production instance without prompting and returns a JSON report of the remaining steps, such as DNS records to add and OAuth credentials to enter. Without --domain, it only returns the report.
Clerk Skills — Accept the optional prompt during clerk init (which installs Clerk's agent skills, including clerk-cli), or run npx skills add clerk/skills anytime, to install Clerk Skills — giving your AI agent deeper knowledge about Clerk's SDKs and patterns.
Clerk MCP server — clerk mcp install connects your AI clients to Clerk's MCP server, which serves up-to-date Clerk SDK snippets and implementation patterns. In agent mode it runs non-interactively, targets all detected clients by default, and reports per-client results as JSON.
The CLI's curated commands don't cover every Clerk feature, but clerk api can reach any Backend API or Platform API endpoint. A few things are only available in the Clerk Dashboard: analytics and usage metrics, email logs, managing your Clerk workspace (team members, plan, and billing for your Clerk subscription), Account Portal branding and customization, and Clerk Protect security settings.
The CLI supports frameworks such as Next.js, React, Vue, Nuxt, Astro, React Router, TanStack Start, iOS, macOS, Android, and more. Native Apple setup requires Xcode, and clerk init --starter can create the Xcode project. Native Android setup works on any operating system, and clerk init --starter can create the Gradle project. Some frameworks like Expo, Express, and Fastify are supported for SDK installation but don't yet include full scaffolding. Run clerk init --help for the current list.