@vesviet/agent-skills 5.6.0 → 5.7.0

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.
Files changed (184) hide show
  1. package/INDEX.md +5 -5
  2. package/README.md +1 -1
  3. package/VERSION +1 -1
  4. package/adapters/antigravity/a2a-config.template.yaml +1 -1
  5. package/adapters/antigravity/role-skill-index.json +12 -12
  6. package/adapters/claude/CLAUDE_ADAPTER.md +1 -1
  7. package/adapters/cursor/README.md +185 -185
  8. package/bin/agent-skills.mjs +17 -14
  9. package/core/contracts/README.md +1 -1
  10. package/core/contracts/schemas/api-contract-spec.json +191 -191
  11. package/core/contracts/schemas/data-pipeline-spec.json +1 -1
  12. package/core/contracts/schemas/design-tokens-spec.json +19 -0
  13. package/core/contracts/schemas/feature-ticket.json +1293 -1293
  14. package/core/contracts/schemas/pull-request-spec.json +338 -338
  15. package/core/contracts/schemas/references/detailed/01-solution-and-governance.md +19 -19
  16. package/core/contracts/schemas/references/detailed/02-engineering-delivery.md +93 -93
  17. package/core/contracts/schemas/references/detailed/04-finance-accounting-and-compliance.md +54 -54
  18. package/core/contracts/schemas/references/detailed/05-design-and-content.md +92 -92
  19. package/core/contracts/schemas/references/detailed/06-seo-and-publishing.md +48 -48
  20. package/core/contracts/schemas/references/detailed/07-a2a-protocol.md +85 -85
  21. package/core/contracts/schemas/security-audit.json +143 -12
  22. package/core/contracts/schemas/system-design-spec.json +9 -1
  23. package/core/contracts/schemas/test-report.json +530 -530
  24. package/core/contracts/schemas/ux-flow-spec.json +66 -0
  25. package/core/roles/ai-systems-engineer.md +31 -18
  26. package/core/roles/aws-engineer.md +33 -29
  27. package/core/roles/backend-developer.md +6 -4
  28. package/core/roles/content-manager.md +7 -7
  29. package/core/roles/data-engineer.md +39 -36
  30. package/core/roles/qa-engineer.md +18 -18
  31. package/core/roles/references/ai-systems-engineer-review-checklist.md +11 -3
  32. package/core/roles/references/aws-engineer-review-checklist.md +29 -16
  33. package/core/roles/references/business-analyst-responsibilities.md +207 -207
  34. package/core/roles/references/content-manager-governance-standards.md +2 -2
  35. package/core/roles/references/content-manager-review-checklist.md +7 -1
  36. package/core/roles/references/data-engineer-review-checklist.md +11 -3
  37. package/core/roles/references/frontend-developer-responsibilities.md +275 -275
  38. package/core/roles/references/qa-engineer-review-checklist.md +10 -5
  39. package/core/roles/references/security-engineer-review-checklist.md +8 -0
  40. package/core/roles/references/solution-architect-review-checklist.md +6 -1
  41. package/core/roles/references/system-engineer-review-checklist.md +11 -0
  42. package/core/roles/references/ui-ux-designer-review-checklist.md +12 -0
  43. package/core/roles/security-engineer.md +35 -5
  44. package/core/roles/solution-architect.md +7 -7
  45. package/core/roles/system-engineer.md +470 -465
  46. package/core/roles/ui-ux-designer.md +17 -3
  47. package/core/skills/agent/agent-memory-compaction/references/anchored-schema-and-compaction-algorithms.md +141 -141
  48. package/core/skills/agent/architect-mcp-server/SKILL.md +3 -3
  49. package/core/skills/agent/decompose-agentic-system/SKILL.md +1 -1
  50. package/core/skills/ai/deploy-vllm-inference/SKILL.md +14 -14
  51. package/core/skills/ai-agent/agent-evaluation/SKILL.md +5 -0
  52. package/core/skills/ai-agent/context-optimization/SKILL.md +9 -0
  53. package/core/skills/backend/add-api-endpoint/SKILL.md +1 -0
  54. package/core/skills/backend/add-event-handler/SKILL.md +1 -0
  55. package/core/skills/backend/add-service-client/SKILL.md +1 -0
  56. package/core/skills/backend/build-mcp-server/SKILL.md +101 -100
  57. package/core/skills/backend/implement-auth/SKILL.md +1 -0
  58. package/core/skills/backend/implement-structured-outputs/SKILL.md +95 -94
  59. package/core/skills/backend/optimize-postgres/SKILL.md +1 -0
  60. package/core/skills/backend/scaffold-new-service/SKILL.md +1 -0
  61. package/core/skills/business/elicit-requirements/SKILL.md +102 -102
  62. package/core/skills/business/elicit-requirements/references/elicitation-techniques-and-babok-criteria.md +60 -60
  63. package/core/skills/business/trace-requirements-impact/SKILL.md +97 -97
  64. package/core/skills/business/trace-requirements-impact/references/rtm-graph-and-prioritization-models.md +109 -109
  65. package/core/skills/business/write-use-cases/SKILL.md +106 -106
  66. package/core/skills/business/write-use-cases/references/cockburn-scoping-and-13-field-template.md +135 -135
  67. package/core/skills/content/audit-content/SKILL.md +3 -2
  68. package/core/skills/content/audit-content/references/information-gain-rubric.md +1 -1
  69. package/core/skills/content/design-content-strategy/SKILL.md +6 -5
  70. package/core/skills/content/design-content-strategy/references/information-gain-and-decay-triage.md +2 -2
  71. package/core/skills/content/optimize-seo/SKILL.md +6 -5
  72. package/core/skills/content/optimize-seo/references/geo-ai-citation-playbook.md +2 -2
  73. package/core/skills/content/optimize-seo/references/process-and-checklist.md +1 -1
  74. package/core/skills/content/repurpose-content/SKILL.md +4 -3
  75. package/core/skills/content/write-article/SKILL.md +6 -5
  76. package/core/skills/content/write-copy/SKILL.md +3 -2
  77. package/core/skills/document/pptx/SKILL.md +1 -0
  78. package/core/skills/document/pptx/scripts/add_slide.py +0 -0
  79. package/core/skills/document/pptx/scripts/clean.py +0 -0
  80. package/core/skills/document/pptx/scripts/thumbnail.py +0 -0
  81. package/core/skills/document/xlsx/scripts/recalc.py +0 -0
  82. package/core/skills/documentation/write-documentation/SKILL.md +143 -143
  83. package/core/skills/documentation/write-tech-radar/SKILL.md +149 -149
  84. package/core/skills/foundation/accessibility-review/SKILL.md +160 -160
  85. package/core/skills/foundation/design-review/SKILL.md +11 -1
  86. package/core/skills/foundation/design-ux-flow/SKILL.md +13 -1
  87. package/core/skills/foundation/performance-profiling/SKILL.md +3 -1
  88. package/core/skills/foundation/release-notes/SKILL.md +192 -192
  89. package/core/skills/foundation/webapp-server-runner/scripts/with_server.py +0 -0
  90. package/core/skills/foundation/write-product-brief/SKILL.md +160 -160
  91. package/core/skills/foundation/write-tests/SKILL.md +11 -10
  92. package/core/skills/frontend/anti-ui-slop-finish-gate/SKILL.md +5 -0
  93. package/core/skills/frontend/design-md-specification/SKILL.md +1 -0
  94. package/core/skills/frontend/design-system-engineering/SKILL.md +4 -2
  95. package/core/skills/meetings-analysis/analyze-business-requirements/SKILL.md +1 -1
  96. package/core/skills/platform/add-telemetry-instrumentation/SKILL.md +2 -1
  97. package/core/skills/platform/aws-infrastructure/SKILL.md +12 -11
  98. package/core/skills/platform/cloudflare-email-service/SKILL.md +166 -166
  99. package/core/skills/platform/cloudflare-email-service/references/routing.md +199 -199
  100. package/core/skills/platform/debug-runtime-platform/SKILL.md +1 -0
  101. package/core/skills/platform/debug-workers-edge/SKILL.md +111 -111
  102. package/core/skills/platform/sandbox-sdk/SKILL.md +183 -183
  103. package/core/skills/platform/setup-gpu-finops/SKILL.md +111 -107
  104. package/core/skills/platform/setup-llm-gateway/SKILL.md +110 -108
  105. package/core/skills/platform/supply-chain-security/SKILL.md +1 -0
  106. package/core/skills/platform/system-design/SKILL.md +7 -0
  107. package/core/skills/platform/turnstile-spin/SKILL.md +118 -118
  108. package/core/skills/platform/turnstile-spin/scripts/auth-probe.sh +0 -0
  109. package/core/skills/platform/turnstile-spin/scripts/fetch-secret.sh +0 -0
  110. package/core/skills/platform/turnstile-spin/scripts/persist-skill.sh +0 -0
  111. package/core/skills/platform/turnstile-spin/scripts/validate.sh +0 -0
  112. package/core/skills/platform/turnstile-spin/scripts/widget-create.sh +0 -0
  113. package/core/skills/platform/turnstile-spin/scripts/worker-deploy.sh +0 -0
  114. package/core/skills/platform/turnstile-spin/templates/worker/src/index.ts +199 -199
  115. package/core/skills/platform/turnstile-spin/templates/worker/wrangler.toml +31 -31
  116. package/core/skills/platform/web-perf/SKILL.md +151 -151
  117. package/core/skills/platform/workers-best-practices/references/rules.md +463 -463
  118. package/core/skills/product/build-story-map/SKILL.md +104 -104
  119. package/core/skills/product/build-story-map/references/story-mapping-and-cpm-scheduling.md +101 -101
  120. package/core/skills/product/define-product-strategy/SKILL.md +105 -105
  121. package/core/skills/product/define-product-strategy/references/strategy-frameworks-and-pr-faq.md +142 -142
  122. package/core/skills/product/model-saas-metrics/SKILL.md +104 -104
  123. package/core/skills/product/model-saas-metrics/references/saas-unit-economics-and-pricing.md +110 -110
  124. package/core/skills/product/prioritize-roadmap/SKILL.md +106 -106
  125. package/core/skills/product/prioritize-roadmap/references/prioritization-scoring-and-kill-criteria.md +105 -105
  126. package/core/skills/repo-ops/commit-code/SKILL.md +190 -190
  127. package/core/skills/repo-ops/commit-code/references/multi-repo-and-deployment.md +21 -21
  128. package/core/skills/repo-ops/navigate-service/SKILL.md +199 -199
  129. package/core/skills/repo-ops/review-code/references/process-and-format.md +100 -100
  130. package/core/skills/repo-ops/review-service/SKILL.md +186 -186
  131. package/core/skills/repo-ops/troubleshoot-service/SKILL.md +127 -127
  132. package/core/skills/repo-ops/troubleshoot-service/references/failure-modes-and-security.md +22 -22
  133. package/core/skills/repo-ops/troubleshoot-service/references/suggested-process.md +110 -110
  134. package/core/skills/security-data/build-data-pipeline/SKILL.md +15 -14
  135. package/core/skills/security-data/build-data-pipeline/references/producer-contracts-and-lakehouse.md +5 -5
  136. package/core/skills/security-data/database-maintenance/SKILL.md +1 -0
  137. package/core/skills/security-data/database-maintenance/references/relational-and-vector-maintenance.md +5 -5
  138. package/core/skills/security-data/manage-secrets/SKILL.md +3 -0
  139. package/core/skills/security-data/optimize-olap-database/SKILL.md +14 -13
  140. package/core/skills/security-data/optimize-olap-database/references/olap-database-guide.md +2 -2
  141. package/core/skills/security-data/prompt-injection-defense/SKILL.md +3 -0
  142. package/core/skills/security-data/query-analytical-engine/SKILL.md +8 -7
  143. package/core/skills/security-data/query-analytical-engine/references/analytical-query-guide.md +3 -3
  144. package/core/skills/security-data/security-audit/SKILL.md +126 -119
  145. package/core/workflows/add-new-feature.md +212 -212
  146. package/core/workflows/agent-a2a-delegation.md +142 -142
  147. package/core/workflows/bug-fix.md +147 -147
  148. package/core/workflows/build-deploy.md +208 -208
  149. package/core/workflows/code-review.md +137 -137
  150. package/core/workflows/curriculum-delivery.md +1 -1
  151. package/core/workflows/dependency-upgrade.md +193 -193
  152. package/core/workflows/feature-delivery.md +149 -149
  153. package/core/workflows/hotfix-production.md +172 -172
  154. package/core/workflows/qa-validation.md +231 -231
  155. package/core/workflows/refactoring.md +154 -154
  156. package/core/workflows/revert-deployment.md +147 -147
  157. package/core/workflows/security-incident-response.md +191 -191
  158. package/core/workflows/seo-content-lifecycle.md +91 -91
  159. package/core/workflows/service-review-release.md +223 -223
  160. package/core/workflows/setup-new-service.md +214 -214
  161. package/core/workflows/tech-repo-review.md +245 -245
  162. package/core/workflows/troubleshooting.md +241 -241
  163. package/overlays/astro-cloudflare/README.md +93 -93
  164. package/overlays/data-analyst-stack/README.md +109 -109
  165. package/overlays/data-analyst-stack/rules/metric-dashboard-templates.md +135 -135
  166. package/overlays/data-analyst-stack/rules/stack-conventions.md +80 -80
  167. package/overlays/ecommerce-microservices/README.md +65 -65
  168. package/overlays/go-microservices/README.md +78 -78
  169. package/overlays/go-microservices/rules/go-conventions.md +223 -223
  170. package/overlays/laravel-filament/README.md +90 -90
  171. package/overlays/laravel-filament/rules/laravel-conventions.md +220 -220
  172. package/overlays/laravel-filament/skills/develop-laravel-feature/SKILL.md +141 -141
  173. package/overlays/laravel-filament/workflows/deploy-laravel.md +133 -133
  174. package/overlays/obj-configurator/rules/obj-project-rules.md +111 -111
  175. package/overlays/obj-configurator/skills/develop-obj-feature/SKILL.md +71 -71
  176. package/overlays/r3f-stack/README.md +89 -89
  177. package/overlays/r3f-stack/rules/stub.md +43 -43
  178. package/overlays/r3f-stack/skills/debug-3d-scene/SKILL.md +166 -166
  179. package/overlays/r3f-stack/skills/integrate-r3f-three-legacy/SKILL.md +159 -159
  180. package/overlays/r3f-stack/skills/optimize-3d-assets/SKILL.md +128 -128
  181. package/overlays/seo-publishing/rules/site-mix-and-cannibalization.md +52 -52
  182. package/overlays/ui-design-system/rules/handoff-conventions.md +73 -73
  183. package/package.json +2 -2
  184. package/core/README.md +0 -53
@@ -1,108 +1,110 @@
1
- ---
2
- name: setup-llm-gateway
3
- description: Configure a centralized LLM proxy gateway for token routing, budgeting, and failover. Use when deploying multi-model routing, enforcing token rate limits, managing provider credentials, or centralizing AI observability.
4
- allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, execute_command]
5
- ---
6
-
7
- # Setup LLM Gateway
8
-
9
- Use this skill to implement an AI infrastructure gateway (e.g., LiteLLM, Portkey) that sits between internal applications and external LLM providers (OpenAI, Anthropic, Gemini).
10
-
11
- ## Core Rules
12
-
13
- - **Centralized Choke Point**: All LLM traffic MUST route through the gateway. Direct calls to provider APIs using raw keys are prohibited.
14
- - **Failover Routing**: Configure multi-provider fallback logic (e.g., primary: Claude 3.5 Sonnet → secondary: GPT-4o → fallback: Llama 3) to guarantee inference uptime.
15
- - **Cost Attribution**: Enforce mandatory metadata tags (e.g., `team_id`, `project_id`) on all requests to track token budgets accurately.
16
- - **Rate Limiting**: Apply token and request rate limits per user/tenant to prevent abusive spikes or accidental infinite loops from autonomous agents.
17
- - **Credential Vaulting**: Secure provider master API keys in a dedicated secrets manager; never expose upstream keys to client applications.
18
- - **LLM-SLO-TARGETS**: Define measurable SLOs for each virtual model tier: TTFT (Time-to-First-Token) p95 < 800ms for interactive, < 3s for batch; TBT (Time-Between-Tokens) p95 < 25ms; alert on SLO breaches per model, not globally.
19
- - **PROMPTOPS-TOKEN-BUDGET**: Track token usage per `(team_id, model, prompt_template_version)` tuple — prompt template version changes must be reflected in metadata tagging so cost attribution remains accurate after prompt engineering changes.
20
- - **AGENTIC-CIRCUIT-BREAKER**: Configure a hard circuit breaker (max total tokens per agent invocation session) to prevent autonomous agent loops from exhausting daily budgets — set per-session token cap ≤ 10% of daily budget.
21
-
22
- ## Suggested Process
23
-
24
- ### 1. Select Gateway Architecture & Engine
25
-
26
- Evaluate and select the LLM gateway engine based on technical requirements:
27
- - LiteLLM Proxy for Python/Kubernetes native environments supporting 100+ LLM providers.
28
- - Portkey or Cloudflare AI Gateway for edge-deployed, managed caching and routing pipelines.
29
- - Verify support for streaming responses, function/tool calling passthrough, and structured JSON output constraints.
30
-
31
- ### 2. Deploy Gateway Infrastructure & Vault Credentials
32
-
33
- Provision the gateway runtime:
34
- - Deploy the gateway service as a high-availability deployment behind a load balancer.
35
- - Store upstream provider API keys (OpenAI, Anthropic, Google Vertex AI) in AWS Secrets Manager or HashiCorp Vault.
36
- - Configure internal API key generation for downstream applications with role-based permissions and spending limits.
37
-
38
- ### 3. Configure Model Routing Matrix & Failover Fallbacks
39
-
40
- Define routing rules and resilience strategies:
41
- - Define virtual model aliases (e.g., `fast-model`, `reasoning-model`) mapping to concrete upstream endpoints.
42
- - Configure automated failover fallbacks triggered by HTTP 429 (rate limits), 5xx server errors, or timeout thresholds.
43
- - Set up latency-based and cost-optimized routing rules where appropriate.
44
-
45
- ### 4. Enforce Token Budgets, Rate Limits & Metadata Tagging
46
-
47
- Implement traffic controls and governance:
48
- - Require client requests to include metadata headers (`x-team-id`, `x-project-id`, `x-user-id`).
49
- - Configure token-bucket rate limits (requests per minute and tokens per minute) per client key.
50
- - Set hard monthly budget caps per project with automated request rejection when budgets are exhausted.
51
-
52
- ### 5. Instrument Observability & Tracing
53
-
54
- Use skill: `add-telemetry-instrumentation`
55
- - Configure OpenTelemetry trace export following OpenTelemetry GenAI semantic conventions (`gen_ai.system`, `gen_ai.request.model`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`).
56
- - Forward gateway access logs to centralized logging backends.
57
- - Set up monitoring dashboards for token consumption, latency percentiles (p50, p95, p99), and provider error rates.
58
-
59
- ### 6. Validate Routing, Failover & Load Resilience
60
-
61
- Use skill: `troubleshoot-service`
62
- - Execute end-to-end integration tests routing test prompts across all configured virtual models.
63
- - Simulate provider outages by injecting HTTP 500/429 responses and assert that fallback models respond without client disruption.
64
- - Verify that rate limiting correctly throttles traffic when request ceilings are exceeded.
65
-
66
- ## Output Contracts
67
-
68
- When this skill is invoked as part of a coordinated multi-role delivery, emit:
69
-
70
- - **`contracts/schemas/deployment-plan.json`** — Required fields: `infrastructure_changes[]`, `config_updates[]`, and `validation_run` output proving the gateway successfully routes a test request and triggers a failover correctly.
71
-
72
- ## Failure Modes
73
-
74
- - **Direct provider call**: an application calls OpenAI/Anthropic directly with a raw key, bypassing the gateway. Mitigation: enforce gateway-only routing via egress policy; reject direct provider URLs in the app's outbound allowlist.
75
- - **Provider key leaked**: an upstream provider API key is committed to the repo or exposed in client config. Mitigation: vault upstream keys in AWS Secrets Manager or HashiCorp Vault; never expose to client apps.
76
- - **Failover not tested**: a failover path is configured but never exercised. Mitigation: inject 500/429 in integration tests; assert fallback model responds without client disruption.
77
- - **Missing cost metadata**: a request arrives without `x-team-id`, `x-project-id`, `x-user-id`. Mitigation: reject requests missing cost metadata; enforce at the gateway.
78
- - **Token budget unmonitored**: monthly budgets are configured but no alert fires when exhausted. Mitigation: wire budget exhaustion to a 429 response; alert on > 80% consumption.
79
- - **Agent loop exhausts budget**: an autonomous agent loops and consumes the daily token budget. Mitigation: enforce the per-session circuit breaker (≤ 10% of daily budget); raise `budget_exhausted` on breach.
80
- - **Prompt version drift**: prompt template version changes are not reflected in the cost tuple. Mitigation: include `prompt_template_version` in the metadata tag; re-attribute cost after every prompt change.
81
-
82
- ## Security Guardrails (OWASP ASI)
83
-
84
- - **ASI03 Identity & Privilege Abuse**: every client must authenticate to the gateway with a scoped key; reject anonymous or unscoped requests.
85
- - **ASI04 Supply Chain**: gateway engine, provider SDKs, and OTel collector must be schema-validated against the expected manifest; treat unknown versions as untrusted.
86
- - **ASI05 RCE Guard**: never construct virtual model aliases, routing rules, or function-call payloads from external content without strict schema validation.
87
- - **ASI07 Inter-Agent Communication**: the deployment plan is consumed by DevOps and SRE roles; emit a structured contract so each role can validate the rollout.
88
- - **ASI09 Human-Agent Trust Exploitation**: do not present the gateway as "failover-ready" without a test run; surface the actual failover coverage honestly.
89
-
90
- ## Checklist
91
-
92
- - [ ] LLM gateway service deployed in high-availability configuration.
93
- - [ ] Upstream provider API keys vaulted in secrets management.
94
- - [ ] Virtual model aliases and multi-provider failover routing configured.
95
- - [ ] Client authentication, rate limits, and token budgets enforced per tenant.
96
- - [ ] Mandatory cost attribution metadata tagging validated on incoming requests.
97
- - [ ] OpenTelemetry GenAI semantic tracing and latency metrics enabled.
98
- - [ ] Failover and throttling behaviors verified via integration tests.
99
- - [ ] `deployment-plan.json` emitted.
100
-
101
- ## Related Skills
102
-
103
- - **agent-model-routing**: Select cost-effective models dynamically before dispatching to the gateway
104
- - **setup-gpu-finops**: Track token spend and GPU compute costs across infrastructure layers
105
- - **implement-structured-outputs**: Ensure gateway preserves JSON Schema constrained decoding across routed models
106
- - **add-telemetry-instrumentation**: Wire OpenTelemetry GenAI semantic conventions and trace propagation
107
- - **manage-secrets**: Securely store and rotate provider API keys and gateway authentication tokens
108
- - **system-design**: Architect high-availability LLM proxy clusters and failover topologies
1
+ ---
2
+ name: setup-llm-gateway
3
+ description: Configure a centralized LLM proxy gateway for token routing, budgeting, and failover. Use when deploying multi-model routing, enforcing token rate limits, managing provider credentials, or centralizing AI observability.
4
+ version: 2.0.0
5
+ allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, execute_command]
6
+ ---
7
+
8
+ # Setup LLM Gateway
9
+
10
+ Use this skill to implement an AI infrastructure gateway (e.g., LiteLLM, Portkey) that sits between internal applications and external LLM providers (OpenAI, Anthropic, Gemini).
11
+
12
+ ## Core Rules
13
+
14
+ - **Centralized Choke Point**: All LLM traffic MUST route through the gateway. Direct calls to provider APIs using raw keys are prohibited.
15
+ - **Failover Routing**: Configure multi-provider fallback logic (e.g., primary: Claude 3.5 Sonnet → secondary: GPT-4o → fallback: Llama 3) to guarantee inference uptime.
16
+ - **Cost Attribution**: Enforce mandatory metadata tags (e.g., `team_id`, `project_id`) on all requests to track token budgets accurately.
17
+ - **Rate Limiting**: Apply token and request rate limits per user/tenant to prevent abusive spikes or accidental infinite loops from autonomous agents.
18
+ - **Credential Vaulting**: Secure provider master API keys in a dedicated secrets manager; never expose upstream keys to client applications.
19
+ - **LLM-SLO-TARGETS**: Define measurable SLOs for each virtual model tier: TTFT (Time-to-First-Token) p95 < 800ms for interactive, < 3s for batch; TBT (Time-Between-Tokens) p95 < 25ms; alert on SLO breaches per model, not globally.
20
+ - **PROMPTOPS-TOKEN-BUDGET**: Track token usage per `(team_id, model, prompt_template_version)` tuple — prompt template version changes must be reflected in metadata tagging so cost attribution remains accurate after prompt engineering changes.
21
+ - **AGENTIC-CIRCUIT-BREAKER**: Configure a hard circuit breaker (max total tokens per agent invocation session) to prevent autonomous agent loops from exhausting daily budgets — set per-session token cap ≤ 10% of daily budget.
22
+
23
+ ## Suggested Process
24
+
25
+ ### 1. Select Gateway Architecture & Engine
26
+
27
+ Evaluate and select the LLM gateway engine based on technical requirements:
28
+ - LiteLLM Proxy for Python/Kubernetes native environments supporting 100+ LLM providers.
29
+ - Portkey or Cloudflare AI Gateway for edge-deployed, managed caching and routing pipelines.
30
+ - Agent Router (formerly Envoy AI Gateway; renamed 2026-09) for Kubernetes-native inference-aware routing via Gateway API Inference Extension (InferencePool, endpoint picking for KV/prefix-aware routing) when the gateway fronts self-hosted vLLM/SGLang fleets.
31
+ - Verify support for streaming responses, function/tool calling passthrough, and structured JSON output constraints.
32
+
33
+ ### 2. Deploy Gateway Infrastructure & Vault Credentials
34
+
35
+ Provision the gateway runtime:
36
+ - Deploy the gateway service as a high-availability deployment behind a load balancer.
37
+ - Store upstream provider API keys (OpenAI, Anthropic, Google Vertex AI) in AWS Secrets Manager or HashiCorp Vault.
38
+ - Configure internal API key generation for downstream applications with role-based permissions and spending limits.
39
+
40
+ ### 3. Configure Model Routing Matrix & Failover Fallbacks
41
+
42
+ Define routing rules and resilience strategies:
43
+ - Define virtual model aliases (e.g., `fast-model`, `reasoning-model`) mapping to concrete upstream endpoints.
44
+ - Configure automated failover fallbacks triggered by HTTP 429 (rate limits), 5xx server errors, or timeout thresholds.
45
+ - Set up latency-based and cost-optimized routing rules where appropriate.
46
+
47
+ ### 4. Enforce Token Budgets, Rate Limits & Metadata Tagging
48
+
49
+ Implement traffic controls and governance:
50
+ - Require client requests to include metadata headers (`x-team-id`, `x-project-id`, `x-user-id`).
51
+ - Configure token-bucket rate limits (requests per minute and tokens per minute) per client key.
52
+ - Set hard monthly budget caps per project with automated request rejection when budgets are exhausted.
53
+
54
+ ### 5. Instrument Observability & Tracing
55
+
56
+ Use skill: `add-telemetry-instrumentation`
57
+ - Configure OpenTelemetry trace export following OpenTelemetry GenAI semantic conventions (`gen_ai.system`, `gen_ai.request.model`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`).
58
+ - Forward gateway access logs to centralized logging backends.
59
+ - Set up monitoring dashboards for token consumption, latency percentiles (p50, p95, p99), and provider error rates.
60
+
61
+ ### 6. Validate Routing, Failover & Load Resilience
62
+
63
+ Use skill: `troubleshoot-service`
64
+ - Execute end-to-end integration tests routing test prompts across all configured virtual models.
65
+ - Simulate provider outages by injecting HTTP 500/429 responses and assert that fallback models respond without client disruption.
66
+ - Verify that rate limiting correctly throttles traffic when request ceilings are exceeded.
67
+
68
+ ## Output Contracts
69
+
70
+ When this skill is invoked as part of a coordinated multi-role delivery, emit:
71
+
72
+ - **`contracts/schemas/deployment-plan.json`** — Required fields: `infrastructure_changes[]`, `config_updates[]`, and `validation_run` output proving the gateway successfully routes a test request and triggers a failover correctly.
73
+
74
+ ## Failure Modes
75
+
76
+ - **Direct provider call**: an application calls OpenAI/Anthropic directly with a raw key, bypassing the gateway. Mitigation: enforce gateway-only routing via egress policy; reject direct provider URLs in the app's outbound allowlist.
77
+ - **Provider key leaked**: an upstream provider API key is committed to the repo or exposed in client config. Mitigation: vault upstream keys in AWS Secrets Manager or HashiCorp Vault; never expose to client apps.
78
+ - **Failover not tested**: a failover path is configured but never exercised. Mitigation: inject 500/429 in integration tests; assert fallback model responds without client disruption.
79
+ - **Missing cost metadata**: a request arrives without `x-team-id`, `x-project-id`, `x-user-id`. Mitigation: reject requests missing cost metadata; enforce at the gateway.
80
+ - **Token budget unmonitored**: monthly budgets are configured but no alert fires when exhausted. Mitigation: wire budget exhaustion to a 429 response; alert on > 80% consumption.
81
+ - **Agent loop exhausts budget**: an autonomous agent loops and consumes the daily token budget. Mitigation: enforce the per-session circuit breaker (≤ 10% of daily budget); raise `budget_exhausted` on breach.
82
+ - **Prompt version drift**: prompt template version changes are not reflected in the cost tuple. Mitigation: include `prompt_template_version` in the metadata tag; re-attribute cost after every prompt change.
83
+
84
+ ## Security Guardrails (OWASP ASI)
85
+
86
+ - **ASI03 Identity & Privilege Abuse**: every client must authenticate to the gateway with a scoped key; reject anonymous or unscoped requests.
87
+ - **ASI04 Supply Chain**: gateway engine, provider SDKs, and OTel collector must be schema-validated against the expected manifest; treat unknown versions as untrusted.
88
+ - **ASI05 RCE Guard**: never construct virtual model aliases, routing rules, or function-call payloads from external content without strict schema validation.
89
+ - **ASI07 Inter-Agent Communication**: the deployment plan is consumed by DevOps and SRE roles; emit a structured contract so each role can validate the rollout.
90
+ - **ASI09 Human-Agent Trust Exploitation**: do not present the gateway as "failover-ready" without a test run; surface the actual failover coverage honestly.
91
+
92
+ ## Checklist
93
+
94
+ - [ ] LLM gateway service deployed in high-availability configuration.
95
+ - [ ] Upstream provider API keys vaulted in secrets management.
96
+ - [ ] Virtual model aliases and multi-provider failover routing configured.
97
+ - [ ] Client authentication, rate limits, and token budgets enforced per tenant.
98
+ - [ ] Mandatory cost attribution metadata tagging validated on incoming requests.
99
+ - [ ] OpenTelemetry GenAI semantic tracing and latency metrics enabled.
100
+ - [ ] Failover and throttling behaviors verified via integration tests.
101
+ - [ ] `deployment-plan.json` emitted.
102
+
103
+ ## Related Skills
104
+
105
+ - **agent-model-routing**: Select cost-effective models dynamically before dispatching to the gateway
106
+ - **setup-gpu-finops**: Track token spend and GPU compute costs across infrastructure layers
107
+ - **implement-structured-outputs**: Ensure gateway preserves JSON Schema constrained decoding across routed models
108
+ - **add-telemetry-instrumentation**: Wire OpenTelemetry GenAI semantic conventions and trace propagation
109
+ - **manage-secrets**: Securely store and rotate provider API keys and gateway authentication tokens
110
+ - **system-design**: Architect high-availability LLM proxy clusters and failover topologies
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: supply-chain-security
3
3
  description: Implement software supply chain security by generating SBOMs (CycloneDX/SPDX), enforcing SLSA build provenance levels, integrating artifact signing (Sigstore), and maintaining VEX context for vulnerability management. Use when hardening CI/CD pipelines, generating per-build inventory, achieving SLSA Level 2 or 3 compliance, or auditing third-party dependencies including MCP server registries.
