edge-logic

Implements A/B testing, redirects, geo-personalization, and feature flags on Cloudflare Workers Static Assets.

Updated Jun 17, 2026
One-click install
npx skills add https://github.com/ccediland/web-stack-skills --skill edge-logic-ccediland
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: edge-logic
Source: https://github.com/ccediland/web-stack-skills/tree/main/plugin/skills/edge-logic
Command: npx skills add https://github.com/ccediland/web-stack-skills --skill edge-logic-ccediland

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding edge logic to a fully prerendered Astro site on Cloudflare Workers is full of traps: Astro middleware silently cannot intercept prerendered pages, run_worker_first couples every pageview to the shared 100k/day invocation cap, Workers Caching bills normally-free asset requests, and Flagship is an unpriced beta. This Skill provides the routing and billing model, decision tables, and code snippets that keep each job on its cheapest correct surface. ## Core Features & Use Cases - Decision forks for five edge jobs: A/B testing, where edge logic lives, geo personalization, feature flags, and redirect surface selection — each with cost, failure mode, and when-to-flip guidance. - Four documented traps: middleware non-interception, run_worker_first billing coupling, Workers Caching charges, and Flagship beta risk, with platform pins and quarterly review-gates. - Ready snippets: client-side A/B assignment script, a geo endpoint reading request.cf, and a custom Worker entry wrapping the adapter handler. - Use Case: You want to run an A/B test on a prerendered marketing site. The Skill steers you to zero-invocation client-side assignment with an inline pre-paint script, and tells you exactly when worker-first assignment is worth the billing risk. ## Quick Start Ask the AI to add an A/B test, redirect rules, geo targeting, or feature flags to your Astro site on Cloudflare Workers Static Assets.

Frequently Asked Questions about edge-logic

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run an A/B test on a Cloudflare Workers static site?▼

Use client-side assignment by default: ship both variants in the prerendered HTML, assign with an inline pre-paint script stored in localStorage, and fire one exposure event to analytics. Switch to worker-first cookie assignment only when flicker hurts the metric or variants must be SEO-visible.

Why doesn't Astro middleware work on prerendered pages?▼

Middleware runs at build time for prerendered pages, so nothing executes at runtime. The asset layer also answers matching requests before the Worker runs, and even worker-first the adapter handler falls back to the ASSETS binding without entering the render pipeline.

What is the run_worker_first billing risk on Cloudflare Workers Free?▼

run_worker_first makes every matched request a billed invocation, sharing the single 100,000 requests/day Free-plan cap with endpoints like forms. Over the cap, matched pages return 429, so scope globs narrowly and exclude subresources like /_astro/*.

How do I add geo personalization to a static Astro site?▼

Use client-side heuristics like timezone and navigator.language for coarse cases, or a tiny on-demand endpoint returning request.cf fields cached in sessionStorage for real country data. Reserve worker-first edge rewrites for geo content that must be crawlable in the initial HTML.

Which redirect surface should I use on Cloudflare: _redirects, Redirect Rules, or Bulk Redirects?▼

Default to the _redirects file for path-to-path moves since it lives in git and costs zero invocations. Use Redirect Rules for cross-host or scheme redirects, Bulk Redirects for migrations past 2,000 URLs, and Worker code only for computed targets.

Should I use Cloudflare Flagship for feature flags?▼

Prefer build-time env flags on a fully prerendered site since flipping is just a git push with zero invocations. Use Flagship only for runtime toggles in code already running in the Worker, noting it is a public beta with no published pricing.