Skip to content

secondsky/claude-skills / plugins/cloudflare-hyperdrive/skills/cloudflare-hyperdrive

cloudflare-hyperdrive

Verified

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.

templates/local-dev-setup.sh

View on GitHub
#!/bin/bash
#
# Hyperdrive Local Development Setup Helper
#
# This script helps set up environment variables for local development
# with Hyperdrive. Use this to avoid committing credentials to wrangler.jsonc.
#
# Usage:
#   ./local-dev-setup.sh
#   source .env.local  # Load variables into current shell
#   npm run dev        # Start wrangler dev
#

set -e

echo "🚀 Hyperdrive Local Development Setup"
echo ""

# Get binding name from wrangler.jsonc
BINDING_NAME=$(grep -A 2 '"hyperdrive"' wrangler.jsonc | grep '"binding"' | cut -d'"' -f4 | head -1)

if [ -z "$BINDING_NAME" ]; then
  echo "❌ Could not find Hyperdrive binding in wrangler.jsonc"
  echo "   Please ensure you have a hyperdrive configuration with a binding."
  exit 1
fi

echo "Found Hyperdrive binding: $BINDING_NAME"
echo ""

# Ask for database details
echo "Enter your local database connection details:"
echo ""

read -p "Database type (postgres/mysql): " DB_TYPE
read -p "Host (default: localhost): " DB_HOST
DB_HOST=${DB_HOST:-localhost}

if [ "$DB_TYPE" = "postgres" ]; then
  read -p "Port (default: 5432): " DB_PORT
  DB_PORT=${DB_PORT:-5432}
else
  read -p "Port (default: 3306): " DB_PORT
  DB_PORT=${DB_PORT:-3306}
fi

read -p "Database name: " DB_NAME
read -p "Username: " DB_USER
read -sp "Password: " DB_PASSWORD
echo ""

# Build connection string
if [ "$DB_TYPE" = "postgres" ]; then
  CONNECTION_STRING="postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
else
  CONNECTION_STRING="mysql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}"
fi

# Create .env.local file
ENV_VAR_NAME="CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_${BINDING_NAME}"

cat > .env.local <<EOF
# Hyperdrive Local Development Environment Variables
# Generated on: $(date)
#
# Load these variables before running wrangler dev:
#   source .env.local
#   npm run dev
#
# DO NOT commit this file to version control!

export ${ENV_VAR_NAME}="${CONNECTION_STRING}"
EOF

# Add to .gitignore
if ! grep -q ".env.local" .gitignore 2>/dev/null; then
  echo ".env.local" >> .gitignore
  echo "✅ Added .env.local to .gitignore"
fi

echo ""
echo "✅ Created .env.local with environment variable:"
echo "   ${ENV_VAR_NAME}"
echo ""
echo "Next steps:"
echo "1. Load the environment variable:"
echo "   source .env.local"
echo ""
echo "2. Start local development server:"
echo "   npx wrangler dev"
echo ""
echo "3. Your Worker will connect to:"
echo "   ${DB_TYPE}://${DB_HOST}:${DB_PORT}/${DB_NAME}"
echo ""
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall