cloudflare-kv
Store key-value data globally with Cloudflare KV's edge network. Use when: caching API responses, storing configuration, managing user preferences, handling TTL expiration, or troubleshooting KV_ERROR, 429 rate limits, eventual consistency, or cacheTtl errors.
What this skill does
# Cloudflare Workers KV **Status**: Production Ready ✅ **Last Updated**: 2025-10-21 **Dependencies**: cloudflare-worker-base (for Worker setup) **Latest Versions**: [email protected], @cloudflare/[email protected] --- ## Quick Start (5 Minutes) ### 1. Create KV Namespace ```bash # Create a new KV namespace npx wrangler kv namespace create MY_NAMESPACE # Output includes namespace_id - save this! # ✅ Success! # Add the following to your wrangler.toml or wrangler.jsonc: # # [[kv_namespaces]] # binding = "MY_NAMESPACE" # id = "<UUID>" ``` **For development (preview) namespace:** ```bash npx wrangler kv namespace create MY_NAMESPACE --preview # Output: # [[kv_namespaces]] # binding = "MY_NAMESPACE" # preview_id = "<UUID>" ``` ### 2. Configure Bindings Add to your `wrangler.jsonc`: ```jsonc { "name": "my-worker", "main": "src/index.ts", "compatibility_date": "2025-10-11", "kv_namespaces": [ { "binding": "MY_NAMESPACE", // Available as env.MY_NAMESPACE "id": "<production-uuid>", // Production namespace ID "preview_id": "<preview-uuid>" // Local dev namespace ID (optional) } ] } ``` **Or use `wrangler.toml`:** ```toml name = "my-worker" main = "src/index.ts" compatibility_date = "2025-10-11" [[kv_namespaces]] binding = "MY_NAMESPACE" id = "<production-uuid>" preview_id = "<preview-uuid>" # optional ``` **CRITICAL:** - `binding` is how you access the namespace in code (`env.MY_NAMESPACE`) - `id` is the production namespace UUID - `preview_id` is for local dev (optional, separate namespace) - **Never commit real namespace IDs to public repos** - use environment variables or secrets ### 3. Write Your First Key-Value Pair ```typescript import { Hono } from 'hono'; type Bindings = { MY_NAMESPACE: KVNamespace; }; const app = new Hono<{ Bindings: Bindings }>(); app.post('/set/:key', async (c) => { const key = c.req.param('key'); const value = await c.req.text(); // Simple write await c.env.MY_NAMESPACE.put(key, value); return c.json({ success: true, key }); }); app.get('/get/:key', async (c) => { const key = c.req.param('key'); const value = await c.env.MY_NAMESPACE.get(key); if (!value) { return c.json({ error: 'Not found' }, 404); } return c.json({ value }); }); export default app; ``` ### 4. Test Locally ```bash # Start local development server npm run dev # In another terminal, test the endpoints curl -X POST http://localhost:8787/set/test -d "Hello KV" # {"success":true,"key":"test"} curl http://localhost:8787/get/test # {"value":"Hello KV"} ``` --- ## Complete Workers KV API ### 1. Read Operations #### `get()` - Read Single Key ```typescript // Get as string (default) const value: string | null = await env.MY_KV.get('my-key'); // Get as JSON const data: MyType | null = await env.MY_KV.get('my-key', { type: 'json' }); // Get as ArrayBuffer const buffer: ArrayBuffer | null = await env.MY_KV.get('my-key', { type: 'arrayBuffer' }); // Get as ReadableStream const stream: ReadableStream | null = await env.MY_KV.get('my-key', { type: 'stream' }); // Get with cache optimization const value = await env.MY_KV.get('my-key', { type: 'text', cacheTtl: 300, // Cache at edge for 5 minutes (minimum 60 seconds) }); ``` #### `get()` - Read Multiple Keys (Bulk) ```typescript // Read multiple keys at once (counts as 1 operation) const keys = ['key1', 'key2', 'key3']; const values: Map<string, string | null> = await env.MY_KV.get(keys); // Access values const value1 = values.get('key1'); // string | null const value2 = values.get('key2'); // string | null // Convert to object const obj = Object.fromEntries(values); ``` #### `getWithMetadata()` - Read with Metadata ```typescript // Get single key with metadata const { value, metadata } = await env.MY_KV.getWithMetadata('my-key'); // value: string | null // metadata: any | null // Get as JSON with metadata const { value, metadata } = await env.MY_KV.getWithMetadata<MyType>('my-key', { type: 'json', cacheTtl: 300, }); // Get multiple keys with metadata const keys = ['key1', 'key2']; const result: Map<string, { value: string | null, metadata: any | null }> = await env.MY_KV.getWithMetadata(keys); for (const [key, data] of result) { console.log(key, data.value, data.metadata); } ``` **Type Options:** - `text` (default) - Returns `string` - `json` - Parses JSON, returns `object` - `arrayBuffer` - Returns `ArrayBuffer` - `stream` - Returns `ReadableStream` **Note:** Bulk read with `get(keys[])` only supports `text` and `json` types. For `arrayBuffer` or `stream`, use individual `get()` calls with `Promise.all()`. --- ### 2. Write Operations #### `put()` - Write Key-Value Pair ```typescript // Simple write await env.MY_KV.put('key', 'value'); // Write JSON await env.MY_KV.put('user:123', JSON.stringify({ name: 'John', age: 30 })); // Write with expiration (TTL) await env.MY_KV.put('session:abc', sessionData, { expirationTtl: 3600, // Expire in 1 hour (minimum 60 seconds) }); // Write with absolute expiration const expirationTime = Math.floor(Date.now() / 1000) + 86400; // 24 hours from now await env.MY_KV.put('token', tokenValue, { expiration: expirationTime, // Seconds since epoch }); // Write with metadata await env.MY_KV.put('config:theme', 'dark', { metadata: { updatedAt: Date.now(), updatedBy: 'admin', version: 2 }, }); // Write with everything await env.MY_KV.put('feature:flags', JSON.stringify(flags), { expirationTtl: 600, metadata: { source: 'api', timestamp: Date.now() }, }); ``` **CRITICAL Limits:** - **Key size**: Maximum 512 bytes - **Value size**: Maximum 25 MiB - **Metadata size**: Maximum 1024 bytes (JSON serialized) - **Write rate**: Maximum 1 write per second **per key** - **Expiration minimum**: 60 seconds (both TTL and absolute) **Rate Limit Handling:** ```typescript async function putWithRetry( kv: KVNamespace, key: string, value: string, options?: KVPutOptions ) { let attempts = 0; const maxAttempts = 5; let delay = 1000; // Start with 1 second while (attempts < maxAttempts) { try { await kv.put(key, value, options); return; // Success } catch (error) { const message = (error as Error).message; if (message.includes('429') || message.includes('Too Many Requests')) { attempts++; if (attempts >= maxAttempts) { throw new Error('Max retry attempts reached'); } console.warn(`Attempt ${attempts} failed. Retrying in ${delay}ms...`); await new Promise(resolve => setTimeout(resolve, delay)); // Exponential backoff delay *= 2; } else { throw error; // Different error, rethrow } } } } ``` --- ### 3. List Operations #### `list()` - List Keys ```typescript // List all keys (up to 1000) const result = await env.MY_KV.list(); console.log(result.keys); // Array of key objects console.log(result.list_complete); // boolean - false if more keys exist console.log(result.cursor); // string - for pagination // List with prefix filter const result = await env.MY_KV.list({ prefix: 'user:', // Only keys starting with 'user:' }); // List with limit const result = await env.MY_KV.list({ limit: 100, // Maximum 1000 (default 1000) }); // Pagination with cursor let cursor: string | undefined; let allKeys: any[] = []; do { const result = await env.MY_KV.list({ cursor }); allKeys = allKeys.concat(result.keys); cursor = result.list_complete ? undefined : result.cursor; } while (cursor); // Combined: prefix + pagination let cursor: string | undefined; const userKeys: any[] = []; do { const result = await env.MY_KV.list({ prefix: 'user:', cursor, }); userKeys.push(...result.keys); cursor = result.list_complete ? undefined : result.cursor; } while (cursor); ``` **List Response Format:** ```typescript { keys: [ { name: "user:123", expiration: 1234
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.