# Cloudflare Audit

> Cloudflare platform cost optimization expert. Monitors Workers, D1, KV, R2 usage, identifies cost anomalies, and provides optimization recommendations. Trigger when user mentions Cloudflare costs, Workers optimization, or platform audit.

- Skill: `huifer/cloudflare-audit` (Agent Skill, multi-file: 8 files)
- Install (CLI): `npx skillmds@latest add huifer/cloudflare-audit`
- Raw SKILL.md: https://api.skillmd.com/api/skills/huifer/cloudflare-audit/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Security
- Author: huifer (https://skillmd.com/u/huifer)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/huifer/cloudflare-audit

---


# Cloudflare Cost Optimization Expert

## Cost Components

| Service | Free Tier | Billing Metric |
|---------|-----------|----------------|
| Workers | 100K req/day | Invocations |
| D1 | 5M reads/day | Row Reads |
| KV | 100K reads/day | Operations |
| R2 | 10GB storage | Storage + Operations |
| Pages | 500 builds/month | Builds |

## Audit Workflow

### Step 1: Check Workers Usage

```bash
wrangler analytics
```

Analyze invocation patterns and CPU time.
See `cases/workers-optimization.md` for optimization.

### Step 2: Audit D1 Costs

Check Row Reads and query patterns.
See `d1-cost-optimizer` skill for detailed analysis.

### Step 3: Monitor KV Operations

```bash
wrangler kv:key list --binding=MY_KV
```

Identify read/write patterns.
See `cases/kv-optimization.md` for optimization.

### Step 4: Review R2 Storage

```bash
wrangler r2 bucket list
```

Check storage usage and operation counts.
See `cases/r2-optimization.md` for optimization.

## Matching Cases

| Service | Case File | Focus |
|---------|-----------|-------|
| Workers | `cases/workers-optimization.md` | Invocations, CPU time |
| KV | `cases/kv-optimization.md` | Operations, storage |
| R2 | `cases/r2-optimization.md` | Storage, operations |

## Benchmark Reference

| Optimization | Before | After | Improvement |
|--------------|--------|-------|-------------|
| Workers caching | 100K req/day | 10K req/day | 90% |
| KV batching | 100K reads | 20K reads | 80% |
| R2 presigned URLs | 1M ops | 100K ops | 90% |

## Output Format

```
## Cloudflare Cost Audit Report

### 1. Service Usage
| Service | Current | Free Tier | Status |
|---------|---------|-----------|--------|
| Workers | X req | 100K/day | X% |
| D1 | X reads | 5M/day | X% |
| KV | X ops | 100K/day | X% |
| R2 | X GB | 10GB | X% |

### 2. Cost Analysis
- Current monthly cost: $X
- Projected cost: $X

### 3. Recommendations (by priority)
1. [P0] Apply case: <case-name> → Expected savings: $X/month

### 4. Implementation
Reference: cases/<case-name>.md
```

