Code & Engineering

Cloudflare Workers Review: D1, OpenNext, Fetch

Reviews pasted Cloudflare Workers code and configuration (a Worker, a Next.js app on OpenNext, D1 queries, wrangler config) for platform pitfalls that pass every local test and then fail in production or quietly cost money. It flags the edge runtime under OpenNext, a fetch to your own Worker's workers.dev address (error 1042), D1 queries that bind more than 100 parameters as data grows, LIKE patterns over D1's 50-byte limit, reading rowsAffected where D1 returns meta.changes, interactive transactions D1 does not have, secrets kept in plain vars, outbound fetch code that treats only a thrown error as failure, a browser User-Agent that bot protection challenges, client hop-by-hop headers forwarded to fetch, cron triggers whose day of the week is written as numbers, and unbounded queries on the request path. Each finding has a fixed code, the place, the reason and a fix, then one verdict. Use to review a Cloudflare Worker before deploy, check D1 or wrangler code, or audit a Next.js app running on Cloudflare.

Cloudflare Workers Review: D1, OpenNext, Fetch is a SKILL.md that reviews pasted Cloudflare Workers code and configuration (a Worker, a Next.js app on OpenNext, D1 queries, wrangler config) for platform pitfalls that pass every local test and then fail in production or quietly cost money; an agent buys it once for $0.05 over x402.

Tested 2026-10-08No code, no hidden instructionsv1.2.0 · 9.8 KB · perpetual license

Not for

General code review, style, performance tuning or security beyond the listed pitfalls, and anything that needs the running system: it reads pasted code, so it cannot see indexes, data sizes or bindings that the paste does not show, and it does not cover Durable Objects, Queues or KV.

Tested, honestly

Tested 2026-10-08 with a strong and a weak model.

With and without the skill

Results with and without the skill, for Sonnet and Haiku
SonnetHaiku
withwithoutwithwithout
Planted pitfalls named (19 snippets)19/1916/1919/1912/19

One run per model and snippet, the same word-based check on both sides, every miss read by hand. Without the skill Sonnet missed three: both browser User-Agent snippets (it objected to the header on grounds of terms and brittleness, never that from a Worker it is what gets challenged) and the Sunday cron written as 0, which it did not know Cloudflare refuses; it did catch 1-5 as Sunday to Thursday. Haiku without the skill missed the same three, the 1-5 range, the edge runtime under OpenNext twice and D1's 50-byte LIKE limit. With the skill Haiku found all nineteen in substance; four of its answers broke the line format.

Same cases and the same checks with and without the skill. The cases are ours, written around what the skill is for; with a handful of cases, a difference of one or two is within noise.

SonnetStrong model, claude-sonnet-5-5
Version 1.2, all thirty-three snippets: named every planted pitfall with the right code and verdict, including the new cron weekday one (a Sunday cleanup written as 0, which Cloudflare refuses at deploy, and a Monday-to-Friday report written as 1-5, which runs Sunday to Thursday), and left all fourteen correct snippets alone, among them a cron written with day names and one written 2-6 under a Monday-to-Friday comment.
HaikuWeak model, claude-haiku-5-5
Named every planted pitfall in substance, but still slipped on the answer format four times with the skill: twice the verdict line was misplaced or left empty, once text followed the verdict, and once a correct hop-by-hop finding came without its code in brackets.

Full test summary

Example

Our own test text, before and after the skill ran. Excerpts only.

English · claude-sonnet-5-5

Before

// src/index.ts — a plain Worker, deployed with wrangler deploy export default { async fetch(): Promise<Response> { return new Response("hello"); }, };

After

No findings. Verdict: no known pitfalls

What is in the file

  • The answer
  • The codes
  • Rules
  • Work in this order
  • Short example

Languages

Any language. Tried in: English.

License

Perpetual, non-exclusive; use and modify for yourself incl. paid work; no resale or republishing. Holder: Georgi Kalchev, aiskills402.com. Full terms.

Versions

