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/terraformFlags
| Flag | Description | Default |
|---|---|---|
--path | Path to a Terraform root module directory. | . |
--format | Output format: text, markdown, json, junit, html, csv, or sarif. Goes to stdout — redirect with > file to save. | text |
--usage | Path to a usage file for variable-cost resources. | c3x-usage.yml |
--budget | Maximum allowed monthly cost in USD. Exits with code 1 if exceeded. | — |
--save-baseline | After the estimate, write the JSON to this path for use as a c3x diff baseline. | — |
--what-if | Override a resource attribute for what-if analysis. Can be specified multiple times. Format: resource.attr=value. | — |
--offline | Use only the local pricing database. No network calls are made. | false |
--show-skipped | After the breakdown, list resources that were parsed but couldn't be priced, with the reason. | false |
--no-cache | Bypass the on-disk price cache (every lookup hits pricing.c3x.dev). | false |
--var | Variable override: name=value (repeatable; HCL or bare string). | — |
--var-file | Path to a .tfvars / .tfvars.json file (repeatable; applied after auto-tfvars). | — |
--currency | Display currency (USD, EUR, GBP, JPY, …); USD rates converted via Frankfurter. | USD |
--region | Default region when the IaC source doesn't declare one. | — |
--pricing-endpoint | Override the pricing GraphQL endpoint. | pricing.c3x.dev |
--cache-path | SQLite 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 EURc3x 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.jsonFlags
| Flag | Description | Default |
|---|---|---|
--baseline | Path to a saved baseline JSON (from c3x estimate --save-baseline). Required. | — |
--path | Terraform input: directory, .tf, .hcl, or plan JSON. | . |
--budget-delta | Fail with exit code 1 when the project delta exceeds this monthly amount (0 disables). | 0 |
--format | Output 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 500c3x 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
| Flag | Description | Default |
|---|---|---|
--path | Path to the Terraform root module directory. | . |
--format | Output format: text, markdown, or json. | text |
Examples
# Table output
c3x recommend --path .
# JSON output for programmatic use
c3x recommend --path . --format jsonc3x 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| Flag | Description |
|---|---|
--path | Path to the Terraform root module directory. |
--token | GitHub API token with permission to write PR comments. |
--github-api-url | GitHub API URL for GitHub Enterprise. Defaults to https://api.github.com. |
--pr | Pull request number. Auto-detected in CI environments. |
--repo | Repository in owner/repo format. Auto-detected in CI environments. |
--delete-old-comment | Delete previous C3X comments instead of updating them. |
c3x comment gitlab
c3x comment gitlab --path . --token $GITLAB_TOKEN| Flag | Description |
|---|---|
--path | Path to the Terraform root module directory. |
--token | GitLab API token with permission to write MR comments. |
--gitlab-server-url | GitLab server URL for self-managed instances. Defaults to https://gitlab.com. |
--mr | Merge request IID. Auto-detected in CI environments. |
--project | GitLab project path. Auto-detected in CI environments. |
c3x comment bitbucket
c3x comment bitbucket --path . --token $BITBUCKET_TOKEN| Flag | Description |
|---|---|
--path | Path to the Terraform root module directory. |
--token | Bitbucket API token with permission to write PR comments. |
--base-url | Bitbucket server URL for self-hosted instances. |
--pr | Pull request ID. Auto-detected in CI environments. |
--repo | Repository in workspace/repo format. Auto-detected in CI environments. |
c3x comment azuredevops
c3x comment azuredevops --path . --token $SYSTEM_ACCESSTOKEN| Flag | Description |
|---|---|
--path | Path to the Terraform root module directory. |
--token | Azure DevOps access token. |
--pr | Pull request ID. Auto-detected in CI environments. |
--repo | Azure 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-1Flags
| Flag | Description | Default |
|---|---|---|
--providers | Comma-separated list of providers to sync: aws, azure, google. | aws,azure |
--db-path | Path 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 rowThese 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 doctorc3x 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 jsonc3x 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 configurec3x version
Print the c3x version and build info.
c3x versionGlobal Flags
These flags are available on every C3X command.
| Flag | Description | Default |
|---|---|---|
-v, --verbose | Increase log verbosity. Repeatable: -v info, -vv debug, -vvv adds source locations. | — |
--version | Print 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 .