fcakyon/claude-codex-settings / plugins/cloudflare-skills/skills/turnstile-spin
turnstile-spin
VerifiedSet up, repair, or migrate to Cloudflare Turnstile bot verification in an existing frontend and backend, including server-side Siteverify.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 3.8 KB |
| SKILL.md | skill md | 28.2 KB |
| references/astro.md | markdown | 5.8 KB |
| references/hugo.md | markdown | 3.8 KB |
| references/nextjs-app.md | markdown | 7.5 KB |
| references/nextjs-pages.md | markdown | 2.7 KB |
| references/skill-feedback.md | markdown | 2.7 KB |
| references/sveltekit.md | markdown | 5.4 KB |
| references/vanilla-html.md | markdown | 5.6 KB |
| scripts/auth-probe.shexecutable | script | 11.0 KB |
| scripts/persist-skill.shexecutable | script | 3.6 KB |
| scripts/validate.shexecutable | script | 4.3 KB |
| scripts/widget-create.shexecutable | script | 4.1 KB |
| tests/test_persist_skill.py | script | 3.1 KB |
| tests/validation.md | markdown | 3.2 KB |
references/hugo.md
View on GitHub# Hugo
For Hugo static sites. The widget renders on any page that includes the partial; siteverify happens at whatever backend handles your form submissions (a Cloudflare Pages Function, a Worker, an external API, or a form host with a server-side hook).
```html title="layouts/partials/turnstile.html"
<script
src="https://challenges.cloudflare.com/turnstile/v0/api.js"
async
defer
></script>
<form action="{{ .Site.Params.turnstileFormEndpoint }}" method="POST">
<input name="email" type="email" required />
<div
class="cf-turnstile"
data-sitekey="{{ .Site.Params.turnstileSitekey }}"
data-action="subscribe"
></div>
<button type="submit">Subscribe</button>
</form>
```
Add the params to your site config:
```toml title="hugo.toml"
[params]
turnstileSitekey = "YOUR_SITEKEY"
turnstileFormEndpoint = "/api/subscribe" # path to your existing form handler
```
Reference the partial from any layout or content file:
```text
{{ partial "turnstile.html" . }}
```
## Backend (where siteverify lives)
Hugo doesn't host server-side code, so the form endpoint must live elsewhere. Two common setups:
**Cloudflare Pages Function** (`functions/api/subscribe.js`):
```js
export async function onRequestPost({ request, env }) {
const form = await request.formData();
const token = form.get("cf-turnstile-response");
const expectedHostnames = new Set(
(env.TURNSTILE_HOSTNAMES ?? "")
.split(",")
.map((h) => h.trim())
.filter(Boolean),
);
if (expectedHostnames.size === 0) {
return new Response("forbidden", { status: 403 });
}
const r = await fetch("https://challenges.cloudflare.com/turnstile/v0/siteverify", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
secret: env.TURNSTILE_SECRET,
response: token,
remoteip: request.headers.get("CF-Connecting-IP"),
}),
});
const result = await r.json();
if (
r.ok !== true ||
result.success !== true ||
result.action !== "subscribe" ||
!expectedHostnames.has(result.hostname)
) {
return new Response("forbidden", { status: 403 });
}
// process subscribe
return new Response("ok");
}
```
`subscribe` is the stable action for this surface. Preserve an existing custom migration action and compare the returned action to the same value. Siteverify is mandatory for every widget mode, including pre-clearance. Set `TURNSTILE_HOSTNAMES` to the deployment-specific frontend hostnames; a production value must not include `localhost` or `127.0.0.1`.
After the user approves a canonical absolute `WRANGLER_BIN` outside the project, set the secret with `(set +x; printf '%s' "$WIDGET_SECRET" | "$WRANGLER_BIN" pages secret put TURNSTILE_SECRET)` (or use the dashboard's Pages → your project → Settings → Environment variables → Add secret).
**External backend**: any Node/Ruby/Python/Go handler can do the same call. See the [vanilla-html reference](./vanilla-html.md) for non-Cloudflare-specific snippets.
## Variant: shortcode for content files
If you want to drop the widget into Markdown content (not just layouts), create a shortcode:
```html title="layouts/shortcodes/turnstile-form.html"
{{ partial "turnstile.html" . }}
```
Use in content:
```markdown title="content/contact.md"
---
title: Contact
---
Contact us:
{{< turnstile-form >}}
```
## Substitutions
| Placeholder | Replace with |
| ------------------------ | -------------------------------------------------------------------- |
| `YOUR_SITEKEY` | The widget site key from Step 8 |
| `turnstileFormEndpoint` | The path or URL to your form handler (Pages Function, Worker, etc.) |
| `TURNSTILE_SECRET` | Env-var name in your backend. Value is the secret captured in Step 8.|
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |