Departments / devops / cost-optimizer

cost-optimizer

Use when quarterly cloud bills need review or a cost-cut mandate lands. Ingests AWS Cost Explorer exports, Azure Cost Management data, or GCP Billing exports and returns a ranked list of idle resources, over-provisioned instances, unused reservations, and data-transfer waste with estimated monthly savings.

Department

DevOps

Safety

safe
Safe · read-only

Supported stacks

Stack-agnostic — no detection required.

When to use

Do not use for real-time cost alerting; that’s a budget alarm, not this skill.

Inputs

Outputs

Tool dependencies

Procedure

1. Snapshot current spend

AWS (Cost Explorer + CUR):

# Top-level trend
aws ce get-cost-and-usage \
  --time-period Start=2026-01-19,End=2026-04-19 \
  --granularity MONTHLY \
  --metrics UnblendedCost \
  --group-by Type=DIMENSION,Key=SERVICE \
  --output table

# CUR in Athena
athena-cli -d cur -q "
SELECT line_item_product_code, SUM(line_item_unblended_cost) AS cost
FROM cur.cur
WHERE line_item_usage_start_date >= DATE '2026-01-19'
GROUP BY 1 ORDER BY cost DESC LIMIT 20;"

Azure:

az costmanagement query \
  --type ActualCost \
  --timeframe TheLastMonth \
  --dataset-granularity Daily \
  --dataset-aggregation '{"totalCost":{"name":"Cost","function":"Sum"}}' \
  --dataset-grouping '[{"type":"Dimension","name":"ServiceName"}]' \
  --scope "/subscriptions/$SUB"

GCP:

SELECT service.description, SUM(cost) AS cost
FROM `proj.billing.gcp_billing_export_v1_XXXX`
WHERE usage_start_time BETWEEN TIMESTAMP('2026-01-19') AND TIMESTAMP('2026-04-19')
GROUP BY 1 ORDER BY cost DESC LIMIT 20;

2. Enumerate candidate waste

Run each category in parallel. Only keep candidates exceeding min_savings_usd.

Idle resources

AWS example (unattached EBS):

aws ec2 describe-volumes \
  --filters Name=status,Values=available \
  --query 'Volumes[?CreateTime<=`2026-04-12`].{ID:VolumeId,Size:Size,AZ:AvailabilityZone,Tags:Tags}' \
  --output table

Cost estimate: EBS gp3 at $0.08/GB-month -> size_gb * 0.08.

Over-provisioned

Use CloudWatch / Azure Monitor / Cloud Monitoring metrics to get p95, not averages.

# AWS CloudWatch p95 CPU over 14 days
aws cloudwatch get-metric-statistics \
  --namespace AWS/EC2 --metric-name CPUUtilization \
  --dimensions Name=InstanceId,Value=i-0abc \
  --start-time 2026-04-05T00:00:00Z --end-time 2026-04-19T00:00:00Z \
  --period 3600 --extended-statistics p95

Unused reserved capacity / commitments

Also look for missing commitments: on-demand spend patterns that have been stable for 90+ days with no coverage are candidates for new commitments.

Data transfer

CUR query:

SELECT line_item_usage_type, SUM(line_item_unblended_cost) AS cost
FROM cur.cur
WHERE line_item_usage_type LIKE '%DataTransfer%'
  AND line_item_usage_start_date >= DATE '2026-03-19'
GROUP BY 1 ORDER BY cost DESC LIMIT 20;

3. Pull platform-native recommendations

These services do a lot of the math already; merge their output with your analysis.

# AWS
aws compute-optimizer get-ec2-instance-recommendations
aws trustedadvisor describe-checks --language en | jq -r '.checks[] | select(.category=="cost_optimizing") | .id' \
  | xargs -I{} aws trustedadvisor describe-check-result --check-id {}

# Azure
az advisor recommendation list --category Cost -o table

# GCP
gcloud recommender recommendations list \
  --project=$PROJ --location=global \
  --recommender=google.compute.instance.MachineTypeRecommender

4. Rank and quantify

For each candidate:

Output table:

RankResourceAction$/mo now$/mo afterSavingsEffortOwner
1nat-0abc (us-east-1c)Consolidate to single-AZ NAT963264lowplatform
2db-reporting-prodDownsize r6i.2xlarge -> r6i.xlarge425213212mediumdata
342 unattached EBS volsDelete after 30-day snapshot2870287lowunowned

5. Produce outputs

6. Close the loop

Examples

Example 1 — AWS prod account review

Inputs: cloud=aws, CUR in s3://acme-cur-prod/, window=90d, min_savings_usd=100.

Produces a report with: top-line $142k/mo, top 5 services (EC2, RDS, NAT, S3, DataTransfer), 23 recommendations totaling $18.6k/mo projected savings. Quick-wins ($4.1k/mo): 42 unattached EBS volumes, 7 idle EIPs, 3 idle LBs, single-AZ NAT consolidation in dev. Structural ($14.5k/mo): rightsizing 11 RDS instances, converting 60% of the flat EC2 baseline into Compute Savings Plan.

Example 2 — Azure subscription with missing tags

Inputs: cloud=azure, Cost Management export, tag_filter=none, min_savings_usd=50.

First pass: 38% of spend is on resources without an Owner tag. Output prioritizes a tagging action item before savings work — you can’t rightsize what you can’t attribute. Second-pass recommendations follow the same table format; the unowned block is surfaced to the platform team.

Constraints

Quality checks

Customise for your organisation

cost-optimizer

The LLM will rewrite this skill for your environment. Your API key and form inputs stay in your browser — only the skill and your environment go to OpenRouter.

One line. Be specific — cloud, language, framework, orchestrator.

Free text that steers the rewrite. Leave blank if nothing specific.

cost estimate: