# Use the CLI with AI coding agents

**Check that the CLI is ready for your coding agent and install the commercetools AI plugin from the terminal.**

The CLI is designed to be run by AI coding agents as well as by people. Commands print structured output when you ask for it, destructive commands can be previewed, and a single command checks whether everything is set up.

This page covers the commands that connect the CLI with the [commercetools AI plugin](/dev-tooling/build-with-ai-overview.md), which bundles the skills and MCP servers for your coding agent.

## Check your setup with doctor

The `doctor` command reports the CLI version and the authentication status. It also lists the AI coding agents installed on the machine and whether the commercetools AI plugin is installed.

```bash title="Check your setup"
commercetools doctor
```

Use `--json` for machine-readable output:

```bash title="Print the result as JSON"
commercetools doctor --json
```

```json title="Example output"
{
  "ok": true,
  "cli": { "version": "0.1.0", "node": "22.23.4", "minVersion": null, "compatible": true },
  "auth": { "authenticated": true, "projectKey": "my-project", "region": "europe-west1.gcp" },
  "agents": [
    { "id": "claude", "detected": true, "pluginInstalled": true },
    { "id": "cursor", "detected": false, "pluginInstalled": null }
  ]
}
```

The `pluginInstalled` value is `true` or `false`, or `null` when the CLI cannot determine the state for that agent. Only agents that are detected on the machine are reported as installed or not installed.

### Require a minimum CLI version

Skills, scripts, and agents can require a minimum CLI version with `--min-version`. The command fails if the installed CLI is older, so the caller knows to update it:

```bash title="Require a minimum version"
commercetools doctor --json --min-version 0.1.0
```

| Exit code | Meaning |
| --- | --- |
| `0` | The CLI satisfies the minimum version, or no minimum was requested |
| `1` | The CLI is older than the requested minimum version |
| `2` | The value of `--min-version` is not a valid version, for example `latest` |

## Install the AI plugin

The `ai install` command installs the commercetools AI plugin into your coding agent, so you do not need to know the plugin commands of each agent.

```bash title="Install the plugin for detected agents"
commercetools ai install
```

Without `--agent`, the command installs the plugin for every agent it detects on the machine. To choose agents yourself, repeat the flag:

```bash title="Install the plugin for chosen agents"
commercetools ai install --agent claude --agent codex
```

To see the commands without running them, use `--dry-run`:

```bash title="Preview the installation"
commercetools ai install --agent claude --dry-run
```

### Supported agents

| Agent (`--agent`) | What the command does |
| --- | --- |
| `claude` (Claude Code) | Adds the plugin marketplace and installs the plugin with the `claude` command |
| `codex` (OpenAI Codex) | Adds the plugin marketplace and installs the plugin with the `codex` command |
| `copilot` (VS Code/Copilot) | Installs the plugin with the GitHub Copilot CLI when it supports plugins. Otherwise it prints the steps for the VS Code Command Palette. |
| `cursor` (Cursor) | Prints the steps to follow in Cursor, because Cursor installs plugins through its settings |
| `pi` (Pi), `opencode` (OpenCode) | Installs only the skills, using the `skills` CLI |
| `other` | Installs the skills for any agent that reads `SKILL.md` files. Use `--skills-agent <id>` to target one agent, for example `--skills-agent windsurf`. |

If the command for an agent is not available on the machine, the CLI prints the steps to follow manually instead of failing.

### Flags

| Flag | Description |
| --- | --- |
| `--agent` | The agent to install the plugin for. Repeat the flag for several agents. Defaults to every detected agent. |
| `--skills-agent` | With `--agent other`, install the skills for this agent id of the `skills` CLI |
| `--marketplace` | The source of the plugin marketplace. Defaults to `commercetools/commercetools-ai-plugins`. You can also set it with the `COMMERCETOOLS_AI_MARKETPLACE` environment variable, for example to use a mirror. |
| `--dry-run` | Print the commands that would run without running them |
| `--json` | Print the result as JSON. Each agent has a `status` of `installed`, `planned`, `manual`, or `failed`. |

The command exits with a non-zero code if an installation fails.

## Run the CLI from an agent

These behaviors make the CLI easier to run from an agent or a script:

- Pass `--json` where it is available to get output you can parse.
- Run `--dry-run` first on commands that change or delete resources, and pass `--yes` to skip confirmation prompts in non-interactive runs.
- Run `commercetools doctor --json --min-version <version>` at the start of a workflow to check that the CLI is recent enough.
- Run `commercetools <topic> <command> --help` to discover flags and examples.

For the list of commands that support these flags, see [Common flags](/dev-tooling/cli/overview.md#common-flags).

## Related pages

- [Area overview page with navigation](/dev-tooling.md)
- [Previous page: Import](/dev-tooling/cli/import.md)
- [Search documentation and API specs](/search.md)