> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ada.cx/llms.txt.

# Output and exit codes

In a terminal, adacli prints readable tables. An AI assistant adds `--json` after the command name to get JSON, and reads the typed exit code to check the result. This page lists the global options, the output modes, and the exit codes.

> **Warning**
>
> Do not build an integration or a script on adacli. adacli is for a person or an AI assistant that works in a terminal. A release that removes or changes a command name, an option name, or an exit code increases the major version. Most output comes from the Ada service, so it can change without a new adacli release. Only the latest release of adacli is supported. For details, see [Versioning](/adacli/versioning) and [Supported releases](/adacli/versioning#supported-releases). To build an integration, use the [Ada API](/reference/introduction/overview). The Ada API is the only stable interface.

## Global options

Put a global option after the instance and before the command name:

```bash
adacli acme --output json alerts rules list
```

An option after the command name fails with `unknown option`, unless the command has its own option with that name. `--session` works in any place.

When a command has its own option with the same name as a global option, the command reads only its own option. For example, `mcp-tools delete` has its own `--yes`. `adacli acme --yes mcp-tools delete <id>` does not confirm the delete: the command prints that it needs a confirmation, exits with code `0`, and deletes nothing. Put `--yes` after the command name: `adacli acme mcp-tools delete <id> --yes`.

Not every command reads the global output options yet. A command that does not read them prints tables. To get JSON, put `--json` after the command name. Most commands have their own `--json` option:

```bash
adacli acme knowledge list --json
```

| Option            | Description                                                                                           |
| ----------------- | ----------------------------------------------------------------------------------------------------- |
| `--json`          | Prints JSON on stdout.                                                                                |
| `--output <mode>` | Sets the output mode: `table`, `json`, or `quiet`.                                                    |
| `-q`, `--quiet`   | Prints minimal output. A list prints only the IDs.                                                    |
| `--no-color`      | Prints no color.                                                                                      |
| `-y`, `--yes`     | Skips the confirmation prompts of a command that has no `--yes` option of its own.                    |
| `--session <id>`  | Connects the command to a session from [`session-tracking start`](/adacli/commands/session-tracking). |
| `-h`, `--help`    | Shows the help for a command.                                                                         |
| `-V`, `--version` | Shows the adacli release.                                                                             |

## Output modes

A command that reads the global output options selects the output mode in this order:

1. The `--json`, `--output`, or `--quiet` option.
2. The `ADACLI_OUTPUT` environment variable, set to `table`, `json`, or `quiet`.
3. JSON when stdout is not a terminal, for example when you pipe the output to another command. Otherwise, tables.

A command that has its own `--json` option prints JSON when you put `--json` after the command name, whatever the output mode.

To read one value from the output in a terminal, use `--json` with a tool such as `jq`:

```bash
adacli acme playbooks list --json | jq '.playbooks[] | select(.is_active == true) | .name'
```

## Errors

When a command fails in JSON mode, adacli writes the error to stderr as JSON. Stdout stays empty, so an AI assistant does not read the error as data.

`status` is an exception. When there is no working session, `status --json` writes `not_logged_in` or `session_invalid` to stdout and nothing to stderr. See [Sessions](/adacli/commands/sessions).

```json
{
  "error": {
    "code": "SESSION_EXPIRED",
    "category": "auth",
    "message": "Session expired. Please log in again.",
    "exitCode": 3,
    "hint": "Run: adacli <instance> login"
  }
}
```

`hint` tells you what to do next. For a usage error, `allowed` lists the values that the option accepts.

## Exit codes

An AI assistant reads the exit code to check the result of a command. The text of a message can change, so the exit code is the result to check.

| Code | Meaning                                                                             |
| ---- | ----------------------------------------------------------------------------------- |
| `0`  | The command succeeded.                                                              |
| `1`  | The Ada service returned an error, or adacli failed.                                |
| `2`  | The command, an argument, or an option is not valid.                                |
| `3`  | You are not logged in, or the session expired.                                      |
| `4`  | Your role does not allow the action.                                                |
| `5`  | The item does not exist.                                                            |
| `6`  | Too many requests. Wait, then try again.                                            |
| `7`  | The item cannot be changed.                                                         |
| `8`  | adacli cannot connect to the Ada service.                                           |
| `9`  | The item is in a state that refuses the request. For example, a limit is reached.   |
| `20` | A command that reads many pages stopped before the end. The output is not complete. |
| `21` | A command that reads many pages found nothing in the date range.                    |
| `22` | A read returned empty, and adacli cannot confirm the result.                        |
| `23` | A handoff integration reconnected, but adacli cannot confirm the new connection.    |

Codes 20 to 23 are not failures. Do not use the output as a complete result:

* With `20`, the command printed the rows that it read to stdout. `conversations export -o <file>` writes them to `<file>.partial` instead, and does not change `<file>`.
* With `21`, `conversations export` writes nothing to stdout and no file.
* With `22` and `23`, the command printed its output to stdout.

To read the exit codes as JSON, run `adacli agent-context`. For details, see [`agent-context`](/adacli/commands/agent-context).

## Environment variables

| Variable                          | Description                                                                                                                 |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `ADACLI_OUTPUT`                   | The default output mode: `table`, `json`, or `quiet`.                                                                       |
| `ADACLI_EMAIL`, `ADACLI_PASSWORD` | The credentials for a login without a browser, for example in a remote terminal. See [Sessions](/adacli/commands/sessions). |
| `ADACLI_NO_UPDATE_CHECK`          | Set to `1` to stop the notice about new releases.                                                                           |
| `NO_COLOR`, `FORCE_COLOR`         | The standard variables that turn color off or on.                                                                           |

---

Have any questions? Contact your Ada team, or email us at [](mailto:help@ada.cx?subject=Help%20Docs%20inquiry).