Skip to content

secondsky/claude-skills / plugins/cloudflare-turnstile/skills/cloudflare-turnstile

cloudflare-turnstile

Verified

This skill should be used when the user asks to "add turnstile", "implement bot protection", "validate turnstile token", "fix turnstile error", "setup captcha alternative", or encounters error codes 100*/300*/600*, CSP errors, or token validation failures. Provides CAPTCHA-alternative protection for Cloudflare Workers, React, Next.js, and Hono.

scripts/check-csp.sh

View on GitHub
#!/bin/bash
#
# Turnstile CSP Checker
#
# Verifies that Content Security Policy headers allow Turnstile to function
#
# Usage:
#   ./check-csp.sh https://example.com
#   ./check-csp.sh https://example.com/contact
#

set -e

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

# Check if URL is provided
if [ -z "$1" ]; then
  echo -e "${RED}Error: Please provide a URL${NC}"
  echo "Usage: $0 <url>"
  echo "Example: $0 https://example.com"
  exit 1
fi

URL="$1"

echo -e "${GREEN}Checking CSP for Turnstile compatibility...${NC}"
echo "URL: $URL"
echo ""

# Fetch headers
HEADERS=$(curl -sI "$URL")

# Extract CSP header
CSP=$(echo "$HEADERS" | grep -i "content-security-policy:" | sed 's/content-security-policy: //I')

if [ -z "$CSP" ]; then
  echo -e "${YELLOW}No Content-Security-Policy header found${NC}"
  echo "✅ Turnstile should work (no CSP restrictions)"
  exit 0
fi

echo "CSP Header found:"
echo "$CSP"
echo ""

# Initialize pass/fail counters
PASS=0
FAIL=0

# Check script-src
echo -e "${GREEN}Checking script-src...${NC}"
if echo "$CSP" | grep -q "script-src"; then
  if echo "$CSP" | grep -E "script-src[^;]*https://challenges.cloudflare.com" > /dev/null; then
    echo "✅ script-src allows https://challenges.cloudflare.com"
    ((PASS++))
  elif echo "$CSP" | grep -E "script-src[^;]*\*" > /dev/null; then
    echo "✅ script-src allows * (wildcard)"
    ((PASS++))
  else
    echo -e "${RED}❌ script-src does NOT allow https://challenges.cloudflare.com${NC}"
    echo "   Add: script-src https://challenges.cloudflare.com;"
    ((FAIL++))
  fi
else
  echo "⚠️  No script-src directive found (defaults may apply)"
fi
echo ""

# Check frame-src
echo -e "${GREEN}Checking frame-src...${NC}"
if echo "$CSP" | grep -q "frame-src"; then
  if echo "$CSP" | grep -E "frame-src[^;]*https://challenges.cloudflare.com" > /dev/null; then
    echo "✅ frame-src allows https://challenges.cloudflare.com"
    ((PASS++))
  elif echo "$CSP" | grep -E "frame-src[^;]*\*" > /dev/null; then
    echo "✅ frame-src allows * (wildcard)"
    ((PASS++))
  else
    echo -e "${RED}❌ frame-src does NOT allow https://challenges.cloudflare.com${NC}"
    echo "   Add: frame-src https://challenges.cloudflare.com;"
    ((FAIL++))
  fi
else
  echo "⚠️  No frame-src directive found (defaults may apply)"
fi
echo ""

# Check connect-src
echo -e "${GREEN}Checking connect-src...${NC}"
if echo "$CSP" | grep -q "connect-src"; then
  if echo "$CSP" | grep -E "connect-src[^;]*https://challenges.cloudflare.com" > /dev/null; then
    echo "✅ connect-src allows https://challenges.cloudflare.com"
    ((PASS++))
  elif echo "$CSP" | grep -E "connect-src[^;]*\*" > /dev/null; then
    echo "✅ connect-src allows * (wildcard)"
    ((PASS++))
  else
    echo -e "${RED}❌ connect-src does NOT allow https://challenges.cloudflare.com${NC}"
    echo "   Add: connect-src https://challenges.cloudflare.com;"
    ((FAIL++))
  fi
else
  echo "⚠️  No connect-src directive found (defaults may apply)"
fi
echo ""

# Final verdict
echo "========================================"
if [ $FAIL -eq 0 ]; then
  echo -e "${GREEN}✅ CSP is compatible with Turnstile!${NC}"
  exit 0
else
  echo -e "${RED}❌ CSP may block Turnstile${NC}"
  echo ""
  echo "Recommended CSP directives:"
  echo ""
  echo "<meta http-equiv=\"Content-Security-Policy\" content=\""
  echo "  script-src 'self' https://challenges.cloudflare.com;"
  echo "  frame-src 'self' https://challenges.cloudflare.com;"
  echo "  connect-src 'self' https://challenges.cloudflare.com;"
  echo "\">"
  echo ""
  echo "Or in HTTP header:"
  echo ""
  echo "Content-Security-Policy: script-src 'self' https://challenges.cloudflare.com; frame-src 'self' https://challenges.cloudflare.com; connect-src 'self' https://challenges.cloudflare.com"
  echo ""
  exit 1
fi
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall