mirror of
https://github.com/cloudflare/skills.git
synced 2026-09-14 16:49:26 +08:00
Make Cursor Workers rule relevance-selected and align defaults
This commit is contained in:
+10
-49
@@ -1,59 +1,20 @@
|
||||
---
|
||||
description: Guidance for building applications on Cloudflare Workers or with frameworks that deploy to Cloudflare Workers.
|
||||
description: Guidance for writing, reviewing, or configuring Cloudflare Workers and applications deployed to Workers.
|
||||
alwaysApply: false
|
||||
globs:
|
||||
- "**/*.ts"
|
||||
- "**/*.tsx"
|
||||
- "**/*.js"
|
||||
- "**/*.mts"
|
||||
- "**/*.mjs"
|
||||
- "wrangler.jsonc"
|
||||
- "wrangler.json"
|
||||
- "wrangler.toml"
|
||||
- "worker-configuration.d.ts"
|
||||
- "**/workers/**"
|
||||
- "**/worker/**"
|
||||
---
|
||||
|
||||
# Cloudflare Workers
|
||||
|
||||
Your knowledge of Cloudflare Workers APIs and limits may be outdated. Always retrieve [current documentation](http://developers.cloudflare.com/) when an affected API signature, configuration field, runtime behavior, or limit is uncertain or the task requests current guidance.
|
||||
Your knowledge of Cloudflare Workers APIs, types, and configuration may be outdated. **Prefer retrieval over pre-training.** Use the project's installed versions, generated types, and compatibility settings as the baseline. Retrieve relevant Cloudflare documentation to verify API, configuration, runtime behavior, and limit claims.
|
||||
|
||||
## Docs
|
||||
## Workers Defaults
|
||||
|
||||
- https://developers.cloudflare.com/workers/
|
||||
- Cloudflare MCP (`docs` tool): `https://mcp.cloudflare.com/mcp`
|
||||
- **Keep compatibility dates current.** Use today's date for new Workers. Encourage periodic updates for existing Workers, reviewing compatibility changes and running relevant tests.
|
||||
- **Enable logs and traces.** When creating or preparing a Worker for production, set `observability.enabled` and `observability.traces.enabled` to `true`. The top-level setting alone does not enable traces. Use structured JSON logging and configure sampling for the workload. During reviews, flag missing logs or traces. See [Workers Logs](https://developers.cloudflare.com/workers/observability/logs/workers-logs/) and [Traces](https://developers.cloudflare.com/workers/observability/traces/).
|
||||
- **Keep binding types in sync.** Run `wrangler types` after changing bindings in the project's Wrangler configuration, whether JSONC, JSON, or TOML.
|
||||
|
||||
When citing or relying on a limit or quota, verify it on the product's `/platform/limits/` page.
|
||||
## Shared Guidance
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Purpose |
|
||||
|---------|---------|
|
||||
| `npx wrangler dev` | Local development |
|
||||
| `npx wrangler deploy` | Deploy to Cloudflare |
|
||||
| `npx wrangler types` | Generate TypeScript types |
|
||||
|
||||
Run `wrangler types` after changing bindings in wrangler.jsonc.
|
||||
|
||||
## Node.js Compatibility
|
||||
|
||||
If you encounter `Dynamic require of "X" is not supported` or missing Node.js APIs:
|
||||
|
||||
```jsonc
|
||||
{
|
||||
"compatibility_flags": ["nodejs_compat"],
|
||||
"compatibility_date": "YYYY-MM-DD" // Use today's date
|
||||
}
|
||||
```
|
||||
|
||||
Docs: https://developers.cloudflare.com/workers/runtime-apis/nodejs/
|
||||
|
||||
## Errors
|
||||
|
||||
- **Error 1102** (CPU/Memory exceeded): Retrieve limits from `/workers/platform/limits/`
|
||||
- **All errors**: https://developers.cloudflare.com/workers/observability/errors/
|
||||
|
||||
## Product Docs
|
||||
|
||||
For products used by the Worker, find the relevant documentation in the [Cloudflare docs directory](https://developers.cloudflare.com/directory/). Retrieve the API reference, configuration guidance, or limits needed for the task.
|
||||
- Use [workers-best-practices](../skills/workers-best-practices/SKILL.md) for runtime patterns, anti-patterns, configuration, and platform API checks. Read the references relevant to the task.
|
||||
- Use [wrangler](../skills/wrangler/SKILL.md) for CLI commands and deployment configuration.
|
||||
- Find documentation for products used by the Worker in the [Cloudflare docs directory](https://developers.cloudflare.com/directory/). Verify limits and quotas against the affected product's documentation.
|
||||
|
||||
Reference in New Issue
Block a user