Current version 1.2.0, updated 2026-10-09. Whoever bought an earlier version gets new ones free through the same re-download token.

  1. v1.2.0 · 2026-10-08

    New: `[CRON-WEEKDAY]`, a wrangler cron trigger whose day-of-week field uses numbers. Cloudflare counts them from 1 = Sunday, so `1-5` runs Sunday to Thursday instead of Monday to Friday, and `0` (as in `0 3 * * 0` for every Sunday) is refused at deploy, which leaves the new code uploaded with the old schedule. The finding is in the group that breaks at once and names both effects; the fix is the day names (`MON-FRI`, `SUN`). A numeric range that really is Monday to Friday (`2-6`) is not flagged. Measured on 8 October 2026 with a throwaway Worker.

    Price stays $0.05. Measured value for the strong model: Sonnet 16 of 19 planted pitfalls without the skill, 19 of 19 with it (the misses: both browser User-Agent snippets and the Sunday cron written as 0).

  2. v1.1.0 · 2026-10-08

    Three platform facts measured again on the day with throwaway Workers. New: `[WORKERS-DEV-FETCH]`, a fetch to the workers.dev address of another Worker on the same account, which Cloudflare answers with 404 and error 1042 (fix: a service binding or the global_fetch_strictly_public flag; a custom domain is not flagged). New: `[BROWSER-UA]`, a browser User-Agent on outbound fetch, which bot protection challenges from a Worker while a bare request passes. `[HOP-BY-HOP]` now says what a forwarded `upgrade` does on the edge (the POST becomes a GET handshake without a body) and also catches filters that drop only part of the hop-by-hop set. Fetch codes apply only to code that runs in a Worker, and `[FETCH-STATUS]` now says that code which already checks the status, or a proxy that passes it on, is not a finding.

    Price changed from $0.03 to $0.05. Measured value for the strong model: Sonnet 15 of 17 planted pitfalls without the skill, 17 of 17 with it (both misses were the browser User-Agent).

  3. v1.0.0 · 2026-10-08

    First release: reviews pasted Cloudflare Workers code and configuration for platform pitfalls and lists each with a fixed code, the place, the reason and a fix, then a verdict (will break, fix before deploy, no known pitfalls). Breaks at once: the edge runtime under OpenNext, interactive D1 transactions. Breaks later or costs money: more than 100 bound D1 parameters, LIKE patterns over 50 bytes, rowsAffected instead of meta.changes, fetch code that only catches thrown errors, forwarded hop-by-hop headers, secrets in vars, unbounded queries on the request path.

FAQ

Which pitfalls does it look for?

Twelve: the edge runtime under OpenNext, interactive D1 transactions, a cron weekday written as a number, a fetch to your own Worker's workers.dev address (error 1042), D1 queries past 100 bound parameters, LIKE patterns over 50 bytes, rowsAffected where D1 returns meta.changes, fetch code that only catches thrown errors, a browser User-Agent that bot protection challenges, forwarded hop-by-hop headers, secrets in plain vars and unbounded queries on the request path. Each was checked in the documentation or measured by us; the three fetch pitfalls of 1.1 were measured again on 8 October 2026.

Does it help Claude Sonnet?

A little, on measured facts. Without the skill Sonnet named sixteen of the nineteen planted pitfalls. It missed both browser User-Agent snippets (it called the header impolite or brittle, never that from a Worker it is what bot protection challenges) and a Sunday cron written as 0, which Cloudflare refuses at deploy. With the skill it named all nineteen. Haiku went from twelve to nineteen. The rest is the fixed codes and a verdict line a pipeline can act on.

Will it flag code that is fine?

Rarely, but not never. With version 1.1 Sonnet left all twelve correct snippets alone, including code that already uses a service binding or the global_fetch_strictly_public flag; Haiku flagged public vars holding a site address and a locale as secrets. A draft of 1.1 made Sonnet flag the fetch status on code that already checked it; that wording was fixed and the affected snippets were run again before release.

Is calling my other Worker with fetch always a problem?

No. We measured error 1042 only for the workers.dev address of a Worker on the same account; the other Worker's custom domain answered normally, even inside the same zone, so the skill leaves that alone. A service binding or the global_fetch_strictly_public compatibility flag removes the error, and the skill does not flag code that already uses either.

Read more

Share

Read this page as Markdown: /skills/workers-pitfalls-review.md.

  • Code Review

    Code & Engineering

    SKILL.md · v1.0.4 · 6.0 KB

    Reviews a code change (a diff or a changed file pasted as text) and reports real problems ranked by severity — correctness bugs, security holes, data loss, missing error handling, edge cases, resource leaks — each with location, reason and a concrete fix in words. Use when asked to review code, a diff or a pull request, check a change for bugs, or find security problems in a snippet.

    $0.01once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 30 Sep 2026

  • SQL Query Optimizer for D1, SQLite and Turso

    Code & Engineering

    SKILL.md · v1.0.2 · 9.8 KB

    Reviews SQL queries, schemas and migrations for SQLite, Cloudflare D1 and Turso, where the bill and the speed follow the rows a query READS, not the rows it returns. Finds full scans hidden behind LIMIT, aggregates over growing tables, index column gaps, NOT IN, OR, functions and LIKE patterns that switch an index off, OFFSET pagination, N+1 loops, the D1 limit of 100 bound parameters, tables that never shrink and new flag columns that turn the whole history into pending work; ranks them by cost and gives the index or rewrite that fixes each. Use when asked to optimize a SQL query, review a database schema or a migration, find a slow query, or cut rows read on D1, SQLite or Turso.

    $0.05once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 3 Oct 2026

  • Unexpected Cloud Bill Spike: Find the Cause

    Code & Engineering

    SKILL.md · v1.0.0 · 15.9 KB

    Finds the loops behind a bill spike or an unexpected bill. Reviews a web app's code and config for loops and repeats that run up the bill on their own on Vercel, Turso, Cloudflare Workers and D1 and paid AI APIs. Finds two schedulers on one job, retries without a cap, work that triggers itself, client polling and React render loops, caches cleared on every write, middleware running on every static file, queues that resend failures forever, image settings that multiply transformations, health checks that count whole tables, alerts sent on every run and bots crawling endless filter URLs. Counts the runs per month, names the billed unit, ranks by cost and gives the change that stops each one. Use when asked why a Vercel, Turso or Cloudflare bill jumped, to find an infinite loop or a runaway cost, or to review a cron job, webhook, queue consumer, middleware or polling code before it ships.

    $0.05once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 4 Oct 2026

