skills/data-cost-optimizer/SKILL.md
Warehouse cost reduction, auto-scaling, query optimization, and lifecycle policies for data infrastructure. Activate on: data cost, warehouse credits, cost reduction, auto-scaling, lifecycle policy, cold storage, cost monitoring, resource optimization. NOT for: query performance tuning (use data-warehouse-optimizer), batch job optimization (use batch-processing-optimizer).
npx skillsauth add curiositech/windags-skills data-cost-optimizerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Reduce data infrastructure costs through warehouse right-sizing, storage lifecycle policies, query optimization, and FinOps practices.
Activate on: "data cost", "warehouse credits", "cost reduction", "auto-scaling", "lifecycle policy", "cold storage", "cost monitoring", "Snowflake credits", "BigQuery slots", "FinOps"
NOT for: Query performance tuning → data-warehouse-optimizer | Batch job resource sizing → batch-processing-optimizer | Infrastructure provisioning → relevant DevOps skill
| Domain | Technologies | |--------|-------------| | Snowflake | Resource monitors, auto-suspend, warehouse sizing, credit tracking | | BigQuery | Slot reservations, flat-rate vs on-demand, BI Engine, editions | | Storage | S3 lifecycle (Standard → IA → Glacier), GCS Nearline/Coldline | | Monitoring | Snowflake Account Usage, BigQuery INFORMATION_SCHEMA, Cost Explorer | | FinOps | Kubecost, Datadog Cloud Cost, custom dashboards |
-- 1. Resource monitor: alert at 80%, suspend at 100%
CREATE RESOURCE MONITOR monthly_budget
WITH CREDIT_QUOTA = 5000
FREQUENCY = MONTHLY
START_TIMESTAMP = IMMEDIATELY
TRIGGERS
ON 80 PERCENT DO NOTIFY
ON 100 PERCENT DO SUSPEND;
ALTER WAREHOUSE analytics_wh SET RESOURCE_MONITOR = monthly_budget;
-- 2. Auto-suspend idle warehouses
ALTER WAREHOUSE analytics_wh SET
AUTO_SUSPEND = 60 -- suspend after 60s idle
AUTO_RESUME = TRUE
MIN_CLUSTER_COUNT = 1
MAX_CLUSTER_COUNT = 3 -- auto-scale up to 3 clusters
SCALING_POLICY = 'ECONOMY'; -- prefer queue over new cluster
-- 3. Find expensive queries
SELECT
query_id,
user_name,
warehouse_name,
total_elapsed_time / 1000 AS seconds,
bytes_scanned / (1024*1024*1024) AS gb_scanned,
credits_used_cloud_services
FROM snowflake.account_usage.query_history
WHERE start_time > DATEADD(day, -7, CURRENT_TIMESTAMP)
ORDER BY credits_used_cloud_services DESC
LIMIT 20;
Data Age Storage Tier Cost (S3) Access
────────── ──────────── ───────── ──────
0-30 days Standard $0.023/GB Frequent
30-90 days Infrequent Access $0.0125/GB Occasional
90-365 days Glacier Instant $0.004/GB Rare
1-3 years Glacier Flexible $0.0036/GB Archive
3+ years Glacier Deep Archive $0.00099/GB Compliance only
Savings: moving 10TB from Standard to lifecycle-managed
Before: $230/mo
After: ~$50/mo (78% reduction)
┌─────────────────────────────────────────────────┐
│ Monthly Data Infrastructure Cost: $12,450 │
│ │
│ By Team: │
│ Analytics ████████████████ $5,200 (42%) │
│ Data Eng ██████████ $3,100 (25%) │
│ ML Platform ████████ $2,500 (20%) │
│ Ad-hoc ████ $1,650 (13%) │
│ │
│ By Category: │
│ Compute █████████████ $7,500 (60%) │
│ Storage ██████ $3,200 (26%) │
│ Egress ███ $1,750 (14%) │
│ │
│ Top Optimization Opportunities: │
│ 1. Idle warehouse X-Large: $800/mo savings │
│ 2. Full-scan query by user@co: $400/mo │
│ 3. Duplicate staging tables: $300/mo storage │
└─────────────────────────────────────────────────┘
tools
Building resilient distributed systems with circuit breakers, retries with full-jitter exponential backoff, retry budgets (per-request 3-attempt + per-client 10% ratio per Google SRE), deadline propagation, and the cascading-failure math (4 layers × 3 retries = 64x amplification). Grounded in Resilience4j, Microsoft Cloud Patterns, AWS Architecture Blog (Marc Brooker), and Google SRE Book.
testing
Designing HTTP cache headers that work correctly across browsers, CDNs, and shared proxies — `Cache-Control` directives per RFC 9111, `stale-while-revalidate` and `stale-if-error` per RFC 5861, the Vary header for varying responses, and surrogate keys for tag-based purging. Grounded in IETF RFCs and Cloudflare/Fastly docs.
development
Use when designing or fixing a Content Security Policy on a real site, choosing between nonce-based and hash-based CSP, adding strict-dynamic, debugging "Refused to execute inline script" errors, deploying CSP in report-only mode first, configuring report-to / report-uri, or auditing an existing policy for unsafe-inline / unsafe-eval / wildcards. Triggers: "CSP blocks legitimate inline script", strict-dynamic, nonce-{RANDOM}, sha256-{HASH}, object-src none, base-uri none, frame-ancestors, Trusted Types, X-Content-Security-Policy obsolete, report-only vs enforced. NOT for general HTTP security headers (HSTS, COOP/COEP), Trusted Types deep dive, CORS configuration, or building a WAF.
tools
Choosing and operating an HTTP API versioning strategy that doesn't break clients — Stripe's date-based pinned versions, the Deprecation/Sunset header pair (RFC 9745 + RFC 8594), URI vs header vs media-type approaches, and the version-transformer pattern. Grounded in Stripe's published architecture and IETF RFCs.