### Install and Authenticate Infracost CLI Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Installs the Infracost CLI using Homebrew and logs in to authenticate your account. This is a one-time setup step. ```bash brew install infracost infracost auth login ``` -------------------------------- ### Install Infracost CLI via Homebrew or Script Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Install the Infracost CLI using Homebrew on macOS or the provided installation script on Linux. Verify the installation afterwards. ```bash # Install via Homebrew (macOS) brew install infracost # Or via the installation script (Linux) curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh # Verify it's on PATH which infracost infracost --version ``` -------------------------------- ### Install Infracost CLI Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md If the Infracost CLI is not installed, use this command to install it via Homebrew. ```bash brew install infracost ``` -------------------------------- ### Install Infracost Plugin via CLI Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Installs the Infracost plugin using the Claude Code CLI. This is an alternative to manual or Claude.ai installation. ```bash claude install plugin infracost ``` -------------------------------- ### Install Infracost CLI Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Installs the Infracost CLI using different package managers or direct download. Ensure you have version v2.2.0 or newer for MCP support. ```bash # macOS (Homebrew) brew install infracost ``` ```bash # Linux (curl) curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh ``` ```bash # Docker docker run --rm -v $(pwd):/root infracost/infracost --version ``` ```bash # Windows (Chocolatey) choco install infracost ``` -------------------------------- ### Verify Infracost CLI Installation Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/errors.md After installing or upgrading the Infracost CLI, verify its installation by checking the version. If the CLI is installed but not found, ensure it is on the system's PATH. ```bash infracost --version ``` ```bash export PATH="$PATH:/usr/local/bin" # or wherever you installed it ``` -------------------------------- ### Run Infracost Setup Validation Script Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Execute the validation script to check if the Infracost setup is correct. Claude performs this automatically on first use. ```bash ${CLAUDE_PLUGIN_ROOT}/scripts/validate_setup.sh ``` -------------------------------- ### Manual Infracost Plugin Installation Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Clones the Infracost agent skills repository for manual plugin installation, typically for development purposes. Further configuration in Claude Code settings is required. ```bash git clone https://github.com/infracost/agent-skills /path/to/plugins/infracost ``` -------------------------------- ### Use Group By to Spot Cost Patterns Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Employ `group_by` with `inspect_resources` to identify cost patterns. Examples include grouping by file to find expensive files, by type to see dominant resource types, or by project and policy to analyze policy adherence across projects. ```python # If one file has all the expensive resources inspect_resources(group_by=["file"], top=5) # If one resource type dominates costs inspect_resources(group_by=["type"], top=5) # If policies cluster in one project inspect_resources(group_by=["project", "policy"]) ``` -------------------------------- ### Get Pricing for HCL Snippet Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Use the `price` tool to get a monthly cost estimate and per-component breakdown for a given Terraform HCL snippet without needing an existing IaC directory. ```python price(iac=""" provider "aws" { region = "us-east-1" } resource "aws_instance" "web" { instance_type = "m5.xlarge" root_block_device { volume_size = 100; volume_type = "gp3"; } } """) ``` -------------------------------- ### Inspect Top Savings Opportunities Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Call this tool to get a list of the top N opportunities for cost savings based on analysis. ```python inspect_top_savings(n=10) ``` -------------------------------- ### Validate Infracost Plugin Installation Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Confirms the Infracost plugin is correctly installed and accessible by the system. It checks for a compatible version and its location. ```bash infracost --version # Output: infracost v2.2.0+ found at /path/to/infracost ``` -------------------------------- ### Get Top Savings Opportunities Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Use `inspect_top_savings` to identify the top N resources that can yield the most savings through FinOps practices. ```python inspect_top_savings(n=10, path="/absolute/path/to/iac") ``` -------------------------------- ### Iterative Cost Estimation with Price Lookup Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md Use the `price` tool with small IaC snippets during drafting to get immediate cost feedback and FinOps recommendations. This aids in making informed decisions about resource sizing, types, and regions. ```hcl price(iac=""" provider "aws" { region = "us-east-1" } resource "aws_instance" "web" { instance_type = "t3.large" root_block_device { volume_type = "gp3"; volume_size = 50; } } """) ``` -------------------------------- ### Get Cloud Resource Pricing Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Estimates the cost of infrastructure code snippets during the development iteration process. Use this for incremental cost feedback. ```bash price() ``` -------------------------------- ### Synthesize Minimal Terraform for RDS Instance Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md Example of creating a minimal Terraform snippet for an AWS RDS instance, including pricing-affecting attributes and region. ```hcl provider "aws" { region = "us-east-1" } resource "aws_rds_instance" "main" { engine = "mysql" instance_class = "db.r5.xlarge" allocated_storage = 100 storage_type = "gp3" } ``` -------------------------------- ### Establish Organization Context for IaC Generation Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md Before writing IaC, call these tools to understand organizational constraints like tagging policies, spending limits, and budget status. This helps ensure cost optimization and policy compliance from the start. ```bash policies(providers=["aws"]) guardrails(path="/workspace/repo") budgets() ``` -------------------------------- ### Inspect Resources Grouped by Type and Project Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Group resources by both type and project to get a more granular cost breakdown. This helps in understanding costs across different projects and resource categories. ```python # By type and project inspect_resources(group_by=["type", "project"]) # Returns: costs broken down by type within each project ``` -------------------------------- ### Inspect Top Savings and Resources Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md Use inspect tools to get more details about savings opportunities and resource aggregation. These are most useful for complex, multi-resource scenarios. ```python inspect_top_savings(n=5) # Top savings opportunities ``` ```python inspect_resources(group_by=["type"]) # Aggregate by type ``` -------------------------------- ### Price a Specific Resource with Infracost Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/INDEX.md Use the `price()` function to get cost estimates for a given Infrastructure as Code snippet. Ensure the IaC is correctly formatted. ```bash price(iac=""" provider "aws" { region = "us-east-1" } resource "aws_instance" "web" { instance_type = "m5.xlarge" } """) ``` -------------------------------- ### Analyze Terraform Directory Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Use the `scan` tool to analyze a Terraform directory and get a breakdown of monthly costs, failing policies, guardrails, and budgets. ```python scan(path="/absolute/path/to/iac") ``` -------------------------------- ### Workflow: Analyze and Optimize Existing IaC Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md A workflow to analyze and optimize existing IaC by first getting an overview with `scan`, then finding savings with `inspect_top_savings`, drilling into policies with `inspect_policy_detail`, and grouping resources by type using `inspect_resources`. ```python # 1. Get overview scan(path="/workspace/iac") # 2. Find biggest savings inspect_top_savings(n=5) # 3. Drill into specific policy inspect_policy_detail(policy="Use GP3") # 4. Group by resource type to find patterns inspect_resources(group_by=["type"], top=10) ``` -------------------------------- ### Fix FinOps Findings Workflow Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Details the workflow for fixing FinOps findings, offering options for local edits, creating pull requests, or dismissing findings. It guides through listing, getting details, and applying fixes. ```bash findings_list() findings_get(id="f-abc") create_fix(type="manual") update_task_status(status="confirm") preview_fix(...) create_fix(type="open_pr", ...) update_task_status(status="dismiss", reason="...") ``` -------------------------------- ### Analyze IaC with Infracost Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/INDEX.md Use `scan()` to see key metrics for a given path. Use `inspect_failing()` to identify failing configurations and `inspect_top_savings()` to find the top cost-saving opportunities. ```bash # See key metrics scan(path="/workspace/terraform") # What's failing? insp ect_failing() # Top savings? inspect_top_savings(n=5) ``` -------------------------------- ### Price Small Snippets for Comparison Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Use the `price()` function with an inline IaC string to quickly compare the costs of different configurations, such as instance types. ```python # Compare instance types in seconds price(iac=""" provider "aws" { region = "us-east-1" } resource "aws_instance" "t3" { instance_type = "t3.large"; ... } resource "aws_instance" "t4" { instance_type = "t4g.large"; ... } # Graviton """) # Returns both in one call; easy to compare ``` -------------------------------- ### Run Initial Scan for Cost Analysis Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md Execute a `scan` on a repository path to obtain a summary of cost metrics, resource counts, policy failures, and guardrail triggers. This scan result is cached for subsequent inspection calls. ```bash scan(path="/abs/path/to/repo") ``` -------------------------------- ### Check Constraints Before Generating Infrastructure Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Retrieves organization policies, spending guardrails for a given path, and budget status before writing new infrastructure code. These are required to understand constraints. ```bash policies() guardrails(path="/workspace/repo") budgets() ``` -------------------------------- ### Get Finding Details Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/findings-tools.md Retrieve full details for a specific finding using its ID. ```python findings_get(id="f-abc123") ``` ```python findings_get(id="f-def456") ``` -------------------------------- ### Uninstall Infracost CLI via Homebrew Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Remove the Infracost CLI installation using Homebrew. ```bash # Homebrew brew uninstall infracost ``` -------------------------------- ### Create a Ticket Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/findings-tools.md Create a real ticket in a configured ticketing system for a task, using configuration potentially obtained from `preview_fix`. This is a destructive action. ```python create_fix( finding_id="f-abc123", task_id="t-2", type="create_ticket", config={...} ) ``` -------------------------------- ### List Repository Cost Guardrails Source: https://github.com/infracost/agent-skills/blob/main/plugins/infracost/skills/iac-generation/SKILL.md Call `guardrails()` with the repository path to list configured cost guardrails. Note the thresholds and actions, paying attention to `block_pr` actions which indicate hard constraints. ```shell guardrails(path="/abs/path/to/repo") ``` -------------------------------- ### Get FinOps Finding Detail Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Retrieve detailed information for a specific FinOps finding by its ID. This operation can take some time. ```python findings_get(id=...) ``` -------------------------------- ### List FinOps Findings Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Get a list of FinOps investigation results generated by Infracost Agents. This operation can take some time. ```python findings_list() ``` -------------------------------- ### Authenticate with Infracost CLI for Multi-Org Users Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Demonstrates how to set the Infracost CLI organization slug for users managing multiple organizations. Credentials are stored locally. ```bash export INFRACOST_CLI_ORG=org-slug ``` -------------------------------- ### List All Organization Policies Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/policy-tools.md Retrieve all FinOps and tagging policies configured for the organization. Use this to understand the current policy landscape. ```python policies() ``` -------------------------------- ### Lifecycle Hooks (hooks.json) Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/architecture.md Configures lifecycle hooks for the Infracost plugin, specifically running a validation script on session start. ```json { "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/scripts/validate_setup.sh" } ] } ] } } ``` -------------------------------- ### Infracost MCP Plugin Configuration Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md The .mcp.json file configures the Infracost plugin to register with Claude. This configuration is typically installed automatically. ```json { "mcpServers": { "infracost": { "command": "${CLAUDE_PLUGIN_ROOT}/scripts/mcp.sh" } } } ``` -------------------------------- ### Authenticate Infracost CLI Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Log in to Infracost to authenticate your CLI. Use `infracost auth whoami` to verify the authentication status. ```bash # Login once infracost auth login # Verify infracost auth whoami ``` -------------------------------- ### Check Organization Policies and Guardrails Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Use `policies()` to check applicable tagging and cost policies, and `guardrails()` to review spending limits that act as hard constraints. ```python policies() guardrails(path="/workspace/repo") ``` -------------------------------- ### Infracost CLI Authentication Flow Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/architecture.md Illustrates the user authentication process for the Infracost CLI with Infracost Cloud, including initial login and subsequent API key usage. ```text First run: ├─ infracost auth login │ └─ Opens browser to https://dashboard.infracost.io/auth/claude │ ├─ User logs in / signs up │ └─ Returns auth code to terminal │ └─ CLI saves API key to ~/.infracost/config.yml (user now authenticated for all future commands) Subsequent runs: ├─ CLI reads API key from ~/.infracost/config.yml ├─ All API calls include the API key in Authorization header └─ Infracost Cloud validates and returns data ``` -------------------------------- ### Scan and Inspect Summary for Diffing Source: https://github.com/infracost/agent-skills/blob/main/plugins/infracost/skills/scan/SKILL.md This pseudo-code illustrates the flow for comparing cost changes between branches. It involves running scans on separate worktrees and then inspecting their summary details. ```bash # Pseudo-flow: scan(path="/abs/path/to/repo") # current branch scan(path="/abs/path/to/repo-baseline-worktree") # baseline checkout # Compare the two summary.monthly_cost / failing_policies / etc. values. # Then for each side, optionally: inspect_summary(path="/abs/path/to/repo") inspect_summary(path="/abs/path/to/repo-baseline-worktree") ``` -------------------------------- ### Configure Azure Credentials for Infracost Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Set environment variables for Azure authentication, including subscription ID and tenant ID. ```bash export AZURE_SUBSCRIPTION_ID=... export AZURE_TENANT_ID=... ``` -------------------------------- ### List and Get Findings Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Use `findings_list()` to see all open findings or filter by effort. Use `findings_get()` to retrieve detailed information for a specific finding by its ID. ```python findings_list() findings_list(effort="small") findings_get(id="f-abc123") ``` -------------------------------- ### Configure GCP Credentials for Infracost Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Set environment variables for GCP authentication, including the path to the service account key file and the project ID. ```bash export GOOGLE_CREDENTIALS=/path/to/service-account-key.json export GOOGLE_PROJECT_ID=myproject ``` -------------------------------- ### Scan Existing Infrastructure as Code Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Analyzes existing Infrastructure as Code (IaC) files in a specified directory to estimate costs. Ensure the path is absolute. ```bash scan(path="/absolute/path/to/terraform") ``` -------------------------------- ### Configure Custom Terraform and Terragrunt Paths Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Set environment variables to specify custom paths for Terraform and Terragrunt binaries if they are not in the system's PATH. ```bash export TERRAFORM_BINARY=/custom/path/to/terraform export TERRAGRUNT_BINARY=/custom/path/to/terragrunt ``` -------------------------------- ### Price Terraform Snippet Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Use this tool to get a cost estimate for a given Terraform snippet. Initial calls may take longer, but cached results are instant. ```python price(iac="...") ``` -------------------------------- ### List and Get FinOps Findings Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Lists available FinOps findings and retrieves detailed information for a specific finding by its ID. Used to identify areas for cost optimization. ```bash findings_list() findings_get(id="f-abc") ``` -------------------------------- ### Scan IaC Directory Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/scan-tools.md Analyzes an IaC directory to estimate cloud costs and check policy compliance. Use this to get an overview of your project's cost and security posture. ```python scan(path="/workspace/iac-repo") ``` ```python scan(path="/workspace/iac-repo", currency="EUR") ``` -------------------------------- ### Check Policies, Guardrails, and Budgets Before Writing IaC Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/INDEX.md Use `policies()` to check for mandatory tags, `guardrails()` to enforce cost limits on a repository, and `budgets()` to review budget status. ```bash policies() # Mandatory tags? guardrails(path="/workspace/repo") # Cost limits? budgets() # Budget status? ``` -------------------------------- ### Create Manual Fix Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md Claim a task and initiate a manual fix process. This is used when the fix can be applied locally to your Infrastructure as Code. ```python create_fix(finding_id="...", task_id="...", type="manual", config={...}) ``` -------------------------------- ### Inspect Budget Details Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/scan-tools.md Drill into a budget to see matching resources and their costs. The `path` parameter allows comparison with a previous scan. ```python inspect_budget_detail(budget="Production budget") # Budget detail from a baseline scan inspect_budget_detail(budget="Frontend Q2", path="/workspace/baseline-iac") ``` -------------------------------- ### Inspect Detail for a Specific Budget Source: https://github.com/infracost/agent-skills/blob/main/plugins/infracost/skills/scan/SKILL.md Use `inspect_budget_detail` to get detailed information about a specific budget. This includes the budget's scope, matching resources from the current scan, and potential FinOps savings on those resources. ```python inspect_budget_detail(budget="Production budget") ``` -------------------------------- ### List Guardrails for a Repository Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/policy-tools.md Retrieve cost guardrails configured for a specific repository path. This helps in understanding cost constraints applied to a particular codebase. ```python guardrails(path="/workspace/terraform-repo") ``` ```python guardrails(path="/workspace/other-repo") ``` -------------------------------- ### Workflow: Fix Multiple FinOps Findings Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md This workflow outlines steps to list, get, and act upon FinOps findings. It includes options for local fixes, creating pull requests, or dismissing findings. ```python # 1. List findings findings_list() ``` ```python # 2. For each finding the user picks: findings_get(id="f-abc") ``` ```python # 3. Decide per-task: # Path A (local fix) create_fix(finding_id="f-abc", task_id="t-1", type="manual") # ... edit file ... update_task_status(task_id="t-1", status="confirm") ``` ```python # OR Path B (PR) preview_fix(finding_id="f-abc", task_id="t-2", type="open_pr") create_fix(finding_id="f-abc", task_id="t-2", type="open_pr", config={...}) ``` ```python # OR Path C (decline) update_task_status(task_id="t-3", status="dismiss", reason="Not applicable") ``` -------------------------------- ### Price Terraform Snippet Source: https://github.com/infracost/agent-skills/blob/main/plugins/infracost/skills/iac-generation/SKILL.md Use `price()` with a Terraform snippet to get a cost estimate without writing to disk. This is useful for fast feedback when iterating on individual resources or comparing configurations. Supports specifying a currency. ```shell price(iac=""" provider "aws" { region = "us-east-1" } resource "aws_instance" "web" { instance_type = "m5.xlarge" root_block_device { volume_size = 100 volume_type = "gp3" } } """) ``` ```shell price(iac=""" provider "aws" { region = "us-east-1" } resource "aws_instance" "web" { instance_type = "m5.xlarge" root_block_device { volume_size = 100 volume_type = "gp3" } } """, currency="EUR") ``` -------------------------------- ### Inspect Policy Detail Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md Use to list resources failing a specific policy, including file/line, and current vs. required values. ```python inspect_policy_detail(policy="Use GP3") ``` -------------------------------- ### File Structure of Documentation Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/DOCUMENTATION-SUMMARY.md This tree displays the organization of documentation files within the output directory, indicating the purpose of each file. ```bash output/ ├── README.md (main index) ├── configuration.md (setup guide) ├── quick-reference.md (lookup guide) ├── types.md (type catalog) ├── errors.md (error reference) ├── architecture.md (system design) ├── skill-workflows.md (workflow guide) └── api-reference/ ├── scan-tools.md (scan API) ├── price-lookup-tools.md (price API) ├── policy-tools.md (policy API) └── findings-tools.md (findings API) ``` -------------------------------- ### Infracost Agent Skills Architecture Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/DOCUMENTATION-SUMMARY.md Illustrates the interaction flow between Claude Code, the MCP Server, Infracost CLI, and Infracost Cloud. ```text Claude Code ↓ (MCP protocol) mcp Server (infracost mcp) ↓ (shell commands) Infracost CLI (v2.2.0+) ↓ (REST APIs) Infracost Cloud (pricing, policies, findings) ``` -------------------------------- ### Get Specific Finding Details Source: https://github.com/infracost/agent-skills/blob/main/plugins/infracost/skills/fix-findings/SKILL.md Use `findings_get(id="...")` to retrieve detailed information about a specific finding, including all nested tasks, their action descriptions, code snippets, suggested actions, and savings. This is crucial for determining if a task is locally fixable. ```python findings_get(id="f-abc") ``` -------------------------------- ### List Repository Guardrails Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Fetch the guardrails configured for the current repository, which are used to set repository-specific cost thresholds. This operation can take some time. ```python guardrails(path=...) ``` -------------------------------- ### Authenticate Infracost CLI Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/configuration.md Logs into the Infracost CLI, initiating a browser-based authentication flow. This saves an API key locally for subsequent operations. ```bash infracost auth login ``` -------------------------------- ### List FinOps and Tagging Policies Source: https://github.com/infracost/agent-skills/blob/main/plugins/infracost/skills/iac-generation/SKILL.md Call `policies()` to list FinOps and tagging policies for the organization. If a tagging policy has `requirements` with `mandatory` tags or `allowed_values`, note them. Ask the user for clarification if unsure about tag values. ```shell policies() ``` ```shell policies(providers=["aws"]) ``` -------------------------------- ### Preview Fix for Finding Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Use this tool to draft a Pull Request or ticket for a FinOps finding before submitting it. ```python preview_fix(...) ``` -------------------------------- ### Create a Pull Request Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/findings-tools.md Create a real GitHub pull request for a task, using configuration potentially obtained from `preview_fix`. This is a destructive action. ```python create_fix( finding_id="f-abc123", task_id="t-1", type="open_pr", config={...} // config from preview_fix response ) ``` -------------------------------- ### Write Cost-Optimized Terraform Workflow Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md A workflow for writing cost-optimized Terraform code. It emphasizes understanding constraints first, then iterating with price checks and final validation scans. ```bash policies() guardrails(path="/workspace/repo") budgets() price() scan() ``` -------------------------------- ### Inspect Resources Grouped by Policy and Type Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Group resources by both policy and type to analyze cost breakdowns for resources that fail specific policies within different types. This provides a detailed view for targeted optimization. ```python # By policy and type inspect_resources(group_by=["policy", "type"]) # Returns: cost breakdown per policy + type combination ``` -------------------------------- ### Inspect Resources Grouped by Type Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Group resources by their type to see a breakdown of costs per resource type. This is useful for identifying which types of resources contribute most to your cloud spend. ```python # By resource type inspect_resources(group_by=["type"]) # Returns: one row per resource type with count + total cost ``` -------------------------------- ### Optimize Infrastructure Costs to a Budget Source: https://github.com/infracost/agent-skills/blob/main/README.md Identify resources exceeding a monthly budget and receive recommendations for the quickest way to reduce costs. ```plaintext Our budget is $2,000/month. Which resources are pushing us over, and what is the quickest way to get under budget? ``` -------------------------------- ### Infracost Scan Operation Workflow Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/architecture.md Illustrates the workflow for scanning Terraform code for cost analysis. The process involves Claude Code invoking a scan, the MCP server calling the Infracost CLI, which then communicates with Infracost Cloud for pricing and policy data. ```text User: "Scan this Terraform for cost" │ ├─ Claude Code invokes: scan(path="/workspace/iac") │ └─ MCP Server: └─ Calls: infracost scan /workspace/iac │ └─ Infracost CLI: ├─ Parses /workspace/iac (local, no upload) ├─ Constructs pricing query │ └─ Calls Infracost Cloud: ├─ /api/v1/projects/pricing │ ├─ Request: resource definitions │ └─ Response: cost estimates + FinOps checks │ └─ /api/v1/organizations/ORG_ID/policies ├─ Request: org slug └─ Response: policy + guardrail configs │ └─ Returns: scan summary + per-project details │ └─ MCP Server builds ScanResult JSON │ └─ Returns to Claude Code │ └─ Claude Code presents to user ``` -------------------------------- ### Check Guardrails for a Repository Path Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/policy-tools.md Evaluates guardrails for a given repository path. Pay attention to guardrails with the `block_pr` action, as these represent hard constraints that generated code must adhere to. ```shell guardrails(path="/workspace/repo") ``` -------------------------------- ### Full IaC Scan for Compliance and Cost Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md After completing IaC drafting, run a `scan` on the entire directory to check for cost, policy violations, and guardrail adherence. The summary provides key metrics for review. ```bash scan(path="/path/to/written/iac") ``` -------------------------------- ### Price a Single EC2 Instance Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/price-lookup-tools.md Use the `price` tool to estimate the monthly cost of a single AWS EC2 instance by providing its Terraform configuration as a string. Ensure the Terraform snippet includes a provider block and the necessary resource attributes. ```python # Price a single EC2 instance price(iac=""" provider "aws" { region = "us-east-1" } resource "aws_instance" "example" { ami = "ami-0c55b159cbfafe1f0" instance_type = "m5.xlarge" root_block_device { volume_size = 100; volume_type = "gp3" } } """ ) ``` -------------------------------- ### List Findings with Filters Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md List all cost-saving findings, with options to filter by effort level or status. Findings are presented sorted by estimated monthly savings. ```python findings_list() # List all findings ``` ```python findings_list(effort="small") # Filter by effort level ``` ```python findings_list(status="dismissed") # Filter by status ``` -------------------------------- ### Drill Into Specific Policy Details Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Use `inspect_policy_detail` to find all resources failing a specific policy, including file locations and potential savings. ```python inspect_policy_detail(policy="Use GP3", path="/absolute/path/to/iac") ``` -------------------------------- ### Draft Pull Request for a Finding Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/quick-reference.md Use `preview_fix` to see a preview of the changes for a finding before creating the actual fix with `create_fix`, specifying the `open_pr` type. ```python # 1. Preview preview_fix(finding_id="f-abc", task_id="t-1", type="open_pr") # 2. On user approval, submit create_fix(finding_id="f-abc", task_id="t-1", type="open_pr", config={...}) ``` -------------------------------- ### Create or Preview FinOps Fixes Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/README.md Applies FinOps findings locally, previews a fix for a pull request, or creates a pull request with the fix. Choose the appropriate type based on your workflow. ```bash create_fix(..., type="manual") preview_fix(...) create_fix(..., type="open_pr", ...) ``` -------------------------------- ### List Organization Budgets Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/api-reference/policy-tools.md Retrieve all tag-scoped budgets configured for the organization. Budgets reflect actual cloud spend and are informational for IaC generation. ```python budgets() ``` -------------------------------- ### IaC Generation Skill with Cost Iteration Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/skill-workflows.md The IaC Generation skill drafts infrastructure code, iterating on configuration using the price() function to meet budget constraints, and then uses scan() for final validation. ```python policies() guardrails() budgets() price() scan() ``` -------------------------------- ### Select Organization for Infracost CLI Source: https://github.com/infracost/agent-skills/blob/main/_autodocs/errors.md When a user belongs to multiple organizations, explicitly select one for Infracost CLI commands using the --org flag, an environment variable, or by switching the default organization. ```bash # Add --org flag to any subsequent infracost command infracost scan --org my-org-slug /path/to/repo ``` ```bash # Set env var for remainder of shell session export INFRACOST_CLI_ORG=my-org-slug ``` ```bash # Switch organization globally (or per-repo) infracost org switch my-org-slug # Or repository-specific: infracost org switch my-org-slug --repo ```