$npx -y skills add ancoleman/ai-design-components --skill optimizing-costsOptimize cloud infrastructure costs through FinOps practices, commitment discounts, right-sizing, and automated cost management. Use when reducing cloud spend, implementing budget controls, or establishing cost visibility across AWS, Azure, GCP, and Kubernetes environments.
| 1 | # Cost Optimization |
| 2 | |
| 3 | ## Purpose |
| 4 | |
| 5 | Cloud cost optimization transforms uncontrolled spending into strategic resource allocation through the FinOps lifecycle: Inform, Optimize, and Operate. This skill provides decision frameworks for commitment-based discounts (Reserved Instances, Savings Plans), right-sizing strategies, Kubernetes cost management, and automated cost governance across multi-cloud environments. |
| 6 | |
| 7 | ## When to Use This Skill |
| 8 | |
| 9 | Invoke cost-optimization when: |
| 10 | - Reducing cloud spend by 15-40% through systematic optimization |
| 11 | - Implementing cost visibility dashboards and allocation tracking |
| 12 | - Establishing budget alerts and anomaly detection |
| 13 | - Optimizing Kubernetes resource requests and cluster efficiency |
| 14 | - Managing Reserved Instances, Savings Plans, or Committed Use Discounts |
| 15 | - Automating idle resource cleanup and right-sizing recommendations |
| 16 | - Setting up showback/chargeback models for internal teams |
| 17 | - Preventing cost overruns through CI/CD cost estimation (Infracost) |
| 18 | - Responding to finance team requests for cloud cost reduction |
| 19 | |
| 20 | ## FinOps Principles |
| 21 | |
| 22 | ### The FinOps Lifecycle |
| 23 | |
| 24 | ``` |
| 25 | ┌─────────────────────────────────────────────────────┐ |
| 26 | │ INFORM → OPTIMIZE → OPERATE (continuous loop) │ |
| 27 | │ ↓ ↓ ↓ │ |
| 28 | │ Visibility Action Automation │ |
| 29 | └─────────────────────────────────────────────────────┘ |
| 30 | ``` |
| 31 | |
| 32 | **Inform Phase:** Establish cost visibility |
| 33 | - Enable cost allocation tags (Owner, Project, Environment) |
| 34 | - Deploy real-time cost dashboards for engineering teams |
| 35 | - Integrate cloud billing data (AWS CUR, Azure Consumption API, GCP BigQuery) |
| 36 | - Set up Kubernetes cost monitoring (Kubecost, OpenCost) |
| 37 | |
| 38 | **Optimize Phase:** Take action on cost drivers |
| 39 | - Purchase commitment-based discounts (40-72% savings) |
| 40 | - Right-size over-provisioned resources (target 60-80% utilization) |
| 41 | - Implement spot/preemptible instances for fault-tolerant workloads |
| 42 | - Clean up idle resources (unattached volumes, old snapshots) |
| 43 | |
| 44 | **Operate Phase:** Automate and govern |
| 45 | - Budget alerts with cascading notifications (50%, 75%, 90%, 100%) |
| 46 | - Automated cleanup scripts for idle resources |
| 47 | - CI/CD cost estimation to prevent surprise increases |
| 48 | - Continuous monitoring with anomaly detection |
| 49 | |
| 50 | ### Core FinOps Principles |
| 51 | |
| 52 | 1. **Collaboration:** Cross-functional teams (finance, engineering, operations, product) |
| 53 | 2. **Accountability:** Teams own the cost of their services |
| 54 | 3. **Transparency:** All costs visible and understandable to stakeholders |
| 55 | 4. **Optimization:** Continuous improvement of cost efficiency |
| 56 | |
| 57 | For detailed FinOps maturity models and organizational structures, see `references/finops-foundations.md`. |
| 58 | |
| 59 | ## Cost Optimization Strategies |
| 60 | |
| 61 | ### 1. Commitment-Based Discounts |
| 62 | |
| 63 | **Reserved Instances (RIs):** 40-72% discount for 1-3 year commitments |
| 64 | - **Standard RI:** Instance type locked, highest discount (60% for 3-year) |
| 65 | - **Convertible RI:** Flexible instance types, moderate discount (54% for 3-year) |
| 66 | - **Use for:** Databases (RDS, ElastiCache), stable production EC2 workloads |
| 67 | |
| 68 | **Savings Plans:** Flexible compute commitments |
| 69 | - **Compute Savings Plans:** Applies to EC2, Fargate, Lambda (54% discount for 3-year) |
| 70 | - **EC2 Instance Savings Plans:** Tied to instance family (66% discount for 3-year) |
| 71 | - **Use for:** Workloads that change instance types or regions |
| 72 | |
| 73 | **GCP Committed Use Discounts (CUDs):** 25-70% discount |
| 74 | - **Resource-based CUDs:** Commit to vCPU, memory, GPUs |
| 75 | - **Spend-based CUDs:** Commit to dollar amount (flexible) |
| 76 | - **Sustained Use Discounts:** Automatic 20-30% discount for sustained usage (no commitment) |
| 77 | |
| 78 | **Decision Framework:** |
| 79 | ``` |
| 80 | Reserve when: |
| 81 | ├─ Workload is production-critical (24/7 uptime required) |
| 82 | ├─ Usage is predictable (stable baseline over 6+ months) |
| 83 | ├─ Architecture is stable (unlikely to change instance types) |
| 84 | └─ Financial commitment acceptable (1-3 year lock-in) |
| 85 | |
| 86 | Use On-Demand when: |
| 87 | ├─ Development/testing environments |
| 88 | ├─ Unpredictable spiky workloads |
| 89 | ├─ Short-term projects (<6 months) |
| 90 | └─ Evaluating new instance types |
| 91 | ``` |
| 92 | |
| 93 | For detailed commitment strategies and RI coverage analysis, see `references/commitment-strategies.md`. |
| 94 | |
| 95 | ### 2. Spot and Preemptible Instances |
| 96 | |
| 97 | **Discount:** 70-90% off on-demand pricing (interruptible with 2-minute warning) |
| 98 | |
| 99 | **Use Spot For:** CI/CD workers, batch jobs, ML training (with checkpointing), Kubernetes workers, data analytics |
| 100 | **Avoid Spot For:** Stateful databases, real-time services, long-running jobs without checkpointing |
| 101 | |
| 102 | **Best Practices:** |
| 103 | - Diversify instance types and spread across Availability Zones |
| 104 | - Implement graceful shutdown handlers |
| 105 | - Auto-fallback to on-demand when capacity unavailable |
| 106 | - Kubernetes: Mix 70% spot + 30% on-dema |