Skip to main content
All posts
Updated

The LevelFour CLI: Cloud Costs and Savings From Your Terminal

l4 brings costs, savings, commitments, and Terraform estimates to the terminal and to CI, with output built for scripts.

Gabriel Nielsen
Ler em portuguêsA CLI da LevelFour: custos de cloud e economia no seu terminal

Engineers check deploys, logs, and pull requests from a terminal. l4, the LevelFour CLI, puts cloud cost there too: what you spent, what you can save, and what a Terraform change will cost before you apply it.

Install and sign in

Terminal
brew install LevelFourAI/tap/levelfour
l4 auth login
l4 whoami

l4 auth login opens your browser and signs you in, and l4 whoami prints the identity and organization the credential resolved to. That login mints a read key. The commands that record a decision need a read-write key, which you create in the dashboard under Settings > API Keys. In CI, set LEVELFOUR_TOKEN from a secret.

The install also ships a long-form levelfour binary for machines where l4 collides with another tool, and the installation docs cover go install and prebuilt archives for Linux and Windows.

What it does

  • Costs: l4 costs summary gives the overview, and l4 costs breakdown --tui opens an interactive view where you drill into a row and change the grouping.
  • Savings: l4 recommendations list shows what LevelFour found, and with a read-write key, rec accept and rec reject record the decision and rec execute starts the rollout.
  • Commitments: coverage, utilization, renewals, and the terms that expire soon, for AWS and Google Cloud. Every l4 commitments command is read-only.
  • Tags: provider tags and virtual tags with their coverage and costs, and l4 tags preview, a dry run that shows the spend each value would take before you create or replace a virtual tag from a YAML file.
  • Estimates: l4 estimate prices the Terraform in a directory, and l4 diff prices what a change adds.
  • AI agents: l4 mcp install writes the LevelFour MCP server into Claude Code, Claude Desktop, Cursor, VS Code, and Windsurf in one command.

Built for scripts

Every command takes the same output flags: --json, --jq to filter in process, and --template for Go templates. JSON paths and exit codes stay stable across releases: 2 means a check found something, and 4 means no credential resolved. This recipe lists the ten largest savings:

Terminal
l4 recommendations list \
  --sort-by monthly_savings --sort-order desc \
  --page-size 10 \
  --jq '.data.data.items[] | {id: .recommendation_id, service, savings: .monthly_savings}'

A cost gate in CI

Run l4 estimate in the pipeline with a threshold. The job exits with code 2 once the monthly total passes it, so the pipeline can stop before anything deploys. A job with no token exits 4, so branch on 2 alone. --format github-comment shapes the estimate for a pull request comment, and the CI/CD guide has the GitHub Actions and GitLab CI jobs.

Terminal
l4 estimate --fail-above 500 -q ./infra/

Get started

The CLI docs cover installation, authentication, every command, and recipes tested against the live API. The CLI is open source on GitHub, where you can file issues.

Start with LevelFour and run your first l4 costs summary in minutes.

Frequently asked questions

How do I install the LevelFour CLI?

Run brew install LevelFourAI/tap/levelfour with Homebrew. The docs also cover go install and prebuilt archives, Windows included.

Does the CLI change resources in my cloud?

No command touches your cloud account itself. With a read-write key, rec accept and rec reject record a decision in LevelFour, and rec execute starts its rollout there.

Can I use the CLI as a cost check in CI?

Yes. l4 estimate --fail-above exits with code 2 when the monthly Terraform estimate passes your threshold, and l4 diff gates on what a change adds. What is shift-left FinOps?.

More posts

See what LevelFour can save you