Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

aws-billing-and-cost-management — Claude Code skill: what it does

Analyzes AWS spending, discovers savings opportunities, and sets up budgets. Helps evaluate Savings Plans, detect cost anomalies, and right-size infrastructure.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add aws/agent-toolkit-for-aws --skill aws-billing-and-cost-management -a claude-code
Open on GitHub

What aws-billing-and-cost-management does

This skill guides agents through Cost Explorer, Budgets, Compute Optimizer, and the Price List API. It works with standard AWS CLI commands or an AWS MCP server. Before running queries against Cost Explorer or Savings Plans, the agent must check the current system date. That prevents stale analyses based on training data.

The instructions forbid doing math inside model reasoning. The model must run a local Python script or the run_script tool from the AWS MCP server for every sum, average, or percentage. LLM arithmetic produces wrong numbers on billing data, making deterministic scripts essential.

The skill also supports scoping cost metrics to Billing Views with --billing-view-arn. For right-sizing recommendations across EC2 or RDS, Compute Optimizer must be activated first using aws compute-optimizer update-enrollment-status --status Active.

What it helps with

  • find cost reduction opportunities in Cost Optimization Hub
  • configure monthly budgets with alert thresholds
  • right-size EC2, Lambda, RDS, and EBS resources via Compute Optimizer
  • investigate spending spikes using Cost Anomaly Detection
  • query detailed CUR 2.0 billing records in Athena

Example prompts for the agent

  • Analyze last month AWS spend by service grouped by UnblendedCost
  • Run a cost audit to identify our top spend drivers and idle resources
  • Check Compute Optimizer recommendations for our EC2 instances

How to install aws-billing-and-cost-management

1Skills CLI (Vercel)

npx skills add aws/agent-toolkit-for-aws --skill aws-billing-and-cost-management -a claude-code

2Manually: put the files in place

~/.claude/skills/aws-billing-and-cost-management/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/aws-billing-and-cost-management/

From the same set8

The whole set →
aws-iam aws Verified corrections for the IAM mistakes agents keep making, plus step-by-step workflows for roles and baseline policies. Claude Code CX Codex Cursor +1 10,200installs aws-serverless aws A router skill for AWS serverless work: it picks a compute form factor per component and hands off to the skill that owns it. Claude Code CX Codex Cursor +1 10,100installs aws-cdk aws A Claude Code skill that gives the agent AWS CDK expertise in TypeScript and Python: writing constructs, deploying stacks, importing existing resources, and reading CloudFormation failures. Claude Code CX Codex Cursor +1 9,400installs aws-containers aws Deploys containers on AWS: EKS, ECS, Fargate, ECR, Elastic Beanstalk. Use it when deploying, debugging, or optimizing containerized workloads. Claude Code CX Codex Cursor +1 9,300installs aws-cloudformation aws Takes CloudFormation templates from authoring to failed-stack post-mortem: local validation, cfn-guard checks, account-aware pre-deploy checks and root-cause tracing. Claude Code CX Codex Cursor +1 8,800installs connecting-to-data-source aws Builds and tests an AWS Glue connection to Oracle, PostgreSQL, Redshift, Snowflake or BigQuery, so a job does not discover the wiring is wrong at runtime. Claude Code CX Codex Cursor +1 6,800installs querying-data-lake aws A skill that runs SQL in Amazon Athena: it picks a workgroup, stops destructive statements for confirmation and reports what the query cost. Claude Code CX Codex Cursor +1 6,600installs

Similar

managed-agent ruvnet Skill for running Anthropic Claude Managed Agents in the cloud. Best for long asynchronous tasks inside a persistent container with network access. Claude Code CX Codex Cursor +1 596installs workers-best-practices cloudflare Guides coding agents on production Cloudflare Workers standards, Wrangler typing, observability setup, and runtime anti-pattern checks. Claude Code CX Codex Cursor +1 124,900installs cloudflare-email-service cloudflare A skill for Cloudflare Email Sending and Email Routing: it walks the agent through sending and receiving mail in Workers. Claude Code CX Codex Cursor +1 101,400installs firebase-basics official google This skill sets up the Firebase CLI, handles sign-in, creates or switches projects, and downloads Android or iOS app configuration files. Claude Code Gemini CLI CX Codex 14,100installs cloudflare-one cloudflare Walks your agent through designing, configuring and troubleshooting Cloudflare One Zero Trust and SASE deployments. Useful when you need Access, Gateway or tunnel work done without digging through docs yourself. Claude Code CX Codex Cursor +1 92,200installs cloudflare-one-migrations cloudflare Plans a migration from VPN, SWG or SASE to Cloudflare One: maps policies to Cloudflare resources, flags parity gaps and stages the rollout. Claude Code CX Codex Cursor +1 88,700installs google-cloud-networking-observability official google Investigate Google Cloud network logs, metrics, and connectivity paths. Use it to trace packet drops, firewall blocks, or routing problems. Claude Code Gemini CLI CX Codex 11,856installs

