cloudflare
Cloudflare Services Skill
Comprehensive management of Cloudflare services including DNS, Tunnels, Zero Trust, WAF, Workers, and Pages.
Triggers
Use this skill when you see:
- cloudflare, cf, cloudflare tunnel
- argo tunnel, cloudflared, zero trust
- cloudflare workers, cloudflare pages
- waf, ddos protection, cdn
- dns management, cloudflare dns
Instructions
Cloudflare Tunnel Setup
Install cloudflared
# Linux
curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared.deb
# macOS
brew install cloudflared
# Windows (winget)
winget install --id Cloudflare.cloudflared
Authenticate and Create Tunnel
# Login to Cloudflare
cloudflared tunnel login
# Create tunnel
cloudflared tunnel create my-tunnel
# List tunnels
cloudflared tunnel list
# Route DNS to tunnel
cloudflared tunnel route dns my-tunnel app.example.com
Tunnel Configuration
# ~/.cloudflared/config.yml
tunnel: <TUNNEL-ID>
credentials-file: /root/.cloudflared/<TUNNEL-ID>.json
ingress:
# Route to local web server
- hostname: app.example.com
service: http://localhost:3000
# Route to another service
- hostname: api.example.com
service: http://localhost:8080
# SSH access
- hostname: ssh.example.com
service: ssh://localhost:22
# Catch-all (required)
- service: http_status:404
Run Tunnel
# Run tunnel
cloudflared tunnel run my-tunnel
# Install as service
sudo cloudflared service install
# Run with specific config
cloudflared tunnel --config ~/.cloudflared/config.yml run
DNS Management
# Using Cloudflare API
# Set API token
export CF_API_TOKEN="your-api-token"
export CF_ZONE_ID="your-zone-id"
# List DNS records
curl -X GET "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/dns_records" \
-H "Authorization: Bearer ${CF_API_TOKEN}" \
-H "Content-Type: application/json"
# Create A record
curl -X POST "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/dns_records" \
-H "Authorization: Bearer ${CF_API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{
"type": "A",
"name": "app",
"content": "192.0.2.1",
"ttl": 1,
"proxied": true
}'
# Create CNAME record
curl -X POST "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/dns_records" \
-H "Authorization: Bearer ${CF_API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{
"type": "CNAME",
"name": "www",
"content": "example.com",
"ttl": 1,
"proxied": true
}'
Cloudflare Workers
Basic Worker
// worker.js
export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
// Handle different paths
if (url.pathname === '/api/hello') {
return new Response(JSON.stringify({ message: 'Hello World' }), {
headers: { 'Content-Type': 'application/json' },
});
}
// Proxy to origin
return fetch(request);
},
};
Worker with KV Storage
export default {
async fetch(request, env) {
const url = new URL(request.url);
const key = url.pathname.slice(1);
if (request.method === 'GET') {
const value = await env.MY_KV.get(key);
return new Response(value || 'Not found', {
status: value ? 200 : 404,
});
}
if (request.method === 'PUT') {
const value = await request.text();
await env.MY_KV.put(key, value);
return new Response('Saved', { status: 201 });
}
return new Response('Method not allowed', { status: 405 });
},
};
wrangler.toml
name = "my-worker"
main = "src/index.js"
compatibility_date = "2024-01-01"
[vars]
ENVIRONMENT = "production"
[[kv_namespaces]]
binding = "MY_KV"
id = "your-kv-namespace-id"
[triggers]
crons = ["0 * * * *"]
Deploy Worker
# Install Wrangler
npm install -g wrangler
# Login
wrangler login
# Deploy
wrangler deploy
# Tail logs
wrangler tail
Cloudflare Pages
# Deploy from CLI
wrangler pages deploy ./dist --project-name=my-project
# Create project
wrangler pages project create my-project
# List deployments
wrangler pages deployment list --project-name=my-project
Zero Trust Access
Application Access Policy
# Create access application
curl -X POST "https://api.cloudflare.com/client/v4/accounts/${CF_ACCOUNT_ID}/access/apps" \
-H "Authorization: Bearer ${CF_API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{
"name": "Internal App",
"domain": "app.example.com",
"type": "self_hosted",
"session_duration": "24h"
}'
WAF Rules
# Create firewall rule
curl -X POST "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/firewall/rules" \
-H "Authorization: Bearer ${CF_API_TOKEN}" \
-H "Content-Type: application/json" \
--data '[{
"filter": {
"expression": "(ip.src ne 192.0.2.1)",
"paused": false
},
"action": "block",
"description": "Block all except allowed IP"
}]'
Page Rules
# Create page rule for caching
curl -X POST "https://api.cloudflare.com/client/v4/zones/${CF_ZONE_ID}/pagerules" \
-H "Authorization: Bearer ${CF_API_TOKEN}" \
-H "Content-Type: application/json" \
--data '{
"targets": [{
"target": "url",
"constraint": {
"operator": "matches",
"value": "*example.com/static/*"
}
}],
"actions": [{
"id": "cache_level",
"value": "cache_everything"
}],
"priority": 1,
"status": "active"
}'
Best Practices
- Tunnels: Use tunnels instead of exposing ports directly
- DNS: Enable proxied (orange cloud) for DDoS protection
- Workers: Use Workers for edge logic and caching
- Security: Enable Zero Trust for internal applications
- SSL: Use Full (Strict) SSL mode
Common Workflows
Expose Local Service
- Install cloudflared
- Create tunnel:
cloudflared tunnel create my-tunnel - Configure ingress in config.yml
- Route DNS:
cloudflared tunnel route dns my-tunnel app.example.com - Run tunnel:
cloudflared tunnel run my-tunnel
Deploy Static Site
- Build static site
- Deploy with Wrangler:
wrangler pages deploy ./dist - Configure custom domain in dashboard
- Enable HTTPS
More from housegarofalo/claude-code-base
mqtt-iot
Configure MQTT brokers (Mosquitto, EMQX) for IoT messaging, device communication, and smart home integration. Manage topics, QoS levels, authentication, and bridging. Use when setting up IoT messaging, smart home communication, or device-to-cloud connectivity. (project)
22devops-engineer-agent
Infrastructure and DevOps specialist. Manages Docker, Kubernetes, CI/CD pipelines, and cloud deployments. Expert in GitHub Actions, Azure DevOps, Terraform, and container orchestration. Use for deployment automation, infrastructure setup, or CI/CD optimization.
6home-assistant
Ultimate Home Assistant skill - complete administration, wireless protocols (Zigbee/ZHA/Z2M, Z-Wave JS, Thread, Matter), ESPHome device building, advanced troubleshooting, performance optimization, security hardening, custom integration development, and professional dashboard design. Covers configuration, REST API, automation debugging, database optimization, SSL/TLS, Jinja2 templating, and HACS custom cards. Use for any HA task.
6react-typescript
Build modern React applications with TypeScript. Covers React 18+ patterns, hooks, component architecture, state management (Zustand, Redux Toolkit), server components, and best practices. Use for React development, TypeScript integration, component design, and frontend architecture.
5power-automate
Expert guidance for Power Automate development including cloud flows, desktop flows, Dataverse connector, expression functions, custom connectors, error handling, and child flow patterns. Use when building automated workflows, writing flow expressions, creating custom connectors from OpenAPI, or implementing error handling patterns.
5matter-thread
>
5