thomast1906/cost-optimization
Analyze Azure architectures for cost optimization opportunities, provide savings recommendations, and calculate ROI for improvements.
npx skills add https://github.com/thomast1906/github-copilot-agent-skills --skill cost-optimization
Analyze Azure costs and identify optimization opportunities across compute, storage, networking, and data services. Provide actionable recommendations with savings estimates.
Adjust resource SKUs to match actual usage patterns.
Target Resources:
Analysis Method:
Typical Savings: 30-50%
Commit to 1-year or 3-year terms for predictable workloads.
Eligible Services:
Savings (typical ranges — always verify with the azure-pricing skill using price-type: Reservation):
When to Use: Workloads with consistent, predictable usage
To confirm exact RI rates: use tool_search_tool_regex with pattern pricing, then call the tool with price-type: Reservation and include-savings-plan: true for the specific SKU and region. Compare the returned retailPrice against the Consumption rate to calculate the actual saving percentage.
Scale resources based on demand instead of static provisioning.
Applicable Services:
Typical Savings: 20-40% (eliminates idle capacity during off-peak)
Move infrequently accessed data to cheaper storage tiers.
Blob Storage Tiers:
Implementation: Lifecycle management policies
Typical Savings: 50-90% on archived data
Identify and remove unused resources.
Common Waste:
Typical Savings: £200-2,000/month per environment
Before estimating any costs, invoke the azure-pricing skill to fetch real retail prices.
First, use tool_search_tool_regex with pattern pricing to discover the exact tool name — do not hardcode it. Then call the tool with:
sku: <ARM SKU e.g. Standard_D4ds_v5>
service: <e.g. Virtual Machines, Azure Kubernetes Service>
region: <ARM region slug e.g. uksouth, eastus>
currency: GBP
price-type: Consumption # on-demand baseline
include-savings-plan: true # returns 1yr/3yr rates in nested array
Then follow up with price-type: Reservation to retrieve exact reserved instance rates.
Monthly cost formula: hourly_price × 730
Important: The tool requires a specific SKU or service name — do not call it with only a broad category (e.g. "Virtual Machines"). Confirm the SKU before calling.
Build a three-column cost table per resource:
| Resource | Pay-as-you-go | 1-yr Reserved | 3-yr Reserved |
|----------|--------------|---------------|---------------|
| (data from pricing tool) | | | |
Extract cost data from Azure Cost Management:
For each major resource:
Categorize findings:
For each recommendation:
> Note: All cost figures in the template below are illustrative placeholders. Before populating any analysis, use the azure-pricing skill to retrieve actual retail prices per SKU and region (currency: GBP by default). Never copy heuristic amounts into a real recommendation — always fetch live prices.
# Cost Optimization Analysis
**Architecture**: [Name]
**Current Monthly Cost**: £X,XXX
**Optimized Monthly Cost**: £X,XXX
**Potential Savings**: £XXX/month (XX%)
**Annual Savings**: £X,XXX
---
## Executive Summary
[2-3 sentences on current spending, biggest opportunities, recommended priorities]
---
## Current Cost Breakdown
| Category | Monthly Cost | % of Total |
|----------|-------------|------------|
| Compute | £1,200 | 45% |
| Database | £800 | 30% |
| Storage | £300 | 11% |
| Networking | £250 | 9% |
| Monitoring | £150 | 5% |
| **Total** | **£2,700** | **100%** |
---
## Optimization Opportunities
### Priority 1: Quick Wins (< 1 day effort)
#### Opportunity #1: Delete Unattached Disks
**Current Cost**: £80/month
**Savings**: £80/month (100%)
**Effort**: 30 minutes
**Risk**: Low (verify not needed)
**Action**:
1. Identify unattached disks: `az disk list --query "[?diskState=='Unattached']"`
2. Verify with team (ensure not needed)
3. Delete: `az disk delete --ids <disk-id>`
#### Opportunity #2: Stop Unused Dev/Test VMs After Hours
**Current Cost**: £500/month (VM running 24/7)
**Savings**: £300/month (60%)
**Effort**: 2 hours (automation script)
**Risk**: Low (dev environment)
**Action**: Auto-shutdown policy: 7 PM - 7 AM weekdays, all day weekends
---
### Priority 2: Right-Sizing (< 1 week effort)
#### Opportunity #3: Downsize App Service Plan
**Current**: P2v3 (2 cores, 8GB RAM) - Avg CPU: 20%, RAM: 35%
**Current Cost**: £292/month
**Recommended**: P1v3 (2 cores, 4GB RAM)
**Optimized Cost**: £146/month
**Savings**: £146/month (50%)
**Effort**: 4 hours (testing + validation)
**Risk**: Medium (test performance after change)
**Action**:
1. Validate scaling limits in lower SKU
2. Scale down during low-traffic window
3. Monitor performance for 48 hours
4. Rollback if issues detected
#### Opportunity #4: SQL Database DTU Optimization
**Current**: S3 (100 DTU) - Avg DTU: 35%
**Current Cost**: £300/month
**Recommended**: S1 (20 DTU) with auto-scaling to S2
**Optimized Cost**: £120/month (avg)
**Savings**: £180/month (60%)
**Effort**: 1 day (testing + validation)
**Risk**: Medium (requires performance testing)
---
### Priority 3: Commitment Savings (< 1 hour setup)
#### Opportunity #5: Reserved Instances for Production VMs
**Current**: 2x Standard_D4s_v3 VMs (pay-as-you-go)
**Current Cost**: £280/month per VM = £560/month
**Recommended**: 1-year reserved instance
**Optimized Cost**: £392/month (2 VMs)
**Savings**: £168/month (30%)
**Effort**: 30 minutes (purchase reservation)
**Risk**: Low (production VMs run continuously)
**Commitment**: 1 year
#### Opportunity #6: Azure SQL Reserved Capacity
**Current**: Pay-as-you-go
**Current Cost**: £300/month
**Recommended**: 1-year reserved capacity
**Optimized Cost**: £210/month
**Savings**: £90/month (30%)
**Effort**: 15 minutes
**Commitment**: 1 year
---
### Priority 4: Architecture Optimization (> 1 week)
#### Opportunity #7: Migrate to Serverless Cosmos DB
**Current**: Provisioned 1000 RU/s (24/7)
**Current Cost**: £58/month
**Recommended**: Serverless (pay-per-request)
**Optimized Cost**: £20/month (estimated based on usage patterns)
**Savings**: £38/month (65%)
**Effort**: 1 week (code changes + testing)
**Risk**: Medium (requires application changes)
#### Opportunity #8: Implement Storage Lifecycle Policies
**Current**: 2TB in Hot tier
**Current Cost**: £40/month
**Recommended**: Hot (30 days) → Cool (90 days) → Archive
**Optimized Cost**: £22/month
**Savings**: £18/month (45%)
**Effort**: 4 hours (policy setup)
**Risk**: Low (automated)
---
## Implementation Roadmap
### Month 1: Quick Wins
- Delete unattached disks [£80/month]
- Configure auto-shutdown for dev VMs [£300/month]
- **Month 1 Savings**: £380
### Month 2: Right-Sizing
- Downsize App Service Plan [£146/month]
- Optimize SQL Database DTU [£180/month]
- **Month 2 Savings**: £326
### Month 3: Commitment Savings
- Purchase VM Reserved Instances [£168/month]
- Purchase SQL Reserved Capacity [£90/month]
- **Month 3 Savings**: £258
### Months 4-6: Architecture Changes
- Migrate to Serverless Cosmos DB [£38/month]
- Implement Storage Lifecycle [£18/month]
- **Months 4-6 Savings**: £56
---
## Total Savings Summary
| Timeframe | Cumulative Monthly Savings | Annual Savings |
|-----------|---------------------------|----------------|
| Month 1 | £380 | £4,560 |
| Month 2 | £706 | £8,472 |
| Month 3 | £964 | £11,568 |
| Months 4-6 | £1,020/month | £12,240 |
**Final Optimized Cost**: £1,680/month (from £2,700)
**Total Annual Savings**: £12,240 (38% reduction)
---
## Cost Governance Recommendations
### 1. Set Up Budgets & Alerts
- Monthly budget: £1,800 (10% buffer)
- Alert at 50%, 80%, 90%, 100%
- Auto-notification to team leads
### 2. Tag Resources for Cost Allocation
Environment: Production | Staging | Development
CostCenter: IT-12345
Project: ProjectName
Owner: [email protected]
### 3. Regular Reviews
- Weekly: Review anomalies (via Cost Management)
- Monthly: Cost optimization review
- Quarterly: Reserved instance optimization
### 4. Enable Azure Advisor Recommendations
- Automatically flags optimization opportunities
- Cost, security, reliability, performance recommendations
---
## Conclusion
[Summary with total savings, timeline, and priorities]
Start with Quick Wins: Delete unused resources first
Monitor Before Changing: 30-day metrics for right-sizing decisions
Test Performance: Validate after SKU changes
Use Automation: Auto-shutdown, lifecycle policies, auto-scaling
Set Budgets: Prevent surprise bills
Tag Everything: Enable cost allocation and tracking
Review Regularly: Monthly cost reviews catch drift
Document Decisions: Why resources are sized as they are
Avoid: Blind right-sizing, skipping performance validation, ignoring monitoring, missing reservations
Take thomast1906/cost-optimization from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.