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: text, markdown, json, junit, html, csv, or sarif. Goes to stdout — redirect with > file to save.text
--usagePath to a usage file for variable-cost resources.c3x-usage.yml
--budgetMaximum allowed monthly cost in USD. Exits with code 1 if exceeded.
--save-baselineAfter the estimate, write the JSON to this path for use as a c3x diff baseline.
--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
--show-skippedAfter the breakdown, list resources that were parsed but couldn't be priced, with the reason.false
--no-cacheBypass the on-disk price cache (every lookup hits pricing.c3x.dev).false
--varVariable override: name=value (repeatable; HCL or bare string).
--var-filePath to a .tfvars / .tfvars.json file (repeatable; applied after auto-tfvars).
--currencyDisplay currency (USD, EUR, GBP, JPY, …); USD rates converted via Frankfurter.USD
--regionDefault region when the IaC source doesn't declare one.
--pricing-endpointOverride the pricing GraphQL endpoint.pricing.c3x.dev
--cache-pathSQLite file for the on-disk price cache.XDG cache dir

Examples

# Basic estimate
c3x estimate --path .

# JSON output to file
c3x estimate --path . --format json > 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 (after 'c3x pricing sync')
c3x estimate --path . --offline

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

# Display in another currency
c3x estimate --path . --currency EUR

c3x diff

Compare the current estimate against a saved baseline JSON (produced by c3x estimate --save-baseline on the base branch). Useful for understanding the cost impact of a change.

c3x diff --path . --baseline base.json

Flags

FlagDescriptionDefault
--baselinePath to a saved baseline JSON (from c3x estimate --save-baseline). Required.
--pathTerraform input: directory, .tf, .hcl, or plan JSON..
--budget-deltaFail with exit code 1 when the project delta exceeds this monthly amount (0 disables).0
--formatOutput format: text, markdown, json, junit, html, csv, or sarif.text

Examples

# Save a baseline (e.g. from main), then diff the PR branch against it
c3x estimate --path . --save-baseline base.json
c3x diff --path . --baseline base.json

# JSON diff with a delta gate (fail if monthly cost rises > $500)
c3x diff --path . --baseline base.json --format json --budget-delta 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: text, markdown, or json.text

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 . --token $GITHUB_TOKEN
FlagDescription
--pathPath to the Terraform root module directory.
--tokenGitHub API token with permission to write PR comments.
--github-api-urlGitHub API URL for GitHub Enterprise. Defaults to https://api.github.com.
--prPull request number. Auto-detected in CI environments.
--repoRepository in owner/repo format. Auto-detected in CI environments.
--delete-old-commentDelete previous C3X comments instead of updating them.

c3x comment gitlab

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

c3x comment bitbucket

c3x comment bitbucket --path . --token $BITBUCKET_TOKEN
FlagDescription
--pathPath to the Terraform root module directory.
--tokenBitbucket API token with permission to write PR comments.
--base-urlBitbucket server URL for self-hosted instances.
--prPull request ID. Auto-detected in CI environments.
--repoRepository in workspace/repo format. Auto-detected in CI environments.

c3x comment azuredevops

c3x comment azuredevops --path . --token $SYSTEM_ACCESSTOKEN
FlagDescription
--pathPath to the Terraform root module directory.
--tokenAzure DevOps access token.
--prPull request ID. Auto-detected in CI environments.
--repoAzure Repos URL. Auto-detected in CI environments.

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,gcp --regions us-east-1

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 stats / where / clear

Inspect and manage the on-disk price cache.

c3x pricing where   # print the cache file path
c3x pricing stats   # row counts: total, live, stale
c3x pricing clear   # delete every cached row

These take no additional flags (besides --cache-path). Use c3x pricing sync (above) to populate the cache for offline use.

c3x doctor

Run pre-flight checks and exit non-zero if any fail — usable as a CI gate. Verifies the embedded catalog parses, pricing.c3x.dev responds, the cache directory is writable, and user config resolves.

c3x doctor

c3x supported-resources

List every Terraform / CloudFormation resource kind c3x can estimate, with its pricing status: LIVE (queried from pricing.c3x.dev), STATIC (inline rate), or FREE (no per-resource charge).

c3x supported-resources --provider aws --status live
c3x supported-resources --format json

c3x policy eval

Evaluate Rego policies against an estimate or diff to gate merges on cost rules. Exits non-zero on a policy deny. Point --policy at a .rego file or directory, and either --path (compute a fresh estimate) or --estimate (a saved JSON).

c3x policy eval --policy ./policies --path .

c3x configure

First-run setup wizard. Prompts for the settings most users pin once (currency, format, region, pricing endpoint) and writes them to ~/.config/c3x/config.toml (XDG-aware). Re-running pre-fills from the current values. Project-level overrides go in a .c3x.toml in your repo.

c3x configure

c3x version

Print the c3x version and build info.

c3x version

Global Flags

These flags are available on every C3X command.

FlagDescriptionDefault
-v, --verboseIncrease log verbosity. Repeatable: -v info, -vv debug, -vvv adds source locations.
--versionPrint the c3x version and exit.

Examples

# Debug logging
c3x estimate --path . -vv

# Disable color (c3x respects the NO_COLOR environment variable)
NO_COLOR=1 c3x estimate --path .