# Migrate users to Clerk with the CLI

The [Clerk CLI](https://clerk.com/docs/cli.md) can now migrate users from other platforms into Clerk. `clerk migrate export` pulls users out of your current platform, and `clerk migrate import` checks each one against your instance before it creates anything. The new `clerk-migrate` skill gives your agent the same commands, so it can run the migration for you or write a source for a platform the CLI doesn't support yet.

## Get the latest CLI and skills

`clerk migrate` ships in Clerk CLI 4.2.0 and later. Update the CLI, or install it if you haven't yet:

```bash
$ # Update an existing install
$ clerk update

$ # Or install it globally
$ npm install -g clerk
```

Install Clerk's skills to get `clerk-migrate`:

```bash
$ npx skills add clerk/skills
```

If you already have Clerk's skills, add the new one with `npx skills add clerk/skills --skill clerk-migrate`.

## Migrate with your agent

Ask your agent to migrate your users to Clerk. The skill exports your users, runs a dry run against your instance, and shows you what the checks found. It imports only after you approve.

Try prompts like:

- "Migrate my users from Supabase to Clerk"
- "Write a migration source for this user export"

## Migrate from a supported platform

The CLI exports from Auth0, Auth.js, Better Auth, Firebase, Supabase, WorkOS, and other Clerk instances. To run a migration yourself, sign in with `clerk auth login` and `clerk link`, or set `CLERK_SECRET_KEY` to the Secret Key of the instance you're importing into. Then run:

```bash
$ clerk migrate export supabase                  # prints a run ID
$ clerk migrate import <export_run_id> --dry-run # checks, writes nothing
$ clerk migrate import <export_run_id> --yes     # imports
```

A development instance holds 100 users by default, and the dry run checks the import against it. Production has no limit: add `--instance prod` to both import commands, or use your production instance's Secret Key.

Supabase, Firebase, and Better Auth exports carry password hashes, so those users keep their passwords. Each platform's migration guide lists the exceptions. `clerk migrate sources` shows what each source carries, including passwords and MFA.

The import records every user's outcome, and running the same command again continues a run that stopped partway. `clerk migrate runs` shows what each run did, and `clerk migrate undo <import_run_id>` deletes the users an import created.

## Migrate from any other platform

For a platform without a built-in source, give your agent the export file and ask it to write a Clerk migration source. The skill asks how your platform records email verification and hashes passwords, writes the source, and checks it with `clerk migrate sources`.

To write the source yourself, create a `.ts` or `.js` file in your project that maps your export's fields onto Clerk's user schema, then pass its path:

```bash
$ clerk migrate sources ./my-platform.ts
$ clerk migrate import users.json --source ./my-platform.ts --dry-run
```

See [Write a custom source](https://clerk.com/docs/guides/development/migrating/custom-source.md) for the source format.

## Get started

See the [migration guides](https://clerk.com/docs/guides/development/migrating/overview.md) for each platform's export steps.