4
+ version: 1.0.0
4
5
  allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, execute_command]
5
6
  ---
6
7
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: system-design
3
3
  description: Design, specify, and document complex system architectures covering compute, network, storage, middleware, and AI inference layers. Translate NFRs into measurable infrastructure targets and produce capacity models. Use when designing or reviewing system topology, sizing infrastructure, planning capacity, or specifying AI infrastructure (GPU, inference servers, vector databases).
4
+ version: 2.0.0
4
5
  allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, execute_command]
5
6
  ---
6
7
 
@@ -31,6 +32,9 @@ Use this skill when designing system topology for a new service or infrastructur
31
32
  - **LLM-SLOS & TOKEN-ECONOMICS**: Set measurable LLM SLOs ($TTFT_{P95} \le 800\text{ms}$, $TBT_{P95} \le 25\text{ms}$, throughput $> 40$ tokens/s per user); compute Cost-Per-Token ($CPT$) and enforce Value-Per-Token ($VPT \ge 4 \times CPT$) viability before sizing clusters.
32
33
  - **VECTOR-DB-TUNING**: Explicitly specify HNSW $m$ (connectivity), $ef\_construction$ (build quality), and query-time $ef$ (recall-latency trade-off).
33
34
  - **EMBEDDING-CACHE**: Always design an embedding cache layer; repeated embedding of identical content is the most common preventable AI cost spike.
35
+ - **KV-CACHE-TIERING (2026)**: For agentic and long-context workloads, evaluate KV-cache offloading tiers (GPU → CPU RAM → storage; vLLM/SGLang offloading, NVIDIA ICMS) before scaling GPU count; record the tiering decision in `ai_infrastructure.kv_cache_tiering` — idle GPU VRAM used as a KV warehouse is the most expensive storage in the stack.
36
+ - **SPECULATIVE-DECODING-DECISION (2026)**: Evaluate EAGLE-3/MTP speculative decoding as a capacity lever for decode-bound workloads (up to 6.5x throughput on supported stacks); gate the decision on measured draft acceptance rate (net loss below ~70%) and record it in `ai_infrastructure.speculative_decoding`.
37
+ - **DRA-GPU-ALLOCATION (2026)**: On Kubernetes v1.34+, allocate accelerators via DRA ResourceClaims (GA; admin-access and extended-resource support GA in v1.36/v1.37) with structured VRAM requests instead of opaque integer `nvidia.com/gpu` counts; combine with MIG partitioning for multi-tenant isolation.
34
38
  - See [`references/cellular-topology-and-capacity-sizing.md`](references/cellular-topology-and-capacity-sizing.md) for combinatorial proofs, Go HRW router code, and worked GPU sizing examples.
