All skills
theprimeagen avatar

/cloudflare-hyperdrive

@56c7e25
by theprimeagentheprimeagen/skills233 stars
6

Cloudflare Hyperdrive connection usage rules

  • 1 file
  • 1.1 KB
  • Updated 7 months ago
  • GitHub

Use this Skill: https://skilld.dev/gh/theprimeagen/skills/cloudflare-hyperdrive

This session only. Nothing lands on disk.

SKILL.md

≈17 tokens always: the name and description. ≈256 when used: this file.

Cloudflare Hyperdrive

Rules

  1. Create a new database client/connection inside each Worker invocation (fetch, queue, scheduled, or Durable Object method); never create global clients or driver pools (new Pool(), createPool()). Hyperdrive manages the shared origin pool.
  2. Use the Hyperdrive binding directly: Postgres uses env.HYPERDRIVE.connectionString
  3. Let Hyperdrive manage connection lifecycle: keep transactions short, avoid long-lived pinned connections, and do not call client.end() / connection.end() for routine per-request cleanup.

Example 1: PostgreSQL (Hyperdrive handles pooling)

import { Client } from "pg";

export default {
  async fetch(_request, env): Promise<Response> {
    const client = new Client({
      connectionString: env.HYPERDRIVE.connectionString,
    });

    await client.connect();
    const result = await client.query("SELECT NOW() AS now");
    return Response.json(result.rows[0]);
  },
} satisfies ExportedHandler<{ HYPERDRIVE: Hyperdrive }>;

Source: SKILL.md on GitHub

No third-party reports yet.

Signed by skilld at 56c7e25. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 7 months ago
globs
src/**/*.ts
alwaysApply
false

README badge

README badge for theprimeagen/skills/cloudflare-hyperdrive