CLI Reference

Complete reference for every C3X command, flag, and output format. All commands support the global flags listed at the bottom of this page.

c3x estimate

Parse Terraform configurations and estimate monthly cloud costs. This is the primary command for most workflows.

c3x estimate --path /path/to/terraform

Flags

FlagDescriptionDefault
--pathPath to a Terraform root module directory..
--formatOutput format: json, table, or html.table
--out-fileWrite output to a file instead of stdout.
--usage-filePath to a usage file for variable-cost resources.c3x-usage.yml
--budgetMaximum allowed monthly cost in USD. Exits with code 1 if exceeded.
--budget-increaseMaximum allowed cost increase in USD (compared to current state). Exits with code 1 if exceeded.
--what-ifOverride a resource attribute for what-if analysis. Can be specified multiple times. Format: resource.attr=value.
--offlineUse only the local pricing database. No network calls are made.false
--recommendInclude cost optimization recommendations in the output.false
--show-skippedShow resources that were skipped (unsupported or free-tier).false
--no-cacheDisable caching of pricing data and Terraform plan output.false
--config-filePath to a C3X configuration file.c3x.yml
--terraform-var-filePath to a Terraform .tfvars file. Can be specified multiple times.
--terraform-varSet a Terraform input variable. Format: key=value. Can be specified multiple times.
--terraform-workspaceTerraform workspace to select before planning.default
--terraform-init-flagsAdditional flags passed to terraform init.
--terraform-plan-flagsAdditional flags passed to terraform plan.
--terraform-force-cliForce use of the Terraform CLI for plan generation instead of the built-in HCL parser.false
--include-all-pathsInclude all Terraform root modules found recursively under --path.false
--exclude-pathExclude a path from recursive discovery. Can be specified multiple times.
--project-nameOverride the project name shown in output.Directory name

Examples

# Basic estimate
c3x estimate --path .

# JSON output to file
c3x estimate --path . --format json --out-file estimate.json

# Budget gate in CI
c3x estimate --path . --budget 5000

# What-if: change instance type
c3x estimate --path . --what-if 'aws_instance.web.instance_type=m6i.2xlarge'

# Offline mode with usage file
c3x estimate --path . --offline --usage-file c3x-usage.yml

# Multiple Terraform var files
c3x estimate --path . --terraform-var-file prod.tfvars --terraform-var-file secrets.tfvars

# Recursive scan of a monorepo
c3x estimate --path . --include-all-paths --exclude-path modules/deprecated

c3x diff

Compare cost estimates between two states, such as the current branch and the main branch. Useful for understanding the cost impact of a change.

c3x diff --path . --compare-to main

Flags

FlagDescriptionDefault
--pathPath to the Terraform root module directory..
--compare-toGit ref (branch, tag, or commit SHA) to compare against.
--formatOutput format: json, table, or html.table
--out-fileWrite output to a file instead of stdout.
--budgetMaximum allowed monthly cost in USD.
--budget-increaseMaximum allowed cost increase in USD.

Examples

# Compare current branch to main
c3x diff --path . --compare-to main

# JSON diff with budget gate
c3x diff --path . --compare-to main --format json --budget-increase 500

c3x recommend

Analyze your Terraform configuration and suggest cost optimization opportunities such as right-sizing instances, switching to reserved pricing, or removing unused resources.

c3x recommend --path .

Flags

FlagDescriptionDefault
--pathPath to the Terraform root module directory..
--formatOutput format: json or table.table

Examples

# Table output
c3x recommend --path .

# JSON output for programmatic use
c3x recommend --path . --format json

c3x comment

Post a cost estimate as a comment on a pull request or merge request. Supports GitHub, GitLab, Bitbucket, and Azure Repos.

Subcommands

c3x comment github

c3x comment github --path . --github-token $GITHUB_TOKEN
FlagDescription
--pathPath to the Terraform root module directory.
--github-tokenGitHub API token with permission to write PR comments.
--github-api-urlGitHub API URL for GitHub Enterprise. Defaults to https://api.github.com.
--pull-requestPull request number. Auto-detected in CI environments.
--repoRepository in owner/repo format. Auto-detected in CI environments.
--tagTag to identify and update the comment on subsequent runs.
--delete-old-commentDelete previous C3X comments instead of updating them.

c3x comment gitlab

c3x comment gitlab --path . --gitlab-token $GITLAB_TOKEN
FlagDescription
--pathPath to the Terraform root module directory.
--gitlab-tokenGitLab API token with permission to write MR comments.
--gitlab-server-urlGitLab server URL for self-managed instances. Defaults to https://gitlab.com.
--merge-requestMerge request IID. Auto-detected in CI environments.
--projectGitLab project path. Auto-detected in CI environments.
--tagTag to identify and update the comment on subsequent runs.

c3x comment bitbucket

c3x comment bitbucket --path . --bitbucket-token $BITBUCKET_TOKEN
FlagDescription
--pathPath to the Terraform root module directory.
--bitbucket-tokenBitbucket API token with permission to write PR comments.
--bitbucket-server-urlBitbucket server URL for self-hosted instances.
--pull-requestPull request ID. Auto-detected in CI environments.
--repoRepository in workspace/repo format. Auto-detected in CI environments.
--tagTag to identify and update the comment on subsequent runs.

c3x comment azure-repos

c3x comment azure-repos --path . --azure-access-token $SYSTEM_ACCESSTOKEN
FlagDescription
--pathPath to the Terraform root module directory.
--azure-access-tokenAzure DevOps access token.
--pull-requestPull request ID. Auto-detected in CI environments.
--repo-urlAzure Repos URL. Auto-detected in CI environments.
--tagTag to identify and update the comment on subsequent runs.

c3x pricing sync

Download cloud pricing data to a local SQLite database for offline use. See the Self-Hosted & Offline guide for details.

c3x pricing sync --providers aws,azure,google

Flags

FlagDescriptionDefault
--providersComma-separated list of providers to sync: aws, azure, google.aws,azure
--db-pathPath to the local pricing database file.~/.c3x/pricing.db

c3x pricing status

Show the status of the local pricing database, including the last sync time and the number of records for each provider.

c3x pricing status

This command takes no additional flags.

c3x report

Generate a report from one or more JSON estimate files. Useful for combining estimates from multiple Terraform root modules into a single output.

c3x report --path estimate-*.json --format html --out-file report.html

Flags

FlagDescriptionDefault
--pathGlob pattern or paths to JSON estimate files. Can be specified multiple times.
--formatOutput format: json, table, or html.table
--out-fileWrite output to a file instead of stdout.

c3x config

Get or set C3X configuration values that persist across runs.

Subcommands

# Get a configuration value
c3x config get pricing_api_endpoint

# Set a configuration value
c3x config set pricing_api_endpoint http://localhost:4000

Configuration is stored in ~/.c3x/config.yml. You can also edit this file directly.

c3x auth

Authenticate with the C3X Cloud service to access team dashboards and historical cost tracking.

Subcommands

# Log in (opens browser for OAuth flow)
c3x auth login

After login, your API key is stored securely in the system keychain or in ~/.c3x/credentials.

Global Flags

These flags are available on every C3X command.

FlagDescriptionDefault
--no-colorDisable colored output. Also respects the NO_COLOR environment variable.false
--log-levelSet the log verbosity: trace, debug, info, warn, or error.info

Examples

# Debug logging
c3x estimate --path . --log-level debug

# No color (useful in CI environments that don't support ANSI codes)
c3x estimate --path . --no-color