# CLI Overview

> The l4 command line tool. Install it, sign in, and run your first commands, then the command groups, the global flags every command takes, and the exit codes to script against.

Source: https://docs.levelfour.ai/cli


`l4` runs LevelFour from the terminal. The official client reaches the same costs, recommendations and integrations as the dashboard, and adds what only a terminal can do: Terraform and CloudFormation cost estimates before you deploy, structured output for scripting, and an interactive TUI for browsing recommendations.

## Quick start

### Install

```bash
brew install LevelFourAI/tap/levelfour
```

See [Installation](/cli/installation) for `go install`, prebuilt archives including Windows, and shell completion.

### Sign in

```bash
l4 auth login
```

This opens your browser and signs you in. See [Authentication](/cli/authentication) for CI, where there is no browser to open.

### Confirm identity

```bash
l4 whoami
```

> **Success**
>
> Your identity and organization printing back is the proof that a credential resolved and is bound to an organization. Exit code `4` instead means no credential resolved.

### Run something

```bash
l4 costs summary
l4 recommendations list --status available
l4 estimate ./infra/
```

`l4 costs summary` is the KPI overview, `l4 recommendations list --status available` shows pending savings opportunities, and `l4 estimate ./infra/` estimates the cost of the Terraform and CloudFormation under `./infra/`. [Recipes](/cli/recipes) has longer pipelines.

## Two binaries, same tool

A single `brew install LevelFourAI/tap/levelfour` ships two interchangeable binaries with identical behavior, both from the one cask:

* `l4`: short form, recommended for everyday use
* `levelfour`: long form, useful when `l4` collides with another tool on your `PATH`

Throughout the docs we use `l4`. Substitute `levelfour` if you prefer.

## Command groups

| Group                                        | Commands                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Core**                                     | [`costs`](/cli/commands/costs), [`recommendations`](/cli/commands/recommendations), [`integrations`](/cli/commands/integrations), [`status`](/cli/commands/status), [`estimate`](/cli/commands/estimate), [`diff`](/cli/commands/diff), [`export`](/cli/commands/export), [`api`](/cli/commands/api), [`whoami`](/cli/authentication#inspect-the-active-session)                                                                                                                                                                                         |
| **Recommendation writes**                    | [`rec accept`](/cli/commands/recommendations/accept), [`rec reject`](/cli/commands/recommendations/reject), [`rec execute`](/cli/commands/recommendations/execute)                                                                                                                                                                                                                                                                                                                                                                                       |
| **[Commitments](/cli/commands/commitments)** | [`commitments summary`](/cli/commands/commitments#summary), [`commitments list`](/cli/commands/commitments#list), [`commitments expiring`](/cli/commands/commitments/expiring), [`commitments view`](/cli/commands/commitments#view), [`commitments renewal`](/cli/commands/commitments/renewal), [`commitments utilization`](/cli/commands/commitments#utilization), [`commitments coverage`](/cli/commands/commitments/coverage), [`commitments plan`](/cli/commands/commitments#plan), [`commitments contracts`](/cli/commands/commitments#contracts) |
| **Tags**                                     | [`tags list`](/cli/commands/tags/list), [`tags show`](/cli/commands/tags/show), [`tags coverage`](/cli/commands/tags/coverage), [`tags resources`](/cli/commands/tags/resources), [`tags costs`](/cli/commands/tags/costs), [`tags preview`](/cli/commands/tags/preview), [`tags apply`](/cli/commands/tags/apply), [`tags delete`](/cli/commands/tags/delete)                                                                                                                                                                                           |
| **[Cost alerts](/cli/commands/alerts)**      | [`alerts list`](/cli/commands/alerts#list), [`alerts get`](/cli/commands/alerts#get), [`alerts sources`](/cli/commands/alerts#sources), [`alerts events`](/cli/commands/alerts#events), [`alerts create`](/cli/commands/alerts/create), [`alerts update`](/cli/commands/alerts/update), [`alerts pause`](/cli/commands/alerts#pause-and-resume), [`alerts resume`](/cli/commands/alerts#pause-and-resume), [`alerts delete`](/cli/commands/alerts/delete)                                                                                                |
| **Agent integration**                        | [`mcp install`](/cli/commands/mcp/install), [`mcp uninstall`](/cli/commands/mcp/uninstall), [`mcp status`](/cli/commands/mcp/status), [`mcp serve`](/cli/commands/mcp/serve)                                                                                                                                                                                                                                                                                                                                                                             |
| **[Authentication](/cli/authentication)**    | `auth login`, `auth logout`, `auth status`, `login` (alias)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| **Configuration**                            | [`config`](/cli/commands/config), [`telemetry`](/cli/commands/telemetry), [`completion`](/cli/installation#shell-completion)                                                                                                                                                                                                                                                                                                                                                                                                                             |

Run `l4 <command> --help` (or `--help` on any subcommand) for the full flag list. `rec` and `recs` are aliases for `recommendations`, and `costalerts` for `alerts`.

## Global flags

| Flag                   | Effect                                                                 |
| ---------------------- | ---------------------------------------------------------------------- |
| `--json`               | Output as JSON for piping to `jq` or other tools                       |
| `--jq <expr>`          | Filter the JSON output with a `jq` expression in-process               |
| `--template <tpl>`     | Format output with a Go text template                                  |
| `--csv`                | CSV output (export commands only)                                      |
| `--quiet` / `-q`       | Suppress output; communicate via exit code                             |
| `--no-color`           | Disable ANSI colors. The `NO_COLOR` environment variable does the same |
| `--web` / `-w`         | Open the equivalent dashboard URL instead of printing                  |
| `--token <key>` / `-t` | One-shot token override                                                |
| `--api <url>`          | Point at a non-default API base URL                                    |

`--quiet` is mutually exclusive with `--json`, `--jq`, `--template`, and `--csv`. See [Output formats](/cli/output-formats) for what each one emits.

## Exit codes

| Code  | Meaning                                                                                                                                                                                                      |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `0`   | Success                                                                                                                                                                                                      |
| `1`   | General error                                                                                                                                                                                                |
| `2`   | Issues found (`l4 estimate --fail-above` triggered, `l4 commitments expiring --fail-within` found a lapsing term, `l4 tags apply --dry-run` found a difference, or recommendations exceed a threshold in CI) |
| `4`   | Authentication required (no token, expired token, or invalid token)                                                                                                                                          |
| `130` | Interrupted (`SIGINT`, e.g. Ctrl+C)                                                                                                                                                                          |

These are stable. Script against them.

## Credentials

`l4` looks for a credential in the `--token` flag, then the `LEVELFOUR_TOKEN` environment variable, then the OS keychain. Set `LEVELFOUR_TOKEN` from a secret in CI. On a laptop, run `l4 auth login`.

[Authentication](/cli/authentication) has the full resolution order, the keychain each platform uses, and the troubleshooting table.

## Reporting issues

File CLI bugs at [github.com/LevelFourAI/levelfour-cli/issues](https://github.com/LevelFourAI/levelfour-cli/issues). Include `l4 --version` output and the failing command.

## Next

* [Installation](/cli/installation) has `go install`, prebuilt archives, CI images and shell completion
* [Authentication](/cli/authentication) is the credential order in full, and the read-write key the write commands need
* [Output formats](/cli/output-formats) is what `--json`, `--jq`, `--template` and `--csv` emit
* [Commands](/cli/commands/costs) is the per-command reference
* [Recipes](/cli/recipes) has shell pipelines validated against the live API
* [MCP](/mcp) is the same data inside an assistant
