R2

Write Cloudflare R2 object-storage code for uploads, downloads, metadata, streaming, signed access patterns, large files, generated exports, public assets, and D1/R2 metadata separation. Use when Workers handle blobs or egress-sensitive storage.

Install

skills CLI (Claude Code, Cursor, Codex and more)
npx skills add zllovesuki/cloudflare-agent-skills --skill r2
Manual install
git 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/r2 ~/.claude/skills/r2

Personal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.

From the SKILL.md

# R2

Use this skill when code needs object/blob storage. R2 stores bytes; keep queryable metadata in D1 or Durable Object state.

## Best uses

- User uploads.
- Images, video, audio, attachments.
- Generated exports/reports.
- Backups and archives.
- Parsed document chunks for RAG pipelines.
- Public or signed downloads.

## Key design

Use predictable, tenant-safe keys that avoid collisions and make cleanup possible.

```text
tenants/{tenantId}/uploads/{yyyy}/{mm}/{objectId}-{safeFilename}
tenants/{tenantId}/exports/{jobId}.csv
documents/{documentId}/chunks/{chunkIndex}.txt
```

Do not expose raw keys to users unless the key contains no sensitive information and authorization is still enforced.

## Upload pattern

```ts
export interface Env {
  BUCKET: R2Bucket;
  DB: D1Database;
}

export async function upload(request: Request, env: Env, tenantId: string) {
  const contentType = request.headers.get("content-type") ?? "application/octet-stream";
  const objectId = crypto.randomUUID();
  const key = `tenants/${tenantId}/uploads/${objectId}`;

  await env.BUCKET.put(key, request.body, {
    httpMetadata: { contentType },
    customMetadata: { tenantId }
  });

  await env.DB.prepare(
    `INSERT INTO files (id, tenant_id, r2_key, content_type, created_at)
     VALUES (?, ?, ?, ?, ?)`
  ).bind(objectId, tenantId, key, contentType, new Date().toISOString()).run();

  return Response.json({ id: objectId });
}
```

## Download pattern
Read the full skill on GitHub

Details

Skill name
r2
Path
skills/r2/SKILL.md
Repo updated
28 April 2026

FAQ

What does the R2 skill do?

Write Cloudflare R2 object-storage code for uploads, downloads, metadata, streaming, signed access patterns, large files, generated exports, public assets, and D1/R2 metadata separation. Use when Workers handle blobs or egress-sensitive storage.

How do I install the R2 skill?

skills CLI (Claude Code, Cursor, Codex and more): npx skills add zllovesuki/cloudflare-agent-skills --skill r2. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.

Is R2 popular?

It lives in zllovesuki/cloudflare-agent-skills, which has 9 GitHub stars and 0 forks.

Related skills

Agents

9

zllovesuki/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.

AI, LLMs & Agents

Cloudflare Architecture

9

zllovesuki/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.

Software Development

Containers

9

zllovesuki/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.

DevOps & Cloud

Realtime

9

zllovesuki/cloudflare-agent-skills

Build realtime Cloudflare applications using Durable Objects with WebSockets for data realtime and Cloudflare Realtime/WebRTC for audio and video. Use for chat rooms, multiplayer, collaboration, presence, live dashboards, and media-session routing.

DevOps & Cloud

Queues

9

zllovesuki/cloudflare-agent-skills

Use Cloudflare Queues for asynchronous background work, producers, consumers, batching, retries, idempotent message handling, delayed processing, fan-out, and decoupling request latency. Use when Worker code should do something later without needing strict ordering.

DevOps & Cloud

Security Deployment

9

zllovesuki/cloudflare-agent-skills

Secure and deploy Cloudflare Workers applications with secrets, least-privilege bindings, authz, tenant isolation, input validation, CORS, preview/prod separation, migrations, rollout, and rollback practices. Use before shipping Cloudflare code.

DevOps & Cloud

Browse the most popular Claude skills, all devops & cloud skills, or write your own with the skills generator.