Cloudflare Hyperdrive logo

Cloudflare Hyperdrive

Community
secondsky
cloudflare-hyperdrive

Cloudflare Hyperdrive for Workers-to-database connections with pooling and caching. Use for PostgreSQL/MySQL, Drizzle/Prisma, or encountering pool errors, TLS issues, connection refused.

Overview

Publishersecondsky
Repositoryclaude-skills
Skill namecloudflare-hyperdrive
Stars
219
Forks
31
Bundled files
19
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 19 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by secondsky on GitHub. Read the source before you install it.

Installation

Install the Cloudflare Hyperdrive AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/secondsky/claude-skills.git /tmp/claude-skills
mkdir -p .claude/skills
cp -r /tmp/claude-skills/plugins/cloudflare-hyperdrive/skills/cloudflare-hyperdrive .claude/skills/cloudflare-hyperdrive
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Cloudflare Hyperdrive in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Cloudflare Hyperdrive on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Cloudflare Hyperdrive is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Cloudflare Hyperdrive

Status: Production Ready ✅ | Last Verified: 2025-11-18


What Is Hyperdrive?

Connect Workers to existing PostgreSQL/MySQL databases:

  • Global connection pooling
  • Query caching
  • Reduced latency
  • Works with node-postgres, postgres.js, mysql2

Quick Start (5 Minutes)

1. Create Hyperdrive Config

bash
bunx wrangler hyperdrive create my-db \
  --connection-string="postgres://user:pass@host:5432/database"

Save the id!

2. Configure Binding

jsonc
{
  "name": "my-worker",
  "main": "src/index.ts",
  "compatibility_date": "2024-09-23",
  "compatibility_flags": ["nodejs_compat"],  // REQUIRED!
  "hyperdrive": [
    {
      "binding": "HYPERDRIVE",
      "id": "<ID_FROM_STEP_1>"
    }
  ]
}

3. Install Driver

bash
bun add pg  # or postgres, or mysql2

4. Query Database

typescript
import { Client } from 'pg';

export default {
  async fetch(request, env, ctx) {
    const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
    await client.connect();

    const result = await client.query('SELECT * FROM users LIMIT 10');
    await client.end();

    return Response.json(result.rows);
  }
};

Load references/setup-guide.md for complete walkthrough.


Critical Rules

Always Do ✅

  1. Enable nodejs_compat flag (required!)
  2. Use env.HYPERDRIVE.connectionString (not original DB string)
  3. Close connections after queries
  4. Handle errors explicitly
  5. Use connection pooling (built-in)
  6. Test locally with wrangler dev
  7. Monitor query performance
  8. Use prepared statements
  9. Enable query caching (automatic)
  10. Secure connection strings (use secrets)

Never Do ❌

  1. Never skip nodejs_compat (drivers won't work)
  2. Never use original DB connection string in Workers
  3. Never leave connections open (pool exhaustion)
  4. Never skip error handling (DB can fail)
  5. Never hardcode credentials in code
  6. Never exceed connection limits
  7. Never use eval/Function (blocked in Workers)
  8. Never skip TLS for production DBs
  9. Never use blocking queries (Worker timeout)
  10. Never expose DB errors to users

Database Drivers

PostgreSQL (node-postgres)

typescript
import { Client } from 'pg';

const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
const result = await client.query('SELECT * FROM users');
await client.end();

PostgreSQL (postgres.js)

typescript
import postgres from 'postgres';

const sql = postgres(env.HYPERDRIVE.connectionString);
const users = await sql`SELECT * FROM users`;

MySQL

typescript
import mysql from 'mysql2/promise';

const connection = await mysql.createConnection(env.HYPERDRIVE.connectionString);
const [rows] = await connection.execute('SELECT * FROM users');
await connection.end();

With Drizzle ORM

typescript
import { drizzle } from 'drizzle-orm/node-postgres';
import { Client } from 'pg';

const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();

const db = drizzle(client);
const users = await db.select().from(usersTable);

await client.end();

Common Use Cases

Use Case 1: Read-Only Queries

typescript
export default {
  async fetch(request, env, ctx) {
    const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
    await client.connect();

    const users = await client.query('SELECT * FROM users WHERE active = true');
    await client.end();

    return Response.json(users.rows);
  }
};

Use Case 2: Parameterized Queries

typescript
const userId = new URL(request.url).searchParams.get('id');

const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();

const result = await client.query(
  'SELECT * FROM users WHERE id = $1',
  [userId]
);

await client.end();

Use Case 3: Transactions

typescript
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();

try {
  await client.query('BEGIN');
  await client.query('UPDATE accounts SET balance = balance - 100 WHERE id = $1', [1]);
  await client.query('UPDATE accounts SET balance = balance + 100 WHERE id = $1', [2]);
  await client.query('COMMIT');
} catch (e) {
  await client.query('ROLLBACK');
  throw e;
} finally {
  await client.end();
}

Supported Databases

PostgreSQL:

  • Amazon RDS
  • Amazon Aurora
  • Neon
  • Supabase
  • Railway
  • Render
  • DigitalOcean
  • Any PostgreSQL 11+

MySQL:

  • Amazon RDS
  • Amazon Aurora
  • PlanetScale
  • Any MySQL 5.7+

Official Documentation


Bundled Resources

References (references/):

  • setup-guide.md - Complete setup walkthrough (create config, bind, query)
  • connection-pooling.md - Connection pool configuration and best practices
  • query-caching.md - Query caching strategies and optimization
  • drizzle-integration.md - Drizzle ORM integration patterns
  • prisma-integration.md - Prisma ORM integration patterns
  • supported-databases.md - Complete list of supported PostgreSQL and MySQL providers
  • tls-ssl-setup.md - TLS/SSL configuration for secure connections
  • troubleshooting.md - Common issues and solutions
  • wrangler-commands.md - Complete wrangler CLI commands for Hyperdrive

Templates (templates/):

  • postgres-basic.ts - Basic PostgreSQL with node-postgres
  • postgres-js.ts - PostgreSQL with postgres.js driver
  • postgres-pool.ts - PostgreSQL with connection pooling
  • mysql2-basic.ts - MySQL with mysql2 driver
  • drizzle-postgres.ts - Drizzle ORM with PostgreSQL
  • drizzle-mysql.ts - Drizzle ORM with MySQL
  • prisma-postgres.ts - Prisma ORM with PostgreSQL
  • local-dev-setup.sh - Local development setup script
  • wrangler-hyperdrive-config.jsonc - Wrangler configuration example

Questions? Issues?

  1. Check references/setup-guide.md for complete setup
  2. Verify nodejs_compat flag enabled
  3. Ensure using env.HYPERDRIVE.connectionString
  4. Check connection properly closed

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Cloudflare Hyperdrive AI skill do?

Cloudflare Hyperdrive for Workers-to-database connections with pooling and caching. Use for PostgreSQL/MySQL, Drizzle/Prisma, or encountering pool errors, TLS issues, connection refused.

Why use Cloudflare Hyperdrive on TypingMind?

Because you install it once and use it with any model. Cloudflare Hyperdrive is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Cloudflare Hyperdrive in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/secondsky/claude-skills/tree/main/plugins/cloudflare-hyperdrive/skills/cloudflare-hyperdrive. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Cloudflare Hyperdrive?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Cloudflare Hyperdrive?

As many as you like. As long as a model supports skills, you can use Cloudflare Hyperdrive with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Cloudflare Hyperdrive AI skill free?

Yes. It is published on GitHub by secondsky under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