turnstile-spin1
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "turnstile-spin1":https://skillpi.com/zh/skills/deepskill-1dbf5ab494873184e90b2ce3e776b8a91d40118e4644db4197a5a3cfae7815f4。安装前核对上游来源和版本:https://skillhub.cn/skills/org-02qudk26/turnstile-spin1。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
skillhub.cn
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
用于需要 Cloudflare Turnstile(验证码、机器人防护、站点验证)的项目。
介绍来源: third_party · org-02qudk26 · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: turnstile-spin
description: Use when a project needs Cloudflare Turnstile, CAPTCHA, bot protection, siteverify integration, or protection for signup, login, contact, and other public forms.
displayName: Cloudflare Turnstile 人机验证
version: 1.0.0
slug: turnstile-spin
references:
- vanilla-html
- nextjs-app
- nextjs-pages
- astro
- sveltekit
- hugoTurnstile Spin skill
Turns the prompt "set up Turnstile" into a working end-to-end integration: a widget, a deployed managed siteverify Worker, frontend snippets at every chosen insertion point, and a real validation pass before reporting success.
You are the agent. Run the wizard below by invoking the scripts under scripts/ and branching on their JSON output. The scripts hold the deterministic logic (API calls, retry/error handling); your job is orchestration, codebase reading, confirmation, and the frontend edits.
Canonical instructions live at developers.cloudflare.com/turnstile/spin. If the docs page and this file disagree, trust the docs page.
When to load this skill
Load when the user's prompt mentions any of:
- "Turnstile", "CAPTCHA", "bot protection"
- "siteverify", "cf-turnstile-response"
- "protect this form", "stop bot signups", "spam signups"
- A specific signup, login, or contact form combined with "Cloudflare" or "bot"
Do not load for unrelated Cloudflare tasks (Workers, Pages, R2, etc.) unless Turnstile is also mentioned.
Conversation flow
The user pasted the prompt. You are in a multi-step dialog. Detect what you can, ask only when you have to, confirm before every irreversible step. Each numbered moment is one agent message. Items marked [wait for user] require a user response.
-
Brief acknowledge. One sentence: "I'll run Turnstile setup end to end. That's: check auth, scan the codebase, create the widget, deploy the Worker, wire the frontend, validate. Proceed?" [wait for user] Do NOT present a plan yet. Auth + scan come first.
-
Wrangler check.
npx wrangler --version. If missing, ask once: "Install wrangler withnpm install --save-dev wrangler(Node project) ornpm install -g wrangler(other)? Proceed?" [wait for user] If install is blocked entirely (corporate policy, blocked npm), fall back to driving Steps 4-5 viacurlagainstapi.cloudflare.com/client/v4/. -
Auth + scope probe (FIRST irreversible action). Run
scripts/auth-probe.sh. Branch onstatus:ok: continue to Step 4. The script already picked the account (single-account token, or one matching$CLOUDFLARE_ACCOUNT_ID).missing_token,missing_scope, ormissing_workers_scope: ask the user to create a token at https://dash.cloudflare.com/profile/api-tokens → Custom token → permissionsAccount.Turnstile:EditandAccount.Workers Scripts:Edit→ include the target account in Account Resources. Do NOT direct them towrangler login. Its OAuth scope doesn't includeAccount.Turnstile:EditorAccount.Workers Scripts:Edit. Offer three ways to hand the token over, cleanest first:- Export + relaunch (token never enters chat):
export CLOUDFLARE_API_TOKEN=<token>then restart the agent from that terminal. - Save to file (token in file with user-only perms, not in chat):
umask 077 && printf '%s' '<token>' > ~/.cf-turnstile-token, then read withTOKEN=$(cat ~/.cf-turnstile-token). - Paste in chat (fastest, but token lands in conversation log; user should rotate it after if the log is ever shared).
If the user picks option 3 (paste in chat), you can use the wait to run Steps 5, 6, 7 (Domain, Codebase scan, Insertion plan). Options 1 and 2 will restart your session, so do not pre-fetch state in those cases. When auth is established, re-run
auth-probe.sh, then continue to Step 8.
- Export + relaunch (token never enters chat):
multiple_accounts: the token covers more than one account and$CLOUDFLARE_ACCOUNT_IDis unset. Present the numberedaccountslist. [wait for user] Then exportCLOUDFLARE_ACCOUNT_ID=<chosen>and re-runauth-probe.sh.account_mismatch:$CLOUDFLARE_ACCOUNT_IDis set but isn't one of the token's accounts. Show theaccountslist and ask the user to eitherunset CLOUDFLARE_ACCOUNT_IDor set it to one of those IDs.
-
Account selection. If
auth-probe.shreturnedokafter amultiple_accountsround-trip, this is already done. Otherwise the script picked the single account silently and you continue to Step 5. -
Domain. Always include
localhostand127.0.0.1. For production, scanpackage.jsonhomepage,wrangler.toml,README.md,AGENTS.md, git remote. Confirm: "I'll register forlocalhost,127.0.0.1, and<domain>. OK?" [wait for user] If no production domain is found, ask. -
Codebase scan. Detect framework + insertion candidates silently.
-
Insertion plan. Show the candidate list with
[recommended]/[skip by default]markers; ask the user to confirm (numbers, "all", "recommended", or a list). [wait for user] If an existing CAPTCHA was detected, present a migration plan instead (see "Migrating from another CAPTCHA"). -
Widget creation. Run
scripts/widget-create.sh --account-id <id> --name <name> --domains <list> --mode managed. Report the sitekey. The secret stays in env; never write it to disk. -
Worker deploy. Run
scripts/worker-deploy.sh --name turnstile-siteverify-<project-slug>withWIDGET_SECRETexported. Report the Worker URL onstatus: ok. Onset_secret_failed, the Worker deployed butTURNSTILE_SECRET_KEYis not set on it; surface the error, then retry withecho "$WIDGET_SECRET" | npx wrangler secret put TURNSTILE_SECRET_KEY --name <returned worker_name>before running validation. -
Frontend edits. State the contract: "I'll add the widget + gate the existing submit handler on
success === true. The existing handler logic stays the same." Ask "yes" / "show". [wait for user] If "show", print unified diffs and ask again. Do NOT propose alternate behavior (mail delivery, custom backends). -
Validation. Run
scripts/validate.sh. Report each check as it passes. If any fails, surface the error and stop. [wait for user if anything fails] -
Persist skill. Ask: "Save the Spin skill to
.claude/skills/turnstile-spin/SKILL.mdso I can reuse it on follow-up tasks?" Default yes. [wait for user] Then runscripts/persist-skill.sh --path <agent-specific-path>. -
Final report. Print the structured summary: what was created, what was validated, what to do next.
Things you must NOT do
- Do not write the Turnstile secret to disk. Only pass it via stdin to
wrangler secret put(the worker-deploy.sh script handles this). - Do not skip validation.
- Do not overwrite files without showing a diff.
- Do not deploy a Worker to a different account than the widget was created in.
- Do not call siteverify from the browser. Always: browser → user's Worker → siteverify.
- Do not use
sudoor install global packages without asking.
Hard scope boundary: DO NOT ask the user about
Spin validates the Turnstile token via a managed Worker before the user's existing form handler runs. Everything else is out of scope:
- Email / SMS / notification delivery. Leave the existing submit handler alone (just gate it on
success === true). Don't propose Resend, Mailchannels, SMTP, mailto. - Custom Worker code. Deploy the stock Worker template bundled at
templates/worker/. Don't write a new Worker. Don't add features (rate limiting, custom routing, third-party integrations). - Database / payment / OAuth / form persistence. Out of scope.
- Frontend framework migration, refactoring, or styling. Edit only what's needed.
- reCAPTCHA v3 score thresholds. Turnstile returns
success: true/false. - Pre-clearance-only setups. If
clearance_level !== no_clearance, siteverify is optional and Spin doesn't apply. Redirect the user and exit.
Recovery flow: respect existing widget configuration
When the user has Cloudflare dashboard access, the in-dashboard Fix with Spin banner is the preferred recovery path; it deploys the managed siteverify Worker server-side without requiring wrangler or an API token. This skill's recovery flow below is the fallback: use it when the user is driving from their editor without leaving it, or when the dashboard recovery does not apply (FedRAMP, gate-restricted account, etc.).
If the user tells you they already have a Turnstile widget set up and want to wire siteverify to it without rotating the sitekey (e.g. "I have a sitekey but siteverify never worked", "set up Spin against my existing widget <sitekey>"):
- Skip Step 8 (widget creation). The sitekey already exists; get it from the user.
- Fetch the widget metadata via
scripts/fetch-secret.sh --account-id <id> --sitekey <key>. Branch onstatus:ok: readsecret,clearance_level, anddomainsfrom the response. Confirmdomainsincludes the user's production hostname; if not, surface the gap before proceeding.missing_read_scope: tell the user to addAccount.Turnstile:Readto the token, or fall back to asking them to paste the secret. In the paste path, you do not haveclearance_levelordomains; ask the user to confirm both.
- Check
clearance_levelfrom the response (or the user's answer):no_clearance: standard recovery (deploy Worker, wire siteverify).- anything else: ask whether they want siteverify on top of pre-clearance, or exit per the scope boundary.
- Continue from Step 9 (Worker deploy). Site key does not change. Dashboard's
Deploymentcolumn flips fromManualtoSpinon the first request carryingdata-action="turnstile-spin-v1"(this skill) ordata-action="turnstile-spin-v2"(dashboard "Set up with Spin" button).
If the user is recovering a widget that was created via the dashboard "Set up with Spin" button, a managed Worker is likely already deployed in the account. Confirm with the user whether they want a fresh Worker (proceed) or just need help wiring the frontend to the existing one (skip to Step 10 and ask for the existing Worker URL). 5. Never recreate the widget to get a fresh secret. That breaks the existing sitekey everywhere it's deployed.
The frontend-edit contract
When wiring an existing form to the Worker (Step 10), the contract is: gate, don't replace. The user's existing submit handler keeps doing what it did. Spin only adds a validation step before it.
form.addEventListener("submit", async (e) => {
e.preventDefault();
const token = /* read cf-turnstile-response */;
const result = await fetch(WORKER_URL, { method: 'POST', body: JSON.stringify({ token }) });
const data = await result.json();
if (!data.success) return; // show failure
// existing handler logic runs here, unchanged
});
If the existing handler was a stub, Spin leaves it a stub gated on success. The user can replace the stub later; that's not Spin's job.
Migrating from another CAPTCHA
During the Step 6 codebase scan, also look for existing reCAPTCHA or hCaptcha. If found, switch Step 7 to a migration plan.
Detection signals:
- reCAPTCHA:
https://www.google.com/recaptcha/api.js,class="g-recaptcha",data-sitekey="6L...", backend POST to/recaptcha/api/siteverify - hCaptcha:
https://js.hcaptcha.com/1/api.js,class="h-captcha", backend POST tohttps://hcaptcha.com/siteverify
Substitution:
- Replace script tags with
https://challenges.cloudflare.com/turnstile/v0/api.js(async defer). - Replace
class="g-recaptcha"/class="h-captcha"divs withclass="cf-turnstile", updatedata-sitekeyto the new Turnstile sitekey, adddata-action="turnstile-spin-v1". - Token field changes from
g-recaptcha-responsetocf-turnstile-response. - Backend siteverify URL points at the Spin-deployed Worker. Drop
RECAPTCHA_SECRET/HCAPTCHA_SECRETenv vars.
Edge cases to surface to the user:
- reCAPTCHA v3 score thresholds. Turnstile has no score. Tell the user explicitly that migrated code will reject on
success === false. - reCAPTCHA Enterprise. Don't auto-migrate. Point at developers.cloudflare.com/turnstile/migration/recaptcha/.
- Custom
action=values. Preserve any custom action the user passed togrecaptcha.executeasdata-actionon the widget. Useturnstile-spin-v1only when no custom action exists.
Edge cases
| Situation | Action |
|---|---|
wrangler not installed |
Install path: npm install --save-dev wrangler (Node project) or npm install -g wrangler (other) |
| Multiple Cloudflare accounts | scripts/auth-probe.sh returns all accounts; ask the user to choose, export CLOUDFLARE_ACCOUNT_ID |
| Cloudflare Pages project | Deploy the managed Worker anyway, OR suggest the Pages Plugin |
EXPECTED_HOSTNAME mismatch |
Update widget domains via PUT, not PATCH (PATCH returns 10405 Method not allowed): curl -X PUT .../widgets/$SITEKEY -d '{"name":"...","mode":"managed","domains":[...]}' |
| Worker name conflict | worker-deploy.sh retries automatically with a hash suffix |
| Token expired mid-flow | Stop, re-run scripts/auth-probe.sh, prompt for fresh credentials |
Step 11 returns missing-input-secret |
Secret didn't propagate. Re-set: echo "$WIDGET_SECRET" \| npx wrangler secret put TURNSTILE_SECRET_KEY --name <worker_name from worker-deploy.sh output>, wait 10s, re-validate. Use the worker_name field returned by worker-deploy.sh; do not rely on a $WORKER_NAME env var. |
worker-deploy.sh returns set_secret_failed |
Worker is deployed but secret is not set. Re-run only the secret-put using the returned worker_name: echo "$WIDGET_SECRET" \| npx wrangler secret put TURNSTILE_SECRET_KEY --name <worker_name>. Surface the detail field to the user — it carries the wrangler error. |
Telemetry marker
Every snippet this skill writes must include data-action="turnstile-spin-v1". Widgets created via the dashboard "Set up with Spin" button use data-action="turnstile-spin-v2" instead; preserve that marker if you encounter it on an existing widget you are modifying. Both feed the same account-level aggregate telemetry, never per-user. Cloudflare uses it to measure activation. If the user removes the attribute, the integration still works; only the analytics segmentation is lost.
Do not
- Do not write the secret to disk.
- Do not skip validation (Step 11).
- Do not propose features outside the wizard (custom Worker code, custom domains, advanced WAF rules) unless asked.
- Do not call siteverify from the browser.
- Do not deploy the Worker into a different account than the widget.
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供端到端 Cloudflare Turnstile 人机验证集成,解决 bot 防护、表单安全等核心痛点
- 适用于 signup/login/contact 表单保护,具有高频刚需特性
待提升项
-
description写错位置 原报告严重程度:轻微
description 在顶层 frontmatter 和 skill_body 内部重复出现
改进建议:建议将 description 统一放在顶层 frontmatter,skill_body 内部可省略或改为简要说明
亮点
- 触发词精准完整,覆盖 Turnstile、CAPTCHA、bot protection、siteverify 等多种变体
待提升项
-
缺少When to Use独立章节 原报告严重程度:轻微
文档未设置独立的 When to Use 章节,但 Conversation flow 已覆盖相关内容
改进建议:建议将 When to load this skill 内容提取为独立 When to Use 章节以提升可读性
亮点
- Phase/步骤清晰(13步Conversation flow),有出口条件,含端到端示例
- frontmatter完整,单文件结构良好
待提升项
-
文档过长 原报告严重程度:轻微
文档内容详尽但篇幅较长,可能影响快速查阅
改进建议:建议增加目录导航或折叠章节以提升浏览体验
亮点
- 工具来源明确(wrangler、curl),参数正确
- 覆盖主要异常处理(auth失败、Worker部署失败、secret设置失败等)
- 不可逆操作均有确认机制
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 40, 62, 150, 156, 157 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 44, 87, 155 行 -
管理员或提升权限
确认确有必要再提升权限;不要关闭防护、绕过证书验证或扩大整个系统的访问权限。
主文档提及 · 第 79 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- challenges.cloudflare.com
- dash.cloudflare.com
- developers.cloudflare.com
- hcaptcha.com
- js.hcaptcha.com
- www.google.com
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。