cloudflare-d1

Manage Cloudflare D1 databases with SQL queries, migrations, and bindings.

204|30|Updated Nov 8, 2025
One-click install
npx skills add https://github.com/secondsky/claude-skills --skill cloudflare-d1-secondsky
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cloudflare-d1
Source: https://github.com/secondsky/claude-skills/tree/main/plugins/cloudflare-d1/skills/cloudflare-d1
Command: npx skills add https://github.com/secondsky/claude-skills --skill cloudflare-d1-secondsky

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Deploy and query a serverless SQLite database at the edge with migrations, bindings, and edge-ready patterns.

Core Features & Use Cases

  • 5-minute quick start for D1: create, bind, migrate, query, deploy
  • Migrations, prepared statements, batch queries
  • Read replication and Sessions API guidance
  • Security and performance best practices for edge databases

Quick Start

  1. Create a D1 database, 2) configure wrangler.jsonc binding, 3) add and apply migrations, 4) query from a Worker, 5) deploy.

Frequently Asked Questions about cloudflare-d1

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I deploy a SQLite database to Cloudflare's edge network?

Deploy SQLite to Cloudflare's edge using D1, a serverless database service. Create a D1 database, bind it in wrangler.jsonc, apply migrations, and query from Workers. This approach runs your database across geo-distributed edge locations without managing infrastructure.

What's the best way to run database migrations on Cloudflare D1?

Create migration files, configure them in wrangler.jsonc, then run migrations before deployment. D1 applies migrations sequentially to your edge database, ensuring schema changes propagate consistently across replicas while supporting rollback capabilities.

How do I prevent SQL injection when querying D1 from edge workers?

Use prepared statements with bind() to safely parameterize queries on D1. Binding separates SQL logic from user input at the protocol level, preventing injection attacks while maintaining query performance at the edge.

Can I replicate data across multiple Cloudflare regions with D1?

D1 supports read replication and the Sessions API for geo-distributed consistency. Configure read replicas to distribute queries across regions, use Sessions API to maintain consistency for individual users, and apply PRAGMA optimize for performance tuning.

What are the limits of using SQLite for edge databases?

SQLite on D1 excels for edge workloads but has write constraints in distributed settings. Single-write-region design prevents concurrent writes across replicas; batch operations and prepared statements optimize throughput, but high-concurrency write scenarios require architecture adjustments.

Do I need special configuration to bind D1 to my Cloudflare worker?

Yes, D1 bindings require wrangler.jsonc configuration mapping your database to worker code. Once bound, access D1 through the env object passed to your worker handler, enabling direct SQL queries without separate connection management.