cloudflare-images
This skill should be used when the user asks to "upload images to Cloudflare", "implement direct creator upload", "configure image transformations", "optimize WebP/AVIF", "create image variants", "generate signed URLs", "add image watermarks", "integrate with Next.js/Remix", "configure webhooks", "debug CORS errors", "troubleshoot error 5408/9401-9413", or "build responsive images with Cloudflare Images API".
What this skill does
# Cloudflare Images
**Status**: Production Ready ✅ | **Version**: 3.0.0 | **Last Verified**: 2025-12-27
---
## What Is Cloudflare Images?
Two powerful features:
1. **Images API**: Upload, store, serve images globally
2. **Image Transformations**: Resize/optimize ANY image
**Key benefits:**
- Global CDN delivery
- Automatic WebP/AVIF conversion
- Up to 100 variants
- Direct creator upload (no API keys in frontend)
- Signed URLs for private images
- Transform any image via URL or Workers
---
## Quick Start (5 Minutes)
### 1. Enable Cloudflare Images
Dashboard → **Images** → **Enable**
Get your **Account ID** and create **API token** (Cloudflare Images: Edit permission)
### 2. Upload Image
```bash
curl --request POST \
--url https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/images/v1 \
--header 'Authorization: Bearer <API_TOKEN>' \
--header 'Content-Type: multipart/form-data' \
--form 'file=@./image.jpg'
```
**CRITICAL:** Use `multipart/form-data`, not JSON
### 3. Serve Image
```html
<img src="https://imagedelivery.net/<ACCOUNT_HASH>/<IMAGE_ID>/public" />
```
### 4. Enable Transformations
Dashboard → **Images** → **Transformations** → **Enable for zone**
Transform ANY image:
```html
<img src="/cdn-cgi/image/width=800,quality=85/uploads/photo.jpg" />
```
### 5. Transform via Workers
```typescript
export default {
async fetch(request: Request): Promise<Response> {
return fetch("https://example.com/image.jpg", {
cf: {
image: {
width: 800,
quality: 85,
format: "auto" // WebP/AVIF
}
}
});
}
};
```
**Load `references/setup-guide.md` for complete walkthrough.**
---
## The 3 Core Features
### Feature 1: Images API (Upload & Storage)
**Upload methods:**
1. File upload (server-side)
2. Upload via URL (ingest from external)
3. Direct creator upload (user uploads, no API keys)
**Load `templates/upload-api-basic.ts` for file upload example.**
**Load `references/direct-upload-complete-workflow.md` for user uploads.**
### Feature 2: Image Transformations
Optimize ANY image (uploaded or external).
**Methods:**
1. URL: `/cdn-cgi/image/width=800,quality=85/path/to/image.jpg`
2. Workers: `cf.image` fetch option
**Load `references/transformation-options.md` for all options.**
**Load `templates/transform-via-workers.ts` for Workers example.**
### Feature 3: Variants
Predefined transformations (up to 100).
**Examples:**
- `thumbnail`: 200x200, fit=cover
- `hero`: 1920x1080, quality=90
- `mobile`: 640, quality=75
**Load `references/variants-guide.md` for complete guide.**
---
## Critical Rules
### Always Do ✅
1. **Use multipart/form-data** for uploads (not JSON)
2. **Enable transformations for zones** before using `/cdn-cgi/image/`
3. **Use direct creator upload** for user uploads (don't expose API tokens)
4. **Set CORS headers** for direct uploads from browser
5. **Use signed URLs** for private images
6. **Configure variants** for common sizes (avoid dynamic transformations)
7. **Use format=auto** for automatic WebP/AVIF
8. **Handle error codes** (9401, 9403, 9413, 5408)
9. **Set quality=85** for optimal size/quality balance
10. **Use fit=cover** for consistent aspect ratios
### Never Do ❌
1. **Never expose API tokens** in frontend code
2. **Never use JSON encoding** for file uploads
3. **Never skip CORS configuration** for direct uploads
4. **Never exceed 100 variants** (hard limit)
5. **Never use transformations without enabling for zone**
6. **Never hardcode account IDs** in public code
7. **Never skip error handling** (uploads can fail)
8. **Never use quality >90** (diminishing returns)
9. **Never skip image validation** (size, format, dimensions)
10. **Never use transformations on non-proxied requests**
---
## Top 2 Use Cases
### Use Case 1: User Profile Pictures
Direct creator upload pattern for user-uploaded images:
```typescript
// Backend: Generate upload URL
const response = await fetch(
`https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/images/v2/direct_upload`,
{ method: 'POST', headers: { 'Authorization': `Bearer ${API_TOKEN}` } }
);
const { result } = await response.json();
return Response.json({ uploadURL: result.uploadURL });
// Frontend: Upload file
const formData = new FormData();
formData.append('file', file);
await fetch(uploadURL, { method: 'POST', body: formData });
```
**Load `templates/direct-creator-upload-backend.ts` for complete example.**
**See `examples/basic-upload/` for complete working project.**
### Use Case 2: Responsive Images
Responsive images with srcset for optimal performance:
```html
<img
srcset="
https://imagedelivery.net/abc/xyz/width=400 400w,
https://imagedelivery.net/abc/xyz/width=800 800w,
https://imagedelivery.net/abc/xyz/width=1200 1200w
"
sizes="(max-width: 600px) 400px, (max-width: 1000px) 800px, 1200px"
src="https://imagedelivery.net/abc/xyz/width=800"
/>
```
**Load `templates/responsive-images-srcset.html` for complete example.**
**See `examples/responsive-gallery/` for complete working project.**
**Additional Use Cases:**
- **Transform Existing Images**: Load `references/transformation-options.md`
- **Private Images**: Load `references/signed-urls-guide.md` or see `examples/private-images/`
- **Batch Upload**: Load `templates/batch-upload.ts`
- **Framework Integration**: Load `references/framework-integration.md` for Next.js, Remix, Astro
- **Watermarking**: Load `references/overlays-watermarks.md` and `templates/overlay-watermark.ts`
- **Custom Domains**: Load `references/custom-domains.md`
- **Webhooks**: Load `references/webhooks-guide.md` and `templates/webhook-handler.ts`
---
## Top 2 Errors Prevented
### Error 1: CORS Issues with Direct Upload
**Problem:** Browser blocks direct upload from your domain.
**Solution:** Configure CORS headers when generating upload URL:
```typescript
const response = await fetch(
`https://api.cloudflare.com/client/v4/accounts/${ACCOUNT_ID}/images/v2/direct_upload`,
{
method: 'POST',
headers: { 'Authorization': `Bearer ${API_TOKEN}` },
body: JSON.stringify({
requireSignedURLs: false,
metadata: { source: 'user-upload' }
})
}
);
```
### Error 2: Multipart Form Data Encoding
**Problem:** JSON encoding fails for file uploads (must use multipart/form-data).
**Solution:**
```typescript
// ✅ CORRECT
const formData = new FormData();
formData.append('file', file);
await fetch(uploadURL, { method: 'POST', body: formData });
// ❌ WRONG
const json = JSON.stringify({ file: base64File });
```
**Additional Common Errors:**
- **Error 9401** (Transformations not enabled): Load `references/top-errors.md`
- **Error 9403** (Invalid transformation): Load `references/top-errors.md`
- **Error 9413** (Variant limit exceeded): Load `references/top-errors.md`
- **Error 5408** (Upload timeout): Load `references/top-errors.md`
- **Missing requireSignedURLs**: Load `references/signed-urls-guide.md`
**Load `references/top-errors.md` for all 10 errors with complete solutions.**
---
## When to Load References
### Core References
**Load `references/setup-guide.md` when:**
- First-time Cloudflare Images setup
- Need step-by-step walkthrough
**Load `references/api-reference.md` when:**
- Need complete API documentation
- All endpoints and parameters
**Load `references/top-errors.md` when:**
- Encountering any error code (5408, 9401-9413)
- Troubleshooting upload/transformation issues
### Upload References
**Load `references/direct-upload-complete-workflow.md` when:**
- Implementing user uploads
- Need frontend + backend example
- Configuring CORS
**Load `references/signed-urls-guide.md` when:**
- Implementing private images with access control
- Need HMAC-SHA256 signature generation
**Load `references/webhooks-guide.md` when:**
- Processing upload completion events
- Implementing webhook handlers with signature verification
### Transformation References
**Load `references/transformation-optRelated in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.