35
39
 
36
40
  ## Suggested Process
@@ -141,6 +145,9 @@ Before finalizing:
141
145
  - [ ] all infrastructure changes represented in IaC — no manual-only configuration
142
146
  - [ ] trade-offs documented: what was chosen, what was rejected, and why
143
147
  - [ ] AI infrastructure specified (when in scope): GPU allocation, inference server config, vector DB, embedding pipeline
148
+ - [ ] KV-cache tiering decision recorded for agentic/long-context workloads (when AI in scope)
149
+ - [ ] speculative decoding decision recorded with draft acceptance basis (when AI in scope)
150
+ - [ ] GPU allocation via DRA ResourceClaims on K8s v1.34+ (no opaque integer GPU counts)
144
151
  - [ ] system-design-spec.json produced when structured downstream handoff required
145
152
  - [ ] open questions, accepted risks, and escalation items documented
146
153
 
@@ -1,118 +1,118 @@
1
- ---
2
- name: turnstile-spin
3
- description: Implements end-to-end Cloudflare Turnstile CAPTCHA protection — widget creation, managed siteverify Worker deployment, and frontend integration — turning a "set up Turnstile" request into a validated, working integration. Use when adding bot protection to forms or gated flows in vanilla HTML, Next.js, Astro, SvelteKit, or Hugo projects.
4
- allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, wrangler_deploy, execute_command]
5
- ---
6
-
7
- # Turnstile Spin
8
-
9
- 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.
10
-
11
- 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.
12
-
13
- Canonical instructions live at [`developers.cloudflare.com/turnstile/spin`](https://developers.cloudflare.com/turnstile/spin/). If the docs page and this file disagree, trust the docs page.
14
-
15
- ## When to Use
16
-
17
- - adding bot protection to a form or gated flow (login, signup, checkout)
18
- - integrating Turnstile into vanilla HTML, Next.js, Astro, SvelteKit, or Hugo
19
- - deploying a managed `siteverify` Worker and wiring server-side validation
20
- - choosing the least-intrusive widget mode for a given risk level
21
- - re-triggering the widget on token expiry or backend validation failure
22
-
23
- ## Core Rules
24
- - Do NOT write the Turnstile secret to disk. Only pass it via stdin to `wrangler secret put`.
25
- - Do NOT skip validation (Step 11).
26
- - Do NOT overwrite files without showing a diff.
27
- - Do NOT deploy a Worker to a different account than the widget was created in.
28
- - Do NOT call siteverify from the browser. Always: browser -> user's Worker -> siteverify.
29
- - Always choose the least-invasive widget mode (`non-interactive` or `invisible`) that maintains security requirements, falling back to `managed` for critical checkpoints.
30
- - Ensure that tokens are never reused; they are single-use and expire within 300 seconds. Re-trigger the Turnstile widget on any failed form submission.
31
- - **WIDGET-MODE-SELECTION**: `managed` for login/checkout/password-reset (shows interactive challenge if suspicious); `non-interactive` for medium-risk (browser telemetry only, may fail in privacy-hardened browsers); `invisible` for low-risk only (highest false-positive risk).
32
- - **TOKEN-REUSE-PREVENTION**: On backend validation failure, frontend MUST call `turnstile.reset(widgetId)` — do NOT show a generic error; user must complete a fresh challenge.
33
- - **CSP-TURNSTILE-DOMAINS**: Add Cloudflare Turnstile script domains to the site's Content Security Policy (`script-src` and `frame-src`) before deployment — missing CSP entries silently block the widget.
34
-
35
- ## Retrieval Sources
36
-
37
- | Source | How to retrieve | Use for |
38
- |--------|----------------|---------|
39
- | Turnstile docs | `https://developers.cloudflare.com/turnstile/` | Core API reference, script widget parameters |
40
-
41
- ## Suggested Process
42
- 1. Check credentials and account ID by running the auth-probe script.
43
- 2. Probe active domain settings, scans codebase layout, and present insertion plans.
44
- 3. Call api.cloudflare.com client endpoints to build the CAPTCHA widget.
45
- 4. Deploy siteverify Workers templates with wrangler.
46
- 5. Apply frontend changes and check responses via validate tool scripts.
47
- 6. Guide the integration by choosing the right widget mode and setting up token expiration handling.
48
- 7. Implement frontend listeners to reset and re-render the Turnstile widget upon backend validation failure or token expiry.
49
-
50
- ### Widget Modes, Token Handling, and Verification
51
-
52
- #### Widget Modes Selection
53
-
54
- Widget mode details (`managed`, `non-interactive`, `invisible`) and the
55
- rule-of-thumb for choosing the least-intrusive mode that satisfies the
56
- security threat model are documented in
57
- [`references/code-patterns.md`](references/code-patterns.md#widget-modes-reference).
58
- Framework-specific integration patterns (Astro, Hugo, Next.js app/pages,
59
- SvelteKit, vanilla HTML) live under `references/`.
60
-
61
- #### Token Expiry & Reuse Prevention
62
-
63
- Turnstile validation tokens are single-use to prevent replay attacks and
64
- remain valid for exactly 300 seconds (5 minutes). If validation fails on the
65
- backend, the token becomes spent. The frontend must immediately reset the
66
- widget instance rather than showing a generic submission failure. The full
67
- frontend reset pattern and the siteverify Worker template live in
68
- [`references/code-patterns.md`](references/code-patterns.md).
69
-
70
- #### Backend verify Worker Endpoint Pattern
71
-
72
- Always verify the client token server-side via a secure endpoint. Never
73
- invoke siteverify directly from the web client. The siteverify Worker
74
- implementation is in
75
- [`references/code-patterns.md`](references/code-patterns.md#backend-siteverify-worker-implementation).
76
-
77
- ## Checklist
78
- - [ ] Account and API auth are verified.
79
- - [ ] Target domain is registered for widget.
80
- - [ ] Widget is created via Turnstile API.
81
- - [ ] siteverify Worker is deployed.
82
- - [ ] Frontend form submission gates on widget success.
83
- - [ ] Widget mode (`managed`, `non-interactive`, or `invisible`) is explicitly selected based on use case constraints.
84
- - [ ] Token reuse is prevented by resetting the widget via `turnstile.reset()` on submission failure.
85
- - [ ] Token expiry (300-second window) is handled gracefully with automatic widget re-triggering.
86
-
87
- ## Output Contracts
88
-
89
- When this skill is invoked as part of a coordinated multi-role delivery, emit:
90
-
91
- - **contracts/schemas/deployment-plan.json** — Required fields: infrastructure_changes[], config_updates[], and
92
- alidation_run. Set produced_by_role to the emitting developer role.
93
-
94
- Skip emission for solo refactor work where no downstream handoff is expected.
95
-
96
- ## Failure Modes
97
-
98
- - **Secret on disk**: the Turnstile secret is written to a file or committed. Mitigation: only pass the secret via stdin to `wrangler secret put`; never write it to disk.
99
- - **Validation skipped**: a form submits without siteverify server-side check. Mitigation: require server-side validation; treat browser-side checks as untrusted.
100
- - **Cross-account deploy**: a siteverify Worker is deployed to a different Cloudflare account than the widget. Mitigation: verify the active account before deploy; reject cross-account deploys.
101
- - **Siteverify called from browser**: the browser calls siteverify directly. Mitigation: always route browser → user's Worker → siteverify; reject client-side siteverify calls.
102
- - **Token reuse**: a failed submit does not reset the widget, allowing the same token to be retried. Mitigation: call `turnstile.reset(widgetId)` on backend validation failure; require a fresh challenge.
103
- - **CSP missing**: the widget does not load because the site CSP blocks the Turnstile script. Mitigation: add `challenges.cloudflare.com` to `script-src` and `frame-src` before deploy.
104
- - **Token expired**: a token is older than 300 seconds. Mitigation: re-trigger the widget automatically on token expiry; do not retry the same token.
105
- - **Wrong widget mode**: a low-risk checkpoint uses `invisible` for a high-risk flow. Mitigation: use `managed` for login/checkout/password-reset; reserve `invisible` for low-risk only.
106
- - **Diff not shown**: a frontend file is overwritten without showing a diff. Mitigation: always show a diff before writing; never overwrite silently.
107
-
108
- ## Security Guardrails (OWASP ASI)
109
-
110
- - **ASI01 Goal Hijack**: a malicious frontend could try to bypass the widget by skipping the `cf_token` field. Mitigation: server-side validation must reject any request without a verified token.
111
- - **ASI03 Identity & Privilege Abuse**: the Turnstile secret must never reach the browser; load it only into the siteverify Worker via `wrangler secret put`.
112
- - **ASI04 Supply Chain**: the Turnstile widget script URL and the siteverify endpoint must be the canonical Cloudflare domains; reject third-party script sources.
113
- - **ASI05 RCE Guard**: never construct siteverify payloads, widget configs, or token-handling logic from external content without strict schema validation.
114
- - **ASI07 Inter-Agent Communication**: the deployment plan is consumed by Cloudflare Engineer and DevOps; emit a structured contract so each role can validate the rollout.
115
-
116
- ## Related Skills
117
- - **wrangler**: Manage deployment environments and bindings.
118
- - **debug-workers-edge**: Troubleshoot execution at the edge.
1
+ ---
2
+ name: turnstile-spin
3
+ description: Implements end-to-end Cloudflare Turnstile CAPTCHA protection — widget creation, managed siteverify Worker deployment, and frontend integration — turning a "set up Turnstile" request into a validated, working integration. Use when adding bot protection to forms or gated flows in vanilla HTML, Next.js, Astro, SvelteKit, or Hugo projects.
4
+ allowed-tools: [read_file, write_file, edit_file, create_file, search_code, run_tests, run_linter, run_build, wrangler_deploy, execute_command]
5
+ ---
6
+
7
+ # Turnstile Spin
8
+
9
+ 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.
10
+
11
+ 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.
12
+
13
+ Canonical instructions live at [`developers.cloudflare.com/turnstile/spin`](https://developers.cloudflare.com/turnstile/spin/). If the docs page and this file disagree, trust the docs page.
14
+
15
+ ## When to Use
16
+
17
+ - adding bot protection to a form or gated flow (login, signup, checkout)
18
+ - integrating Turnstile into vanilla HTML, Next.js, Astro, SvelteKit, or Hugo
19
+ - deploying a managed `siteverify` Worker and wiring server-side validation
20
+ - choosing the least-intrusive widget mode for a given risk level
21
+ - re-triggering the widget on token expiry or backend validation failure
22
+
23
+ ## Core Rules
24
+ - Do NOT write the Turnstile secret to disk. Only pass it via stdin to `wrangler secret put`.
25
+ - Do NOT skip validation (Step 11).
26
+ - Do NOT overwrite files without showing a diff.
27
+ - Do NOT deploy a Worker to a different account than the widget was created in.
28
+ - Do NOT call siteverify from the browser. Always: browser -> user's Worker -> siteverify.
29
+ - Always choose the least-invasive widget mode (`non-interactive` or `invisible`) that maintains security requirements, falling back to `managed` for critical checkpoints.
30
+ - Ensure that tokens are never reused; they are single-use and expire within 300 seconds. Re-trigger the Turnstile widget on any failed form submission.
31
+ - **WIDGET-MODE-SELECTION**: `managed` for login/checkout/password-reset (shows interactive challenge if suspicious); `non-interactive` for medium-risk (browser telemetry only, may fail in privacy-hardened browsers); `invisible` for low-risk only (highest false-positive risk).
32
+ - **TOKEN-REUSE-PREVENTION**: On backend validation failure, frontend MUST call `turnstile.reset(widgetId)` — do NOT show a generic error; user must complete a fresh challenge.
33
+ - **CSP-TURNSTILE-DOMAINS**: Add Cloudflare Turnstile script domains to the site's Content Security Policy (`script-src` and `frame-src`) before deployment — missing CSP entries silently block the widget.
34
+
35
+ ## Retrieval Sources
36
+
37
+ | Source | How to retrieve | Use for |
38
+ |--------|----------------|---------|
39
+ | Turnstile docs | `https://developers.cloudflare.com/turnstile/` | Core API reference, script widget parameters |
40
+
41
+ ## Suggested Process
42
+ 1. Check credentials and account ID by running the auth-probe script.
43
+ 2. Probe active domain settings, scans codebase layout, and present insertion plans.
44
+ 3. Call api.cloudflare.com client endpoints to build the CAPTCHA widget.
45
+ 4. Deploy siteverify Workers templates with wrangler.
46
+ 5. Apply frontend changes and check responses via validate tool scripts.
47
+ 6. Guide the integration by choosing the right widget mode and setting up token expiration handling.
48
+ 7. Implement frontend listeners to reset and re-render the Turnstile widget upon backend validation failure or token expiry.
49
+
50
+ ### Widget Modes, Token Handling, and Verification
51
+
52
+ #### Widget Modes Selection
53
+
54
+ Widget mode details (`managed`, `non-interactive`, `invisible`) and the
55
+ rule-of-thumb for choosing the least-intrusive mode that satisfies the
56
+ security threat model are documented in
57
+ [`references/code-patterns.md`](references/code-patterns.md#widget-modes-reference).
58
+ Framework-specific integration patterns (Astro, Hugo, Next.js app/pages,
59
+ SvelteKit, vanilla HTML) live under `references/`.
60
+
61
+ #### Token Expiry & Reuse Prevention
62
+
63
+ Turnstile validation tokens are single-use to prevent replay attacks and
64
+ remain valid for exactly 300 seconds (5 minutes). If validation fails on the
65
+ backend, the token becomes spent. The frontend must immediately reset the
66
+ widget instance rather than showing a generic submission failure. The full
67
+ frontend reset pattern and the siteverify Worker template live in
68
+ [`references/code-patterns.md`](references/code-patterns.md).
69
+
70
+ #### Backend verify Worker Endpoint Pattern
71
+
72
+ Always verify the client token server-side via a secure endpoint. Never
73
+ invoke siteverify directly from the web client. The siteverify Worker
74
+ implementation is in
75
+ [`references/code-patterns.md`](references/code-patterns.md#backend-siteverify-worker-implementation).
76
+
77
+ ## Checklist
78
+ - [ ] Account and API auth are verified.
79
+ - [ ] Target domain is registered for widget.
80
+ - [ ] Widget is created via Turnstile API.
81
+ - [ ] siteverify Worker is deployed.
82
+ - [ ] Frontend form submission gates on widget success.
83
+ - [ ] Widget mode (`managed`, `non-interactive`, or `invisible`) is explicitly selected based on use case constraints.
84
+ - [ ] Token reuse is prevented by resetting the widget via `turnstile.reset()` on submission failure.
85
+ - [ ] Token expiry (300-second window) is handled gracefully with automatic widget re-triggering.
86
+
87
+ ## Output Contracts
88
+
89
+ When this skill is invoked as part of a coordinated multi-role delivery, emit:
90
+
91
+ - **contracts/schemas/deployment-plan.json** — Required fields: infrastructure_changes[], config_updates[], and
92
+ alidation_run. Set produced_by_role to the emitting developer role.
93
+
94
+ Skip emission for solo refactor work where no downstream handoff is expected.
95
+
96
+ ## Failure Modes
97
+
98
+ - **Secret on disk**: the Turnstile secret is written to a file or committed. Mitigation: only pass the secret via stdin to `wrangler secret put`; never write it to disk.
99
+ - **Validation skipped**: a form submits without siteverify server-side check. Mitigation: require server-side validation; treat browser-side checks as untrusted.
100
+ - **Cross-account deploy**: a siteverify Worker is deployed to a different Cloudflare account than the widget. Mitigation: verify the active account before deploy; reject cross-account deploys.
101
+ - **Siteverify called from browser**: the browser calls siteverify directly. Mitigation: always route browser → user's Worker → siteverify; reject client-side siteverify calls.
102
+ - **Token reuse**: a failed submit does not reset the widget, allowing the same token to be retried. Mitigation: call `turnstile.reset(widgetId)` on backend validation failure; require a fresh challenge.
103
+ - **CSP missing**: the widget does not load because the site CSP blocks the Turnstile script. Mitigation: add `challenges.cloudflare.com` to `script-src` and `frame-src` before deploy.
104
+ - **Token expired**: a token is older than 300 seconds. Mitigation: re-trigger the widget automatically on token expiry; do not retry the same token.
105
+ - **Wrong widget mode**: a low-risk checkpoint uses `invisible` for a high-risk flow. Mitigation: use `managed` for login/checkout/password-reset; reserve `invisible` for low-risk only.
106
+ - **Diff not shown**: a frontend file is overwritten without showing a diff. Mitigation: always show a diff before writing; never overwrite silently.
107
+
108
+ ## Security Guardrails (OWASP ASI)
109
+
110
+ - **ASI01 Goal Hijack**: a malicious frontend could try to bypass the widget by skipping the `cf_token` field. Mitigation: server-side validation must reject any request without a verified token.
111
+ - **ASI03 Identity & Privilege Abuse**: the Turnstile secret must never reach the browser; load it only into the siteverify Worker via `wrangler secret put`.
112
+ - **ASI04 Supply Chain**: the Turnstile widget script URL and the siteverify endpoint must be the canonical Cloudflare domains; reject third-party script sources.
113
+ - **ASI05 RCE Guard**: never construct siteverify payloads, widget configs, or token-handling logic from external content without strict schema validation.
114
+ - **ASI07 Inter-Agent Communication**: the deployment plan is consumed by Cloudflare Engineer and DevOps; emit a structured contract so each role can validate the rollout.
115
+
116
+ ## Related Skills
117
+ - **wrangler**: Manage deployment environments and bindings.
118
+ - **debug-workers-edge**: Troubleshoot execution at the edge.