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: json, table, or html. | table |
--out-file | Write output to a file instead of stdout. | — |
--usage-file | 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. | — |
--budget-increase | Maximum allowed cost increase in USD (compared to current state). Exits with code 1 if exceeded. | — |
--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 |
--recommend | Include cost optimization recommendations in the output. | false |
--show-skipped | Show resources that were skipped (unsupported or free-tier). | false |
--no-cache | Disable caching of pricing data and Terraform plan output. | false |
--config-file | Path to a C3X configuration file. | c3x.yml |
--terraform-var-file | Path to a Terraform .tfvars file. Can be specified multiple times. | — |
--terraform-var | Set a Terraform input variable. Format: key=value. Can be specified multiple times. | — |
--terraform-workspace | Terraform workspace to select before planning. | default |
--terraform-init-flags | Additional flags passed to terraform init. | — |
--terraform-plan-flags | Additional flags passed to terraform plan. | — |
--terraform-force-cli | Force use of the Terraform CLI for plan generation instead of the built-in HCL parser. | false |
--include-all-paths | Include all Terraform root modules found recursively under --path. | false |
--exclude-path | Exclude a path from recursive discovery. Can be specified multiple times. | — |
--project-name | Override 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/deprecatedc3x 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 mainFlags
| Flag | Description | Default |
|---|---|---|
--path | Path to the Terraform root module directory. | . |
--compare-to | Git ref (branch, tag, or commit SHA) to compare against. | — |
--format | Output format: json, table, or html. | table |
--out-file | Write output to a file instead of stdout. | — |
--budget | Maximum allowed monthly cost in USD. | — |
--budget-increase | Maximum 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 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: json or table. | table |
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 . --github-token $GITHUB_TOKEN| Flag | Description |
|---|---|
--path | Path to the Terraform root module directory. |
--github-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. |
--pull-request | Pull request number. Auto-detected in CI environments. |
--repo | Repository in owner/repo format. Auto-detected in CI environments. |
--tag | Tag to identify and update the comment on subsequent runs. |
--delete-old-comment | Delete previous C3X comments instead of updating them. |
c3x comment gitlab
c3x comment gitlab --path . --gitlab-token $GITLAB_TOKEN| Flag | Description |
|---|---|
--path | Path to the Terraform root module directory. |
--gitlab-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. |
--merge-request | Merge request IID. Auto-detected in CI environments. |
--project | GitLab project path. Auto-detected in CI environments. |
--tag | Tag to identify and update the comment on subsequent runs. |
c3x comment bitbucket
c3x comment bitbucket --path . --bitbucket-token $BITBUCKET_TOKEN| Flag | Description |
|---|---|
--path | Path to the Terraform root module directory. |
--bitbucket-token | Bitbucket API token with permission to write PR comments. |
--bitbucket-server-url | Bitbucket server URL for self-hosted instances. |
--pull-request | Pull request ID. Auto-detected in CI environments. |
--repo | Repository in workspace/repo format. Auto-detected in CI environments. |
--tag | Tag to identify and update the comment on subsequent runs. |
c3x comment azure-repos
c3x comment azure-repos --path . --azure-access-token $SYSTEM_ACCESSTOKEN| Flag | Description |
|---|---|
--path | Path to the Terraform root module directory. |
--azure-access-token | Azure DevOps access token. |
--pull-request | Pull request ID. Auto-detected in CI environments. |
--repo-url | Azure Repos URL. Auto-detected in CI environments. |
--tag | Tag 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,googleFlags
| 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 status
Show the status of the local pricing database, including the last sync time and the number of records for each provider.
c3x pricing statusThis 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.htmlFlags
| Flag | Description | Default |
|---|---|---|
--path | Glob pattern or paths to JSON estimate files. Can be specified multiple times. | — |
--format | Output format: json, table, or html. | table |
--out-file | Write 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:4000Configuration 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 loginAfter 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.
| Flag | Description | Default |
|---|---|---|
--no-color | Disable colored output. Also respects the NO_COLOR environment variable. | false |
--log-level | Set 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