davila7/claude-code-templates / cli-tool/components/skills/development/cloudflare-deploy
cloudflare-deploy
FlaggedDeploy applications and infrastructure to Cloudflare using Workers, Pages, and related platform services. Use when the user asks to deploy, host, publish, or set up a project on Cloudflare.
references/images/patterns.md
View on GitHub# Common Patterns
## URL Transform Options
```
width=<PX> height=<PX> fit=scale-down|contain|cover|crop|pad
quality=85 format=auto|webp|avif|jpeg|png dpr=2
gravity=auto|face|left|right|top|bottom sharpen=2 blur=10
rotate=90|180|270 background=white metadata=none|copyright|keep
```
## Responsive Images (srcset)
```html
<img src="https://imagedelivery.net/{hash}/{id}/width=800"
srcset=".../{id}/width=400 400w, .../{id}/width=800 800w, .../{id}/width=1200 1200w"
sizes="(max-width: 600px) 400px, 800px" />
```
## Format Negotiation
```typescript
async fetch(request: Request, env: Env): Promise<Response> {
const accept = request.headers.get('Accept') || '';
const format = /image\/avif/.test(accept) ? 'avif' : /image\/webp/.test(accept) ? 'webp' : 'jpeg';
return env.IMAGES.input(buffer).transform({ format, quality: 85 }).output().response();
}
```
## Direct Creator Upload
```typescript
// Backend: Generate upload URL
const response = await fetch(
`https://api.cloudflare.com/client/v4/accounts/${env.ACCOUNT_ID}/images/v2/direct_upload`,
{ method: 'POST', headers: { 'Authorization': `Bearer ${env.API_TOKEN}` },
body: JSON.stringify({ requireSignedURLs: false, metadata: { userId } }) }
);
// Frontend: Upload to returned uploadURL
const formData = new FormData();
formData.append('file', file);
await fetch(result.uploadURL, { method: 'POST', body: formData });
// Use: https://imagedelivery.net/{hash}/${result.id}/public
```
## Transform & Store to R2
```typescript
async fetch(request: Request, env: Env): Promise<Response> {
const file = (await request.formData()).get('image') as File;
const transformed = await env.IMAGES
.input(await file.arrayBuffer())
.transform({ width: 800, format: 'avif', quality: 80 })
.output();
await env.R2.put(`images/${Date.now()}.avif`, transformed.response().body);
return Response.json({ success: true });
}
```
## Watermarking
```typescript
const watermark = await env.ASSETS.fetch(new URL('/watermark.png', request.url));
const result = await env.IMAGES
.input(await image.arrayBuffer())
.draw(env.IMAGES.input(watermark.body).transform({ width: 100 }), { bottom: 20, right: 20, opacity: 0.7 })
.transform({ format: 'avif' })
.output();
return result.response();
```
## Device-Based Transforms
```typescript
const ua = request.headers.get('User-Agent') || '';
const isMobile = /Mobile|Android|iPhone/i.test(ua);
return env.IMAGES.input(buffer)
.transform({ width: isMobile ? 400 : 1200, quality: isMobile ? 75 : 85, format: 'avif' })
.output().response();
```
## Caching Strategy
```typescript
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
const cache = caches.default;
let response = await cache.match(request);
if (!response) {
response = await env.IMAGES.input(buffer).transform({ width: 800, format: 'avif' }).output().response();
response = new Response(response.body, { headers: { ...response.headers, 'Cache-Control': 'public, max-age=86400' } });
ctx.waitUntil(cache.put(request, response.clone()));
}
return response;
}
```
## Batch Processing
```typescript
const results = await Promise.all(images.map(buffer =>
env.IMAGES.input(buffer).transform({ width: 800, fit: 'cover', format: 'avif' }).output()
));
```
## Error Handling
```typescript
try {
return (await env.IMAGES.input(buffer).transform({ width: 800 }).output()).response();
} catch (error) {
console.error('Transform failed:', error);
return new Response('Image processing failed', { status: 500 });
}
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |