# Migrate an older CLI

> Move a CLI that Okibi's earlier, agent-led generator built onto the pipeline, review what changed, and publish it.

CLIs made before the pipeline were built by an agent that planned them in `cli-spec.md`. They keep working, and they keep regenerating that way, until you migrate them. A migration rebuilds the CLI with the current generator. It's free.

After it, the CLI has everything a pipeline CLI has: [the studio](https://okibi.ai/docs/guides/studio.md), [the pipeline](https://okibi.ai/docs/guides/pipeline.md), and agent ready optimization.

## What a migration does

- **A published CLI** keeps its commands, flags, and requests. Okibi compares the new CLI with the one people use and reports every difference. Nothing publishes until you've reviewed it.
- **An unpublished CLI** is rebuilt from its source, with nothing to compare.

## Start it

**In the app**

A CLI an older generator built shows a banner on every page of the project, except while a build runs: "my-cli was built with an older Okibi generator." Click **Migrate**, then **Migrate** again to confirm. The banner follows the rebuild.

**In the CLI**

```sh
okibi migration show my-cli
okibi migrate my-cli
```
`migration show` says where the CLI stands. `migrate` asks first, starts the migration, follows it, and prints the review. Add `--yes` to skip the question, and `--no-wait` to return at once. In the TUI, run `/migrate my-cli`.

A migration won't start while a build is still running, or while the CLI has an open release pull request. Close the pull request first.

## Review the differences

Once it's built, the review lists:

- the OpenAPI document the CLI now builds from;
- each check, such as "Same where compared";
- each **blocking difference**: a way the new CLI differs from the one people use, with what it was before and after;
- other differences, what was added, and what wasn't compared.

Read each blocking difference before you accept it. Accepting one says that change is fine for your users.

**In the app**

Click **Review** on the banner. Blocking differences are listed under **Needs your OK**. Tick each one you accept.

**In the CLI**

```sh
okibi migration show my-cli
okibi migration accept my-cli '<difference-id>'
okibi migration accept my-cli --all
okibi migration unaccept my-cli '<difference-id>'
okibi migration unaccept my-cli --all
```
`migration show --wait` follows a running migration and shows the review once it's built.

## Publish it

When every blocking difference is accepted, publish the migration's build:

```sh
okibi runs publish <run-id>
```

In the app, click **Publish** in the review. If Publish fails, the banner says why. You can press it again, unless the banner offers **Migrate again** instead.

## If it fails

A failed migration leaves your current CLI as it is. After a failed attempt, the banner offers **Migrate again**. A CLI whose attempts are spent says "the migration failed, and we've been notified".

- [The studio](https://okibi.ai/docs/guides/studio.md): Change the migrated CLI with okibi.yml.
- [okibi migration](https://okibi.ai/docs/cli/reference/migration.md): Every migration command and flag.
