secondsky/claude-skills / plugins/cloudflare-kv/skills/cloudflare-kv
cloudflare-kv
VerifiedCloudflare Workers KV global key-value storage. Use for namespaces, caching, TTL, or encountering KV_ERROR, 429 rate limits, consistency issues.
references/setup-guide.md
View on GitHub# Cloudflare Workers KV Complete Setup
Quick setup for global key-value storage on Cloudflare edge.
---
## Step 1: Create KV Namespace
```bash
# Production namespace
npx wrangler kv namespace create MY_NAMESPACE
# Preview namespace (for dev)
npx wrangler kv namespace create MY_NAMESPACE --preview
```
Save the `id` and `preview_id`!
---
## Step 2: Configure Binding
Add to `wrangler.jsonc`:
```jsonc
{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2025-10-11",
"kv_namespaces": [
{
"binding": "MY_NAMESPACE", // env.MY_NAMESPACE
"id": "<PRODUCTION_ID>",
"preview_id": "<PREVIEW_ID>"
}
]
}
```
---
## Step 3: Use in Worker
```typescript
export default {
async fetch(request, env, ctx) {
// Write
await env.MY_NAMESPACE.put('key', 'value');
// Read
const value = await env.MY_NAMESPACE.get('key');
// Delete
await env.MY_NAMESPACE.delete('key');
return new Response(value);
}
};
```
---
## Common Patterns
### With TTL
```typescript
await env.MY_NAMESPACE.put('key', 'value', {
expirationTtl: 3600 // 1 hour
});
```
### With Metadata
```typescript
await env.MY_NAMESPACE.put('user:123', JSON.stringify({ name: 'Alice' }), {
metadata: { role: 'admin', created: Date.now() }
});
const { value, metadata } = await env.MY_NAMESPACE.getWithMetadata('user:123');
```
### List Keys
```typescript
const { keys } = await env.MY_NAMESPACE.list({
prefix: 'user:',
limit: 100
});
```
---
## Official Documentation
- **KV Overview**: https://developers.cloudflare.com/kv/
- **KV API**: https://developers.cloudflare.com/kv/api/
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |