$npx -y skills add getsentry/sentry-for-ai --skill sentry-cloudflare-sdkFull Sentry SDK setup for Cloudflare Workers and Pages. Use when asked to "add Sentry to Cloudflare Workers", "install @sentry/cloudflare", or configure error monitoring, tracing, logging, crons, or AI monitoring for Cloudflare Workers, Pages, Durable Objects, Queues, Workflows,
| 1 | > [All Skills](../../SKILL_TREE.md) > [SDK Setup](../sentry-sdk-setup/SKILL.md) > Cloudflare SDK |
| 2 | |
| 3 | # Sentry Cloudflare SDK |
| 4 | |
| 5 | Opinionated wizard that scans your Cloudflare project and guides you through complete Sentry setup for Workers, Pages, Durable Objects, Queues, Workflows, and Hono. |
| 6 | |
| 7 | ## Invoke This Skill When |
| 8 | |
| 9 | - User asks to "add Sentry to Cloudflare Workers" or "set up Sentry" in a Cloudflare project |
| 10 | - User wants to install or configure `@sentry/cloudflare` |
| 11 | - User wants error monitoring, tracing, logging, crons, or AI monitoring for Cloudflare Workers or Pages |
| 12 | - User asks about `withSentry`, `sentryPagesPlugin`, `instrumentDurableObjectWithSentry`, or `instrumentD1WithSentry` |
| 13 | - User wants to monitor Durable Objects, Queues, Workflows, Scheduled handlers, or Email handlers on Cloudflare |
| 14 | |
| 15 | > **Note:** SDK versions and APIs below reflect current Sentry docs at time of writing (`@sentry/cloudflare` v10.61.0). |
| 16 | > Always verify against [docs.sentry.io/platforms/javascript/guides/cloudflare/](https://docs.sentry.io/platforms/javascript/guides/cloudflare/) before implementing. |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ## Phase 1: Detect |
| 21 | |
| 22 | Run these commands to understand the project before making any recommendations: |
| 23 | |
| 24 | ```bash |
| 25 | # Detect Cloudflare project |
| 26 | ls wrangler.toml wrangler.jsonc wrangler.json 2>/dev/null |
| 27 | |
| 28 | # Detect existing Sentry |
| 29 | cat package.json 2>/dev/null | grep -E '"@sentry/' |
| 30 | |
| 31 | # Detect project type (Workers vs Pages) |
| 32 | ls functions/ functions/_middleware.js functions/_middleware.ts 2>/dev/null && echo "Pages detected" |
| 33 | cat wrangler.toml 2>/dev/null | grep -E 'main|pages_build_output_dir' |
| 34 | |
| 35 | # Detect framework |
| 36 | cat package.json 2>/dev/null | grep -E '"hono"|"remix"|"astro"|"svelte"' |
| 37 | |
| 38 | # Detect Durable Objects |
| 39 | cat wrangler.toml 2>/dev/null | grep -i 'durable_objects' |
| 40 | |
| 41 | # Detect D1 databases |
| 42 | cat wrangler.toml 2>/dev/null | grep -i 'd1_databases' |
| 43 | |
| 44 | # Detect Queues |
| 45 | cat wrangler.toml 2>/dev/null | grep -i 'queues' |
| 46 | |
| 47 | # Detect Workflows |
| 48 | cat wrangler.toml 2>/dev/null | grep -i 'workflows' |
| 49 | |
| 50 | # Detect Scheduled handlers (cron triggers) |
| 51 | cat wrangler.toml 2>/dev/null | grep -i 'crons\|triggers' |
| 52 | |
| 53 | # Detect compatibility flags |
| 54 | cat wrangler.toml 2>/dev/null | grep -i 'compatibility_flags' |
| 55 | cat wrangler.jsonc 2>/dev/null | grep -i 'compatibility_flags' |
| 56 | |
| 57 | # Detect AI/LLM libraries |
| 58 | cat package.json 2>/dev/null | grep -E '"openai"|"@anthropic-ai"|"ai"|"@google/generative-ai"|"@langchain"' |
| 59 | |
| 60 | # Detect logging libraries |
| 61 | cat package.json 2>/dev/null | grep -E '"pino"|"winston"' |
| 62 | |
| 63 | # Check for companion frontend |
| 64 | ls frontend/ web/ client/ 2>/dev/null |
| 65 | cat package.json 2>/dev/null | grep -E '"react"|"vue"|"svelte"|"next"' |
| 66 | ``` |
| 67 | |
| 68 | **What to determine:** |
| 69 | |
| 70 | | Question | Impact | |
| 71 | |----------|--------| |
| 72 | | Workers or Pages? | Determines wrapper: `withSentry` vs `sentryPagesPlugin` | |
| 73 | | Hono framework? | Recommend standalone `@sentry/hono` package (v10.55.0+) for cleaner integration | |
| 74 | | `@sentry/cloudflare` already installed? | Skip install, go to feature config | |
| 75 | | Durable Objects configured? | Recommend `instrumentDurableObjectWithSentry` | |
| 76 | | D1 databases bound? | `withSentry` auto-instruments D1 bindings (v10.57.0+); no manual wrapping needed | |
| 77 | | Queues configured? | `withSentry` auto-instruments queue handlers | |
| 78 | | Workflows configured? | Recommend `instrumentWorkflowWithSentry` | |
| 79 | | Cron triggers configured? | `withSentry` auto-instruments scheduled handlers; recommend Crons monitoring | |
| 80 | | `nodejs_als` or `nodejs_compat` flag set? | **Required** — SDK needs `AsyncLocalStorage` | |
| 81 | | AI/LLM libraries? | Recommend AI Monitoring integrations | |
| 82 | | Companion frontend? | Trigger Phase 4 cross-link | |
| 83 | |
| 84 | --- |
| 85 | |
| 86 | ## Phase 2: Recommend |
| 87 | |
| 88 | Present a concrete recommendation based on what you found. Don't ask open-ended questions — lead with a proposal: |
| 89 | |
| 90 | **Recommended (core coverage):** |
| 91 | - ✅ **Error Monitoring** — always; captures unhandled exceptions in fetch, scheduled, queue, email, and Durable Object handlers |
| 92 | - ✅ **Tracing** — automatic HTTP request spans, outbound fetch tracing, D1 query spans |
| 93 | |
| 94 | **Optional (enhanced observability):** |
| 95 | - ⚡ **Logging** — structured logs via `Sentry.logger.*`; recommend when log search is needed |
| 96 | - ⚡ **Crons** — detect missed/failed scheduled jobs; recommend when cron triggers are configured |
| 97 | - ⚡ **D1 Instrumentation** — automatic query spans and breadcrumbs; recommend when D1 is bound |
| 98 | - ⚡ **Durable Objects** — automatic error capture and spans for DO methods; recommend when DOs are configured |
| 99 | - ⚡ **Workflows** — automatic span creation for workflow steps; recommend when Workflows are configured |
| 100 | - ⚡ **AI Monitoring** — Vercel AI SDK, OpenAI, An |