Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Cloudflare Workers: Edge APIs with D1, KV, R2 & AI

    1

    Architect, build, and deploy serverless apps on Cloudflare Workers with D1, R2, KV, and Hono.

    Free

    Security scanned
    Cloudflare Workers: Edge APIs with D1, KV, R2 & AI

    Cloudflare Workers: Edge APIs with D1, KV, R2 & AI

    Example session with this skill installed

    Create a Cloudflare Worker using Hono that stores user profiles in a D1 database and caches frequently accessed metadata in KV. Include the wrangler config and a migration script.

    • Read your context and instructions
    • Compiled the cloudflare workers

    I have scaffolded the Cloudflare Worker using Hono with D1 and KV bindings. This setup includes the API logic, the database schema migration, and the configuration file required for deployment.

    Cloudflare Worker Implementation

    // src/index.ts
    import { Hono } from 'hono';
    
    type Bindings = {
      DB: D1Database;
      USER_CACHE: KVNamespace;
    };
    
    const app = new Hono<{ Bindings: Bindings }>();
    
    app.get('/user/:id', async (c) => {
      const id = c.req.param('id');
      
      // Try KV cache first
      const cached = await c.env.USER_CACHE.get(`user:${id}`);
      if (cached) return c.json(JSON.parse(cached));
    
      // Fallback to D1
      const user = await c.env.DB.prepare('SELECT * FROM users WHERE id = ?')
        .bind(id)
        .first();
    
      if (!user) return c.json({ error: 'Not found' }, 404);
    
      // Update cache for 1 hour
      await c.env.USER_CACHE.put(`user:${id}`, JSON.stringify(user), { expirationTtl: 3600 });
    
      return c.json(user);
    });
    
    export default app;
    
    // wrangler.jsonc
    {
      "name": "user-api",
      "main": "src/index.ts",
      "compatibility_date": "2024-05-01",
      "d1_databases": [
        {
          "binding": "DB",
          "database_name": "production-db",
          "database_id": "YOUR_D1_UUID"
        }
      ],
      "kv_namespaces": [
        {
          "binding": "USER_CACHE",
          "id": "YOUR_KV_UUID"
        }
      ]
    }
    
    -- migrations/0001_create_users.sql
    CREATE TABLE users (
      id TEXT PRIMARY KEY,
      name TEXT NOT NULL,
      email TEXT UNIQUE,
      created_at DATETIME DEFAULT CURRENT_TIMESTAMP
    );
    

    Next steps

    1. Run npx wrangler d1 create production-db and update the ID in wrangler.jsonc.
    2. Apply the migration locally using npx wrangler d1 migrations apply production-db --local.
    3. Use npx wrangler dev to start the local development server with Miniflare.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Deploying to the edge often results in configuration debt, cold start issues, or broken database bindings. This skill provides a direct path for building and deploying serverless applications on Cloudflare's global network using the full suite of developer tools.

    What it does

    • Architectural mapping selects the right primitives like Hono for APIs, D1 for relational data, or R2 for object storage.
    • Wrangler configuration generates valid wrangler.jsonc files including environment bindings and compatibility flags.
    • Database management handles D1 SQLite migrations and parameterized queries to prevent SQL injection.
    • State management implements Durable Objects for WebSockets or per-user state and KV for high-read caching.
    • Background processing configures Queues with Dead Letter Queues and Cron Triggers for scheduled tasks.
    • Inference integration scripts Workers AI and Vectorize for edge-based machine learning workflows.

    How it works

    1. Define the stack by specifying your frontend framework or API needs to select between Workers and Pages.
    2. Configure bindings for D1, R2, KV, or Durable Objects within the Wrangler configuration.
    3. Develop and test using local Miniflare environments and Vitest pool workers for edge-consistent testing.
    4. Deploy and monitor using deployment commands, custom domain routing, and live log tailing.

    Frameworks & tools

    Uses Hono for routing, Wrangler CLI for orchestration, Vitest for testing, and Zod for input validation. Supports Next.js (OpenNext), Astro, Nuxt, and SvelteKit.

    Why this beats prompting it yourself

    Generic LLMs often mix up Cloudflare's legacy syntax with modern standards or fail to handle the nuances of env bindings versus process.env. This skill enforces current wrangler.jsonc structures, proper migration flows, and cost-aware execution limits that prevent CPU time-outs.

    Use cases

    • Build a globally distributed REST API using Hono and D1 SQLite.
    • Deploy an S3-compatible image hosting service with R2 and no egress fees.
    • Create real-time collaborative tools using Durable Objects and WebSockets.
    • Run scheduled data processing jobs using Cron Triggers and Queues.

    Known limitations

    Requires manual login via Wrangler for initial authentication. Developers must manually manage secret injection for CI/CD environments beyond local development.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.

    Requires manual Wrangler CLI login. Secrets must be manually added to production via CLI. Subject to Cloudflare CPU and subrequest limits.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Free to use

    No account required to browse

    Trust & safety

    Security scan

    Security scan passed 1 day ago

    • Free with an Agensi account

    Software
    WranglerNode.js

    Permissions

    Terminal / Shell
    Environment Variables
    Listed1 day ago

    What's inside

    Frequently Asked Questions

    This skill eliminates configuration debt and 'cold start' errors by automating the setup of wrangler.jsonc, D1 migrations, and R2 bindings, ensuring your code adheres to Cloudflare's modern standards rather than legacy syntax.

    It is optimized for use with Hono for routing, Vitest for testing, and Zod for validation, while offering full support for frameworks like Next.js, Astro, Nuxt, and SvelteKit.

    You will receive a production-ready blueprint for Cloudflare development, including architectural mapping for D1/R2/KV, migration scripts, and edge-consistent testing configurations.

    While the skill automates the configuration of bindings and infrastructure, you will still need to perform a one-time manual login via the Wrangler CLI to authenticate your local environment with Cloudflare.

    Yes, the skill is specifically designed to handle advanced state management, providing precise configurations for Durable Objects to enable WebSockets and per-user state at the edge.

    New in APIs & Backend

    Free