Analyze Cloudflare architecture and predict monthly costs with optimization recommendations. Use this skill when the user asks about costs, billing, pricing, or wants to understand their Cloudflare spend. Works with wrangler configs, observability data, and AI Gateway logs.
/plugin marketplace add littlebearapps/cloudflare-engineer/plugin install cloudflare-engineer@littlebearapps-cloudflareThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Analyze Cloudflare architectures and predict monthly costs with actionable optimization recommendations. This skill provides engineering-grade cost estimates based on 2026 Cloudflare pricing.
for(row){db.insert()} = N× writes. Always batch ≤1,000.max_retries: 3 = up to 3× message costSUM(_sample_interval) at scale (adaptive sampling)Use MCP tools to collect current usage:
1. Read wrangler.toml/wrangler.jsonc for bindings
2. Query cloudflare-observability for Worker metrics
3. Query cloudflare-ai-gateway for AI costs
4. Check cloudflare-bindings for resource lists
For each service bound in wrangler config:
Workers:
monthly_cost = (requests - 10M) / 1M * $0.30
+ cpu_gb_seconds / 1M * $0.02
D1:
monthly_cost = reads / 1B * $0.25
+ writes / 1M * $1.00
+ storage_gb * $0.75
R2:
monthly_cost = class_a_ops / 1M * $4.50
+ class_b_ops / 1M * $0.36
+ storage_gb * $0.015
KV:
monthly_cost = reads / 1M * $0.50
+ writes / 1M * $5.00
+ storage_gb * $0.50
Queues:
monthly_cost = messages / 1M * $0.40 * (1 + avg_retries)
Flag any service that's >20% of total cost. Common patterns:
| Cost Driver | Typical Cause | Fix |
|---|---|---|
| D1 writes dominating | Per-row inserts | Batch to ≤1,000 |
| Queue costs high | Retries enabled | Set max_retries: 1 if idempotent |
| AI Gateway expensive | No caching | Enable cache, deduplicate prompts |
| Workers AI | Large model | Switch to smaller model or external LLM |
| R2 Class A | Frequent writes | Buffer writes, use R2 presigned |
For each optimization opportunity, provide:
# Cloudflare Cost Analysis
## Monthly Cost Estimate: $X.XX
### Breakdown by Service
| Service | Cost | % of Total | Status |
|---------|------|------------|--------|
| D1 | $X.XX | X% | ⚠️ Cost driver |
| Workers | $X.XX | X% | ✅ Normal |
| R2 | $X.XX | X% | ✅ Normal |
### Cost Drivers Identified
1. **D1 Writes** (80% of total)
- Current: 50M writes/month = $50
- Pattern detected: Per-row inserts in cron job
- Fix: Batch inserts to ≤1,000 rows
### Optimization Opportunities
| Opportunity | Current | Optimized | Savings | Effort |
|-------------|---------|-----------|---------|--------|
| Batch D1 writes | $50/mo | $5/mo | $45/mo ($540/yr) | Low |
| Reduce queue retries | $10/mo | $3/mo | $7/mo ($84/yr) | Trivial |
### Warnings
- ⚠️ D1 writes >50M/day is a red flag
- ⚠️ Workers AI Llama 11B is expensive for high-volume
### Action Items
1. [ ] Change `for(row){insert()}` to `db.batch()` in `processor.ts`
2. [ ] Set `max_retries: 1` for `layer2-queue` in wrangler.jsonc
3. [ ] Consider switching AI model from llama-3-11b to llama-3-8b
mcp__cloudflare-observability__query_worker_observability - Worker request/duration metricsmcp__cloudflare-ai-gateway__list_logs - AI request costsmcp__cloudflare-bindings__workers_get_worker - Worker detailsmcp__cloudflare-bindings__d1_databases_list - D1 databasesmcp__cloudflare-bindings__r2_buckets_list - R2 bucketsmcp__cloudflare-bindings__kv_namespaces_list - KV namespacesWhen user asks:
Invoke this skill to provide detailed cost analysis with actionable recommendations.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.