cost-optimization
wshobson/agents
Optimize cloud costs across AWS, Azure, GCP, and OCI through rightsizing, tagging, and pricing strategies.
What is cost-optimization?
Implement systematic cost optimization strategies to reduce cloud spending while maintaining performance and reliability. Use when reducing cloud expenses, analyzing infrastructure costs, or implementing cost governance policies.
- Implement cost allocation tags and visibility across multi-cloud environments
- Right-size resources based on utilization analysis and remove idle infrastructure
- Leverage reserved instances, savings plans, and spot/preemptible instances for 30-90% savings
- Optimize storage classes with lifecycle policies and tiered data strategies
- Set up budget alerts and cost anomaly detection for continuous monitoring
- Apply architecture patterns like serverless-first and auto-scaling for cost efficiency
How to install cost-optimization
npx skills add https://github.com/wshobson/agents --skill cost-optimizationHow to use cost-optimization
- 1.Review your current cloud resource inventory and utilization metrics using Cost Explorer, Cost Management, or Cost Analysis tools
- 2.Implement cost allocation tags across all resources following the provided tagging strategy
- 3.Analyze right-sizing opportunities by comparing current instance types to actual CPU, memory, and network utilization
- 4.Evaluate pricing models: reserve capacity for steady workloads, use spot/preemptible instances for batch jobs, and apply savings plans
- 5.Configure lifecycle policies for storage (S3, Azure Blob, GCP Storage) to transition data to cheaper tiers after 30-90 days
- 6.Set up budget alerts and cost anomaly detection to monitor spending and receive notifications when thresholds are exceeded
- 7.Review the cost optimization checklist monthly and adjust auto-scaling policies, instance types, and storage strategies based on trends
Use cases
- Reduce monthly cloud spending by rightsizing over-provisioned EC2, Azure VMs, or GCP instances
- Implement cost governance with tagging strategies and budget alerts across AWS, Azure, GCP, and OCI
- Optimize storage costs by transitioning data through S3 lifecycle policies or equivalent cloud storage tiers
- Evaluate reserved instances vs. spot instances vs. on-demand pricing for different workload patterns
- Analyze resource utilization and identify unused resources (EBS volumes, snapshots, elastic IPs) for deletion
- Cloud architects designing cost-efficient infrastructure
- DevOps engineers managing multi-cloud environments
- Finance teams implementing cloud cost governance
- Platform engineers optimizing infrastructure spending
- Teams with budget constraints or cost reduction mandates
cost-optimization FAQ
AWS reserved instances offer 30-72% savings vs on-demand pricing depending on term (1 or 3 years) and payment option. Azure reserved VMs offer up to 72% savings, GCP committed use discounts up to 57%, and OCI flexible shapes reduce wasted capacity.
Reserved instances are tied to specific instance types and regions. Savings plans are more flexible, applying across instance families, regions, and operating systems. AWS Compute Savings Plans offer 66% savings and EC2 Instance Savings Plans offer 72% savings.
Use spot/preemptible instances for stateless, fault-tolerant workloads like batch jobs, CI/CD pipelines, and data processing. They offer up to 90% savings but have 2-minute interruption notices. Mix with on-demand instances for critical services.
Implement lifecycle policies to transition data: S3 Standard for hot data, Standard-IA after 30 days, Glacier after 90 days, and Deep Archive after 365 days. Set expiration rules to delete data no longer needed.
Use consistent tags across all resources including Environment, Project, CostCenter, Owner, and ManagedBy. This enables cost allocation, chargeback, and filtering in cost analysis tools.
Full instructions (SKILL.md)
Source of truth, from wshobson/agents.
name: cost-optimization description: Optimize cloud costs across AWS, Azure, GCP, and OCI through resource rightsizing, tagging strategies, reserved instances, and spending analysis. Use when reducing cloud expenses, analyzing infrastructure costs, or implementing cost governance policies.
Cloud Cost Optimization
Strategies and patterns for optimizing cloud costs across AWS, Azure, GCP, and OCI.
Purpose
Implement systematic cost optimization strategies to reduce cloud spending while maintaining performance and reliability.
When to Use
- Reduce cloud spending
- Right-size resources
- Implement cost governance
- Optimize multi-cloud costs
- Meet budget constraints
Cost Optimization Framework
1. Visibility
- Implement cost allocation tags
- Use cloud cost management tools
- Set up budget alerts
- Create cost dashboards
2. Right-Sizing
- Analyze resource utilization
- Downsize over-provisioned resources
- Use auto-scaling
- Remove idle resources
3. Pricing Models
- Use reserved capacity
- Leverage spot/preemptible instances
- Implement savings plans
- Use committed use discounts
4. Architecture Optimization
- Use managed services
- Implement caching
- Optimize data transfer
- Use lifecycle policies
AWS Cost Optimization
Reserved Instances
Savings: 30-72% vs On-Demand
Term: 1 or 3 years
Payment: All/Partial/No upfront
Flexibility: Standard or Convertible
Savings Plans
Compute Savings Plans: 66% savings
EC2 Instance Savings Plans: 72% savings
Applies to: EC2, Fargate, Lambda
Flexible across: Instance families, regions, OS
Spot Instances
Savings: Up to 90% vs On-Demand
Best for: Batch jobs, CI/CD, stateless workloads
Risk: 2-minute interruption notice
Strategy: Mix with On-Demand for resilience
S3 Cost Optimization
resource "aws_s3_bucket_lifecycle_configuration" "example" {
bucket = aws_s3_bucket.example.id
rule {
id = "transition-to-ia"
status = "Enabled"
transition {
days = 30
storage_class = "STANDARD_IA"
}
transition {
days = 90
storage_class = "GLACIER"
}
expiration {
days = 365
}
}
}
Azure Cost Optimization
Reserved VM Instances
- 1 or 3 year terms
- Up to 72% savings
- Flexible sizing
- Exchangeable
Azure Hybrid Benefit
- Use existing Windows Server licenses
- Up to 80% savings with RI
- Available for Windows and SQL Server
Azure Advisor Recommendations
- Right-size VMs
- Delete unused resources
- Use reserved capacity
- Optimize storage
GCP Cost Optimization
Committed Use Discounts
- 1 or 3 year commitment
- Up to 57% savings
- Applies to vCPUs and memory
- Resource-based or spend-based
Sustained Use Discounts
- Automatic discounts
- Up to 30% for running instances
- No commitment required
- Applies to Compute Engine, GKE
Preemptible VMs
- Up to 80% savings
- 24-hour maximum runtime
- Best for batch workloads
OCI Cost Optimization
Flexible Shapes
- Scale OCPUs and memory independently
- Match instance sizing to workload demand
- Reduce wasted capacity from fixed VM shapes
Commitments and Budgets
- Use annual commitments for predictable spend
- Set compartment-level budgets with alerts
- Track monthly forecasts with OCI Cost Analysis
Preemptible Capacity
- Use preemptible instances for batch and ephemeral workloads
- Keep interruption-tolerant autoscaling groups
- Mix with standard capacity for critical services
Tagging Strategy
AWS Tagging
locals {
common_tags = {
Environment = "production"
Project = "my-project"
CostCenter = "engineering"
Owner = "team@example.com"
ManagedBy = "terraform"
}
}
resource "aws_instance" "example" {
ami = "ami-12345678"
instance_type = "t3.medium"
tags = merge(
local.common_tags,
{
Name = "web-server"
}
)
}
Reference: See references/tagging-standards.md
Cost Monitoring
Budget Alerts
# AWS Budget
resource "aws_budgets_budget" "monthly" {
name = "monthly-budget"
budget_type = "COST"
limit_amount = "1000"
limit_unit = "USD"
time_period_start = "2024-01-01_00:00"
time_unit = "MONTHLY"
notification {
comparison_operator = "GREATER_THAN"
threshold = 80
threshold_type = "PERCENTAGE"
notification_type = "ACTUAL"
subscriber_email_addresses = ["team@example.com"]
}
}
Cost Anomaly Detection
- AWS Cost Anomaly Detection
- Azure Cost Management alerts
- GCP Budget alerts
- OCI Budgets and Cost Analysis
Architecture Patterns
Pattern 1: Serverless First
- Use Lambda/Functions for event-driven
- Pay only for execution time
- Auto-scaling included
- No idle costs
Pattern 2: Right-Sized Databases
Development: t3.small RDS
Staging: t3.large RDS
Production: r6g.2xlarge RDS with read replicas
Pattern 3: Multi-Tier Storage
Hot data: S3 Standard
Warm data: S3 Standard-IA (30 days)
Cold data: S3 Glacier (90 days)
Archive: S3 Deep Archive (365 days)
Pattern 4: Auto-Scaling
resource "aws_autoscaling_policy" "scale_up" {
name = "scale-up"
scaling_adjustment = 2
adjustment_type = "ChangeInCapacity"
cooldown = 300
autoscaling_group_name = aws_autoscaling_group.main.name
}
resource "aws_cloudwatch_metric_alarm" "cpu_high" {
alarm_name = "cpu-high"
comparison_operator = "GreaterThanThreshold"
evaluation_periods = "2"
metric_name = "CPUUtilization"
namespace = "AWS/EC2"
period = "60"
statistic = "Average"
threshold = "80"
alarm_actions = [aws_autoscaling_policy.scale_up.arn]
}
Cost Optimization Checklist
- Implement cost allocation tags
- Delete unused resources (EBS, EIPs, snapshots)
- Right-size instances based on utilization
- Use reserved capacity for steady workloads
- Implement auto-scaling
- Optimize storage classes
- Use lifecycle policies
- Enable cost anomaly detection
- Set budget alerts
- Review costs weekly
- Use spot/preemptible instances
- Optimize data transfer costs
- Implement caching layers
- Use managed services
- Monitor and optimize continuously
Tools
- AWS: Cost Explorer, Cost Anomaly Detection, Compute Optimizer
- Azure: Cost Management, Advisor
- GCP: Cost Management, Recommender
- OCI: Cost Analysis, Budgets, Cloud Advisor
- Multi-cloud: CloudHealth, Cloudability, Kubecost
Related Skills
terraform-module-library- For resource provisioningmulti-cloud-architecture- For cloud selection
Related skills
More from wshobson/agents and the wider catalog.

cqrs-implementation
Implement CQRS to separate read and write models for scalable, high-performance architectures.

data-quality-frameworks
Implement data quality validation with Great Expectations, dbt tests, and data contracts for reliable pipelines.

data-storytelling
Transform data into compelling narratives that drive decisions and inspire action.

database-migration
Execute database migrations across ORMs with zero-downtime strategies, data transformation, and rollback procedures.

dataset-curation
Prepare, format, and validate datasets for supervised fine-tuning and preference training.

dbt-transformation-patterns
Master dbt model organization, testing, documentation, and incremental strategies for analytics engineering.