Cloudflare Workers D1 KV R2 Capability Pack Skill
Expert Cloudflare capability skill for designing workers that combine D1, KV, and R2 with clear consistency, caching, and security boundaries.
Open the source and read safety notes before installing.
Prerequisites
- Cloudflare account and worker project
- D1/KV/R2 bindings access
- Defined data model and SLA targets
Schema details
- Install type
- package
- Reading time
- 10 min
- Difficulty score
- 89
- Troubleshooting
- Yes
- Breaking changes
- No
- Package verified
- Yes
- SHA-256
- 2b0c31db74f9b42751e2c14d8dab16fa3ded453bd4397a1347ac782ce5bc792a
- Skill type
- capability-pack
- Skill level
- expert
- Verification
- validated
- Verified at
- 2026-04-10
| Platform | Support | Install path |
|---|---|---|
| claude-code | Native | .claude/skills/<skill-name>/SKILL.md |
| codex | Native | .agents/skills/<skill-name>/SKILL.md |
| windsurf | Native | .windsurf/skills/<skill-name>/SKILL.md |
| gemini | Native | .gemini/skills/<skill-name>/SKILL.md or .agents/skills/<skill-name>/SKILL.md |
| cursor | Adapter | .cursor/rules/<skill-name>.mdc |
| cli | Manual | AGENTS.md or tool-specific context file |
Full copyable content
# Trigger
"Apply the Cloudflare Workers D1/KV/R2 capability pack to this system."
# Required output
1) Data placement strategy
2) Read/write consistency model
3) Cache and invalidation plan
4) Security and abuse controlsAbout this resource
Knowledge Freshness
This capability pack is pinned to documentation verified on 2026-04-10. When upstream docs change, refresh endpoint contracts, examples, and constraints before using this skill for production changes.
Retrieval Sources
- https://developers.cloudflare.com/workers/
- https://developers.cloudflare.com/d1/
- https://developers.cloudflare.com/kv/
- https://developers.cloudflare.com/r2/
Always prefer direct retrieval from official docs/API references over model memory for limits, endpoint signatures, and behavior guarantees.
Core Workflow
- Confirm target version/runtime and pull latest official docs for the task scope.
- Build an execution plan with explicit read-only discovery before any mutation.
- Validate contracts, permissions, and safety constraints before applying changes.
- Execute with deterministic checkpoints and rollback criteria.
- Produce a verification report with evidence, caveats, and next actions.
Overview
This capability pack teaches agents how to choose the right Cloudflare storage primitive per workload and combine them safely. It focuses on practical consistency, performance, and operational correctness.
Capability Scope
- D1 for relational transactional paths
- KV for globally distributed low-latency reads
- R2 for object storage and package/media assets
- Cache key strategy and invalidation mechanics
- Security boundaries, rate controls, and abuse mitigation
Compatibility
Native
- Claude Code / Claude: native skill usage via
SKILL.md. - Codex/OpenAI workflows: compatible with Agent Skills-style
SKILL.mdcontent as reusable workflow instructions.
Manual Adaptation
- Gemini CLI: native skill usage via
.gemini/skills/<skill-name>/SKILL.mdor.agents/skills/<skill-name>/SKILL.mdwhere supported. - Cursor: use the generated
.cursor/rules/*.mdcadapter for project rules. - OpenClaw and similar agents: use the same skill content as a reusable prompt/workflow file when native skill import is unavailable.
Production Rules
- Align storage choice with access pattern, not convenience.
- Keep mutation paths deterministic and auditable.
- Avoid cross-store race conditions without explicit coordination.
- Enforce endpoint-level auth and rate limits for write operations.
Troubleshooting
Issue: Stale reads after updates
Fix: Define explicit invalidation/order rules between D1 source of truth and KV caches.
Issue: High read latency on hot paths
Fix: Move read-heavy projection to KV with controlled sync from D1.
Issue: Unexpected storage cost growth
Fix: Add lifecycle policies and payload minimization for R2/KV objects.
Output Contract
- Provide an implementation plan ordered by risk and dependency.
- Provide exact production-ready config/commands with no placeholders.
- Call out secrets, permissions, and least-privilege requirements.
- Include rollback and recovery guidance for each risky step.
Validation Checklist
- Verify all referenced docs/versions before applying changes.
- Run regression checks for core user flow and error paths.
- Confirm observability/logging is enabled for changed components.
- Confirm security controls (auth, rate limits, input validation) still pass.
- Record final known limitations and follow-up actions.
Source citations
Signals
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.