try-works/role-model / .agents/skills/cloudflare
cloudflare
UnverifiedComprehensive Cloudflare platform skill covering Workers, Pages, storage (KV, D1, R2), AI (Workers AI, Vectorize, Agents SDK), feature flags (Flagship), networking (Tunnel, Spectrum), security (WAF, DDoS), and infrastructure-as-code (Terraform, Pulumi). Use for any Cloudflare development task. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
references/observability/patterns.md
View on GitHub# Observability Patterns
## Usage-Based Billing
```typescript
env.ANALYTICS.writeDataPoint({
blobs: [customerId, request.url, request.method],
doubles: [1], // request_count
indexes: [customerId]
});
```
```sql
SELECT blob1 AS customer_id, SUM(_sample_interval * double1) AS total_calls
FROM api_usage WHERE timestamp >= DATE_TRUNC('month', NOW())
GROUP BY customer_id
```
## Performance Monitoring
```typescript
const start = Date.now();
const response = await fetch(url);
env.ANALYTICS.writeDataPoint({
blobs: [url, response.status.toString()],
doubles: [Date.now() - start, response.status]
});
```
```sql
SELECT blob1 AS url, AVG(double1) AS avg_ms, percentile(double1, 0.95) AS p95_ms
FROM fetch_metrics WHERE timestamp >= NOW() - INTERVAL '1' HOUR
GROUP BY url
```
## Error Tracking
```typescript
env.ANALYTICS.writeDataPoint({
blobs: [error.name, request.url, request.method],
doubles: [1],
indexes: [error.name]
});
```
## Multi-Tenant Tracking
```typescript
env.ANALYTICS.writeDataPoint({
indexes: [tenantId], // efficient filtering
blobs: [tenantId, url.pathname, method, status],
doubles: [1, duration, bytesSize]
});
```
## Tail Worker Log Filtering
```typescript
export default {
async tail(events, env, ctx) {
const critical = events.filter(e =>
e.exceptions.length > 0 || e.event.wallTime > 1000000
);
if (critical.length === 0) return;
ctx.waitUntil(
fetch('https://logging.example.com/ingest', {
method: 'POST',
headers: { 'Authorization': `Bearer ${env.API_KEY}` },
body: JSON.stringify(critical.map(e => ({
outcome: e.event.outcome,
cpu_ms: e.event.cpuTime / 1000,
errors: e.exceptions
})))
})
);
}
};
```
## OpenTelemetry Export
```typescript
export default {
async tail(events, env, ctx) {
const otelSpans = events.map(e => ({
traceId: generateId(32),
spanId: generateId(16),
name: e.scriptName || 'worker.request',
attributes: [
{ key: 'worker.outcome', value: { stringValue: e.event.outcome } },
{ key: 'worker.cpu_time_us', value: { intValue: String(e.event.cpuTime) } }
]
}));
ctx.waitUntil(
fetch('https://api.honeycomb.io/v1/traces', {
method: 'POST',
headers: { 'X-Honeycomb-Team': env.HONEYCOMB_KEY },
body: JSON.stringify({ resourceSpans: [{ scopeSpans: [{ spans: otelSpans }] }] })
})
);
}
};
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 469k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 469k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 469k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |