AGENT SKILL

cloudflare-workers

Builds and deploys high-performance edge logic on Cloudflare Workers. Use when working within Workers' 128MB memory and 5–50ms CPU constraints, integrating KV/R2/D1 storage, or writing Wrangler-managed edge-first request/response code.

License 许可
MIT
最近更新
2026-05-27
Stars
★ 0
Forks
0

01 前言 Front Matter

name
cloudflare-workers
vendor
cloudflare
description
Builds and deploys high-performance edge logic on Cloudflare Workers. Use when working within Workers' 128MB memory and 5–50ms CPU constraints, integrating KV/R2/D1 storage, or writing Wrangler-managed edge-first request/response code.

03 SKILL.md 正文

Skill: Cloudflare Workers

Policy Capsule

  • Respect the Worker resource envelope: 128MB memory and 5–50ms CPU per invocation; design code paths to fit inside it.
  • Configure and deploy via Wrangler; do not hand-roll deployment scripts.
  • Pick the right storage primitive: KV for simple key-value, R2 for object storage, D1 for relational data.
  • Use the standard Fetch API for outgoing HTTP; never reach for Node-flavored HTTP clients.
  • Store secrets with wrangler secret; never commit secrets to source.
  • Minimize sub-requests per invocation to stay under platform limits.
  • Stream large payloads via TransformStream; never buffer them entirely into memory.
  • Install a global error handler so a single failing request does not take down the worker.

Guidelines for building and deploying high-performance serverless logic at the edge.

1. Core Principles

  • Edge First: Run code as close to the user as possible.
  • Resource Constraints: Be mindful of the 128MB memory limit and the strict CPU time limits (e.g., 5-50ms) for workers.
  • Cold Starts: Workers have near-zero cold starts, but external resource initialization must be optimized.

2. Technical Standards

  • Routing: Use Wrangler for configuration and local development.
  • Storage Integration: Use KV for simple key-value needs, R2 for object storage, and D1 for relational data.
  • Fetch API: Always use the standard Fetch API for outgoing network requests.
  • Security: Use wrangler secret for environment variables and API keys.

3. Best Practices

  • Sub-requests: Minimize the number of sub-requests per worker invocation to stay within limits.
  • Streaming: Use the TransformStream API for processing large payloads without loading everything into memory.
  • Error Handling: Implement robust global error handlers to prevent total worker failure on a single request error.

04 同仓库更多 Skills

chrisbarrantes
chrisbarrantes/mandrel

no-capsule-skill

Fixture without a Policy Capsule section.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

backend-security-patterns

Combined backend protocols for authentication (Clerk JWT verification) and PII-safe observability. Use when handling auth on the server, verifying Clerk webhooks via `svix`, scoping metadata via `publicMetadata`/ `privateMetadata`, or sanitizing logs to keep emails, tokens, and request bodies out of telemetry.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

vitest

Writes fast, isolated unit and integration tests with Vitest. Use when each test must run on file-save without shared state — `vi.mock()` for external deps, `vi.spyOn()` for call monitoring, AAA structure, and edge-case coverage for null/undefined/boundary inputs.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

playwright

Robust E2E browser testing with Playwright. Use when writing browser-driven tests — leverage auto-waiting (no `waitForTimeout`), prefer user-visible locators (`getByRole`, `getByText`, `getByLabel`) over CSS/XPath, reuse `storageState` for auth, and enable trace-on-first-retry for CI debugging.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

playwright-bdd

Wires Gherkin `.feature` files to Playwright via the `playwright-bdd` library. Use when running BDD scenarios on a Playwright runtime — pairs with the `gherkin-authoring` skill (scenario prose) and the `playwright` skill (browser conventions). Drives execution by tag expression with trace-first debugging and Playwright-native sharding.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

lighthouse-baseline

Codifies the capture-and-check baseline pattern for long-running quality signals (Lighthouse scores, bundle size, p95 latency, runtime memory). Use when wiring a new metric that needs a baseline file, paired :capture / :check npm scripts, a tolerance-bounded gate, and a weekly refresh cadence — the goal is a hard CI signal that ratchets only with intent.

★ 0