Skip to content

Cloudflare Hono Template Commands

Specialized commands for building edge-first applications with Cloudflare Workers and Hono.

Overview

The Cloudflare template provides 10 commands optimized for edge computing, serverless APIs, and Cloudflare's ecosystem of services.

Available Commands

API Development

Storage & Data

Infrastructure

Deployment

Usage Examples

Creating an API

bash
/template add-api-route /api/users GET,POST,PUT,DELETE
/template add-middleware rate-limiting
/template add-middleware cors

Setting Up Storage

bash
/template add-r2-storage user-uploads
/template setup-database user-data

Authentication Setup

bash
/template setup-auth jwt
/template add-middleware auth-required

Deployment

bash
/template deploy-worker production
/template setup-analytics

Key Features

Edge-First Architecture

All commands generate code optimized for edge runtime:

  • Minimal cold starts
  • Global distribution
  • Low latency responses

Cloudflare Services Integration

Commands integrate seamlessly with:

  • Workers KV for session storage
  • R2 for object storage
  • D1 for SQL databases
  • Queues for async processing
  • Analytics for monitoring

Type Safety

  • Full TypeScript support
  • Hono's type-safe routing
  • Generated types for all services

Best Practices

  1. Start with API Routes: Define your API structure first
  2. Add Middleware Early: Security and CORS from the beginning
  3. Use R2 for Files: Don't store files in KV
  4. Monitor Performance: Enable analytics early
  5. Test Locally: Use wrangler dev for local testing

Common Workflows

Building a REST API

bash
/template add-api-route /api/auth/login POST
/template add-api-route /api/auth/logout POST
/template setup-auth jwt
/template add-middleware auth-required

File Upload System

bash
/template add-r2-storage uploads
/template add-api-route /api/upload POST
/template add-middleware file-size-limit

Background Processing

bash
/template implement-queue email-queue
/template add-worker-cron cleanup-job "0 2 * * *"

Integration with Core Prompts

Use Cloudflare commands with core Orchestre prompts:

bash
# Plan the architecture
/orchestrate "Build image processing API"

# Implement with template commands
/template add-api-route /api/images/process POST
/template add-r2-storage processed-images
/template implement-queue image-processing

# Review and document
/review
/document-feature "Image processing pipeline"

Built with ❤️ for the AI Coding community, by Praney Behl