xiaohongshu
xiaohongshu
cloudflare-deployment
Deploy and manage Cloudflare Workers, Pages, KV, R2, and D1 using wrangler CLI or MCP server. Use when working with Cloudflare services, serverless functions, or edge deployments.
Full skill instructions
Activate this skill when:
# Install wrangler
pnpm add -g wrangler
# Login
wrangler login
# Initialize new Worker
wrangler init my-worker
# Local development
wrangler dev
# Deploy to Cloudflare
wrangler deploy
# View logs
wrangler tail my-worker
| Service | Purpose | Use Case |
|---|---|---|
| Workers | Serverless functions | API endpoints, middleware |
| Pages | Static sites + functions | SvelteKit, Next.js |
| KV | Key-value storage | Caching, session data |
| R2 | Object storage | Files, images, backups |
| D1 | SQLite database | Structured data |
wrangler init my-worker --type javascript
cd my-worker
wrangler dev
wrangler deploy
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname === '/api/hello') {
return new Response(JSON.stringify({ message: 'Hello!' }), {
headers: { 'Content-Type': 'application/json' }
});
}
return new Response('Not found', { status: 404 });
}
}
# Create namespace
wrangler kv namespace create MY_KV
# Add to wrangler.toml
# kv_namespaces = [{ binding = "MY_KV", id = "abc123" }]
// In Worker
export default {
async fetch(request, env) {
// Write
await env.MY_KV.put("key", "value");
// Read
const value = await env.MY_KV.get("key");
return new Response(value);
}
}
wrangler r2 bucket create my-bucket
# Add: r2_buckets = [{ binding = "MY_BUCKET", bucket_name = "my-bucket" }]
// In Worker
await env.MY_BUCKET.put("file.txt", "content");
const object = await env.MY_BUCKET.get("file.txt");
const text = await object.text();
wrangler d1 create my-database
wrangler d1 execute my-database --command="CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)"
# Add: d1_databases = [{ binding = "DB", database_name = "my-database", database_id = "..." }]
// In Worker
const { results } = await env.DB.prepare(
"SELECT * FROM users WHERE id = ?"
).bind(1).all();
return Response.json(results);
# Deploy static site
wrangler pages deploy ./build --project-name=my-site
# With SvelteKit
pnpm add -D @sveltejs/adapter-cloudflare
pnpm build
wrangler pages deploy .svelte-kit/cloudflare
name = "my-worker"
main = "src/index.js"
compatibility_date = "2024-01-01"
# Automatic resource provisioning (v4.45.0+)
kv_namespaces = [{ binding = "MY_KV" }]
r2_buckets = [{ binding = "MY_BUCKET" }]
d1_databases = [{ binding = "DB" }]
# Local (simulated resources)
wrangler dev
# Remote (real Cloudflare resources)
wrangler dev --remote
# Set secret
wrangler secret put API_KEY --name my-worker
# Access in code
const apiKey = env.API_KEY;
wrangler dev for local testing firstwrangler tailexport default {
async fetch(request, env) {
const url = new URL(request.url);
const cacheKey = url.pathname;
// Check KV cache
let content = await env.MY_KV.get(cacheKey);
if (content) return new Response(content);
// Fetch from R2
const object = await env.MY_BUCKET.get(cacheKey.slice(1));
if (!object) return new Response("Not found", { status: 404 });
content = await object.text();
// Cache in KV
await env.MY_KV.put(cacheKey, content, { expirationTtl: 3600 });
return new Response(content);
}
}
See AgentUsage/cloudflare_guide.md for complete documentation including:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience