CostGuard CLI
Shift-left cost governance for CI/CD pipelines. One command validates your Terraform or CloudFormation plan against cost policies, budget limits, and guardrails — before infrastructure is deployed.
Note: A SKYXOPS subscription is required to use this CLI. This module can run as a standalone tool or be integrated into CI/CD pipelines.
Install
pip install costguard-cli
Quick Start
# Set your API key
export COSTGUARD_API_KEY="your-api-key"
# Validate costs
costguard-validate --plan plan.json --budget-code CS-FY2026-BU105-M03 --post-comment
Configuration
| Env Variable | Description | Required |
|---|---|---|
COSTGUARD_API_KEY |
API authentication key | Yes |
COSTGUARD_BUDGET_CODE |
Budget code for validation (use --skip-budget for pricing-only) |
No |
COSTGUARD_TAG |
Tag to identify this comment (e.g. production, staging) | No |
API URL is built-in. Set
COSTGUARD_API_URLonly for custom deployments.
CI/CD Integration
Azure DevOps (Extension)
Install the CostGuard extension from the VS Marketplace, then use the native task:
- task: CostGuard@1
inputs:
planPath: plan.json
budgetCode: $(COSTGUARD_BUDGET_CODE)
env:
COSTGUARD_API_KEY: $(COSTGUARD_API_KEY)
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
GitHub Actions
- uses: skyxops-io/costguard-action@v1
with:
plan-path: plan.json
api-key: ${{ secrets.COSTGUARD_API_KEY }}
budget-code: ${{ secrets.COSTGUARD_BUDGET_CODE }}
GitLab CI
include:
- remote: 'https://gitlab.com/skyxops-io/costguard-templates/-/raw/v1/gitlab/costguard.yml'
costguard:
extends: .costguard-review
needs: [terraform-plan]
Any CI/CD Platform
- script: |
pip install -q costguard-cli
costguard-validate --plan plan.json --post-comment
env:
COSTGUARD_API_KEY: $(COSTGUARD_API_KEY)
Output Formats
| Format | Flag | Use Case |
|---|---|---|
| Terminal | --format terminal |
CI logs (default) |
| Markdown | --format markdown |
PR/MR comments |
| HTML | --format html |
Executive reports |
| JSON | --format json |
Integrations |
Exit Codes
| Code | Decision | Pipeline Effect |
|---|---|---|
| 0 | ALLOW | Continues |
| 1 | BLOCK | Stops |
| 2 | WARN | Continues (use allow_failure: exit_codes: [2]) |
| 3 | ERROR | Stops |
Multi-Environment Tags
Use --tag to post separate comments for each Terraform root or environment in a single MR/PR:
costguard-validate --plan prod/plan.json --tag production --post-comment
costguard-validate --plan staging/plan.json --tag staging --post-comment
Each tag gets its own isolated comment. Without --tag, a single comment is posted. Set via env var: COSTGUARD_TAG.
Comment Behavior
--post-comment is idempotent: creates one comment on first run, updates it on re-push. No duplicates. Works on GitLab MRs, GitHub PRs, and Azure DevOps PRs.
How It Works
- Reads plan file (Terraform
plan.jsonor CloudFormation changeset) - Sends to CostGuard API for pricing, budget validation, and guardrail checks
- Displays cost breakdown, AI recommendations, and decision
- Posts result as MR/PR comment (if
--post-comment) - Exits with decision code so the pipeline can ALLOW, WARN, or BLOCK
No cloud credentials required — the CLI only reads the plan file.
Documentation
| Doc | Description |
|---|---|
| Getting Started | Prerequisites, installation, quick start |
| CLI Reference | Complete flag and option reference |
| Architecture | Technical architecture, API flow, data model |
| Troubleshooting | Common issues across all platforms |
Integration Guides
| Platform | Guide |
|---|---|
| Azure DevOps | Native extension (CostGuard@1 task) |
| GitHub Actions | Composite action (costguard-action@v1) |
| GitLab CI | Remote template (include: remote:) |
| Generic CI/CD | Raw CLI for any platform |
Metadata
Release files for costguard-cli 2.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| costguard_cli-2.7.0.tar.gz | 41.1 kB | Without provenance | Details for costguard_cli-2.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| costguard_cli-2.7.0-py3-none-any.whl | Python 3 | none | any | Details for costguard_cli-2.7.0-py3-none-any.whl |
Total release size: 79.9 kB
Release files / costguard_cli-2.7.0.tar.gz
| Download URL | costguard_cli-2.7.0.tar.gz |
|---|---|
| Size | 41.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7ad348213b133d9322d73518fd0d58021b43ff552a073d407b306816310c8612
|
|
BLAKE2b-256 checksum How to use checksums |
283996093e63396b31eae27cb7fdbd7ba77beda08b692829eef5a6bd8ac5bbe3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.6
|
Release files / costguard_cli-2.7.0-py3-none-any.whl
| Download URL | costguard_cli-2.7.0-py3-none-any.whl |
|---|---|
| Size | 38.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4eb3494c0655e55c5ee826202fe677b6d6d15043673bace2e893add4ef7dc21b
|
|
BLAKE2b-256 checksum How to use checksums |
12335da61a1e5ece95defff78ee93d15f4176016e08e4c995fe482cc0c0140e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.6
|
Security for costguard-cli 2.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.