cloudflare-static-assets

cloudflare-static-assets is a skill for Claude Code from atman-33/workhub. It costs 48 tokens per session (1,583 once invoked), scanned A, original, MIT.

A guide for serving files from a React Router application's public folder when deploying it to Cloudflare Workers.

In plain words
What is it for?
Use it to configure Cloudflare Static Assets and access public files consistently in development and production.
Why use it?
Files that work automatically during local Vite development can return 404 errors in production unless Cloudflare Static Assets are configured.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the stack-cloudflare plugin — 1 skill shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/atman-33/workhub/cloudflare-static-assets
Any agent
npx skills add atman-33/workhub --skill cloudflare-static-assets
Clone the repo
git clone --depth 1 https://github.com/atman-33/workhub

Made for: Claude Code.

Or install stack-cloudflare, the plugin that ships this one along with the rest of its 1 skill.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cloudflare-static-assets

README.md
[![agentmods](https://agentmods.dev/badge/skills/atman-33/workhub/cloudflare-static-assets.svg)](https://agentmods.dev/skills/atman-33/workhub/cloudflare-static-assets)
Your own site
<a href="https://agentmods.dev/skills/atman-33/workhub/cloudflare-static-assets"><img src="https://agentmods.dev/badge/skills/atman-33/workhub/cloudflare-static-assets.svg" alt="Measured on agentmods" height="20"></a>
Per session 48 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,583 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00048 $0.01583
Opus 5 $0.00024 $0.00792
Sonnet 5 $0.00010 $0.00317
Haiku 4.5 $0.00005 $0.00158

Measured 2d ago against content hash c3b50471cc22, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

cloudflare-static-assets scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const response = await context.cloudflare.env.ASSETS.fetch(assetRequest);
plugins/stack-cloudflare/skills/cloudflare-static-assets/SKILL.md · 249 lines

How it starts

The opening of the file, as written. The whole thing — 249 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Cloudflare Static Assets

Overview

This skill provides a robust solution for handling static assets in React Router applications deployed to Cloudflare Workers. It addresses the common issue where files in the public directory work in development (Vite) but fail with 404 errors in production due to differences in how assets are served.

Problem Context

Development vs Production Mismatch:

  • Development (Vite): Files in public/ are automatically served at the root path
  • Production (Cloudflare Workers): Static files need to be configured separately as Static Assets

This causes code like fetch('/data/config.json') to work locally but fail with 404 in production.

Solution: Configuration + Utility Functions

Step 1: Configure wrangler.jsonc

Enable Static Assets by adding the assets configuration:

{
  "compatibility_date": "2024-11-18",
  "assets": {
    "directory": "./public",
    "binding": "ASSETS"
  }
}

Step 2: Create Utility Functions

Create app/lib/utils/static-assets.ts (or similar path) with the following implementation:

/**
 * Static Assets Utility
 * 
 * Provides unified access to static files across different environments:
 * - Development (Vite): Uses standard fetch()
 * - Production (Cloudflare Workers): Uses ASSETS binding
 * - Build time (Node.js): Falls back to file system access
 */

interface CloudflareContext {
  cloudflare?: {
    env: Env;
  };
}

/**
 * Determines if we have access to Cloudflare Workers ASSETS binding
 */
function hasAssetsBinding(context?: CloudflareContext): boolean {
  return !!context?.cloudflare?.env?.ASSETS;
}

/**
 * Fetches a static asset with automatic fallback between ASSETS and standard fetch
 */
export async function fetchStaticAsset(
  path: string,
  context?: CloudflareContext,
  request?: Request,
): Promise<Response> {
  const normalizedPath = path.startsWith("/") ? path : `/${path}`;

  // Try Static Assets first if available
  if (hasAssetsBinding(context) && context?.cloudflare?.env?.ASSETS) {
    try {
      const assetUrl = new URL(normalizedPath, "https://example.com");
      const assetRequest = new Request(assetUrl.toString());
      const response = await context.cloudflare.env.ASSETS.fetch(assetRequest);

      if (response.ok) return response;

      // Log fallback only in development
      if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
        console.warn(
          `[Static Assets] Failed for ${normalizedPath} (${response.status}), using fallback`
        );
      }
    } catch (error) {
      // Log errors only in development
      if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
        console.warn(`[Static Assets] Error for ${normalizedPath}:`, error);
      }
    }
  }

  // Fallback: Use standard fetch
  let url = normalizedPath;
  if (request) {
    const requestUrl = new URL(request.url);
    url = `${requestUrl.origin}${normalizedPath}`;
  }

  const response = await fetch(url);
  if (!response.ok) {
    throw new Error(
      `Static asset not found: ${normalizedPath} (${response.status})`
    );
  }

  return response;
}

/**
 * Fetches and parses a JSON static asset
 */
export async function fetchStaticJSON<T>(
  path: string,
  context?: CloudflareContext,
  request?: Request,
): Promise<T> {
  try {
    const response = await fetchStaticAsset(path, context, request);
    const json = await response.json();
    return json as T;
  } catch (error) {
    // Log detailed errors only in development
    if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
      console.error(`Failed to fetch static JSON ${path}:`, error);
    }
    throw new Error(`Failed to load JSON asset: ${path}`);
  }
}

/**
 * Fetches a text static asset
 */
export async function fetchStaticText(
  path: string,
  context?: CloudflareContext,
  request?: Request,
): Promise<string> {
  try {
    const response = await fetchStaticAsset(path, context, request);
    const text = await response.text();
    return text;
  } catch (error) {
    // Log detailed errors only in development
    if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
      console.error(`Failed to fetch static text ${path}:`, error);
    }
    throw new Error(`Failed to load text asset: ${path}`);
  }
}

Read the full file on GitHub · 249 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 249 lines · 48 tokens per session scan A c3b50471cc22

Subscribe to this mod's changes

cloudflare-static-assets is a skill published in the GitHub repository atman-33/workhub (2 stars, last pushed yesterday), licensed MIT. It adds 48 tokens to every session and 1,583 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories