All skills
openai avatar

/cloudflare-deploy

@bf9e226 official
by openaiopenai/skills28k stars
1,891

Deploy 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.

Use this Skill: https://skilld.dev/gh/openai/skills/cloudflare-deploy

This session only. Nothing lands on disk.

referencesstatic-assetsconfiguration.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Configuration

Basic Setup

Minimal configuration requires only assets.directory:

{
  "name": "my-worker",
  "compatibility_date": "2025-01-01",  // Use current date for new projects
  "assets": {
    "directory": "./dist"
  }
}

Full Configuration Options

{
  "name": "my-worker",
  "main": "src/index.ts",
  "compatibility_date": "2025-01-01",
  "assets": {
    "directory": "./dist",
    "binding": "ASSETS",
    "not_found_handling": "single-page-application",
    "html_handling": "auto-trailing-slash",
    "run_worker_first": ["/api/*", "!/api/docs/*"]
  }
}

Configuration keys:

  • directory (string, required): Path to assets folder (e.g. ./dist, ./public, ./build)
  • binding (string, optional): Name to access assets in Worker code (e.g. env.ASSETS). Default: "ASSETS"
  • not_found_handling (string, optional): Behavior when asset not found
    • "single-page-application": Serve /index.html for non-asset paths (default for SPAs)
    • "404-page": Serve /404.html if present, otherwise 404
    • "none": Return 404 for missing assets
  • html_handling (string, optional): URL trailing slash behavior
  • run_worker_first (boolean | string[], optional): Routes that invoke Worker before checking assets

not_found_handling Modes

Mode Behavior Use Case
"single-page-application" Serve /index.html for non-asset requests React, Vue, Angular SPAs
"404-page" Serve /404.html if exists, else 404 Static sites with custom error page
"none" Return 404 for missing assets API-first or custom routing

html_handling Modes

Controls trailing slash behavior for HTML files:

Mode /page /page/ Use Case
"auto-trailing-slash" Redirect to /page/ if /page/index.html exists Serve /page/index.html Default, SEO-friendly
"force-trailing-slash" Always redirect to /page/ Serve if exists Consistent trailing slashes
"drop-trailing-slash" Serve if exists Redirect to /page Cleaner URLs
"none" No modification No modification Custom routing logic

Default: "auto-trailing-slash"

run_worker_first Configuration

Controls which requests invoke Worker before checking assets.

Boolean syntax:

{
  "assets": {
    "run_worker_first": true  // ALL requests invoke Worker
  }
}

Array syntax (recommended):

{
  "assets": {
    "run_worker_first": [
      "/api/*",           // Positive pattern: match API routes
      "/admin/*",         // Match admin routes
      "!/admin/assets/*"  // Negative pattern: exclude admin assets
    ]
  }
}

Pattern rules:

  • Glob patterns: * (any chars), ** (any path segments)
  • Negative patterns: Prefix with ! to exclude
  • Precedence: Negative patterns override positive patterns
  • Default: false (assets served directly)

Decision guidance:

  • Use true for API-first apps (few static assets)
  • Use array patterns for hybrid apps (APIs + static assets)
  • Use false for static-first sites (minimal dynamic routes)

.assetsignore File

Exclude files from upload using .assetsignore (same syntax as .gitignore):

# .assetsignore
_worker.js
*.map
*.md
node_modules/
.git/

Common patterns:

  • _worker.js - Exclude Worker code from assets
  • *.map - Exclude source maps
  • *.md - Exclude markdown files
  • Development artifacts

Vite Plugin Integration

For Vite-based projects, use @cloudflare/vite-plugin:

// vite.config.ts
import { defineConfig } from 'vite';
import { cloudflare } from '@cloudflare/vite-plugin';

export default defineConfig({
  plugins: [
    cloudflare({
      assets: {
        directory: './dist',
        binding: 'ASSETS'
      }
    })
  ]
});

Features:

  • Automatic asset detection during dev
  • Hot module replacement for assets
  • Production build integration
  • Requires: Wrangler 4.0.0+, @cloudflare/vite-plugin 1.0.0+

Key Compatibility Dates

Date Feature Impact
2025-04-01 Navigation request optimization SPAs skip Worker for navigation, reducing costs

Use current date for new projects. See Compatibility Dates for full list.

Environment-Specific Configuration

Use wrangler.jsonc environments for different configs:

{
  "name": "my-worker",
  "assets": { "directory": "./dist" },
  "env": {
    "staging": {
      "assets": {
        "not_found_handling": "404-page"
      }
    },
    "production": {
      "assets": {
        "not_found_handling": "single-page-application"
      }
    }
  }
}

Deploy with: wrangler deploy --env staging

Source: SKILL.md on GitHub

2 warnings17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides comprehensive guidance for deploying and managing infrastructure on the Cloudflare platform. It includes extensive educational material on secure development practices, such as preventing SQL injection and managing secrets effectively. No malicious patterns or security risks were identified.

  • Socket17d

    2 alerts: gptAnomaly

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    310/310 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at bf9e226. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Activeupdated 8 months ago

README badge

README badge for openai/skills/cloudflare-deploy

Deploys applications and infrastructure to Cloudflare's platform, including Workers, Pages, D1, R2, Durable Objects, KV, and other services. Use decision trees to route to the right Cloudflare product based on compute, storage, AI, networking, security, or media needs.

Generated from the current SKILL.md.

Does this skill cover all Cloudflare products?
The skill is a consolidated index covering compute, storage, AI, networking, security, media, and developer tools on Cloudflare. It uses decision trees to route you to the right product reference, then loads detailed guidance for that product.
What authentication is required before deploying?
Run `npx wrangler whoami` to check if authenticated. For local deployment, use `wrangler login` (one-time OAuth). For CI/CD, set the `CLOUDFLARE_API_TOKEN` environment variable.
What should I do if deployment fails due to network issues?
Rerun the deploy with `sandbox_permissions=require_escalated` to grant elevated network access, which is required for outbound requests to Cloudflare during deployment.
How long does a Cloudflare deployment typically take?
Deployments may take several minutes. Use appropriate timeout values in your configuration or CI/CD environment.

Generated from the current SKILL.md. These answers refresh after source changes.