More in Code & Engineering

  • Spend Cap Review: Do Cost Limits Really Stop?

    Code & Engineering

    SKILL.md · v1.0.1 · 8.1 KB

    Reviews pasted code and configuration that spends money (paid AI or API calls, purchases, paid lookups, anything billed per use) and checks whether the limit on that spending really stands in the way of the spending. It flags a cap that sits beside the path instead of on it (a gateway limit while a script calls the provider directly, a counter only in the browser), a missing setting that means no limit, an alert or a budget email used as the protection, a cap that the caller sets through a header or a request field, a paid job that runs by default, a per-call cap with no running total, a total kept where it resets, a cap checked only after the money is gone, and a spend counter whose failure or missing value lets the call through. Each finding has a fixed code, the place, the reason and a fix, then one verdict. Use before deploying a Worker, script or job that pays per call, or when a cap exists and you want to know if it can fail silently.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026

  • Test Review: Can This Test Ever Fail?

    Code & Engineering

    SKILL.md · v1.0.1 · 10.3 KB

    Reviews a pasted test, check script, smoke test, mutation script or CI step and says whether it can fail when the thing it guards is broken, so a green result is worth something. It finds a completeness guard that counts its own hard-coded list instead of the directory, a one-star glob that never enters subfolders, a mutation script that restores with git checkout and wipes the uncommitted fix under test, a null test that an empty string passes, a status 200 that is only the login page, a wait loop without sleep that measures network speed instead of time, a test that calls the pure function directly and never the call site, a counterfactual control whose data does not create the condition, a fix copied into two branches and tested in one, a limit tested only with ordinary values, and a catch that turns a failure into success. Each finding has a fixed code, the place, why it passes and the one input that would make it fail, or exactly No findings. Use to review a test that cannot fail, a check script that always passes, or a guard before you trust it.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026

  • Cloudflare Rate Limit Review: WAF, Workers, 429

    Code & Engineering

    SKILL.md · v1.0.0 · 9.8 KB

    Reviews a rate-limiting setup on Cloudflare (a WAF rate limiting rule, a Workers Rate Limiting binding, or a counter in your own code) and lists every reason it will not limit what its author thinks it limits. It flags free-plan rules that use the client address or a header field, which the plan refuses, windows the plan does not offer, an address key for callers that are themselves Workers and share one outbound address, a binding number treated as a global figure when each isolate counts for itself, a raw IPv6 address as a key, per-client limits with no global ceiling on a costly action, load tests fired without waiting a full window, one known attacker handled with a rule instead of an IP Access Rule, and a 429 without Retry-After. Each finding has a fixed code, the place, the reason and a fix, then one verdict. Use to check or design rate limiting for an API, a pay endpoint or an agent-facing endpoint on Cloudflare.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026

  • Cloudflare Image Review: Quota, WebP, R2

    Code & Engineering

    SKILL.md · v1.0.0 · 13.1 KB

    Reviews a pasted image pipeline (upload or AI generation, storage in R2, resizing, serving through Cloudflare image transformations, a Next.js loader, a sharp or WebP script) for the traps that quietly ship huge or broken images or spend a shared quota. It flags photographs stored as PNG, files stored exactly as a generator returned them, a redirect-on-error setting that hides an exhausted transformation quota, a list of widths that multiplies the unique-transformation count, widths above the original, transformations "turned off" while the images binding or the zone setting stays on, lossy WebP on charts and infographics, a job that re-encodes WebP that is already lossy, a preview subdomain mistaken for a zone, an original overwritten by a backdated fix, and self-made variants that can 404. Each finding has a fixed code, the place, the reason and a fix, then one verdict. Use to review an image pipeline, Cloudflare image transformations or WebP handling before it ships.

    $0.03once

    • x402
    • USDC
    • Base
    Get skill

    Tested with Sonnet and Haiku, 8 Oct 2026