Generate Cloudflare cost report with projections and optimization recommendations [--validate for live data]
Generates Cloudflare cost reports with optimization recommendations and live data validation.
/plugin marketplace add littlebearapps/cloudflare-engineer/plugin install cloudflare-engineer@littlebearapps-cloudflare[wrangler-path] [--validate] [--detailed]Generate a comprehensive cost analysis for your Cloudflare architecture with optimization recommendations.
Arguments: "$ARGUMENTS"
| Mode | Description | MCP Tools |
|---|---|---|
| Static (default) | Analyze config and code only | None |
Validate (--validate) | Compare static findings against live data | observability, ai-gateway, bindings |
Parse $ARGUMENTS for:
--validate: Enable live data validation--detailed: Per-binding cost breakdown[path]: Explicit wrangler config pathMode Selection:
--validate present: Live Validation ModeBefore using MCP tools, verify availability:
// Lightweight probe to test MCP connectivity
mcp__cloudflare-bindings__workers_list()
Expected outcomes:
[STATIC]If path provided, use it. Otherwise search:
# Find wrangler.toml or wrangler.jsonc
find . -name "wrangler.toml" -o -name "wrangler.jsonc" | head -5
Read the wrangler config and identify all bindings:
max_retries)Analyze code patterns:
Use MCP tools to collect real usage metrics. Reference @skills/probes/SKILL.md for query patterns.
Worker Metrics (cloudflare-observability):
mcp__cloudflare-observability__query_worker_observability({
view: "calculations",
parameters: {
calculations: [
{ operator: "count", as: "total_requests" },
{ operator: "sum", field: "$metadata.cpuTime", as: "total_cpu_ms" }
],
groupBys: [{ type: "string", value: "$metadata.service" }]
},
timeframe: { reference: "now", offset: "-30d" }
})
AI Gateway Logs (cloudflare-ai-gateway):
mcp__cloudflare-ai-gateway__list_logs({
gateway_id: "...",
per_page: 1000
})
// Aggregate by model, calculate actual costs
Resource Lists (cloudflare-bindings):
mcp__cloudflare-bindings__d1_databases_list()
mcp__cloudflare-bindings__r2_buckets_list()
mcp__cloudflare-bindings__kv_namespaces_list()
Apply 2026 Cloudflare pricing:
| Service | Read | Write | Storage |
|---|---|---|---|
| D1 | $0.25/B rows | $1.00/M rows | $0.75/GB |
| R2 | $0.36/M (Class B) | $4.50/M (Class A) | $0.015/GB |
| KV | $0.50/M | $5.00/M | $0.50/GB |
| Queues | $0.40/M messages | - | - |
| Workers | $0.30/M requests | - | - |
| Workers AI | Varies by model | - | - |
Check for common cost traps:
D1 Anti-patterns:
Queue Anti-patterns:
max_retries > 1 for idempotent consumersAI Anti-patterns:
General Anti-patterns:
Compare static estimates against live data:
D1 Write Volume
[LIVE-VALIDATED] or [LIVE-REFUTED]AI Gateway Costs
Queue Retry Rates
max_retries configEXPLAIN QUERY PLAN (D1)
mcp__cloudflare-bindings__d1_database_query({
database_id: "...",
sql: "EXPLAIN QUERY PLAN [detected query]"
})
Output format:
# Cloudflare Cost Report
Generated: [date]
Project: [wrangler name]
Mode: [Static | Live Validated]
## Summary
- **Estimated Monthly Cost**: $XX.XX
- **Cost Trend**: [Stable|Rising|Declining]
- **Optimization Potential**: $XX.XX/month
- **Validation Status**: [Full | Partial | Static Only]
## Service Breakdown
| Service | Monthly Cost | % Total | Status | Source |
|---------|-------------|---------|--------|--------|
| D1 | $XX.XX | XX% | [OK|Warning|Critical] | [STATIC|LIVE] |
| Workers | $XX.XX | XX% | [OK|Warning|Critical] | [STATIC|LIVE] |
| ... | ... | ... | ... | ... |
## Cost Drivers
### [LIVE-VALIDATED] D1 Writes - XX% of total
- **Static Estimate**: $XX.XX/month
- **Live Actual**: $XX.XX/month
- **Evidence**: Observability data, 30-day window
- Root cause: [explanation]
### [STATIC] Queue Retries - XX% of total
- **Estimate**: $XX.XX/month
- Root cause: [explanation]
- Note: Live validation unavailable
### [LIVE-REFUTED] AI Gateway - XX% of total
- **Static Estimate**: $XX.XX/month (based on code patterns)
- **Live Actual**: $XX.XX/month (cache hits reducing cost)
- **Evidence**: AI Gateway logs show 40% cache hit rate
## Optimization Opportunities
| Opportunity | Savings | Effort | Priority | Source |
|-------------|---------|--------|----------|--------|
| [Description] | $XX/mo | [Low|Med|High] | [P1|P2|P3] | [STATIC|LIVE-VALIDATED] |
## Warnings
- [List any concerning patterns with provenance tags]
## Action Items
1. [ ] [LIVE-VALIDATED] [Specific action with file:line reference]
2. [ ] [STATIC] [Specific action with file:line reference]
---
**Finding Tags:**
- `[STATIC]` - Inferred from code/config analysis
- `[LIVE-VALIDATED]` - Confirmed by observability (--validate mode)
- `[LIVE-REFUTED]` - Code smell not observed in production
- `[INCOMPLETE]` - Some MCP tools unavailable
Basic cost report (static):
/cf-costs
Cost report with live validation:
/cf-costs --validate
Specific wrangler file with validation:
/cf-costs workers/wrangler.jsonc --validate
Detailed report with per-binding breakdown:
/cf-costs --detailed --validate
--validate for accurate cost attribution--detailed for capacity planning[STATIC] should be verified manuallyFor --validate mode, these MCP servers should be configured:
cloudflare-observability - Worker metrics, D1 usagecloudflare-ai-gateway - AI cost datacloudflare-bindings - Resource lists, D1 queriesIf any MCP server is unavailable, the command will:
[INCOMPLETE]