cloudflare-development
This skill covers development patterns and architectural guidance for Cloudflare's edge platform, including Workers for compute, Pages for frontend hosting, KV for caching, D1 for databases, R2 for object storage, and Durable Objects for stateful coordination. Learn optimization techniques, security practices, and configuration strategies to build performant serverless applications at the edge.
Cloudflare Development teaches best practices for building serverless edge applications using Workers, Pages, KV, D1, R2, and Durable Objects.
AI-generated summary based on this skill's SKILL.md
Install
Mindrally/skills/cloudflare-development
git clone https://github.com/Mindrally/skills
cp -r skills/cloudflare-development ~/.claude/skills/cloudflare-developmentFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What are the best practices for building serverless applications on Cloudflare's edge platform?
Cloudflare-development covers core patterns for edge serverless work: use Workers for compute logic deployed globally, Pages for frontend hosting, and combine storage solutions strategically. Best practices include minimizing cold starts, leveraging KV for distributed caching, using D1 for relational data, and R2 for large objects. Design for edge locality, implement proper error handling, and use Durable Objects only for genuinely stateful coordination needs to avoid unnecessary latency.
How do I configure and use Cloudflare storage solutions like KV, D1, and R2?
Cloudflare-development guides configuration of three storage tiers: KV provides low-latency key-value caching ideal for sessions and frequently accessed data; D1 offers SQLite databases for structured queries; R2 handles large object storage without egress fees. Each integrates with Workers via bindings in wrangler.toml. KV suits caching strategies, D1 replaces external databases, and R2 stores media and backups. Choose based on access patterns and data structure needs.
What security and performance optimization techniques apply to edge workers?
Cloudflare-development emphasizes security through JWT authentication, rate limiting at the edge, and request validation before processing. Performance optimization includes caching headers strategically, using KV for computed results, minimizing bundle size, and leveraging Cloudflare's global network to reduce latency. Implement security headers, validate inputs early, and use Durable Objects sparingly for coordination. Monitor performance via analytics and adjust caching policies based on traffic patterns.
How do I set up Durable Objects for stateful, coordinated edge computing workloads?
Cloudflare-development explains Durable Objects as persistent, coordinated compute instances ideal for real-time features like WebSocket connections, collaborative editing, and rate limiting. Configure them via wrangler with a migration system for schema changes. Access via stub from Workers, maintain state in memory or storage, and use them judiciously since they incur per-instance costs. Examples include WebSocket handlers and transactional coordination across requests.
What does wrangler configuration guide cover for Cloudflare development?
Cloudflare-development's wrangler guidance covers project setup, environment binding configuration for KV, D1, R2, and Durable Objects, build scripts, and deployment settings. Configure routes, triggers, and compatibility flags in wrangler.toml. Manage secrets, set up local development with wrangler dev, and deploy via wrangler publish. Wrangler streamlines the entire workflow from local testing to production edge deployment.
How do I deploy and test Cloudflare Workers and Pages in production?
Cloudflare-development covers deployment via wrangler publish for Workers and git integration for Pages. Test locally with wrangler dev to simulate edge environment, validate bindings and performance. Use preview deployments before production rollout. Monitor via Cloudflare's analytics dashboard, set up error tracking, and implement gradual rollouts. Pages auto-deploys on git push; Workers require explicit publish commands or CI/CD integration.
SKILL.md
rendered from the published skill — quoted content, verbatim
Cloudflare Development Best Practices
Overview
This skill provides comprehensive guidelines for developing applications on Cloudflare's edge platform, including Workers, Pages, KV storage, D1 databases, R2 object storage, and Durable Objects.
Core Principles
- Write lightweight, fast code optimized for edge execution
- Minimize cold start times and execution duration
- Use appropriate storage solutions for each use case
- Follow security best practices for edge computing
- Leverage Cloudflare's global network for performance
Cloudflare Workers Guidelines
Basic Worker Structure
```typescript export default { async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> { try { const url = new URL(request.url);
// Route handling
if (url.pathname === '/api/data') {
return handleApiRequest(request, env);
}
return new Response('Not Found', { status: 404 });
} catch (error) {
console.error('Worker error:', error);
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
cloudflare-development/SKILL.md