opencode-skills-collection 4.0.68 → 4.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled-skills/.antigravity-install-manifest.json +266 -1
- package/bundled-skills/access-review/SKILL.md +394 -0
- package/bundled-skills/access-review/references/details.md +121 -0
- package/bundled-skills/agent-evals/SKILL.md +420 -0
- package/bundled-skills/agent-observability/SKILL.md +346 -0
- package/bundled-skills/agent-observability/references/details.md +786 -0
- package/bundled-skills/ai-agent-security/SKILL.md +393 -0
- package/bundled-skills/ai-agent-security/references/details.md +912 -0
- package/bundled-skills/ai-coding-agent-guardrails/SKILL.md +442 -0
- package/bundled-skills/ai-coding-agent-guardrails/references/details.md +753 -0
- package/bundled-skills/ai-inference-service-mesh/SKILL.md +449 -0
- package/bundled-skills/ai-pipeline-orchestration/SKILL.md +287 -0
- package/bundled-skills/ai-red-teaming/SKILL.md +409 -0
- package/bundled-skills/ai-security-hardening/SKILL.md +343 -0
- package/bundled-skills/ai-sre-incident-response/SKILL.md +336 -0
- package/bundled-skills/alerting-oncall/SKILL.md +458 -0
- package/bundled-skills/alerting-oncall/references/details.md +84 -0
- package/bundled-skills/apk-redteam-pipeline/SKILL.md +446 -0
- package/bundled-skills/argocd-gitops/SKILL.md +469 -0
- package/bundled-skills/arm-templates/SKILL.md +438 -0
- package/bundled-skills/arm-templates/references/details.md +64 -0
- package/bundled-skills/asset-inventory/SKILL.md +412 -0
- package/bundled-skills/asset-inventory/references/details.md +127 -0
- package/bundled-skills/audit-logging/SKILL.md +476 -0
- package/bundled-skills/aws-cloudtrail/SKILL.md +486 -0
- package/bundled-skills/aws-cost-optimization/SKILL.md +331 -0
- package/bundled-skills/aws-ec2/SKILL.md +426 -0
- package/bundled-skills/aws-ecs-fargate/SKILL.md +388 -0
- package/bundled-skills/aws-iam/SKILL.md +463 -0
- package/bundled-skills/aws-lambda/SKILL.md +428 -0
- package/bundled-skills/aws-rds/SKILL.md +380 -0
- package/bundled-skills/aws-s3/SKILL.md +434 -0
- package/bundled-skills/aws-secrets-manager/SKILL.md +486 -0
- package/bundled-skills/aws-vpc/SKILL.md +436 -0
- package/bundled-skills/azure-ai-document-intelligence-ts/SKILL.md +1 -1
- package/bundled-skills/azure-aks/SKILL.md +423 -0
- package/bundled-skills/azure-devops/SKILL.md +457 -0
- package/bundled-skills/azure-functions-devsec/SKILL.md +436 -0
- package/bundled-skills/azure-keyvault/SKILL.md +455 -0
- package/bundled-skills/azure-keyvault/references/details.md +83 -0
- package/bundled-skills/azure-monitor-audit/SKILL.md +379 -0
- package/bundled-skills/azure-networking/SKILL.md +448 -0
- package/bundled-skills/azure-networking/references/details.md +135 -0
- package/bundled-skills/azure-sql/SKILL.md +413 -0
- package/bundled-skills/azure-sql/references/details.md +113 -0
- package/bundled-skills/azure-vms/SKILL.md +402 -0
- package/bundled-skills/azure-vms/references/details.md +134 -0
- package/bundled-skills/backup-recovery/SKILL.md +388 -0
- package/bundled-skills/bb-methodology/SKILL.md +451 -0
- package/bundled-skills/bb-methodology/references/details.md +120 -0
- package/bundled-skills/block-storage/SKILL.md +371 -0
- package/bundled-skills/blue-green-deploy/SKILL.md +453 -0
- package/bundled-skills/blue-green-deploy/references/details.md +90 -0
- package/bundled-skills/bug-bounty/SKILL.md +447 -0
- package/bundled-skills/bug-bounty/references/details.md +1316 -0
- package/bundled-skills/bugcrowd-reporting/SKILL.md +351 -0
- package/bundled-skills/business-continuity/SKILL.md +463 -0
- package/bundled-skills/career-ops/SKILL.md +186 -0
- package/bundled-skills/cdn-setup/SKILL.md +374 -0
- package/bundled-skills/change-management/SKILL.md +438 -0
- package/bundled-skills/change-management/references/details.md +105 -0
- package/bundled-skills/circleci/SKILL.md +475 -0
- package/bundled-skills/cis-benchmarks/SKILL.md +150 -0
- package/bundled-skills/cloudflare-pages/SKILL.md +318 -0
- package/bundled-skills/cloudflare-r2/SKILL.md +353 -0
- package/bundled-skills/cloudflare-workers/SKILL.md +415 -0
- package/bundled-skills/cloudflare-zero-trust/SKILL.md +361 -0
- package/bundled-skills/cloudformation/SKILL.md +461 -0
- package/bundled-skills/constraint-driven-development/SKILL.md +335 -0
- package/bundled-skills/constraint-driven-development/references/floor-guard.md +99 -0
- package/bundled-skills/container-hardening/SKILL.md +126 -0
- package/bundled-skills/container-registries/SKILL.md +435 -0
- package/bundled-skills/container-scanning/SKILL.md +416 -0
- package/bundled-skills/convex-backend/SKILL.md +338 -0
- package/bundled-skills/dast-scanning/SKILL.md +437 -0
- package/bundled-skills/database-backups/SKILL.md +425 -0
- package/bundled-skills/datadog/SKILL.md +487 -0
- package/bundled-skills/dependency-scanning/SKILL.md +457 -0
- package/bundled-skills/devcontainers-nix/SKILL.md +416 -0
- package/bundled-skills/disaster-recovery/SKILL.md +374 -0
- package/bundled-skills/disaster-recovery/references/details.md +219 -0
- package/bundled-skills/dns-management/SKILL.md +375 -0
- package/bundled-skills/docker-compose/SKILL.md +482 -0
- package/bundled-skills/docker-management/SKILL.md +426 -0
- package/bundled-skills/ebpf-observability/SKILL.md +436 -0
- package/bundled-skills/ebpf-observability/references/details.md +542 -0
- package/bundled-skills/elk-stack/SKILL.md +487 -0
- package/bundled-skills/enterprise-vpn-attack/SKILL.md +395 -0
- package/bundled-skills/evidence-hygiene/SKILL.md +404 -0
- package/bundled-skills/feature-flags/SKILL.md +426 -0
- package/bundled-skills/feature-flags/references/details.md +86 -0
- package/bundled-skills/fedramp-compliance/SKILL.md +453 -0
- package/bundled-skills/firebase-app-platform/SKILL.md +381 -0
- package/bundled-skills/firewall-config/SKILL.md +479 -0
- package/bundled-skills/gcp-audit-logs/SKILL.md +452 -0
- package/bundled-skills/gcp-audit-logs/references/details.md +56 -0
- package/bundled-skills/gcp-cloud-functions/SKILL.md +284 -0
- package/bundled-skills/gcp-cloud-sql/SKILL.md +277 -0
- package/bundled-skills/gcp-compute/SKILL.md +319 -0
- package/bundled-skills/gcp-gke/SKILL.md +307 -0
- package/bundled-skills/gcp-networking/SKILL.md +293 -0
- package/bundled-skills/gcp-secret-manager/SKILL.md +421 -0
- package/bundled-skills/gcp-secret-manager/references/details.md +131 -0
- package/bundled-skills/gdpr-compliance/SKILL.md +451 -0
- package/bundled-skills/gdpr-compliance/references/details.md +145 -0
- package/bundled-skills/geo-audit/SKILL.md +368 -0
- package/bundled-skills/geo-brand-mentions/SKILL.md +68 -0
- package/bundled-skills/geo-brand-mentions/references/details.md +471 -0
- package/bundled-skills/geo-citability/SKILL.md +350 -0
- package/bundled-skills/geo-compare/SKILL.md +340 -0
- package/bundled-skills/geo-content/SKILL.md +383 -0
- package/bundled-skills/geo-crawlers/SKILL.md +408 -0
- package/bundled-skills/geo-llmstxt/SKILL.md +464 -0
- package/bundled-skills/geo-platform-optimizer/SKILL.md +314 -0
- package/bundled-skills/geo-proposal/SKILL.md +378 -0
- package/bundled-skills/geo-prospect/SKILL.md +225 -0
- package/bundled-skills/geo-report/SKILL.md +436 -0
- package/bundled-skills/geo-report-pdf/SKILL.md +157 -0
- package/bundled-skills/geo-schema/SKILL.md +408 -0
- package/bundled-skills/geo-technical/SKILL.md +78 -0
- package/bundled-skills/geo-technical/references/details.md +543 -0
- package/bundled-skills/git-workflow/SKILL.md +460 -0
- package/bundled-skills/github-actions/SKILL.md +368 -0
- package/bundled-skills/gitlab-ci/SKILL.md +340 -0
- package/bundled-skills/gpu-kubernetes-operations/SKILL.md +468 -0
- package/bundled-skills/gpu-server-management/SKILL.md +236 -0
- package/bundled-skills/hashicorp-vault/SKILL.md +408 -0
- package/bundled-skills/helm-charts/SKILL.md +469 -0
- package/bundled-skills/hipaa-compliance/SKILL.md +451 -0
- package/bundled-skills/hunt-aspnet/SKILL.md +321 -0
- package/bundled-skills/hunt-ato/SKILL.md +184 -0
- package/bundled-skills/hunt-auth-bypass/SKILL.md +426 -0
- package/bundled-skills/hunt-auth-bypass/references/details.md +80 -0
- package/bundled-skills/hunt-brute-force/SKILL.md +341 -0
- package/bundled-skills/hunt-business-logic/SKILL.md +281 -0
- package/bundled-skills/hunt-cache-poison/SKILL.md +382 -0
- package/bundled-skills/hunt-captcha-bypass/SKILL.md +136 -0
- package/bundled-skills/hunt-cicd/SKILL.md +311 -0
- package/bundled-skills/hunt-clickjacking/SKILL.md +110 -0
- package/bundled-skills/hunt-cors/SKILL.md +335 -0
- package/bundled-skills/hunt-dom/SKILL.md +323 -0
- package/bundled-skills/hunt-exceptional-conditions/SKILL.md +111 -0
- package/bundled-skills/hunt-file-upload/SKILL.md +202 -0
- package/bundled-skills/hunt-fintech-graphql/SKILL.md +289 -0
- package/bundled-skills/hunt-forgot-password/SKILL.md +114 -0
- package/bundled-skills/hunt-grpc/SKILL.md +317 -0
- package/bundled-skills/hunt-host-header/SKILL.md +309 -0
- package/bundled-skills/hunt-html-injection/SKILL.md +106 -0
- package/bundled-skills/hunt-http-smuggling/SKILL.md +129 -0
- package/bundled-skills/hunt-http-smuggling/references/phase2h-smuggling-cachepoison.md +177 -0
- package/bundled-skills/hunt-idor/SKILL.md +434 -0
- package/bundled-skills/hunt-jwt-crypto/SKILL.md +221 -0
- package/bundled-skills/hunt-k8s/SKILL.md +337 -0
- package/bundled-skills/hunt-laravel/SKILL.md +255 -0
- package/bundled-skills/hunt-ldap/SKILL.md +351 -0
- package/bundled-skills/hunt-lfi/SKILL.md +311 -0
- package/bundled-skills/hunt-llm-ai/SKILL.md +289 -0
- package/bundled-skills/hunt-mfa-bypass/SKILL.md +177 -0
- package/bundled-skills/hunt-misc/SKILL.md +378 -0
- package/bundled-skills/hunt-nextjs/SKILL.md +299 -0
- package/bundled-skills/hunt-nodejs/SKILL.md +263 -0
- package/bundled-skills/hunt-nosqli/SKILL.md +210 -0
- package/bundled-skills/hunt-ntlm-info/SKILL.md +314 -0
- package/bundled-skills/hunt-oauth/SKILL.md +459 -0
- package/bundled-skills/hunt-open-redirect/SKILL.md +223 -0
- package/bundled-skills/hunt-race-condition/SKILL.md +381 -0
- package/bundled-skills/hunt-race-condition/references/details.md +159 -0
- package/bundled-skills/hunt-rag-vector/SKILL.md +212 -0
- package/bundled-skills/hunt-rce/SKILL.md +444 -0
- package/bundled-skills/hunt-rce/references/details.md +110 -0
- package/bundled-skills/hunt-saml/SKILL.md +156 -0
- package/bundled-skills/hunt-session/SKILL.md +342 -0
- package/bundled-skills/hunt-shadow-api/SKILL.md +198 -0
- package/bundled-skills/hunt-source-leak/SKILL.md +345 -0
- package/bundled-skills/hunt-spa-api/SKILL.md +163 -0
- package/bundled-skills/hunt-springboot/SKILL.md +285 -0
- package/bundled-skills/hunt-sqli/SKILL.md +466 -0
- package/bundled-skills/hunt-ssrf/SKILL.md +396 -0
- package/bundled-skills/hunt-ssrf/references/details.md +179 -0
- package/bundled-skills/hunt-ssti/SKILL.md +163 -0
- package/bundled-skills/hunt-subdomain/SKILL.md +379 -0
- package/bundled-skills/hunt-tls-network/SKILL.md +399 -0
- package/bundled-skills/hunt-xxe/SKILL.md +466 -0
- package/bundled-skills/i-have-adhd/SKILL.md +170 -0
- package/bundled-skills/identity-access-management/SKILL.md +382 -0
- package/bundled-skills/identity-access-management/references/details.md +524 -0
- package/bundled-skills/incident-management/SKILL.md +484 -0
- package/bundled-skills/incident-response/SKILL.md +448 -0
- package/bundled-skills/incident-response/references/details.md +113 -0
- package/bundled-skills/interview-me/SKILL.md +248 -0
- package/bundled-skills/iso27001-compliance/SKILL.md +460 -0
- package/bundled-skills/jenkins/SKILL.md +462 -0
- package/bundled-skills/jev-use/SKILL.md +158 -0
- package/bundled-skills/kubernetes-hardening/SKILL.md +154 -0
- package/bundled-skills/kubernetes-ops/SKILL.md +449 -0
- package/bundled-skills/kubernetes-ops/references/details.md +108 -0
- package/bundled-skills/kustomize/SKILL.md +478 -0
- package/bundled-skills/linux-administration/SKILL.md +367 -0
- package/bundled-skills/linux-hardening/SKILL.md +154 -0
- package/bundled-skills/llm-app-security/SKILL.md +389 -0
- package/bundled-skills/llm-app-security/references/details.md +674 -0
- package/bundled-skills/llm-caching/SKILL.md +334 -0
- package/bundled-skills/llm-cost-optimization/SKILL.md +311 -0
- package/bundled-skills/llm-fine-tuning/SKILL.md +329 -0
- package/bundled-skills/llm-gateway/SKILL.md +282 -0
- package/bundled-skills/llm-inference-scaling/SKILL.md +286 -0
- package/bundled-skills/llmops-platform-engineering/SKILL.md +472 -0
- package/bundled-skills/load-balancing/SKILL.md +403 -0
- package/bundled-skills/loki-logging/SKILL.md +479 -0
- package/bundled-skills/m365-entra-attack/SKILL.md +423 -0
- package/bundled-skills/mac-mini-llm-lab/SKILL.md +350 -0
- package/bundled-skills/mcp-server-security/SKILL.md +356 -0
- package/bundled-skills/mcp-server-security/references/details.md +745 -0
- package/bundled-skills/mdm-device-management/SKILL.md +404 -0
- package/bundled-skills/mdm-device-management/references/details.md +410 -0
- package/bundled-skills/meme-coin-audit/SKILL.md +402 -0
- package/bundled-skills/mid-engagement-ir-detection/SKILL.md +377 -0
- package/bundled-skills/model-registry-governance/SKILL.md +452 -0
- package/bundled-skills/model-serving-kubernetes/SKILL.md +339 -0
- package/bundled-skills/model-supply-chain-security/SKILL.md +427 -0
- package/bundled-skills/mongodb/SKILL.md +436 -0
- package/bundled-skills/multi-tenant-llm-hosting/SKILL.md +435 -0
- package/bundled-skills/multi-tenant-llm-hosting/references/details.md +211 -0
- package/bundled-skills/mysql/SKILL.md +390 -0
- package/bundled-skills/new-relic/SKILL.md +472 -0
- package/bundled-skills/nfs-storage/SKILL.md +356 -0
- package/bundled-skills/object-storage/SKILL.md +378 -0
- package/bundled-skills/offensive-osint/SKILL.md +443 -0
- package/bundled-skills/okta-attack/SKILL.md +436 -0
- package/bundled-skills/ollama-stack/SKILL.md +379 -0
- package/bundled-skills/openclaw-deployment-hardening/SKILL.md +135 -0
- package/bundled-skills/openclaw-local-mac-mini/SKILL.md +426 -0
- package/bundled-skills/openclaw-local-mac-mini/references/details.md +221 -0
- package/bundled-skills/openclaw-security-hardening/SKILL.md +135 -0
- package/bundled-skills/openshift/SKILL.md +485 -0
- package/bundled-skills/opentelemetry/SKILL.md +438 -0
- package/bundled-skills/opentelemetry/references/details.md +78 -0
- package/bundled-skills/opentofu-migration/SKILL.md +349 -0
- package/bundled-skills/osint-methodology/SKILL.md +460 -0
- package/bundled-skills/osint-methodology/references/details.md +1350 -0
- package/bundled-skills/pci-dss-compliance/SKILL.md +446 -0
- package/bundled-skills/penetration-testing/SKILL.md +152 -0
- package/bundled-skills/performance-tuning/SKILL.md +381 -0
- package/bundled-skills/planetscale/SKILL.md +297 -0
- package/bundled-skills/platform-engineering/SKILL.md +348 -0
- package/bundled-skills/platform-engineering/references/details.md +944 -0
- package/bundled-skills/podman/SKILL.md +405 -0
- package/bundled-skills/policy-as-code/SKILL.md +434 -0
- package/bundled-skills/policy-as-code/references/details.md +204 -0
- package/bundled-skills/postgresql-devsec/SKILL.md +378 -0
- package/bundled-skills/prometheus-grafana/SKILL.md +469 -0
- package/bundled-skills/prompt-injection-defense/SKILL.md +483 -0
- package/bundled-skills/rag-infrastructure/SKILL.md +269 -0
- package/bundled-skills/rag-observability-evals/SKILL.md +444 -0
- package/bundled-skills/rag-observability-evals/references/details.md +92 -0
- package/bundled-skills/recon-scope-triage/SKILL.md +128 -0
- package/bundled-skills/redis/SKILL.md +421 -0
- package/bundled-skills/redteam-report-template/SKILL.md +370 -0
- package/bundled-skills/report-writing/SKILL.md +426 -0
- package/bundled-skills/report-writing/references/details.md +187 -0
- package/bundled-skills/reverse-proxy/SKILL.md +420 -0
- package/bundled-skills/runbook-creation/SKILL.md +438 -0
- package/bundled-skills/runbook-creation/references/details.md +71 -0
- package/bundled-skills/saas-security-posture/SKILL.md +415 -0
- package/bundled-skills/sast-scanning/SKILL.md +444 -0
- package/bundled-skills/sbom-supply-chain/SKILL.md +433 -0
- package/bundled-skills/security-arsenal/SKILL.md +446 -0
- package/bundled-skills/security-arsenal/references/details.md +540 -0
- package/bundled-skills/security-automation/SKILL.md +146 -0
- package/bundled-skills/semantic-versioning/SKILL.md +434 -0
- package/bundled-skills/semantic-versioning/references/details.md +83 -0
- package/bundled-skills/service-mesh/SKILL.md +422 -0
- package/bundled-skills/soc2-compliance/SKILL.md +409 -0
- package/bundled-skills/sops-encryption/SKILL.md +124 -0
- package/bundled-skills/sre-dashboards/SKILL.md +143 -0
- package/bundled-skills/ssh-configuration/SKILL.md +324 -0
- package/bundled-skills/ssl-tls-management/SKILL.md +428 -0
- package/bundled-skills/ssl-tls-management/references/details.md +99 -0
- package/bundled-skills/startup-it-troubleshooting/SKILL.md +415 -0
- package/bundled-skills/supply-chain-attack-recon/SKILL.md +453 -0
- package/bundled-skills/supply-chain-attack-recon/references/details.md +258 -0
- package/bundled-skills/systemd-services/SKILL.md +379 -0
- package/bundled-skills/terraform-aws/SKILL.md +125 -0
- package/bundled-skills/terraform-azure/SKILL.md +415 -0
- package/bundled-skills/terraform-azure/references/details.md +231 -0
- package/bundled-skills/terraform-gcp/SKILL.md +369 -0
- package/bundled-skills/threat-modeling/SKILL.md +487 -0
- package/bundled-skills/user-management/SKILL.md +383 -0
- package/bundled-skills/using-agent-skills/SKILL.md +220 -0
- package/bundled-skills/vector-database-ops/SKILL.md +300 -0
- package/bundled-skills/vendor-management/SKILL.md +439 -0
- package/bundled-skills/vendor-management/references/details.md +109 -0
- package/bundled-skills/vercel-deployments/SKILL.md +296 -0
- package/bundled-skills/vllm-server/SKILL.md +236 -0
- package/bundled-skills/vmware-vcenter-attack/SKILL.md +412 -0
- package/bundled-skills/vpn-setup/SKILL.md +452 -0
- package/bundled-skills/vulnerability-scanning/SKILL.md +448 -0
- package/bundled-skills/waf-setup/SKILL.md +354 -0
- package/bundled-skills/waf-setup/references/details.md +211 -0
- package/bundled-skills/web2-recon/SKILL.md +440 -0
- package/bundled-skills/web2-recon/references/details.md +319 -0
- package/bundled-skills/web3-audit/SKILL.md +445 -0
- package/bundled-skills/web3-audit/references/details.md +224 -0
- package/bundled-skills/windows-hardening/SKILL.md +454 -0
- package/bundled-skills/windows-hardening/references/details.md +204 -0
- package/bundled-skills/windows-server/SKILL.md +318 -0
- package/bundled-skills/zero-trust/SKILL.md +461 -0
- package/package.json +1 -1
- package/skills_index.json +6943 -323
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cloudflare-workers
|
|
3
|
+
description: Build and deploy edge functions with Cloudflare Workers and Wrangler.
|
|
4
|
+
Use for APIs, cron jobs, and edge middleware.
|
|
5
|
+
category: devops
|
|
6
|
+
risk: critical
|
|
7
|
+
source: https://github.com/BagelHole/DevOps-Security-Agent-Skills
|
|
8
|
+
source_repo: BagelHole/DevOps-Security-Agent-Skills
|
|
9
|
+
source_type: community
|
|
10
|
+
date_added: '2026-09-20'
|
|
11
|
+
license: MIT
|
|
12
|
+
license_source: https://github.com/BagelHole/DevOps-Security-Agent-Skills/blob/main/LICENSE
|
|
13
|
+
compatibility: Requires the relevant OS/platform tooling and privileged access where
|
|
14
|
+
noted. Docs-only; helper scripts and templates not bundled.
|
|
15
|
+
metadata:
|
|
16
|
+
author: devops-skills
|
|
17
|
+
version: '1.0'
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
# Cloudflare Workers
|
|
21
|
+
|
|
22
|
+
Deploy JavaScript and TypeScript functions to Cloudflare's global edge network with sub-millisecond cold starts.
|
|
23
|
+
|
|
24
|
+
## When to Use
|
|
25
|
+
|
|
26
|
+
- Building lightweight APIs and microservices at the edge.
|
|
27
|
+
- Adding middleware (auth, rate limiting, header injection) in front of origin servers.
|
|
28
|
+
- Running cron jobs on a schedule without maintaining infrastructure.
|
|
29
|
+
- Processing webhooks, image transformations, or A/B testing logic.
|
|
30
|
+
- Serving dynamic content from KV, D1, or R2 storage bindings.
|
|
31
|
+
|
|
32
|
+
## Prerequisites
|
|
33
|
+
|
|
34
|
+
- Node.js 18+ installed locally.
|
|
35
|
+
- Wrangler CLI: `npm install -g wrangler`.
|
|
36
|
+
- Cloudflare account (free plan supports 100,000 requests/day).
|
|
37
|
+
- Authenticated: `wrangler login` or set `CLOUDFLARE_API_TOKEN`.
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Scaffold a new Worker project
|
|
43
|
+
npm create cloudflare@latest my-worker
|
|
44
|
+
cd my-worker
|
|
45
|
+
|
|
46
|
+
# Login to Cloudflare
|
|
47
|
+
npx wrangler login
|
|
48
|
+
|
|
49
|
+
# Start local development server (port 8787)
|
|
50
|
+
npx wrangler dev
|
|
51
|
+
|
|
52
|
+
# Deploy to production
|
|
53
|
+
npx wrangler deploy
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Essential Wrangler Commands
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Local development with remote bindings (KV, D1, R2)
|
|
60
|
+
npx wrangler dev --remote
|
|
61
|
+
|
|
62
|
+
# Deploy to a specific environment
|
|
63
|
+
npx wrangler deploy --env staging
|
|
64
|
+
|
|
65
|
+
# Set a secret (prompts for value)
|
|
66
|
+
npx wrangler secret put API_TOKEN
|
|
67
|
+
npx wrangler secret put API_TOKEN --env staging
|
|
68
|
+
|
|
69
|
+
# List secrets
|
|
70
|
+
npx wrangler secret list
|
|
71
|
+
|
|
72
|
+
# Tail production logs in real time
|
|
73
|
+
npx wrangler tail
|
|
74
|
+
|
|
75
|
+
# Tail with filters
|
|
76
|
+
npx wrangler tail --status=error --search="timeout"
|
|
77
|
+
|
|
78
|
+
# View deployment versions
|
|
79
|
+
npx wrangler deployments list
|
|
80
|
+
|
|
81
|
+
# Rollback to a previous deployment
|
|
82
|
+
npx wrangler rollback
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Wrangler Configuration
|
|
86
|
+
|
|
87
|
+
```toml
|
|
88
|
+
# wrangler.toml
|
|
89
|
+
name = "my-api"
|
|
90
|
+
main = "src/index.ts"
|
|
91
|
+
compatibility_date = "2024-09-01"
|
|
92
|
+
compatibility_flags = ["nodejs_compat"]
|
|
93
|
+
|
|
94
|
+
# Custom routes
|
|
95
|
+
routes = [
|
|
96
|
+
{ pattern = "api.example.com/*", zone_name = "example.com" }
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
# Or use a workers.dev subdomain
|
|
100
|
+
# workers_dev = true
|
|
101
|
+
|
|
102
|
+
# Environment variables (non-secret)
|
|
103
|
+
[vars]
|
|
104
|
+
ENVIRONMENT = "production"
|
|
105
|
+
API_VERSION = "v2"
|
|
106
|
+
|
|
107
|
+
# Staging environment override
|
|
108
|
+
[env.staging]
|
|
109
|
+
name = "my-api-staging"
|
|
110
|
+
routes = [
|
|
111
|
+
{ pattern = "api-staging.example.com/*", zone_name = "example.com" }
|
|
112
|
+
]
|
|
113
|
+
[env.staging.vars]
|
|
114
|
+
ENVIRONMENT = "staging"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Worker Examples
|
|
118
|
+
|
|
119
|
+
### Basic API Router
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// src/index.ts
|
|
123
|
+
export interface Env {
|
|
124
|
+
ENVIRONMENT: string;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export default {
|
|
128
|
+
async fetch(request: Request, env: Env, ctx: ExecutionContext): Promise<Response> {
|
|
129
|
+
const url = new URL(request.url);
|
|
130
|
+
|
|
131
|
+
switch (url.pathname) {
|
|
132
|
+
case "/":
|
|
133
|
+
return new Response("OK", { status: 200 });
|
|
134
|
+
|
|
135
|
+
case "/api/health":
|
|
136
|
+
return Response.json({
|
|
137
|
+
status: "healthy",
|
|
138
|
+
env: env.ENVIRONMENT,
|
|
139
|
+
timestamp: new Date().toISOString(),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
case "/api/data":
|
|
143
|
+
if (request.method !== "POST") {
|
|
144
|
+
return new Response("Method Not Allowed", { status: 405 });
|
|
145
|
+
}
|
|
146
|
+
const body = await request.json();
|
|
147
|
+
// Process in the background after returning response
|
|
148
|
+
ctx.waitUntil(logToAnalytics(body));
|
|
149
|
+
return Response.json({ received: true });
|
|
150
|
+
|
|
151
|
+
default:
|
|
152
|
+
return new Response("Not Found", { status: 404 });
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
async function logToAnalytics(data: unknown): Promise<void> {
|
|
158
|
+
await fetch("https://analytics.example.com/ingest", {
|
|
159
|
+
method: "POST",
|
|
160
|
+
body: JSON.stringify(data),
|
|
161
|
+
headers: { "Content-Type": "application/json" },
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### Middleware: Rate Limiting with KV
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
// src/rate-limiter.ts
|
|
170
|
+
interface Env {
|
|
171
|
+
RATE_LIMIT_KV: KVNamespace;
|
|
172
|
+
ORIGIN_URL: string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export default {
|
|
176
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
177
|
+
const ip = request.headers.get("CF-Connecting-IP") || "unknown";
|
|
178
|
+
const key = `ratelimit:${ip}`;
|
|
179
|
+
const window = 60; // seconds
|
|
180
|
+
const maxRequests = 100;
|
|
181
|
+
|
|
182
|
+
const current = parseInt((await env.RATE_LIMIT_KV.get(key)) || "0");
|
|
183
|
+
|
|
184
|
+
if (current >= maxRequests) {
|
|
185
|
+
return new Response("Too Many Requests", {
|
|
186
|
+
status: 429,
|
|
187
|
+
headers: { "Retry-After": String(window) },
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
await env.RATE_LIMIT_KV.put(key, String(current + 1), {
|
|
192
|
+
expirationTtl: window,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// Forward to origin
|
|
196
|
+
const originRequest = new Request(env.ORIGIN_URL + new URL(request.url).pathname, request);
|
|
197
|
+
return fetch(originRequest);
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## KV Storage Binding
|
|
203
|
+
|
|
204
|
+
```toml
|
|
205
|
+
# wrangler.toml
|
|
206
|
+
[[kv_namespaces]]
|
|
207
|
+
binding = "MY_KV"
|
|
208
|
+
id = "abc123def456"
|
|
209
|
+
|
|
210
|
+
# Preview namespace for local dev
|
|
211
|
+
[[kv_namespaces]]
|
|
212
|
+
binding = "MY_KV"
|
|
213
|
+
id = "abc123def456"
|
|
214
|
+
preview_id = "preview789"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
// KV operations in a Worker
|
|
219
|
+
interface Env {
|
|
220
|
+
MY_KV: KVNamespace;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export default {
|
|
224
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
225
|
+
// Write with TTL
|
|
226
|
+
await env.MY_KV.put("session:abc", JSON.stringify({ user: "alice" }), {
|
|
227
|
+
expirationTtl: 3600,
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
// Read
|
|
231
|
+
const session = await env.MY_KV.get("session:abc", "json");
|
|
232
|
+
|
|
233
|
+
// List keys by prefix
|
|
234
|
+
const list = await env.MY_KV.list({ prefix: "session:", limit: 100 });
|
|
235
|
+
|
|
236
|
+
// Delete
|
|
237
|
+
await env.MY_KV.delete("session:abc");
|
|
238
|
+
|
|
239
|
+
return Response.json({ session, keys: list.keys.length });
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
# KV CLI operations
|
|
246
|
+
npx wrangler kv namespace create MY_KV
|
|
247
|
+
npx wrangler kv namespace list
|
|
248
|
+
npx wrangler kv key put --namespace-id=abc123 "config:feature-flags" '{"darkMode":true}'
|
|
249
|
+
npx wrangler kv key get --namespace-id=abc123 "config:feature-flags"
|
|
250
|
+
npx wrangler kv key list --namespace-id=abc123 --prefix="config:"
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## D1 Database Binding
|
|
254
|
+
|
|
255
|
+
```toml
|
|
256
|
+
# wrangler.toml
|
|
257
|
+
[[d1_databases]]
|
|
258
|
+
binding = "DB"
|
|
259
|
+
database_name = "my-app"
|
|
260
|
+
database_id = "xxxx-yyyy-zzzz"
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
// D1 SQL queries in a Worker
|
|
265
|
+
interface Env {
|
|
266
|
+
DB: D1Database;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export default {
|
|
270
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
271
|
+
// Parameterized query
|
|
272
|
+
const { results } = await env.DB.prepare(
|
|
273
|
+
"SELECT id, name, email FROM users WHERE active = ? LIMIT ?"
|
|
274
|
+
)
|
|
275
|
+
.bind(1, 50)
|
|
276
|
+
.all();
|
|
277
|
+
|
|
278
|
+
// Insert
|
|
279
|
+
await env.DB.prepare("INSERT INTO users (name, email) VALUES (?, ?)")
|
|
280
|
+
.bind("Alice", "alice@example.com")
|
|
281
|
+
.run();
|
|
282
|
+
|
|
283
|
+
// Batch multiple statements
|
|
284
|
+
await env.DB.batch([
|
|
285
|
+
env.DB.prepare("UPDATE users SET active = 0 WHERE last_login < ?").bind("2024-01-01"),
|
|
286
|
+
env.DB.prepare("DELETE FROM sessions WHERE expires_at < ?").bind(Date.now()),
|
|
287
|
+
]);
|
|
288
|
+
|
|
289
|
+
return Response.json(results);
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
# D1 CLI operations
|
|
296
|
+
npx wrangler d1 create my-app
|
|
297
|
+
npx wrangler d1 list
|
|
298
|
+
npx wrangler d1 execute my-app --command="CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT, active INTEGER DEFAULT 1)"
|
|
299
|
+
npx wrangler d1 execute my-app --file=./migrations/001_init.sql
|
|
300
|
+
npx wrangler d1 execute my-app --command="SELECT * FROM users" --json
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
## Cron Triggers
|
|
304
|
+
|
|
305
|
+
```toml
|
|
306
|
+
# wrangler.toml
|
|
307
|
+
[triggers]
|
|
308
|
+
crons = [
|
|
309
|
+
"0 */6 * * *", # Every 6 hours
|
|
310
|
+
"0 0 * * MON", # Every Monday at midnight
|
|
311
|
+
"*/15 * * * *", # Every 15 minutes
|
|
312
|
+
]
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
// src/index.ts — scheduled handler
|
|
317
|
+
export default {
|
|
318
|
+
async scheduled(event: ScheduledEvent, env: Env, ctx: ExecutionContext): Promise<void> {
|
|
319
|
+
switch (event.cron) {
|
|
320
|
+
case "0 */6 * * *":
|
|
321
|
+
ctx.waitUntil(cleanupExpiredSessions(env));
|
|
322
|
+
break;
|
|
323
|
+
case "0 0 * * MON":
|
|
324
|
+
ctx.waitUntil(generateWeeklyReport(env));
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
330
|
+
return new Response("OK");
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Durable Objects
|
|
336
|
+
|
|
337
|
+
```toml
|
|
338
|
+
# wrangler.toml
|
|
339
|
+
[durable_objects]
|
|
340
|
+
bindings = [
|
|
341
|
+
{ name = "COUNTER", class_name = "Counter" }
|
|
342
|
+
]
|
|
343
|
+
|
|
344
|
+
[[migrations]]
|
|
345
|
+
tag = "v1"
|
|
346
|
+
new_classes = ["Counter"]
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
```typescript
|
|
350
|
+
// src/counter.ts — Durable Object class
|
|
351
|
+
export class Counter {
|
|
352
|
+
state: DurableObjectState;
|
|
353
|
+
|
|
354
|
+
constructor(state: DurableObjectState) {
|
|
355
|
+
this.state = state;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async fetch(request: Request): Promise<Response> {
|
|
359
|
+
let count = (await this.state.storage.get<number>("count")) || 0;
|
|
360
|
+
count++;
|
|
361
|
+
await this.state.storage.put("count", count);
|
|
362
|
+
return Response.json({ count });
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// src/index.ts — route to Durable Object
|
|
367
|
+
interface Env {
|
|
368
|
+
COUNTER: DurableObjectNamespace;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export default {
|
|
372
|
+
async fetch(request: Request, env: Env): Promise<Response> {
|
|
373
|
+
const id = env.COUNTER.idFromName("global-counter");
|
|
374
|
+
const stub = env.COUNTER.get(id);
|
|
375
|
+
return stub.fetch(request);
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Custom Routing
|
|
381
|
+
|
|
382
|
+
```toml
|
|
383
|
+
# Route to specific zones
|
|
384
|
+
routes = [
|
|
385
|
+
{ pattern = "api.example.com/v1/*", zone_name = "example.com" },
|
|
386
|
+
{ pattern = "api.example.com/v2/*", zone_name = "example.com" },
|
|
387
|
+
]
|
|
388
|
+
|
|
389
|
+
# Or use custom domains (automatic SSL)
|
|
390
|
+
# Dashboard: Workers > your-worker > Triggers > Custom Domains
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## Troubleshooting
|
|
394
|
+
|
|
395
|
+
| Symptom | Cause | Fix |
|
|
396
|
+
|---------|-------|-----|
|
|
397
|
+
| `Error 1101: Worker threw exception` | Unhandled error in fetch handler | Wrap handler in try/catch; check `wrangler tail` for stack trace |
|
|
398
|
+
| `exceeded CPU time limit` | Worker exceeds 10ms CPU (free) or 30s (paid) | Optimize code; offload work with `ctx.waitUntil()` |
|
|
399
|
+
| KV reads return stale data | KV is eventually consistent (~60s) | Use `cacheTtl` option or switch to Durable Objects for strong consistency |
|
|
400
|
+
| `wrangler dev` binding errors | Local bindings not configured | Use `--remote` flag or configure `preview_id` in `wrangler.toml` |
|
|
401
|
+
| Secret not found in Worker | Secret set for wrong environment | Verify with `wrangler secret list --env <env>` |
|
|
402
|
+
| CORS errors from browser | Missing CORS headers in response | Add `Access-Control-Allow-Origin` headers; handle OPTIONS preflight |
|
|
403
|
+
| Route not matching | Pattern does not include `/*` suffix | Add `/*` to catch all paths: `api.example.com/*` |
|
|
404
|
+
|
|
405
|
+
## Related Skills
|
|
406
|
+
|
|
407
|
+
- cloudflare-pages (`cloudflare-pages`) - Frontend deployments with Pages Functions
|
|
408
|
+
- cloudflare-r2 (`cloudflare-r2`) - Object storage at the edge
|
|
409
|
+
- cloudflare-zero-trust (`cloudflare-zero-trust`) - Protect Worker endpoints with Access
|
|
410
|
+
|
|
411
|
+
## Limitations
|
|
412
|
+
|
|
413
|
+
- Infrastructure commands can disrupt services: confirm target host/scope and have backups/snapshots before mutating state.
|
|
414
|
+
- Docs-only import: upstream scripts and templates not bundled.
|
|
415
|
+
|