[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6FGC27719QT18GSB6CMDKNV":3,"skill-same:01M6FGC27719QT18GSB6CMDKNV":118},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":30,"ownerHtmlUrl":31,"ownerBlogUrl":6,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M6FGC27719QT18GSB6CMDKNV","cloudflare-r2",null,"ComeOnOliver\u002Fskillshub","ComeOnOliver","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F43215937?v=4","01M6E5JNFECJAAVFE0W7SMWWD2","Haoran Shu","01M6E5JNNDQS7AJZDYFQ8TPZCK",67,"MIT","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002FSKILL.md",[],[18,19],"cloudflare","cloudflare r2","2026-11-10 10:12:30",false,"---\nname: cloudflare-r2\ndescription: Cloudflare R2 S3-compatible object storage. Use for buckets, uploads, CORS, presigned URLs, or encountering R2_ERROR, CORS failures, multipart issues.\n\n  Keywords: r2, r2 storage, cloudflare r2, r2 bucket, r2 upload, r2 download, r2 binding, object storage,\n  s3 compatible, r2 cors, presigned urls, multipart upload, r2 api, r2 workers, file upload, asset storage,\n  R2_ERROR, R2Bucket, r2 metadata, custom metadata, http metadata, content-type, cache-control,\n  aws4fetch, s3 client, bulk delete, r2 list, storage class\nlicense: MIT\nmetadata:\n  version: \"3.0.0\"\n  last_verified: \"2025-12-27\"\n  production_tested: true\n  token_savings: \"~65%\"\n  errors_prevented: 12\n  templates_included: 5\n  references_included: 11\n  agents_included: 5\n  commands_included: 4\n  scripts_included: 3\n  wrangler_version: \"4.50.0\"\n  workers_types_version: \"4.20251126.0\"\n  aws4fetch_version: \"1.0.20\"\n---\n\n# Cloudflare R2 Object Storage\n\n**Status**: Production Ready ✅ | **Last Verified**: 2025-12-27 | **v3.0.0**\n\n**Contents**: [Quick Start](#quick-start-5-minutes) • [New Features](#new-r2-features-2025) • [Core R2 API](#core-r2-workers-api-quick-reference) • [Critical Rules](#critical-rules) • [Agents & Commands](#available-agents--commands) • [References](#when-to-load-references)\n\n---\n\n## Quick Start (5 Minutes)\n\n### 1. Create R2 Bucket\n\n```bash\nbunx wrangler r2 bucket create my-bucket\n```\n\n**Bucket naming:** 3-63 chars, lowercase, numbers, hyphens only\n\n### 2. Configure Binding\n\nAdd to `wrangler.jsonc`:\n\n```jsonc\n{\n  \"name\": \"my-worker\",\n  \"main\": \"src\u002Findex.ts\",\n  \"compatibility_date\": \"2025-10-11\",\n  \"r2_buckets\": [\n    {\n      \"binding\": \"MY_BUCKET\",          \u002F\u002F env.MY_BUCKET\n      \"bucket_name\": \"my-bucket\",      \u002F\u002F Actual bucket\n      \"preview_bucket_name\": \"my-bucket-preview\"  \u002F\u002F Optional: dev bucket\n    }\n  ]\n}\n```\n\n**CRITICAL:** `binding` = code access name, `bucket_name` = actual R2 bucket\n\n### 3. Basic Upload\u002FDownload\n\n```typescript\nimport { Hono } from 'hono';\n\ntype Bindings = {\n  MY_BUCKET: R2Bucket;\n};\n\nconst app = new Hono\u003C{ Bindings: Bindings }>();\n\n\u002F\u002F Upload\napp.put('\u002Fupload\u002F:filename', async (c) => {\n  const filename = c.req.param('filename');\n  const body = await c.req.arrayBuffer();\n\n  const object = await c.env.MY_BUCKET.put(filename, body, {\n    httpMetadata: {\n      contentType: c.req.header('content-type') || 'application\u002Foctet-stream',\n    },\n  });\n\n  return c.json({\n    success: true,\n    key: object.key,\n    size: object.size,\n  });\n});\n\n\u002F\u002F Download\napp.get('\u002Fdownload\u002F:filename', async (c) => {\n  const object = await c.env.MY_BUCKET.get(c.req.param('filename'));\n\n  if (!object) {\n    return c.json({ error: 'Not found' }, 404);\n  }\n\n  return new Response(object.body, {\n    headers: {\n      'Content-Type': object.httpMetadata?.contentType || 'application\u002Foctet-stream',\n      'ETag': object.httpEtag,\n    },\n  });\n});\n\nexport default app;\n```\n\n**Load `references\u002Fsetup-guide.md` for complete setup walkthrough.**\n\n---\n\n## New R2 Features (2025)\n\n**? R2 SQL Integration** - Query CSV\u002FParquet\u002FJSON data with distributed SQL. Analytics without ETL. **Load `references\u002Fr2-sql-integration.md`**\n\n**? Data Catalog (Apache Iceberg)** - Table versioning, time-travel queries, schema evolution. Spark\u002FSnowflake integration. **Load `references\u002Fdata-catalog-iceberg.md`**\n\n**? Event Notifications** - Trigger Workers on object changes (upload\u002Fdelete). Automate image processing, backups, webhooks. **Load `references\u002Fevent-notifications.md`**\n\n**Advanced Features** - Storage classes, bucket locks (compliance), tus resumable uploads, SSE-C encryption. **Load `references\u002Fadvanced-features.md`**\n\n**Zero Trust Security** - Cloudflare Access integration with SSO, MFA, identity policies, audit logging. **Load `references\u002Fcloudflare-access-integration.md`**\n\n**Performance Tuning** - Caching strategies, compression, range requests, ETags, monitoring best practices. **Load `references\u002Fperformance-optimization.md`**\n\n---\n\n## Core R2 Workers API - Quick Reference\n\n### put() - Upload Objects\n```typescript\nawait env.MY_BUCKET.put(key, data, options?)\n```\nUpload with metadata, prevent overwrites with `onlyIf`. **Load `references\u002Fworkers-api.md`** for complete R2PutOptions.\n\n### get() - Download Objects\n```typescript\nconst object = await env.MY_BUCKET.get(key, options?)\n```\nReturns `R2ObjectBody | null`. Supports range requests, conditional operations. **Load `references\u002Fworkers-api.md`** for read methods (text(), json(), arrayBuffer(), blob()).\n\n### head() - Get Metadata Only\n```typescript\nconst object = await env.MY_BUCKET.head(key)\n```\nCheck existence, get size, etag, metadata without downloading body. Useful for validation and caching.\n\n### delete() - Delete Objects\n```typescript\nawait env.MY_BUCKET.delete(key | keys[])  \u002F\u002F Single or bulk (max 1000)\n```\nBulk delete up to 1000 keys in single call. Always succeeds (idempotent).\n\n### list() - List Objects\n```typescript\nconst listed = await env.MY_BUCKET.list(options?)\n```\nPagination with cursor, prefix filtering, delimiter for folders. **Load `references\u002Fworkers-api.md`** for R2ListOptions.\n\n### createMultipartUpload() - Large Files (>100MB)\n```typescript\nconst multipart = await env.MY_BUCKET.createMultipartUpload(key, options?)\n```\nFor files >100MB. **Load `references\u002Fcommon-patterns.md`** for complete multipart workflow with part upload and completion.\n\n**Load `references\u002Fworkers-api.md` when**: Need complete API reference, interface definitions (R2Object, R2ObjectBody, R2PutOptions, R2GetOptions), conditional operations, checksums, or advanced options.\n\n---\n\n## Critical Rules\n\n### Always Do ✅\n\n1. **Set contentType on uploads** - Files will download as binary otherwise\n2. **Use batch delete** for multiple objects (up to 1000 keys)\n3. **Set cache headers** for static assets (`cacheControl`)\n4. **Use presigned URLs** for large client uploads\n5. **Use multipart upload** for files >100MB\n6. **Set CORS policy** before browser uploads\n7. **Set expiry times** on presigned URLs (1-24 hours)\n8. **Handle errors** with try\u002Fcatch\n9. **Use head()** when you only need metadata (not get())\n10. **Use conditional operations** to prevent overwrites\n\n### Never Do ❌\n\n1. **Never expose R2 access keys** in client-side code\n2. **Never skip contentType** (files will download as binary)\n3. **Never delete in loops** (use batch delete)\n4. **Never upload without error handling**\n5. **Never skip CORS** for browser uploads\n6. **Never use multipart for small files** (\u003C5MB overhead)\n7. **Never delete >1000 keys** in single call (will fail)\n8. **Never assume uploads succeed** (always check response)\n9. **Never skip presigned URL expiry** (security risk)\n10. **Never hardcode bucket names** (use bindings)\n\n---\n\n## Top Use Cases\n\n### Use Case 1: Image\u002FAsset Storage\n\n```typescript\napp.put('\u002Fapi\u002Fupload\u002Fimage', async (c) => {\n  const file = await c.req.parseBody();\n  const image = file['image'] as File;\n\n  await c.env.MY_BUCKET.put(`images\u002F${image.name}`, image.stream(), {\n    httpMetadata: {\n      contentType: image.type,\n      cacheControl: 'public, max-age=31536000, immutable',\n    },\n  });\n\n  return c.json({ success: true });\n});\n```\n\n### Use Case 2: Direct Client Upload (Presigned URLs)\n\nGenerate secure upload URLs for client-side uploads. See `templates\u002Fr2-presigned-urls.ts` for complete implementation using aws4fetch.\n\n### Additional Patterns in References\n\n**Load `references\u002Fcommon-patterns.md` for**:\n- Multipart upload (files >100MB) - Complete workflow with part management\n- Bulk operations - Batch delete, cleanup patterns with pagination\n- Custom metadata tracking - User files, versions, approval workflows\n- Versioned file storage - Version history with latest pointer pattern\n- Backup & archive patterns - Automated backups with retention policies\n- Thumbnail generation & caching - On-demand image processing\n- Static site hosting - SPA fallback and cache strategies\n- CDN with origin fallback - R2 as cache layer\n\n**Load `templates\u002Fr2-multipart-upload.ts`** for complete multipart example.\n\n---\n\n## Available Agents & Commands\n\n### Autonomous Agents\n\nAgents handle complex multi-step workflows automatically:\n\n- **r2-setup-automator** - Complete R2 setup (bucket creation → binding → TypeScript types → deployment)\n- **multipart-orchestrator** - Large file uploads with chunking, error recovery, and progress tracking\n- **cors-debugger** - Systematic CORS troubleshooting with configuration generation and testing\n- **s3-migration-planner** - AWS S3 to R2 migration planning, data transfer, and cost analysis\n- **event-notification-setup** - Event-driven workflows with Workers, Queues, and automation\n\n### Quick Commands\n\nFast access to common R2 operations:\n\n- **\u002Fr2-setup** - Create bucket and configure binding in wrangler.jsonc\n- **\u002Fr2-presigned-url** - Generate presigned URLs for secure client-side uploads\u002Fdownloads\n- **\u002Fr2-cors-debug** - Diagnose and fix CORS configuration issues\n- **\u002Fr2-multipart-init** - Initialize multipart upload workflow for large files\n\n---\n\n## When to Load References\n\n### Core References (Existing Features)\n\n**`references\u002Fsetup-guide.md`** - First-time setup, binding configuration, TypeScript types, deployment walkthrough\n\n**`references\u002Fworkers-api.md`** - Complete API reference (all methods + options), conditional operations, checksums\n\n**`references\u002Fcommon-patterns.md`** - Multipart uploads, retry logic with backoff, batch operations, cache strategies\n\n**`references\u002Fs3-compatibility.md`** - S3 migration guide, S3 client library usage, aws4fetch presigned URL signing\n\n**`references\u002Fcors-configuration.md`** - Browser access setup, CORS debugging, security policies, Dashboard configuration\n\n### New Features References (2025)\n\n**`references\u002Fevent-notifications.md`** - Event-driven automation, Queue integration, image processing, webhook triggers\n\n**`references\u002Fadvanced-features.md`** - Storage classes (cost optimization), bucket locks (compliance), tus resumable uploads, SSE-C encryption\n\n**`references\u002Fr2-sql-integration.md`** - SQL queries on R2 data (CSV\u002FParquet\u002FJSON), analytics patterns, performance tuning\n\n**`references\u002Fdata-catalog-iceberg.md`** - Apache Iceberg tables, time-travel queries, schema evolution, Spark\u002FSnowflake integration\n\n**`references\u002Fcloudflare-access-integration.md`** - Zero Trust security, SSO (Google\u002FOkta\u002FAzure AD), identity policies, MFA, audit logging\n\n**`references\u002Fperformance-optimization.md`** - Caching (browser\u002FCDN\u002FWorkers), compression (gzip\u002FBrotli), range requests, ETags, monitoring\n\n---\n\n## Using Bundled Resources\n\n### References (references\u002F)\n\n- **setup-guide.md** - Complete setup walkthrough (bucket creation → deployment)\n- **workers-api.md** - Complete Workers API reference (all methods + options)\n- **common-patterns.md** - Advanced patterns (multipart, retry, batch, performance)\n- **s3-compatibility.md** - S3 compatibility guide (migration, aws4fetch, S3 clients)\n- **cors-configuration.md** - CORS setup guide (Dashboard, scenarios, troubleshooting, security)\n\n### Templates (templates\u002F)\n\n- **r2-simple-upload.ts** - Basic upload\u002Fdownload Worker\n- **r2-multipart-upload.ts** - Complete multipart upload implementation\n- **r2-presigned-urls.ts** - Presigned URL generation (upload + download)\n- **r2-cors-config.json** - CORS configuration examples\n- **wrangler-r2-config.jsonc** - Complete wrangler.jsonc with R2 binding\n\n---\n\n## CORS Configuration\n\nConfigure CORS for browser uploads\u002Fdownloads. **Load `references\u002Fcors-configuration.md`** for complete guide including Dashboard setup, common scenarios, troubleshooting, and security best practices.\n\n---\n\n## Error Handling\n\n```typescript\ntry {\n  await env.MY_BUCKET.put(key, data);\n} catch (error: any) {\n  const message = error.message;\n\n  if (message.includes('R2_ERROR')) {\n    \u002F\u002F Generic R2 error\n  } else if (message.includes('exceeded')) {\n    \u002F\u002F Quota exceeded\n  } else if (message.includes('precondition')) {\n    \u002F\u002F Conditional operation failed (onlyIf)\n  }\n\n  console.error('R2 Error:', message);\n  return c.json({ error: 'Storage operation failed' }, 500);\n}\n```\n\n**Load `references\u002Fcommon-patterns.md`** for retry logic with exponential backoff, circuit breaker patterns, and advanced error recovery.\n\n---\n\n## Known Issues Prevented\n\n| Issue | Description | Solution |\n|-------|-------------|----------|\n| **CORS errors** | Browser can't upload\u002Fdownload | Configure CORS in bucket settings |\n| **Files download as binary** | Missing content-type | Always set `httpMetadata.contentType` |\n| **Presigned URL security** | URLs never expire | Always set `X-Amz-Expires` (1-24 hours) |\n| **Multipart limits** | Parts >100MB or >10,000 parts | Keep parts 5MB-100MB, max 10,000 |\n| **Bulk delete limits** | >1000 keys fails | Chunk deletes into batches of 1000 |\n| **Metadata overflow** | >2KB custom metadata | Keep total under 2KB |\n\n---\n\n## Wrangler Commands\n\n```bash\n# Bucket management\nwrangler r2 bucket create \u003CBUCKET_NAME>\nwrangler r2 bucket list\nwrangler r2 bucket delete \u003CBUCKET_NAME>\n\n# Object management\nwrangler r2 object put \u003CBUCKET>\u002F\u003CKEY> --file=\u003CPATH>\nwrangler r2 object get \u003CBUCKET>\u002F\u003CKEY> --file=\u003COUTPUT>\nwrangler r2 object delete \u003CBUCKET>\u002F\u003CKEY>\n\n# List objects\nwrangler r2 object list \u003CBUCKET>\nwrangler r2 object list \u003CBUCKET> --prefix=\"folder\u002F\"\n```\n\n---\n\n## Official Documentation\n\n- **R2 Overview**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002F\n- **Workers API**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002Fapi\u002Fworkers\u002Fworkers-api-reference\u002F\n- **Multipart Upload**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002Fapi\u002Fworkers\u002Fworkers-multipart-usage\u002F\n- **Presigned URLs**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002Fapi\u002Fs3\u002Fpresigned-urls\u002F\n- **CORS Configuration**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002Fbuckets\u002Fcors\u002F\n\n---\n\n**Questions? Issues?**\n\n1. Check `references\u002Fsetup-guide.md` for setup walkthrough\n2. Review `references\u002Fworkers-api.md` for API reference\n3. See `references\u002Fcommon-patterns.md` for advanced patterns\n4. Load `templates\u002F` for working code examples\n","# Cloudflare R2 Object Storage\n\n**Status**: Production Ready ✅ | **Last Verified**: 2025-12-27 | **v3.0.0**\n\n**Contents**: [Quick Start](#quick-start-5-minutes) • [New Features](#new-r2-features-2025) • [Core R2 API](#core-r2-workers-api-quick-reference) • [Critical Rules](#critical-rules) • [Agents & Commands](#available-agents--commands) • [References](#when-to-load-references)\n\n---\n\n## Quick Start (5 Minutes)\n\n### 1. Create R2 Bucket\n\n```bash\nbunx wrangler r2 bucket create my-bucket\n```\n\n**Bucket naming:** 3-63 chars, lowercase, numbers, hyphens only\n\n### 2. Configure Binding\n\nAdd to `wrangler.jsonc`:\n\n```jsonc\n{\n  \"name\": \"my-worker\",\n  \"main\": \"src\u002Findex.ts\",\n  \"compatibility_date\": \"2025-10-11\",\n  \"r2_buckets\": [\n    {\n      \"binding\": \"MY_BUCKET\",          \u002F\u002F env.MY_BUCKET\n      \"bucket_name\": \"my-bucket\",      \u002F\u002F Actual bucket\n      \"preview_bucket_name\": \"my-bucket-preview\"  \u002F\u002F Optional: dev bucket\n    }\n  ]\n}\n```\n\n**CRITICAL:** `binding` = code access name, `bucket_name` = actual R2 bucket\n\n### 3. Basic Upload\u002FDownload\n\n```typescript\nimport { Hono } from 'hono';\n\ntype Bindings = {\n  MY_BUCKET: R2Bucket;\n};\n\nconst app = new Hono\u003C{ Bindings: Bindings }>();\n\n\u002F\u002F Upload\napp.put('\u002Fupload\u002F:filename', async (c) => {\n  const filename = c.req.param('filename');\n  const body = await c.req.arrayBuffer();\n\n  const object = await c.env.MY_BUCKET.put(filename, body, {\n    httpMetadata: {\n      contentType: c.req.header('content-type') || 'application\u002Foctet-stream',\n    },\n  });\n\n  return c.json({\n    success: true,\n    key: object.key,\n    size: object.size,\n  });\n});\n\n\u002F\u002F Download\napp.get('\u002Fdownload\u002F:filename', async (c) => {\n  const object = await c.env.MY_BUCKET.get(c.req.param('filename'));\n\n  if (!object) {\n    return c.json({ error: 'Not found' }, 404);\n  }\n\n  return new Response(object.body, {\n    headers: {\n      'Content-Type': object.httpMetadata?.contentType || 'application\u002Foctet-stream',\n      'ETag': object.httpEtag,\n    },\n  });\n});\n\nexport default app;\n```\n\n**Load `references\u002Fsetup-guide.md` for complete setup walkthrough.**\n\n---\n\n## New R2 Features (2025)\n\n**? R2 SQL Integration** - Query CSV\u002FParquet\u002FJSON data with distributed SQL. Analytics without ETL. **Load `references\u002Fr2-sql-integration.md`**\n\n**? Data Catalog (Apache Iceberg)** - Table versioning, time-travel queries, schema evolution. Spark\u002FSnowflake integration. **Load `references\u002Fdata-catalog-iceberg.md`**\n\n**? Event Notifications** - Trigger Workers on object changes (upload\u002Fdelete). Automate image processing, backups, webhooks. **Load `references\u002Fevent-notifications.md`**\n\n**Advanced Features** - Storage classes, bucket locks (compliance), tus resumable uploads, SSE-C encryption. **Load `references\u002Fadvanced-features.md`**\n\n**Zero Trust Security** - Cloudflare Access integration with SSO, MFA, identity policies, audit logging. **Load `references\u002Fcloudflare-access-integration.md`**\n\n**Performance Tuning** - Caching strategies, compression, range requests, ETags, monitoring best practices. **Load `references\u002Fperformance-optimization.md`**\n\n---\n\n## Core R2 Workers API - Quick Reference\n\n### put() - Upload Objects\n```typescript\nawait env.MY_BUCKET.put(key, data, options?)\n```\nUpload with metadata, prevent overwrites with `onlyIf`. **Load `references\u002Fworkers-api.md`** for complete R2PutOptions.\n\n### get() - Download Objects\n```typescript\nconst object = await env.MY_BUCKET.get(key, options?)\n```\nReturns `R2ObjectBody | null`. Supports range requests, conditional operations. **Load `references\u002Fworkers-api.md`** for read methods (text(), json(), arrayBuffer(), blob()).\n\n### head() - Get Metadata Only\n```typescript\nconst object = await env.MY_BUCKET.head(key)\n```\nCheck existence, get size, etag, metadata without downloading body. Useful for validation and caching.\n\n### delete() - Delete Objects\n```typescript\nawait env.MY_BUCKET.delete(key | keys[])  \u002F\u002F Single or bulk (max 1000)\n```\nBulk delete up to 1000 keys in single call. Always succeeds (idempotent).\n\n### list() - List Objects\n```typescript\nconst listed = await env.MY_BUCKET.list(options?)\n```\nPagination with cursor, prefix filtering, delimiter for folders. **Load `references\u002Fworkers-api.md`** for R2ListOptions.\n\n### createMultipartUpload() - Large Files (>100MB)\n```typescript\nconst multipart = await env.MY_BUCKET.createMultipartUpload(key, options?)\n```\nFor files >100MB. **Load `references\u002Fcommon-patterns.md`** for complete multipart workflow with part upload and completion.\n\n**Load `references\u002Fworkers-api.md` when**: Need complete API reference, interface definitions (R2Object, R2ObjectBody, R2PutOptions, R2GetOptions), conditional operations, checksums, or advanced options.\n\n---\n\n## Critical Rules\n\n### Always Do ✅\n\n1. **Set contentType on uploads** - Files will download as binary otherwise\n2. **Use batch delete** for multiple objects (up to 1000 keys)\n3. **Set cache headers** for static assets (`cacheControl`)\n4. **Use presigned URLs** for large client uploads\n5. **Use multipart upload** for files >100MB\n6. **Set CORS policy** before browser uploads\n7. **Set expiry times** on presigned URLs (1-24 hours)\n8. **Handle errors** with try\u002Fcatch\n9. **Use head()** when you only need metadata (not get())\n10. **Use conditional operations** to prevent overwrites\n\n### Never Do ❌\n\n1. **Never expose R2 access keys** in client-side code\n2. **Never skip contentType** (files will download as binary)\n3. **Never delete in loops** (use batch delete)\n4. **Never upload without error handling**\n5. **Never skip CORS** for browser uploads\n6. **Never use multipart for small files** (\u003C5MB overhead)\n7. **Never delete >1000 keys** in single call (will fail)\n8. **Never assume uploads succeed** (always check response)\n9. **Never skip presigned URL expiry** (security risk)\n10. **Never hardcode bucket names** (use bindings)\n\n---\n\n## Top Use Cases\n\n### Use Case 1: Image\u002FAsset Storage\n\n```typescript\napp.put('\u002Fapi\u002Fupload\u002Fimage', async (c) => {\n  const file = await c.req.parseBody();\n  const image = file['image'] as File;\n\n  await c.env.MY_BUCKET.put(`images\u002F${image.name}`, image.stream(), {\n    httpMetadata: {\n      contentType: image.type,\n      cacheControl: 'public, max-age=31536000, immutable',\n    },\n  });\n\n  return c.json({ success: true });\n});\n```\n\n### Use Case 2: Direct Client Upload (Presigned URLs)\n\nGenerate secure upload URLs for client-side uploads. See `templates\u002Fr2-presigned-urls.ts` for complete implementation using aws4fetch.\n\n### Additional Patterns in References\n\n**Load `references\u002Fcommon-patterns.md` for**:\n- Multipart upload (files >100MB) - Complete workflow with part management\n- Bulk operations - Batch delete, cleanup patterns with pagination\n- Custom metadata tracking - User files, versions, approval workflows\n- Versioned file storage - Version history with latest pointer pattern\n- Backup & archive patterns - Automated backups with retention policies\n- Thumbnail generation & caching - On-demand image processing\n- Static site hosting - SPA fallback and cache strategies\n- CDN with origin fallback - R2 as cache layer\n\n**Load `templates\u002Fr2-multipart-upload.ts`** for complete multipart example.\n\n---\n\n## Available Agents & Commands\n\n### Autonomous Agents\n\nAgents handle complex multi-step workflows automatically:\n\n- **r2-setup-automator** - Complete R2 setup (bucket creation → binding → TypeScript types → deployment)\n- **multipart-orchestrator** - Large file uploads with chunking, error recovery, and progress tracking\n- **cors-debugger** - Systematic CORS troubleshooting with configuration generation and testing\n- **s3-migration-planner** - AWS S3 to R2 migration planning, data transfer, and cost analysis\n- **event-notification-setup** - Event-driven workflows with Workers, Queues, and automation\n\n### Quick Commands\n\nFast access to common R2 operations:\n\n- **\u002Fr2-setup** - Create bucket and configure binding in wrangler.jsonc\n- **\u002Fr2-presigned-url** - Generate presigned URLs for secure client-side uploads\u002Fdownloads\n- **\u002Fr2-cors-debug** - Diagnose and fix CORS configuration issues\n- **\u002Fr2-multipart-init** - Initialize multipart upload workflow for large files\n\n---\n\n## When to Load References\n\n### Core References (Existing Features)\n\n**`references\u002Fsetup-guide.md`** - First-time setup, binding configuration, TypeScript types, deployment walkthrough\n\n**`references\u002Fworkers-api.md`** - Complete API reference (all methods + options), conditional operations, checksums\n\n**`references\u002Fcommon-patterns.md`** - Multipart uploads, retry logic with backoff, batch operations, cache strategies\n\n**`references\u002Fs3-compatibility.md`** - S3 migration guide, S3 client library usage, aws4fetch presigned URL signing\n\n**`references\u002Fcors-configuration.md`** - Browser access setup, CORS debugging, security policies, Dashboard configuration\n\n### New Features References (2025)\n\n**`references\u002Fevent-notifications.md`** - Event-driven automation, Queue integration, image processing, webhook triggers\n\n**`references\u002Fadvanced-features.md`** - Storage classes (cost optimization), bucket locks (compliance), tus resumable uploads, SSE-C encryption\n\n**`references\u002Fr2-sql-integration.md`** - SQL queries on R2 data (CSV\u002FParquet\u002FJSON), analytics patterns, performance tuning\n\n**`references\u002Fdata-catalog-iceberg.md`** - Apache Iceberg tables, time-travel queries, schema evolution, Spark\u002FSnowflake integration\n\n**`references\u002Fcloudflare-access-integration.md`** - Zero Trust security, SSO (Google\u002FOkta\u002FAzure AD), identity policies, MFA, audit logging\n\n**`references\u002Fperformance-optimization.md`** - Caching (browser\u002FCDN\u002FWorkers), compression (gzip\u002FBrotli), range requests, ETags, monitoring\n\n---\n\n## Using Bundled Resources\n\n### References (references\u002F)\n\n- **setup-guide.md** - Complete setup walkthrough (bucket creation → deployment)\n- **workers-api.md** - Complete Workers API reference (all methods + options)\n- **common-patterns.md** - Advanced patterns (multipart, retry, batch, performance)\n- **s3-compatibility.md** - S3 compatibility guide (migration, aws4fetch, S3 clients)\n- **cors-configuration.md** - CORS setup guide (Dashboard, scenarios, troubleshooting, security)\n\n### Templates (templates\u002F)\n\n- **r2-simple-upload.ts** - Basic upload\u002Fdownload Worker\n- **r2-multipart-upload.ts** - Complete multipart upload implementation\n- **r2-presigned-urls.ts** - Presigned URL generation (upload + download)\n- **r2-cors-config.json** - CORS configuration examples\n- **wrangler-r2-config.jsonc** - Complete wrangler.jsonc with R2 binding\n\n---\n\n## CORS Configuration\n\nConfigure CORS for browser uploads\u002Fdownloads. **Load `references\u002Fcors-configuration.md`** for complete guide including Dashboard setup, common scenarios, troubleshooting, and security best practices.\n\n---\n\n## Error Handling\n\n```typescript\ntry {\n  await env.MY_BUCKET.put(key, data);\n} catch (error: any) {\n  const message = error.message;\n\n  if (message.includes('R2_ERROR')) {\n    \u002F\u002F Generic R2 error\n  } else if (message.includes('exceeded')) {\n    \u002F\u002F Quota exceeded\n  } else if (message.includes('precondition')) {\n    \u002F\u002F Conditional operation failed (onlyIf)\n  }\n\n  console.error('R2 Error:', message);\n  return c.json({ error: 'Storage operation failed' }, 500);\n}\n```\n\n**Load `references\u002Fcommon-patterns.md`** for retry logic with exponential backoff, circuit breaker patterns, and advanced error recovery.\n\n---\n\n## Known Issues Prevented\n\n| Issue | Description | Solution |\n|-------|-------------|----------|\n| **CORS errors** | Browser can't upload\u002Fdownload | Configure CORS in bucket settings |\n| **Files download as binary** | Missing content-type | Always set `httpMetadata.contentType` |\n| **Presigned URL security** | URLs never expire | Always set `X-Amz-Expires` (1-24 hours) |\n| **Multipart limits** | Parts >100MB or >10,000 parts | Keep parts 5MB-100MB, max 10,000 |\n| **Bulk delete limits** | >1000 keys fails | Chunk deletes into batches of 1000 |\n| **Metadata overflow** | >2KB custom metadata | Keep total under 2KB |\n\n---\n\n## Wrangler Commands\n\n```bash\n# Bucket management\nwrangler r2 bucket create \u003CBUCKET_NAME>\nwrangler r2 bucket list\nwrangler r2 bucket delete \u003CBUCKET_NAME>\n\n# Object management\nwrangler r2 object put \u003CBUCKET>\u002F\u003CKEY> --file=\u003CPATH>\nwrangler r2 object get \u003CBUCKET>\u002F\u003CKEY> --file=\u003COUTPUT>\nwrangler r2 object delete \u003CBUCKET>\u002F\u003CKEY>\n\n# List objects\nwrangler r2 object list \u003CBUCKET>\nwrangler r2 object list \u003CBUCKET> --prefix=\"folder\u002F\"\n```\n\n---\n\n## Official Documentation\n\n- **R2 Overview**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002F\n- **Workers API**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002Fapi\u002Fworkers\u002Fworkers-api-reference\u002F\n- **Multipart Upload**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002Fapi\u002Fworkers\u002Fworkers-multipart-usage\u002F\n- **Presigned URLs**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002Fapi\u002Fs3\u002Fpresigned-urls\u002F\n- **CORS Configuration**: https:\u002F\u002Fdevelopers.cloudflare.com\u002Fr2\u002Fbuckets\u002Fcors\u002F\n\n---\n\n**Questions? Issues?**\n\n1. Check `references\u002Fsetup-guide.md` for setup walkthrough\n2. Review `references\u002Fworkers-api.md` for API reference\n3. See `references\u002Fcommon-patterns.md` for advanced patterns\n4. Load `templates\u002F` for working code examples\n",{},"main","def8531e65114c0fca8fb8551c1871ee0eed705c","skills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2",24,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub","https:\u002F\u002Fskillshub.wtf","https:\u002F\u002Fgithub.com\u002FComeOnOliver","AI & Blockchain Engineer\r\n","2026-06-24 22:07:19",{"source":7,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add ComeOnOliver\u002Fskillshub --skill cloudflare-r2",{"tool":40,"command":41},"bunx","bunx skills add ComeOnOliver\u002Fskillshub --skill cloudflare-r2",{"tool":43,"command":44},"pnpm","pnpm dlx skills add ComeOnOliver\u002Fskillshub --skill cloudflare-r2","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002FSKILL.md",true,[48,54,58,62,66,70,74,78,82,86,90,94,98,104,108,112],{"path":49,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":52,"sourceHtmlUrl":53},"references\u002Fadvanced-features.md","REFERENCE","参考文档",14698,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fadvanced-features.md",{"path":55,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":56,"sourceHtmlUrl":57},"references\u002Fcloudflare-access-integration.md",14841,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fcloudflare-access-integration.md",{"path":59,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Fcommon-patterns.md",13114,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fcommon-patterns.md",{"path":63,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fcors-configuration.md",2774,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fcors-configuration.md",{"path":67,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Fdata-catalog-iceberg.md",15511,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fdata-catalog-iceberg.md",{"path":71,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fevent-notifications.md",16197,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fevent-notifications.md",{"path":75,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":76,"sourceHtmlUrl":77},"references\u002Fperformance-optimization.md",16206,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fperformance-optimization.md",{"path":79,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":80,"sourceHtmlUrl":81},"references\u002Fr2-sql-integration.md",14816,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fr2-sql-integration.md",{"path":83,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":84,"sourceHtmlUrl":85},"references\u002Fs3-compatibility.md",7909,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fs3-compatibility.md",{"path":87,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":88,"sourceHtmlUrl":89},"references\u002Fsetup-guide.md",8674,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fsetup-guide.md",{"path":91,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Fworkers-api.md",9941,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Freferences\u002Fworkers-api.md",{"path":95,"resourceType":50,"resourceTypeDesc":51,"sizeBytes":96,"sourceHtmlUrl":97},"templates\u002Fr2-cors-config.json",3407,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Ftemplates\u002Fr2-cors-config.json",{"path":99,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":102,"sourceHtmlUrl":103},"templates\u002Fr2-multipart-upload.ts","SCRIPT","脚本",5825,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Ftemplates\u002Fr2-multipart-upload.ts",{"path":105,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":106,"sourceHtmlUrl":107},"templates\u002Fr2-presigned-urls.ts",7418,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Ftemplates\u002Fr2-presigned-urls.ts",{"path":109,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":110,"sourceHtmlUrl":111},"templates\u002Fr2-simple-upload.ts",5236,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Ftemplates\u002Fr2-simple-upload.ts",{"path":113,"resourceType":114,"resourceTypeDesc":115,"sizeBytes":116,"sourceHtmlUrl":117},"templates\u002Fwrangler-r2-config.jsonc","OTHER","其他",1162,"https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fsecondsky\u002Fclaude-skills\u002Fcloudflare-r2\u002Ftemplates\u002Fwrangler-r2-config.jsonc",[119,128,137,146,152,158],{"skillNo":120,"name":121,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":20},"01M6FKJN13GMG4KY57J3QD8GY5","model-hierarchy-skill","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzscole\u002Fmodel-hierarchy-skill\u002Fmodel-hierarchy-skill\u002FSKILL.md",[],[125,126,127],"model","model hierarchy","model hierarchy skill",{"skillNo":129,"name":130,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":20},"01M6FKJJJ6GCAMR4PPPRD12M5X","zoom-mcp","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-mcp\u002FSKILL.md",[],[134,135,136],"MCP","zoom","zoom mcp",{"skillNo":138,"name":139,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":140,"categories":141,"keywords":142,"publishedAt":20},"01M6FKJE3KYT3KPEZMEEHYKA6K","zoom-apps-sdk","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fzoom-apps-sdk\u002FSKILL.md",[],[143,144,145,135],"sdk","zoom apps sdk","apps",{"skillNo":147,"name":148,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":20},"01M6FKJ9EDH9Q5VWDF8HAJRSP0","windows","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwindows\u002FSKILL.md",[],[148],{"skillNo":153,"name":154,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":20},"01M6FKJ666BEEFC3AE9GJ72Q93","whiteboard","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwhiteboard\u002FSKILL.md",[],[154],{"skillNo":159,"name":160,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":163,"publishedAt":20},"01M6FKJ21WFCDGTJQ2Q91T9DVW","websockets","https:\u002F\u002Fgithub.com\u002FComeOnOliver\u002Fskillshub\u002Fblob\u002Fmain\u002Fskills\u002Fzoom\u002Fskills\u002Fwebsockets\u002FSKILL.md",[],[160]]