$npx -y skills add aws/agent-toolkit-for-aws --skill aws-billing-and-cost-managementAnalyze 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.
| 1 | # Billing and Cost Management |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | 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. |
| 6 | |
| 7 | ## Usage |
| 8 | |
| 9 | Use this skill when: |
| 10 | |
| 11 | - Analyzing AWS spending, cost trends, or cost breakdowns |
| 12 | - Setting up or managing budget alerts |
| 13 | - Evaluating Savings Plans or Reserved Instance purchases |
| 14 | - Right-sizing EC2, Lambda, RDS, or EBS resources |
| 15 | - Looking up AWS service pricing |
| 16 | - Running cost audits or investigating cost spikes |
| 17 | - Querying CUR data with Athena |
| 18 | - Scoping cost analysis to a specific billing view |
| 19 | - Checking Free Tier usage |
| 20 | |
| 21 | ## Core Concepts |
| 22 | |
| 23 | - **Cost Explorer** — query cost/usage data by service, account, tag, or time range |
| 24 | - **Budgets** — set spending thresholds with alerts; supports billing view scoping |
| 25 | - **Billing Views** — scope cost data to a subset of billing (custom view, billing group, or primary) |
| 26 | - **Compute Optimizer** — right-sizing recommendations for EC2, Lambda, EBS, RDS |
| 27 | - **Cost Optimization Hub** — aggregated savings recommendations across services |
| 28 | - **Savings Plans / Reserved Instances** — commitment-based discounts |
| 29 | - **CUR 2.0** — detailed line-item billing data queryable via Athena |
| 30 | |
| 31 | **Recommended setup:** Use the AWS MCP server for sandboxed execution, audit logging, and enterprise controls. See: https://docs.aws.amazon.com/aws-mcp/ |
| 32 | |
| 33 | **Without AWS MCP:** All commands use standard AWS CLI syntax and work with any agent that has CLI access. |
| 34 | |
| 35 | ## Critical Rule: Always Check the Current Date |
| 36 | |
| 37 | **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. |
| 38 | |
| 39 | ## Critical Rule: Deterministic Calculations |
| 40 | |
| 41 | **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. |
| 42 | |
| 43 | **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. |
| 44 | |
| 45 | Read `references/deterministic-calculations.md` for patterns and examples. |
| 46 | |
| 47 | ## Decision Guide |
| 48 | |
| 49 | | Question | Tool | Reference | |
| 50 | |----------|------|-----------| |
| 51 | | What am I spending? Where are costs going up? | Cost Explorer | `references/cost-explorer.md` | |
| 52 | | How much does a service cost? | Price List API | `references/pricing-lookup.md` | |
| 53 | | Where can I save money? (start here) | Cost Optimization Hub | `references/cost-optimization-hub.md` | |
| 54 | | Should I buy Savings Plans? | CE SP Recommendations | `references/savings-plans.md` | |
| 55 | | Should I buy Reserved Instances? | CE RI Recommendations | `references/reserved-instances.md` | |
| 56 | | 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` | |
| 57 | | How do I set up budget alerts? | Budgets | `references/budgets.md` | |
| 58 | | What's causing a cost spike? | Cost Anomaly Detection | `references/cost-explorer.md` | |
| 59 | | Am I within Free Tier? | Free Tier API | `references/free-tier.md` | |
| 60 | | How do I reduce my bill? | Cost Audit workflow | `references/cost-audit.md` | |
| 61 | | How do I query detailed billing data? | CUR 2.0 + Athena | `references/cur-athena.md` | |
| 62 | | How do I optimize specific services? | Per-service patterns | `references/service-optimization.md` | |
| 63 | | How do I scope costs to a billing view? | Billing Views | See [Billing Views](#billing-views) below | |
| 64 | |
| 65 | ## Common Tasks |
| 66 | |
| 67 | ### Analyze costs by service |
| 68 | |
| 69 | ```bash |
| 70 | aws ce get-cost-and-usage \ |
| 71 | --time-period Start=2026-03-01,End=2026-04-01 \ |
| 72 | --granularity MONTHLY \ |
| 73 | --metrics UnblendedCost \ |
| 74 | --group-by Type=DIMENSION,Key=SERVICE |
| 75 | ``` |
| 76 | |
| 77 | Default to `UnblendedCost`. Exclude Credits/Refunds with `--filter '{"Not":{"Dimensions":{"Key":"RECORD_TYPE","Values":["Credit","Refund"]}}}'`. End date is exclusive. |
| 78 | |
| 79 | ### Run a cost audit |
| 80 | Read `references/cost-audit.md` for the full 7-step workflow: |