> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bymiles.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Miles CLI reference

> The complete public command interface for Miles when it is used through a coding agent.

This is the public CLI API used by the Miles skill. It is for agents and developers that need exact commands, flags, result types, and recovery behavior.

Most people do not need to run these commands themselves. See [Miles + Coding Agents](/coding-agent/why-add-miles) for the collaborative workflow.

## How the CLI works

The agent normally runs `miles <command>`. Commands operate on the active Miles site saved on that machine. Use `miles sites` to list known sites, `miles site-attach <siteId>` to resume one from anywhere, and `miles use <siteId>` to switch between locally known sites.

Use `--json` when an agent needs a structured result. It is supported by the commands documented in this reference. Human-readable output is the default.

The CLI is the supported API surface. The service routes it uses are not a separate public HTTP API.

## Canonical commands

Use the canonical names below for new integrations. Earlier names remain as compatibility aliases and are listed in [Lifecycle and compatibility](/reference/miles-cli/lifecycle-and-compatibility).

| Area               | Commands                                                                                     |
| ------------------ | -------------------------------------------------------------------------------------------- |
| Account            | `auth`, `account-status`, `usage-history`, `doctor`                                          |
| Sites              | `site-create`, `sites`, `site-attach`, `use`, `site-state`, `site-plan`, `history`, `rename` |
| Design and build   | `say`, `upload-assets`, `design-directions`, `build-site`, `screenshot`                      |
| Jobs and safety    | `wait-job`, `cancel`, `approval-respond`, `undo`                                             |
| WordPress          | `wordpress-detect`, `wordpress-setup`, `connect-browser`, `convert-theme`                    |
| Files and delivery | `site-pages`, `export`                                                                       |

## Modes

| Mode        | Meaning                                                                                |
| ----------- | -------------------------------------------------------------------------------------- |
| Headless    | The command can complete without a connected browser.                                  |
| Browser     | The Miles workspace must be open and connected before the command can finish.          |
| Local       | The command works with files on the current computer and may need WordPress or WP-CLI. |
| Conditional | The command can start headlessly, but the resumed work may require a browser.          |

## Outcomes and exit codes

Long-running work returns an outcome. Do not treat printed text as proof that a request completed.

| Exit code | Outcome                          | What an agent should do                                              |
| --------- | -------------------------------- | -------------------------------------------------------------------- |
| `0`       | completed                        | Continue, while still relaying any Miles question.                   |
| `1`       | failed or aborted                | Read the error and recovery guidance before deciding what to do.     |
| `2`       | precondition missing             | Fix login, site selection, arguments, or unsupported capability.     |
| `3`       | browser connection required      | Connect the Miles workspace and retry the same command once.         |
| `4`       | blocked or declined              | The work did not happen. Involve the user when a decision is needed. |
| `5`       | capacity or work already running | Wait for the existing run; do not start a duplicate.                 |

`wait-job --json` returns a structured result with fields such as `outcome`, `phase`, `milesMessage`, `question`, `approvalRequired`, `directions`, `siteReady`, `errorId`, `recovery`, `credits`, and `sessionMemory`.

Next: [Authentication and account](/reference/miles-cli/auth-and-account).
