Cloudflare R2 Storage Management

VerifiedSafe

Manage Cloudflare R2 object storage buckets and objects using Wrangler CLI. Covers bucket creation, object upload/download/delete, custom domain configuration, CORS rules, lifecycle policies, and event notifications. Useful when deploying or maintaining storage in Cloudflare Workers or static sites.

Sby Skills Guide Bot
DevOpsIntermediate
6/2/2026
Claude CodeCursorWindsurf
#cloudflare#r2#object-storage#wrangler-cli

Recommended for

Automated summary

Manage Cloudflare R2 object storage buckets and objects using Wrangler CLI commands.

Strengths

  • Provides quick reference for common bucket and object operations.
  • Includes configuration for CORS, custom domains, and event notifications.
  • Offers bulk upload patterns and migration guidance from S3.

Limitations

  • Requires Wrangler CLI installation and authentication.
  • Some advanced features (e.g., Sippy migration) require dashboard or API.
  • Limited to command-line interface, no GUI.
When to use it

Use this skill when you need to create, configure, or manage Cloudflare R2 buckets and objects programmatically.

When not to use it

Do not use this skill if you need a graphical interface or if you are managing large-scale migrations that require automated tooling beyond CLI.

Security analysis

Safe
Quality score92/100

The skill provides standard Wrangler CLI commands for R2 management. No destructive patterns beyond expected bucket/object deletion, no obfuscation, no external script execution, no disabling of security features. All commands are legitimate and self-contained.

No concerns found

How this analysis is made

Examples

Create R2 bucket
Create a new Cloudflare R2 bucket called 'my-assets' using Wrangler CLI.
Upload files to R2
Upload all .png files from my current directory to the R2 bucket 'my-assets' under the 'images/' prefix.
Set CORS rules
Set CORS rules on the R2 bucket 'my-assets' to allow GET requests from https://example.com.

name: r2 description: Manage Cloudflare R2 object storage buckets and objects using Wrangler CLI. Use when working with R2 buckets, uploading/downloading files, configuring custom domains, CORS, lifecycle policies, or managing R2 storage. Trigger keywords: R2, bucket, object storage, Cloudflare storage, wrangler r2. allowed-tools: Bash, Read, Grep, Glob

Cloudflare R2 Storage Management

This skill provides commands and patterns for managing Cloudflare R2 object storage using the Wrangler CLI.

Prerequisites

  • Wrangler CLI installed (npm install -g wrangler or use npx wrangler)
  • Authenticated with Cloudflare (wrangler login)

Quick Reference

Bucket Operations

# Create a bucket
wrangler r2 bucket create <BUCKET_NAME>

# List all buckets
wrangler r2 bucket list

# Delete a bucket (must be empty)
wrangler r2 bucket delete <BUCKET_NAME>

Object Operations

# Upload an object
wrangler r2 object put <BUCKET>/<KEY> --file <LOCAL_FILE> --remote

# Download an object
wrangler r2 object get <BUCKET>/<KEY> --file <LOCAL_FILE> --remote

# Delete an object
wrangler r2 object delete <BUCKET>/<KEY> --remote

Custom Domains

# Add custom domain to bucket
wrangler r2 bucket domain add <BUCKET_NAME> --domain <DOMAIN> --zone-id <ZONE_ID>

# List custom domains
wrangler r2 bucket domain list <BUCKET_NAME>

# Remove custom domain
wrangler r2 bucket domain remove <BUCKET_NAME> --domain <DOMAIN>

CORS Configuration

# Set CORS rules
wrangler r2 bucket cors put <BUCKET_NAME> --file cors.json

# Get CORS configuration
wrangler r2 bucket cors get <BUCKET_NAME>

# Clear CORS configuration
wrangler r2 bucket cors delete <BUCKET_NAME>

Example cors.json:

{
  "CORSRules": [
    {
      "AllowedOrigins": ["https://example.com", "https://*.example.com"],
      "AllowedMethods": ["GET", "PUT", "POST", "DELETE", "HEAD"],
      "AllowedHeaders": ["*"],
      "MaxAgeSeconds": 3000
    }
  ]
}

Event Notifications

# Enable notifications to a queue
wrangler r2 bucket notification create <BUCKET_NAME> \
  --event-type object-create \
  --queue <QUEUE_NAME>

Bucket Lock Rules

# List lock rules
wrangler r2 bucket lock list <BUCKET_NAME>

Detailed Operations

For detailed API reference and advanced usage, see REFERENCE.md.

Common Patterns

Bulk Upload Directory

# Upload all files from a directory
for file in ./assets/*; do
  wrangler r2 object put my-bucket/assets/$(basename "$file") --file "$file" --remote
done

Migrate from S3 (Sippy)

R2 supports incremental migration from S3 using Sippy. Configure via the Cloudflare dashboard or API.

Public Access via Custom Domain

  1. Create bucket: wrangler r2 bucket create my-bucket
  2. Get zone ID for your domain from Cloudflare dashboard
  3. Add custom domain: wrangler r2 bucket domain add my-bucket --domain assets.example.com --zone-id <ZONE_ID>
  4. Objects are now accessible at https://assets.example.com/<key>

wrangler.toml Binding

To use R2 in Workers, add to wrangler.toml:

[[r2_buckets]]
binding = "MY_BUCKET"
bucket_name = "my-bucket-name"

Important Notes

  • Bucket names: lowercase, numbers, hyphens only (3-63 chars, no leading/trailing hyphens)
  • Use --remote flag to interact with remote R2 (default is local dev)
  • R2 is S3-compatible - AWS SDK works with R2 endpoint
  • No egress fees for R2

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/cloudflare-r2-storage-management-mma3jrkb/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/cloudflare-r2-storage-management-mma3jrkb' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/cloudflare-r2-storage-management-mma3jrkb/download' --output '.skill-downloads/cloudflare-r2-storage-management-mma3jrkb/SKILL.md.part' && mv '.skill-downloads/cloudflare-r2-storage-management-mma3jrkb/SKILL.md.part' '.skill-downloads/cloudflare-r2-storage-management-mma3jrkb/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Original excerpt: Prerequisites
  • Wrangler CLI installed (npm install -g wrangler or use npx wrangler)
  • Authenticated with Cloudflare (wrangler login)

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

This file does not provide a usable name/description header for this native procedure. It remains available to download and inspect; use the manual method below.

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/cloudflare-r2-storage-management-mma3jrkb/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills