CLI

CLI Overview

l4 is the official LevelFour command-line tool. It surfaces the same data as the dashboard — recommendations, costs, integrations — plus terminal-only features like local Terraform cost estimation, structured output for scripting, and an interactive TUI for browsing recommendations.

Installation

brew install LevelFourAI/tap/levelfour

See Installation for go install, GitHub releases, and shell completion.

Quick start

l4 auth login                                  # browser-based authentication
l4 whoami                                      # confirm identity
l4 costs summary                               # KPI overview
l4 recommendations list --status available     # pending savings opportunities
l4 estimate ./infra/                           # estimate Terraform costs locally

Two binaries, same tool

The package installs two binaries with identical behavior:

  • levelfour — long form, useful when l4 collides with another tool on your PATH
  • l4 — short form, recommended for everyday use

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

Command groups

GroupCommands
Corecosts, recommendations, integrations, status, estimate, diff, export, api, whoami
Authenticationauth login, auth logout, auth status, login (alias)
Configurationconfig, completion

Run l4 <command> --help (or --help on any subcommand) for the full flag list.

Global flags

FlagEffect
--jsonOutput 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
--csvCSV output (export commands only)
--quiet / -qSuppress output; communicate via exit code
--no-colorDisable ANSI colors (also honored: NO_COLOR env var)
--web / -wOpen the equivalent dashboard URL instead of printing
--token <key> / -tOne-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.

Exit codes

CodeMeaning
0Success
1General error
2Issues found — e.g. l4 estimate --fail-above triggered, or recommendations exceed a threshold in CI
4Authentication required — no token, expired token, or invalid token
130Interrupted (SIGINT, e.g. Ctrl+C)

These are stable — script against them.

Where authentication is stored

l4 resolves credentials in this order on every command:

  1. The --token / -t flag
  2. The LEVELFOUR_TOKEN environment variable
  3. The OS keychain (macOS Keychain, Linux Secret Service, Windows Credential Vault) — populated by l4 auth login

In CI, set LEVELFOUR_TOKEN from a secret. Locally, l4 auth login is the friendliest path.

Reporting issues

File CLI bugs at github.com/LevelFourAI/levelfour-cli/issues. Include l4 --version output and the failing command.