D1
Write Cloudflare D1 code and schemas for SQLite-backed relational data, prepared statements, bindings, migrations, typed queries, tenant boundaries, indexes, pagination, and idempotent writes. Use when Workers need SQL data on Cloudflare.
Install
npx skills add zllovesuki/cloudflare-agent-skills --skill d1git clone --depth 1 https://github.com/zllovesuki/cloudflare-agent-skills.git /tmp/cloudflare-agent-skills
mkdir -p ~/.claude/skills
cp -r /tmp/cloudflare-agent-skills/skills/d1 ~/.claude/skills/d1Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# D1
Use this skill for Cloudflare D1 relational data. D1 is best when records are queryable with SQL and can be modeled with clear boundaries.
## Data modeling rules
- Design around natural boundaries: tenant, workspace, user, project, region, or product domain.
- Avoid one giant catch-all database if the workload naturally partitions.
- Put large blobs in R2 and store keys/metadata in D1.
- Add indexes for every production query pattern.
- Use pagination; do not return unbounded result sets.
- Use Durable Objects when you need serialized per-entity coordination around writes.
- Use Hyperdrive if the true source of truth must remain an existing Postgres/MySQL database.
## Binding and Env
```ts
export interface Env {
DB: D1Database;
}
```
```jsonc
{
"d1_databases": [
{
"binding": "DB",
"database_name": "app-prod",
"database_id": "REPLACE_WITH_DATABASE_ID"
}
]
}
```
## Prepared statement pattern
```ts
type Todo = {
id: string;
tenant_id: string;
title: string;
completed: number;
created_at: string;
};
export async function listTodos(env: Env, tenantId: string, limit = 50) {
const result = await env.DB.prepare(
`SELECT id, tenant_id, title, completed, created_at
FROM todos
WHERE tenant_id = ?
ORDER BY created_at DESC
LIMIT ?`
).bind(tenantId, limit).all<Todo>();
return result.results;
}
```
## Insert with idempotencyDetails
- Skill name
d1- Repository
- zllovesuki/cloudflare-agent-skills
- Path
skills/d1/SKILL.md- Repo updated
- 28 April 2026
FAQ
What does the D1 skill do?
Write Cloudflare D1 code and schemas for SQLite-backed relational data, prepared statements, bindings, migrations, typed queries, tenant boundaries, indexes, pagination, and idempotent writes. Use when Workers need SQL data on Cloudflare.
How do I install the D1 skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add zllovesuki/cloudflare-agent-skills --skill d1. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is D1 popular?
It lives in zllovesuki/cloudflare-agent-skills, which has 9 GitHub stars and 0 forks.
Related skills
Agents
9zllovesuki/cloudflare-agent-skills
Build Cloudflare Agents SDK applications for autonomous multi-step tool use, AIChatAgent chat agents, Durable Object-backed state, tools, scheduling, callable methods, WebSockets, SQL state, and constrained agent behavior. Use when RAG or Workflows are not enough.
Cloudflare Architecture
9zllovesuki/cloudflare-agent-skills
Choose Cloudflare Developer Platform primitives and architecture shapes before writing code. Use for Cloudflare Workers, Durable Objects, D1, R2, Queues, Workflows, Containers, Realtime, Workers AI, Vectorize, AI Search, Agents, cost, limits, and migration decisions.
Containers
9zllovesuki/cloudflare-agent-skills
Decide when to use Cloudflare Containers instead of Workers and design container-backed workloads, native binaries, long-running processes, image processing, larger runtime shapes, and Worker frontends. Use as an escape hatch when Workers constraints do not fit.
Data Quality Rule Generator
9shisuidata/ss-data-skills
Use when generating data quality rules from a table schema, SQL, metric definition, or data pipeline description. Produces validation rules for freshness, row count, uniqueness, nulls, enums, ranges, referential integrity, metric fluctuation, reconciliation, and SQL checks. 中文触发词:数据质量规则、质量校验、DQC、校验 SQL、上线验收。
Cheat Status
9miaqu766520-a11y/ai-line-skills
cheat-on-content 的状态看板。显示当前模式 / rubric 版本 / 校准进度 / 待复盘 / pool 状态 / 是否该升级 SQLite / 是否该 bump rubric。**任何时候都可调,无副作用**。触发词:"状态"/"看板"/"status"/"我现在该做什么"/"进度怎么样"。
Durable Objects
9zllovesuki/cloudflare-agent-skills
Build Cloudflare Durable Objects for stateful coordination, one-per-entity actors, strong consistency, private SQLite-backed storage, RPC methods, WebSockets, alarms, sessions, rooms, rate limits, and collaborative state. Use when Workers code needs serialized state or race-free coordination.
Browse the most popular Claude skills, all databases skills, or write your own with the skills generator.