Pre-built audit probes for Cloudflare services. Reference these query patterns when validating D1 indexes, observability metrics, AI Gateway costs, and queue health via MCP tools.
/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.
Pre-built diagnostic queries for live validation. Use these probes when --validate mode is enabled to compare static analysis findings against actual production data.
Before running any probes, verify MCP tool availability:
// Lightweight probe to test MCP connectivity
mcp__cloudflare-bindings__workers_list()
// Expected: Returns array of workers
// Failure: MCP tools unavailable, fall back to static analysis
Graceful Degradation:
[STATIC], [LIVE-VALIDATED], [LIVE-REFUTED], [INCOMPLETE]List all tables in the database:
SELECT name, sql
FROM sqlite_master
WHERE type='table'
ORDER BY name;
MCP Call:
mcp__cloudflare-bindings__d1_database_query({
database_id: "your-database-id",
sql: "SELECT name, sql FROM sqlite_master WHERE type='table' ORDER BY name"
})
List all indexes with their definitions:
SELECT name, tbl_name, sql
FROM sqlite_master
WHERE type='index'
AND name NOT LIKE 'sqlite_%'
ORDER BY tbl_name, name;
Interpretation:
Validate query efficiency:
EXPLAIN QUERY PLAN SELECT * FROM users WHERE email = ?;
MCP Call:
mcp__cloudflare-bindings__d1_database_query({
database_id: "your-database-id",
sql: "EXPLAIN QUERY PLAN SELECT * FROM users WHERE email = ?"
})
Interpretation:
| Output Contains | Meaning | Action |
|---|---|---|
SCAN TABLE | Full table scan, no index | Add index on filtered column |
SEARCH USING INDEX | Index used | Good performance |
COVERING INDEX | Index contains all needed data | Optimal |
USING TEMP B-TREE | Temporary sort required | Consider index on ORDER BY column |
Get approximate table sizes:
SELECT name,
(SELECT COUNT(*) FROM pragma_table_info(name)) as columns,
(SELECT seq FROM sqlite_sequence WHERE name = m.name) as approx_rows
FROM sqlite_master m
WHERE type='table'
AND name NOT LIKE 'sqlite_%';
mcp__cloudflare-observability__query_worker_observability({
view: "calculations",
parameters: {
calculations: [
{ operator: "count", as: "total_requests" },
{
operator: "countIf",
as: "errors",
condition: {
field: "$metadata.outcome",
operator: "eq",
value: "exception"
}
}
],
groupBys: [
{ type: "string", value: "$metadata.service" }
]
},
timeframe: {
reference: "now",
offset: "-7d"
}
})
Interpretation:
mcp__cloudflare-observability__query_worker_observability({
view: "calculations",
parameters: {
calculations: [
{ operator: "p50", field: "$metadata.duration", as: "p50_ms" },
{ operator: "p95", field: "$metadata.duration", as: "p95_ms" },
{ operator: "p99", field: "$metadata.duration", as: "p99_ms" }
],
groupBys: [
{ type: "string", value: "$metadata.path" }
]
},
timeframe: {
reference: "now",
offset: "-24h"
}
})
Interpretation:
mcp__cloudflare-observability__query_worker_observability({
view: "calculations",
parameters: {
calculations: [
{ operator: "count", as: "requests" }
],
groupBys: [
{ type: "string", value: "$metadata.path" },
{ type: "time", interval: "1h" }
]
},
timeframe: {
reference: "now",
offset: "-7d"
}
})
Use Case: Identify high-traffic endpoints for cost optimization focus.
mcp__cloudflare-observability__query_worker_observability({
view: "calculations",
parameters: {
calculations: [
{ operator: "sum", field: "$metadata.cpuTime", as: "total_cpu_ms" },
{ operator: "avg", field: "$metadata.cpuTime", as: "avg_cpu_ms" }
],
groupBys: [
{ type: "string", value: "$metadata.service" }
]
},
timeframe: {
reference: "now",
offset: "-30d"
}
})
Cost Impact: CPU time directly impacts Workers billing on paid plans.
const logs = await mcp__cloudflare-ai-gateway__list_logs({
gateway_id: "your-gateway-id",
per_page: 1000,
order_by: "created_at",
direction: "desc"
});
// Aggregate by model
const costByModel = {};
for (const log of logs.result) {
const model = log.model;
const tokens = log.tokens_in + log.tokens_out;
costByModel[model] = (costByModel[model] || 0) + tokens;
}
Pricing Reference (per 1K tokens):
| Model | Input | Output |
|---|---|---|
| @cf/meta/llama-3-8b-instruct | $0.00019 | $0.00019 |
| @cf/mistral/mistral-7b-instruct | $0.00011 | $0.00011 |
| @hf/thebloke/deepseek-coder-6.7b-instruct | $0.00013 | $0.00013 |
const logs = await mcp__cloudflare-ai-gateway__list_logs({
gateway_id: "your-gateway-id",
per_page: 1000
});
const total = logs.result.length;
const cached = logs.result.filter(l => l.cached).length;
const cacheHitRate = (cached / total * 100).toFixed(1);
Interpretation:
const logs = await mcp__cloudflare-ai-gateway__list_logs({
gateway_id: "your-gateway-id",
per_page: 1000
});
// Analyze token distribution
const tokenBuckets = { small: 0, medium: 0, large: 0, xlarge: 0 };
for (const log of logs.result) {
const total = log.tokens_in + log.tokens_out;
if (total < 100) tokenBuckets.small++;
else if (total < 500) tokenBuckets.medium++;
else if (total < 2000) tokenBuckets.large++;
else tokenBuckets.xlarge++;
}
Use Case: Identify if smaller models could handle high-volume, low-token requests.
mcp__cloudflare-bindings__queues_list()
Check For:
-dlq suffix for DLQs)From wrangler config, verify:
{
"queues": {
"consumers": [{
"queue": "my-queue",
"max_batch_size": 10, // 1-100, default 10
"max_batch_timeout": 5, // 0-30 seconds
"max_retries": 2, // 0-100, recommend <= 2
"dead_letter_queue": "my-queue-dlq", // REQUIRED for resilience
"max_concurrency": 10 // 1-20
}]
}
}
Audit Checks:
| Setting | Risk | Recommendation |
|---|---|---|
max_retries > 2 | Cost multiplication | Reduce to 2, use DLQ |
Missing dead_letter_queue | Message loss | Always configure DLQ |
max_batch_size = 1 | Inefficient processing | Increase for throughput |
Currently no direct MCP tool for queue depth. Check via:
wrangler queues listWarning Signs:
mcp__cloudflare-bindings__r2_buckets_list()
From R2 metrics (when available):
Cost Optimization:
mcp__cloudflare-bindings__kv_namespaces_list()
KV doesn't support listing all keys efficiently. Instead, analyze code for:
Cost Note: KV writes are 10x more expensive than reads ($5/M vs $0.50/M).
mcp__cloudflare-bindings__vectorize_indexes_list()
For each index, check:
When reporting probe results, use provenance tags:
### [LIVE-VALIDATED] COST001: D1 writes at 85% of projected
- **Probe**: D1 write volume query
- **Expected** (static): 50M writes/month
- **Actual** (live): 42.5M writes/month
- **Evidence**: Observability data, 30-day window
### [LIVE-REFUTED] PERF001: Missing indexes on users.email
- **Probe**: EXPLAIN QUERY PLAN
- **Static Finding**: No index detected in migrations
- **Live Result**: `SEARCH USING COVERING INDEX idx_users_email`
- **Conclusion**: Index exists, not in tracked migrations
### [INCOMPLETE] SEC001: Rate limiting status
- **Probe**: Could not verify (MCP tool unavailable)
- **Static Finding**: No rate limiting detected in code
- **Action**: Manual verification required
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 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 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.