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.

referencesturnstileconfiguration.md

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

Configuration

Script Loading

Basic (Implicit Rendering)

<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>

Automatically renders widgets with class="cf-turnstile" on page load.

Explicit Rendering

<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit"></script>

Manual control over when/where widgets render via window.turnstile.render().

With Load Callback

<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=myCallback"></script>
<script>
function myCallback() {
  // API ready
  window.turnstile.render('#container', { sitekey: 'YOUR_SITE_KEY' });
}
</script>

Compatibility Mode

<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?compat=recaptcha"></script>

Provides grecaptcha API for Google reCAPTCHA drop-in replacement.

Widget Configuration

Complete Options Object

{
  // Required
  sitekey: 'YOUR_SITE_KEY',        // Widget sitekey from dashboard

  // Callbacks
  callback: (token) => {},          // Success - token ready
  'error-callback': (code) => {},   // Error occurred
  'expired-callback': () => {},     // Token expired (>5min)
  'timeout-callback': () => {},     // Challenge timeout
  'before-interactive-callback': () => {}, // Before showing checkbox
  'after-interactive-callback': () => {},  // After user interacts
  'unsupported-callback': () => {}, // Browser doesn't support Turnstile

  // Appearance
  theme: 'auto',                    // 'light' | 'dark' | 'auto'
  size: 'normal',                   // 'normal' | 'compact' | 'flexible'
  tabindex: 0,                      // Tab order (accessibility)
  language: 'auto',                 // ISO 639-1 code or 'auto'

  // Behavior
  execution: 'render',              // 'render' (auto) | 'execute' (manual)
  appearance: 'always',             // 'always' | 'execute' | 'interaction-only'
  retry: 'auto',                    // 'auto' | 'never'
  'retry-interval': 8000,           // Retry interval (ms), default 8000
  'refresh-expired': 'auto',        // 'auto' | 'manual' | 'never'

  // Form Integration
  'response-field': true,           // Add hidden input (default: true)
  'response-field-name': 'cf-turnstile-response', // Hidden input name

  // Analytics & Data
  action: 'login',                  // Action name (for analytics)
  cData: 'user-session-123',        // Custom data (returned in siteverify)
}

Key Options Explained

execution:

  • 'render' (default): Challenge starts immediately on render
  • 'execute': Wait for turnstile.execute() call

appearance:

  • 'always' (default): Widget always visible
  • 'execute': Hidden until execute() called
  • 'interaction-only': Hidden until user interaction needed

refresh-expired:

  • 'auto' (default): Auto-refresh expired tokens
  • 'manual': App must call reset() after expiry
  • 'never': No refresh, expired-callback triggered

retry:

  • 'auto' (default): Auto-retry failed challenges
  • 'never': Don't retry, trigger error-callback

HTML Data Attributes

For implicit rendering, use data attributes on <div class="cf-turnstile">:

JavaScript Property HTML Data Attribute Example
sitekey data-sitekey data-sitekey="YOUR_KEY"
action data-action data-action="login"
cData data-cdata data-cdata="session-123"
callback data-callback data-callback="onSuccess"
error-callback data-error-callback data-error-callback="onError"
expired-callback data-expired-callback data-expired-callback="onExpired"
timeout-callback data-timeout-callback data-timeout-callback="onTimeout"
theme data-theme data-theme="dark"
size data-size data-size="compact"
tabindex data-tabindex data-tabindex="0"
response-field data-response-field data-response-field="false"
response-field-name data-response-field-name data-response-field-name="token"
retry data-retry data-retry="never"
retry-interval data-retry-interval data-retry-interval="5000"
language data-language data-language="en"
execution data-execution data-execution="execute"
appearance data-appearance data-appearance="interaction-only"
refresh-expired data-refresh-expired data-refresh-expired="manual"

Example:

<div class="cf-turnstile"
     data-sitekey="YOUR_SITE_KEY"
     data-theme="dark"
     data-callback="onTurnstileSuccess"
     data-error-callback="onTurnstileError"></div>

Content Security Policy

Add these directives to CSP header/meta tag:

script-src https://challenges.cloudflare.com;
frame-src https://challenges.cloudflare.com;

Full Example:

<meta http-equiv="Content-Security-Policy" 
      content="default-src 'self'; 
               script-src 'self' https://challenges.cloudflare.com; 
               frame-src https://challenges.cloudflare.com;">

Framework-Specific Setup

React

npm install @marsidev/react-turnstile
import Turnstile from '@marsidev/react-turnstile';

<Turnstile
  siteKey="YOUR_SITE_KEY"
  onSuccess={(token) => console.log(token)}
/>

Vue

npm install vue-turnstile
<template>
  <VueTurnstile site-key="YOUR_SITE_KEY" @success="onSuccess" />
</template>
<script setup>
import VueTurnstile from 'vue-turnstile';
</script>

Svelte

npm install svelte-turnstile
<script>
import Turnstile from 'svelte-turnstile';
</script>
<Turnstile siteKey="YOUR_SITE_KEY" on:turnstile-callback={handleToken} />

Next.js (App Router)

// app/components/TurnstileWidget.tsx
'use client';
import { useEffect, useRef } from 'react';

export default function TurnstileWidget({ sitekey, onSuccess }) {
  const ref = useRef<HTMLDivElement>(null);
  
  useEffect(() => {
    if (ref.current && window.turnstile) {
      const widgetId = window.turnstile.render(ref.current, {
        sitekey,
        callback: onSuccess
      });
      return () => window.turnstile.remove(widgetId);
    }
  }, [sitekey, onSuccess]);
  
  return <div ref={ref} />;
}

Cloudflare Pages Plugin

npm install @cloudflare/pages-plugin-turnstile
// functions/_middleware.ts
import turnstilePlugin from '@cloudflare/pages-plugin-turnstile';

export const onRequest = turnstilePlugin({
  secret: 'YOUR_SECRET_KEY',
  onError: () => new Response('CAPTCHA failed', { status: 403 })
});

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.