Questions about aws-billing-and-cost-management

How to install aws-billing-and-cost-management in Claude Code?

Run npx skills add aws/agent-toolkit-for-aws --skill aws-billing-and-cost-management -a claude-code in your terminal. This downloads the skill into your Claude Code skills directory.

What does aws-billing-and-cost-management do?

It equips the agent with AWS cost workflows: running 7-step cost audits, retrieving Cost Explorer metrics, evaluating Savings Plans, and managing budgets.

Why does the skill require Python scripts for calculations?

Language models make frequent arithmetic errors when summing billing line items. The skill mandates running deterministic Python scripts to ensure accurate cost totals.

Source text

SKILL.md · Apache-2.0
---
name: aws-billing-and-cost-management
description: |
  Analyze AWS costs, find savings, manage budgets, evaluate Savings Plans and
  Reserved Instances, right-size EC2/Lambda/RDS/EBS with Compute Optimizer,
  look up service pricing, query CUR with Athena, detect cost anomalies,
  scope costs to billing views, and monitor Free Tier usage. Triggers on:
  AWS bill, cost analysis, reduce spend, savings plan, reserved instance,
  right-size, budget alert, cost optimization, pricing, free tier, cost
  anomaly, CUR, cost audit, billing view, billing view ARN.
metadata:
  version: "1"
---

# Billing and Cost Management

## Overview

Analyze, optimize, and manage AWS costs. This skill encodes domain expertise from AWS's cost management products — gotchas, correct API usage patterns, and optimization workflows that models frequently get wrong.

## Usage

Use this skill when:

- Analyzing AWS spending, cost trends, or cost breakdowns
- Setting up or managing budget alerts
- Evaluating Savings Plans or Reserved Instance purchases
- Right-sizing EC2, Lambda, RDS, or EBS resources
- Looking up AWS service pricing
- Running cost audits or investigating cost spikes
- Querying CUR data with Athena
- Scoping cost analysis to a specific billing view
- Checking Free Tier usage

## Core Concepts

- **Cost Explorer** — query cost/usage data by service, account, tag, or time range
- **Budgets** — set spending thresholds with alerts; supports billing view scoping
- **Billing Views** — scope cost data to a subset of billing (custom view, billing group, or primary)
- **Compute Optimizer** — right-sizing recommendations for EC2, Lambda, EBS, RDS
- **Cost Optimization Hub** — aggregated savings recommendations across services
- **Savings Plans / Reserved Instances** — commitment-based discounts
- **CUR 2.0** — detailed line-item billing data queryable via Athena

**Recommended setup:** Use the AWS MCP server for sandboxed execution, audit logging, and enterprise controls. See: https://docs.aws.amazon.com/aws-mcp/

**Without AWS MCP:** All commands use standard AWS CLI syntax and work with any agent that has CLI access.

## Critical Rule: Always Check the Current Date

**Before making ANY Cost Explorer, Budgets, or Savings Plans API call, you MUST determine the current date.** Use a tool to get the current date and time — do NOT assume or guess the year. LLMs frequently default to dates from their training data instead of the actual current date, producing analyses of stale data that appear correct but are completely wrong.

## Critical Rule: Deterministic Calculations

**You MUST NEVER perform numerical calculations (sums, averages, percentages, comparisons, counts, min/max) by reasoning in your response.** LLM arithmetic is unreliable and produces wrong answers on cost data.

**You MUST ALWAYS use a script or calculator tool** for any math on data returned from API calls. Write a Python script that performs the calculation and prints the result. If the AWS MCP server's `run_script` tool is available, use it. Otherwise, run the script locally.

Read `references/deterministic-calculations.md` for patterns and examples.

## Decision Guide

| Question | Tool | Reference |
|----------|------|-----------|
| What am I spending? Where are costs going up? | Cost Explorer | `references/cost-explorer.md` |
| How much does a service cost? | Price List API | `references/pricing-lookup.md` |
| Where can I save money? (start here) | Cost Optimization Hub | `references/cost-optimization-hub.md` |
| Should I buy Savings Plans? | CE SP Recommendations | `references/savings-plans.md` |
| Should I buy Reserved Instances? | CE RI Recommendations | `references/reserved-instances.md` |
| Deep-dive on a specific EC2/Lambda/EBS/RDS rec? | Compute Optimizer | `references/ec2-rightsizing.md`, `references/lambda-optimization.md`, `references/rds-optimization.md`, `references/ebs-optimization.md` |
| How do I set up budget alerts? | Budgets | `references/budgets.md` |
| What's causing a cost spike? | Cost Anomaly Detection | `references/cost-explorer.md` |
| Am I within Free Tier? | Free Tier API | `references/free-tier.md` |
| How do I reduce my bill? | Cost Audit workflow | `references/cost-audit.md` |
| How do I query detailed billing data? | CUR 2.0 + Athena | `references/cur-athena.md` |
| How do I optimize specific services? | Per-service patterns | `references/service-optimization.md` |
| How do I scope costs to a billing view? | Billing Views | See [Billing Views](#billing-views) below |

## Common Tasks

### Analyze costs by service

```bash
aws ce get-cost-and-usage \
  --time-period Start=2026-03-01,End=2026-04-01 \
  --granularity MONTHLY \
  --metrics UnblendedCost \
  --group-by Type=DIMENSION,Key=SERVICE
```

Default to `UnblendedCost`. Exclude Credits/Refunds with `--filter '{"Not":{"Dimensions":{"Key":"RECORD_TYPE","Values":["Credit","Refund"]}}}'`. End date is exclusive.

### Run a cost audit
Read `references/cost-audit.md` for the full 7-step workflow: top cost drivers → month-over-month comparison → optimization recommendations → idle resources → commitment coverage → per-service quick wins → report.

### Get right-sizing recommendations
Compute Optimizer requires opt-in first: `aws compute-optimizer update-enrollment-status --status Active`. Then read `references/ec2-rightsizing.md` for EC2 or the relevant resource-specific reference.

### Look up service pricing
Read `references/pricing-lookup.md` for service codes and attribute filters. Common trap: Price List API service codes differ from Cost Explorer service names.

## Billing Views

A billing view scopes cost and usage data to a specific slice of an account's billing (e.g., a billing group, custom view, or the default primary view). When the user wants to analyze costs through a particular billing view, add `--billing-view-arn` to supported API calls.

### Discover available billing views

```bash
aws billing list-billing-views \
  --billing-view-types PRIMARY CUSTOM BILLING_GROUP
```

Requires `billing:ListBillingViews` permission.

### Use a billing view with Cost Explorer

```bash
aws ce get-cost-and-usage \
  --time-period Start=2026-03-01,End=2026-04-01 \
  --granularity MONTHLY \
  --metrics UnblendedCost \
  --group-by Type=DIMENSION,Key=SERVICE \
  --billing-view-arn arn:aws:billing::ACCOUNT_ID:billingview/BILLING_VIEW_ID
```

### Create a budget scoped to a billing view
In the `--budget` JSON, include the `BillingViewArn` field:

```bash
aws budgets create-budget --account-id ACCOUNT_ID \
  --budget '{
    "BudgetName": "TeamX-Monthly",
    "BudgetLimit": {"Amount": "1000", "Unit": "USD"},
    "TimeUnit": "MONTHLY",
    "BudgetType": "COST",
    "BillingViewArn": "arn:aws:billing::ACCOUNT_ID:billingview/BILLING_VIEW_ID"
  }'
```

### API support for `--billing-view-arn`

| Supports `--billing-view-arn` | Does NOT support it |
|-------------------------------|---------------------|
| `ce get-cost-and-usage` | `ce get-reservation-coverage` |
| `ce get-cost-and-usage-with-resources` | `ce get-reservation-utilization` |
| `ce get-cost-forecast` | `ce get-savings-plans-coverage` |
| `ce get-usage-forecast` | `ce get-savings-plans-utilization` |
| `ce get-dimension-values` | |
| `ce get-tags` | |
| `ce get-cost-comparison-drivers` | |
| `budgets create-budget` (in budget JSON) | |

## Troubleshooting

| Error | Cause | Fix |
|-------|-------|-----|
| `ValidationException` on Cost Explorer | Wrong dimension key (e.g., `CHARGE_TYPE` instead of `RECORD_TYPE`) | Use `RECORD_TYPE` for charge type filtering |
| Empty results with filter | Filter value doesn't match exactly | Call `GetDimensionValues` first to get valid values |
| `AccessDeniedException` on hourly data | Hourly granularity not enabled | Enable in Cost Explorer preferences |
| `Account not registered` on Compute Optimizer | Not opted in | Run `update-enrollment-status --status Active` |
| Budgets API fails outside us-east-1 | Budgets requires us-east-1 | Set `--region us-east-1` |
| Cost Explorer `Total` empty with GroupBy | By design — totals excluded when grouping | Make separate call without GroupBy, or sum grouped results using a script |
| `AccessDeniedException` on `list-billing-views` | Missing permission | User needs `billing:ListBillingViews` permissions |
| `ValidationException` with `--billing-view-arn` | API doesn't support billing views, or malformed ARN | Check the API support table above; ARN format is `arn:aws:billing::ACCOUNT_ID:billingview/VIEW_ID` |
| Budget shows `UNHEALTHY` health status | Billing view access revoked or view deleted | Check `HealthStatus.StatusReason` in `describe-budget` output; ensure `billing:GetBillingViewData` is granted |

## Additional Resources

- AWS Cost Management User Guide: https://docs.aws.amazon.com/cost-management/
- AWS Pricing Calculator: https://calculator.aws/
- Compute Optimizer User Guide: https://docs.aws.amazon.com/compute-optimizer/
- Well-Architected Cost Optimization Pillar: https://docs.aws.amazon.com/wellarchitected/latest/cost-optimization-pillar/

© aws · Apache-2.0 · aws/agent-toolkit-for-aws

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor