gcp-waf-cost-optimization
Apply the Google Cloud Well-Architected Framework's Cost Optimization pillar to evaluate workloads and recommend FinOps practices — billing exports, budgets, rightsizing via Active Assist, Spot VMs, Committed Use Discounts, storage lifecycle policies, and serverless adoption. Use for cloud cost reviews, monthly billing analysis, and architecture cost decisions.
Best use case
gcp-waf-cost-optimization is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Apply the Google Cloud Well-Architected Framework's Cost Optimization pillar to evaluate workloads and recommend FinOps practices — billing exports, budgets, rightsizing via Active Assist, Spot VMs, Committed Use Discounts, storage lifecycle policies, and serverless adoption. Use for cloud cost reviews, monthly billing analysis, and architecture cost decisions.
Teams using gcp-waf-cost-optimization should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/gcp-waf-cost-optimization/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How gcp-waf-cost-optimization Compares
| Feature / Agent | gcp-waf-cost-optimization | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Apply the Google Cloud Well-Architected Framework's Cost Optimization pillar to evaluate workloads and recommend FinOps practices — billing exports, budgets, rightsizing via Active Assist, Spot VMs, Committed Use Discounts, storage lifecycle policies, and serverless adoption. Use for cloud cost reviews, monthly billing analysis, and architecture cost decisions.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# GCP Well-Architected Framework — Cost Optimization
## Overview
Cloud is OpEx, not CapEx — getting cost right requires visibility (where is money going?), accountability (who owns each line item?), and continuous tuning (is each resource still earning its cost?). This skill applies the Google Cloud Well-Architected Framework's Cost Optimization pillar to evaluate a workload and recommend FinOps controls.
## Instructions
### Core Principles
| Principle | What it means in practice |
|---|---|
| **Align spending with business value** | Every dollar should map to a product/team/feature; reject infra that doesn't tie back to a business metric |
| **Foster cost awareness** | Make spend visible to engineers via dashboards, not just to finance |
| **Optimize resource usage** | Rightsize, use cheap-when-fault-tolerant compute (Spot), commit when stable (CUDs) |
| **Optimize continuously** | Cost reviews are recurring; act on Recommender insights monthly |
### Visibility Layer (Foundation)
```bash
# Enable BigQuery billing export — required for granular analysis
gcloud beta billing accounts list # find your billing account ID
# Then in Console: Billing → Export → BigQuery export → enable "Detailed usage cost data"
```
```sql
-- Top 20 services by cost, last 30 days
SELECT
service.description AS service,
SUM(cost) AS cost_usd,
SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS credits_usd,
SUM(cost) + SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS net_usd
FROM `my-project.billing_export.gcp_billing_export_resource_v1_*`
WHERE _PARTITIONTIME >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
GROUP BY service
ORDER BY net_usd DESC
LIMIT 20;
```
```sql
-- Cost by label (env, team, app) — requires consistent labeling
SELECT
(SELECT value FROM UNNEST(labels) WHERE key = 'team') AS team,
(SELECT value FROM UNNEST(labels) WHERE key = 'env') AS env,
service.description AS service,
SUM(cost) AS cost_usd
FROM `my-project.billing_export.gcp_billing_export_resource_v1_*`
WHERE _PARTITIONTIME >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
GROUP BY team, env, service
ORDER BY cost_usd DESC;
```
### Budgets and Alerts
```bash
# Per-project budget with alerts at 50%, 90%, 100% of forecasted spend
gcloud billing budgets create \
--billing-account=BILLING_ACCOUNT_ID \
--display-name="prod-monthly-budget" \
--budget-amount=10000USD \
--threshold-rule=percent=0.5,basis=current-spend \
--threshold-rule=percent=0.9,basis=current-spend \
--threshold-rule=percent=1.0,basis=forecasted-spend \
--filter-projects=projects/my-project \
--notifications-rule-pubsub-topic=projects/my-project/topics/billing-alerts
```
Pipe the Pub/Sub topic to a Cloud Function that auto-disables non-critical resources at 95% of budget for dev/test projects.
### Rightsizing via Active Assist
```bash
# List rightsizing recommendations across the project
gcloud recommender recommendations list \
--project=my-project \
--location=us-central1-a \
--recommender=google.compute.instance.MachineTypeRecommender \
--format='table(content.overview.currentMachineType, content.overview.recommendedMachineType, primaryImpact.costProjection.cost.units)'
```
```bash
# Idle VMs (consider stopping or deleting)
gcloud recommender recommendations list \
--project=my-project \
--location=us-central1-a \
--recommender=google.compute.instance.IdleResourceRecommender
```
```bash
# Idle persistent disks
gcloud recommender recommendations list \
--project=my-project \
--location=us-central1-a \
--recommender=google.compute.disk.IdleResourceRecommender
```
### Cheaper Compute
```bash
# Spot VMs — up to 91% cheaper, can be preempted with 30s notice
gcloud compute instances create batch-worker \
--zone=us-central1-a \
--machine-type=n2-standard-4 \
--provisioning-model=SPOT \
--instance-termination-action=DELETE
```
```bash
# Committed Use Discount — 1 or 3 year commit, ~57% off for stable workloads
gcloud compute commitments create prod-commit-3y \
--region=us-central1 \
--resources=vcpu=64,memory=256 \
--plan=THIRTY_SIX_MONTH \
--type=GENERAL_PURPOSE
```
For variable workloads, use **Cloud Run / Cloud Run functions / GKE Autopilot** — pay for actual request seconds, not provisioned capacity. Migrating a low-traffic API from a Compute Engine VM to Cloud Run typically cuts cost 70%+.
### Storage Lifecycle Policies
```bash
# Move objects to cheaper tiers automatically
cat > lifecycle.json <<EOF
{
"lifecycle": {
"rule": [
{ "action": { "type": "SetStorageClass", "storageClass": "NEARLINE" },
"condition": { "age": 30 } },
{ "action": { "type": "SetStorageClass", "storageClass": "COLDLINE" },
"condition": { "age": 90 } },
{ "action": { "type": "SetStorageClass", "storageClass": "ARCHIVE" },
"condition": { "age": 365 } },
{ "action": { "type": "Delete" },
"condition": { "age": 2555 } }
]
}
}
EOF
gcloud storage buckets update gs://my-archive-bucket --lifecycle-file=lifecycle.json
```
Storage class pricing (US, per GB-month, approximate): Standard $0.020, Nearline $0.010, Coldline $0.004, Archive $0.0012. Lifecycle rules pay for themselves within weeks on cold data.
### Workload Assessment Questions
When evaluating a workload, work through:
1. Is BigQuery billing export enabled and used in monthly reviews?
2. Are 100% of resources labeled with `env`, `team`, `app`?
3. Are budgets + alerts configured per project / business unit?
4. Are Active Assist rightsizing recommendations reviewed monthly?
5. Is CUD coverage reviewed against actual stable consumption?
6. Are idle disks, IPs, and VMs swept monthly?
7. Are new workloads serverless-by-default unless there's a hard reason not to be?
8. Do object storage buckets have lifecycle policies?
9. Is dev/test on Spot, off-hours shutdown, or cheaper tiers than prod?
10. Are there organization policies preventing expensive defaults (regions, machine types)?
### Validation Checklist
- [ ] **Cost attribution** — 100% of resources carry `env`, `team`, `app` labels
- [ ] **Granular visibility** — BigQuery billing export enabled, queried in monthly reviews
- [ ] **Budgets and alerts** — every project / BU has a budget with 50%/90%/100% alerts
- [ ] **Rightsizing** — Active Assist recommendations reviewed and acted on monthly
- [ ] **Commitments** — CUD coverage reviewed monthly against stable consumption
- [ ] **Idle resource sweeps** — disks, IPs, VMs cleaned up monthly
- [ ] **Managed services first** — serverless preferred for new workloads
- [ ] **Storage tiering** — lifecycle policies on all archival buckets
- [ ] **Org policies** — region / machine type / external IP restrictions enforced
- [ ] **Dev/test cost** — non-prod runs on Spot, scales to zero, or shuts down off-hours
## Examples
### Example 1 — Monthly cost review for a startup
User shares last month's GCP bill ($15k, up from $9k). Pull billing-export data into BigQuery, group by service and label, identify the spike (a forgotten n2-standard-32 in dev with no auto-shutdown). Run Active Assist rightsizing across the project, surface 6 idle disks and 12 oversized VMs. Estimated savings: $4.2k/month. Recommend a CUD for the stable Compute Engine baseline (+$1.8k/month savings) and lifecycle policies on three archival buckets (+$200/month).
### Example 2 — Architectural cost review of a new service
Team is designing a new background job processor. Default proposal is 6 always-on n2-standard-8 VMs ($1.4k/month). Recommend Cloud Run Jobs with `--task-count` matching peak burst — pay only for actual job seconds (~$200/month at expected volume). For the message queue, Pub/Sub instead of self-hosted RabbitMQ on GCE. For object storage, Standard tier with lifecycle to Coldline at 90 days.
## Guidelines
- **Labels first** — without `env`/`team`/`app` labels, every other recommendation is approximate
- BigQuery billing export beats Console reports for any non-trivial analysis
- **Budgets with Pub/Sub alerts** — wire to a function that can auto-disable resources for dev/test
- Recommender insights are passive — schedule a monthly sweep, don't expect them to act themselves
- Spot VMs are the right default for any fault-tolerant workload (CI, batch, inference, dev/test)
- CUDs require >12 months of usage history to size correctly — never commit before that
- Migrate static-VM workloads to Cloud Run / Cloud Run Jobs / GKE Autopilot whenever possible
- Storage lifecycle policies pay for themselves in weeks; there's no reason not to set them
- For multi-team accounts, use Folders + per-folder budgets and aggregated billing rollups
- Set Org Policies to restrict regions and machine types — prevents accidentally provisioning the world's most expensive VM in SydneyRelated Skills
llm-cost-optimizer
Track, analyze, and reduce LLM API costs — model routing, prompt caching, semantic caching, and budget alerts. Use when someone asks to "reduce AI costs", "track LLM spending", "optimize API costs", "set up model routing", "cache LLM responses", "compare model costs", "set budget limits for AI", or "my OpenAI bill is too high". Covers cost tracking per feature/user, smart model routing (expensive model for hard tasks, cheap for easy), semantic caching, prompt compression, and budget alerting.
k8s-cost-optimizer
Analyzes Kubernetes cluster resource allocation versus actual usage to find waste and generate right-sizing recommendations. Use when someone asks about Kubernetes costs, overprovisioned pods, resource requests/limits tuning, cluster efficiency, or cloud bill reduction for K8s workloads. Trigger words: k8s costs, pod resources, right-size, overprovisioned, resource waste, cluster optimization, CPU/memory requests.
app-store-optimization
Optimize mobile app listings for discovery and conversion in Apple App Store and Google Play. Use when tasks involve ASO keyword research, title and subtitle optimization, screenshot and preview video design, A/B testing store listings, review management, localization for international markets, tracking keyword rankings, or improving download conversion rates. Covers both iOS and Android store algorithms and best practices.
ad-campaign-optimization
Optimize paid advertising campaigns across Google Ads, Meta, TikTok, LinkedIn, and other platforms. Use when tasks involve bid optimization, audience targeting, creative testing, ROAS improvement, attribution modeling, budget allocation, campaign structure, retargeting strategies, lookalike audiences, or reducing customer acquisition cost. Covers multi-platform campaign management and creative performance analysis.
zustand
You are an expert in Zustand, the small, fast, and scalable state management library for React. You help developers manage global state without boilerplate using Zustand's hook-based stores, selectors for performance, middleware (persist, devtools, immer), computed values, and async actions — replacing Redux complexity with a simple, un-opinionated API in under 1KB.
zoho
Integrate and automate Zoho products. Use when a user asks to work with Zoho CRM, Zoho Books, Zoho Desk, Zoho Projects, Zoho Mail, or Zoho Creator, build custom integrations via Zoho APIs, automate workflows with Deluge scripting, sync data between Zoho apps and external systems, manage leads and deals, automate invoicing, build custom Zoho Creator apps, set up webhooks, or manage Zoho organization settings. Covers Zoho CRM, Books, Desk, Projects, Creator, and cross-product integrations.
zod
You are an expert in Zod, the TypeScript-first schema declaration and validation library. You help developers define schemas that validate data at runtime AND infer TypeScript types at compile time — eliminating the need to write types and validators separately. Used for API input validation, form validation, environment variables, config files, and any data boundary.
zipkin
Deploy and configure Zipkin for distributed tracing and request flow visualization. Use when a user needs to set up trace collection, instrument Java/Spring or other services with Zipkin, analyze service dependencies, or configure storage backends for trace data.
zig
Expert guidance for Zig, the systems programming language focused on performance, safety, and readability. Helps developers write high-performance code with compile-time evaluation, seamless C interop, no hidden control flow, and no garbage collector. Zig is used for game engines, operating systems, networking, and as a C/C++ replacement.
zed
Expert guidance for Zed, the high-performance code editor built in Rust with native collaboration, AI integration, and GPU-accelerated rendering. Helps developers configure Zed, create custom extensions, set up collaborative editing sessions, and integrate AI assistants for productive coding.
zeabur
Expert guidance for Zeabur, the cloud deployment platform that auto-detects frameworks, builds and deploys applications with zero configuration, and provides managed services like databases and message queues. Helps developers deploy full-stack applications with automatic scaling and one-click marketplace services.
zapier
Automate workflows between apps with Zapier. Use when a user asks to connect apps without code, automate repetitive tasks, sync data between services, or build no-code integrations between SaaS tools.