# Clerk CLI

The Clerk CLI is a command-line tool for you and your agents to set up and manage [Clerk](https://clerk.com/) authentication directly from the terminal. It supports 10+ frameworks.

## Installation

Install the CLI globally, or run it directly without installing using `npx clerk` or `bunx clerk`.

**npm**

filename: terminal
```bash
$ npm install -g clerk
```

**pnpm**

filename: terminal
```bash
$ pnpm install -g clerk
```

**yarn**

filename: terminal
```bash
$ yarn global add clerk
```

**bun**

filename: terminal
```bash
$ bun add -g clerk
```

**Homebrew**

filename: terminal
```bash
$ brew install clerk/stable/clerk
```

**curl**

filename: terminal
```bash
$ curl -fsSL https://clerk.com/install | bash
```

## Get started

Run `clerk init` in your project directory to get started:

filename: terminal
```bash
$ clerk init
```

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.

## What you can do

- **Set up authentication** — `clerk init` detects your framework, installs the SDK, and scaffolds your project with Clerk's 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** — `clerk env pull` pulls your Clerk API keys into your project's env file.
- **Configure your instance** — `clerk config pull` and `clerk config patch` let you manage your Clerk instance's auth settings as code.
- **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. Use `clerk deploy status` to verify deploy completeness.
- **Access the Clerk API** — `clerk api` is an authenticated client for Clerk's [Backend API](https://clerk.com/docs/reference/backend-api){{ target: '_blank' }}. Target the [Platform API](https://clerk.com/docs/reference/platform-api){{ target: '_blank' }} 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](https://clerk.com/docs/guides/ai/mcp/clerk-mcp-server.md) 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`.
- **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](https://dashboard.clerk.com) 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.

Run `clerk --help` for a full list of commands.

## AI agent integration

The CLI is designed to work seamlessly 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** — `clerk init -y` runs the full setup non-interactively, skipping all confirmation prompts, which is ideal for AI agents.
- **Structured input** — Pass command options as a JSON string with `--input-json` (inline, `@file.json`, or `-` for stdin) instead of individual flags.
- **Read-only production status** — `clerk deploy --mode agent` returns a JSON snapshot of your production instance's configuration state so your AI agent can inspect progress and recommend next steps.
- **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](https://clerk.com/docs/guides/ai/skills.md) — 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](https://clerk.com/docs/guides/ai/mcp/clerk-mcp-server.md), 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.

## Frequently asked questions (FAQ)

### What can't the CLI do?

The CLI's curated commands don't cover every Clerk feature, but `clerk api` can reach any [Backend API](https://clerk.com/docs/reference/backend-api){{ target: '_blank' }} or [Platform API](https://clerk.com/docs/reference/platform-api){{ target: '_blank' }} endpoint. A few things are only available in the [Clerk Dashboard](https://dashboard.clerk.com): analytics and usage metrics, application and 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.

### Which frameworks are supported?

The CLI supports frameworks such as Next.js, React, Vue, Nuxt, Astro, React Router, TanStack Start, and more. 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.

### Is it open source?

Yes. The CLI is open source and available on [GitHub](https://github.com/clerk/cli).

### How do I report a bug?

Open an issue on the [GitHub repo](https://github.com/clerk/cli/issues) or [contact support](https://clerk.com/contact/support).

### How do I request a feature?

Submit feature requests on Clerk's [public roadmap](https://feedback.clerk.com/roadmap).

---

## Sitemap

[Overview of all docs pages](https://clerk.com/docs/llms.txt)
