davila7/claude-code-templates / cli-tool/components/skills/development/cloudflare-deploy
cloudflare-deploy
FlaggedDeploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.
references/hyperdrive/configuration.md
View on GitHub# Configuration
See [README.md](./README.md) for overview.
## Create Config
**PostgreSQL:**
```bash
# Basic
npx wrangler hyperdrive create my-db \
--connection-string="postgres://user:pass@host:5432/db"
# Custom cache
npx wrangler hyperdrive create my-db \
--connection-string="postgres://..." \
--max-age=120 --swr=30
# No cache
npx wrangler hyperdrive create my-db \
--connection-string="postgres://..." \
--caching-disabled=true
```
**MySQL:**
```bash
npx wrangler hyperdrive create my-db \
--connection-string="mysql://user:pass@host:3306/db"
```
## wrangler.jsonc
```jsonc
{
"compatibility_date": "2025-01-01", // Use latest for new projects
"compatibility_flags": ["nodejs_compat"],
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "<HYPERDRIVE_ID>",
"localConnectionString": "postgres://user:pass@localhost:5432/dev"
}
]
}
```
**Generate TypeScript types:** Run `npx wrangler types` to auto-generate `worker-configuration.d.ts` from your wrangler.jsonc.
**Multiple configs:**
```jsonc
{
"hyperdrive": [
{"binding": "HYPERDRIVE_CACHED", "id": "<ID1>"},
{"binding": "HYPERDRIVE_NO_CACHE", "id": "<ID2>"}
]
}
```
## Management
```bash
npx wrangler hyperdrive list
npx wrangler hyperdrive get <ID>
npx wrangler hyperdrive update <ID> --max-age=180
npx wrangler hyperdrive delete <ID>
```
## Config Options
Hyperdrive create/update CLI flags:
| Option | Default | Notes |
|--------|---------|-------|
| `--caching-disabled` | `false` | Disable caching |
| `--max-age` | `60` | Cache TTL (max 3600s) |
| `--swr` | `15` | Stale-while-revalidate |
| `--origin-connection-limit` | 20/100 | Free/paid |
| `--access-client-id` | - | Tunnel auth |
| `--access-client-secret` | - | Tunnel auth |
| `--sslmode` | `require` | PostgreSQL only |
## Smart Placement Integration
For Workers making **multiple queries** per request, enable Smart Placement to execute near your database:
```jsonc
{
"compatibility_date": "2025-01-01",
"compatibility_flags": ["nodejs_compat"],
"placement": {
"mode": "smart"
},
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "<HYPERDRIVE_ID>"
}
]
}
```
**Benefits:** Multi-query Workers run closer to DB, reducing round-trip latency. See [patterns.md](./patterns.md) for examples.
## Private DB via Tunnel
```
Worker → Hyperdrive → Access → Tunnel → Private Network → DB
```
**Setup:**
```bash
# 1. Create tunnel
cloudflared tunnel create my-db-tunnel
# 2. Configure hostname in Zero Trust dashboard
# Domain: db-tunnel.example.com
# Service: TCP -> localhost:5432
# 3. Create service token (Zero Trust > Service Auth)
# Save Client ID/Secret
# 4. Create Access app (db-tunnel.example.com)
# Policy: Service Auth token from step 3
# 5. Create Hyperdrive
npx wrangler hyperdrive create my-private-db \
--host=db-tunnel.example.com \
--user=dbuser --password=dbpass --database=prod \
--access-client-id=<ID> --access-client-secret=<SECRET>
```
**⚠️ Don't specify `--port` with Tunnel** - port configured in tunnel service settings.
## Local Dev
**Option 1: Local (RECOMMENDED):**
```bash
# Env var (takes precedence)
export CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE="postgres://user:pass@localhost:5432/dev"
npx wrangler dev
# wrangler.jsonc
{"hyperdrive": [{"binding": "HYPERDRIVE", "localConnectionString": "postgres://..."}]}
```
**Remote DB locally:**
```bash
# PostgreSQL
export CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE="postgres://user:pass@remote:5432/db?sslmode=require"
# MySQL
export CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE="mysql://user:pass@remote:3306/db?sslMode=REQUIRED"
```
**Option 2: Remote execution:**
```bash
npx wrangler dev --remote # Uses deployed config, affects production
```
See [api.md](./api.md), [patterns.md](./patterns.md), [gotchas.md](./gotchas.md).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |