Skip to main content
skill CX Codex

cloudflare-workers-multi-lang — Claude Code skill: setup & use

cloudflare-workers-multi-lang guides Cloudflare Workers development in Rust, Python, and WebAssembly. Useful when offloading heavy computation to WASM modules.

MIT 317 installs ★ 250 updated 2026-10-20

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add secondsky/claude-skills --skill cloudflare-workers-multi-lang -a claude-code
Open on GitHub

What cloudflare-workers-multi-lang does

This skill guides you through developing Cloudflare Workers outside JavaScript and TypeScript. For Rust, it scaffolds Cargo.toml with worker and wasm-bindgen, enabling Link-Time Optimization (lto = true) and binary size optimizations. Building Rust modules requires wasm-pack installed via Cargo beforehand.

For Python workloads, the skill generates pyproject.toml configurations powered by hatchling for Python 3.12 and newer. When integrating WebAssembly into TypeScript, it sets up streaming instantiation and caches instances in memory.

It also provides a troubleshooting matrix for common runtime failures. These include wasm-bindgen version mismatches, memory exhaustion, startup timeouts caused by heavy imports, and missing COOP/COEP headers.

What it helps with

  • Scaffold a Rust-based Cloudflare Worker using wasm-pack
  • Wire a compiled WebAssembly binary into an existing TypeScript worker
  • Configure a Python 3.12 worker project with hatchling
  • Resolve wasm-bindgen mismatches and CPU timeout errors

Example prompts for the agent

  • Set up a Cloudflare Worker in Rust for heavy computation using the worker crate
  • Show how to import and instantiate a .wasm binary inside a TypeScript worker
  • Create a pyproject.toml and entry point for a Python Cloudflare Worker

How to install cloudflare-workers-multi-lang

1Skills CLI (Vercel)

npx skills add secondsky/claude-skills --skill cloudflare-workers-multi-lang -a claude-code

2Manually: put the files in place

~/.claude/skills/cloudflare-workers-multi-lang/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cloudflare-workers-multi-lang/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cloudflare-workers-multi-lang

How do I install cloudflare-workers-multi-lang in Claude Code?

Run npx skills add secondsky/claude-skills --skill cloudflare-workers-multi-lang -a claude-code.

What does cloudflare-workers-multi-lang do?

It assists in building non-JS Cloudflare Workers using Rust, Python, or WebAssembly, and troubleshoots runtime issues.

What tools are needed before building Rust workers?

You need wasm-pack installed via cargo install wasm-pack alongside worker and wasm-bindgen declared in Cargo.toml.

Source text

SKILL.md · MIT
---
name: cloudflare-workers-multi-lang
description: Multi-language Workers development with Rust, Python, and WebAssembly. Use when building Workers in languages other than JavaScript/TypeScript, or when integrating WASM modules for performance-critical code.
metadata:
  version: "1.0.0"
license: MIT
---

# Multi-Language Workers Development

Build Cloudflare Workers using Rust, Python, or WebAssembly for performance-critical operations.

## Language Comparison

| Feature | JavaScript/TS | Rust | Python |
|---------|---------------|------|--------|
| **Startup** | Fast | Fastest (WASM) | Moderate |
| **CPU Perf** | Good | Excellent | Good |
| **Memory** | Higher | Lower | Higher |
| **Bundle Size** | Smaller | Medium | Larger |
| **Type Safety** | Optional (TS) | Strict | Optional |
| **Best For** | General apps | CPU-intensive | Data/ML |

## Quick Decision

```
Need maximum performance? → Rust/WASM
Heavy computation (crypto, image processing)? → Rust/WASM
Data processing, ML inference? → Python
General web apps? → JavaScript/TypeScript
```

## Top 10 Multi-Lang Errors

| Error | Language | Cause | Solution |
|-------|----------|-------|----------|
| `WebAssembly.instantiate() failed` | Rust | Invalid WASM | Check wasm-pack build output |
| `Module parse failed: Unexpected token` | Rust | ESM/CJS mismatch | Use `--target bundler` |
| `Cannot find module` | Python | Missing dep | Add to pyproject.toml |
| `Out of memory` | All | Large WASM | Enable streaming instantiation |
| `Exceeded CPU time limit` | All | Long computation | Chunk processing |
| `wasm-bindgen version mismatch` | Rust | Dep conflict | Align versions in Cargo.toml |
| `RuntimeError: unreachable` | Rust | Panic in WASM | Add proper error handling |
| `TypeError: not a function` | Rust | Missing export | Add `#[wasm_bindgen]` attribute |
| `Python worker startup timeout` | Python | Slow init | Minimize imports |
| `SharedArrayBuffer not supported` | All | Security | Add COOP/COEP headers |

## Rust Quick Start

```bash
# Install tools
cargo install wasm-pack

# Create project
cargo new --lib my-worker
cd my-worker

# Add to Cargo.toml
cat >> Cargo.toml << 'EOF'
[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
worker = "0.3"
console_error_panic_hook = "0.1"

[profile.release]
opt-level = "s"
lto = true
EOF
```

```rust
// src/lib.rs
use worker::*;

#[event(fetch)]
async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> {
    console_error_panic_hook::set_once();

    Router::new()
        .get("/", |_, _| Response::ok("Hello from Rust!"))
        .get("/compute", |_, _| {
            // CPU-intensive computation
            let result = heavy_computation();
            Response::ok(format!("Result: {}", result))
        })
        .run(req, env)
        .await
}

fn heavy_computation() -> u64 {
    (1..1_000_000).filter(|n| is_prime(*n)).count() as u64
}

fn is_prime(n: u64) -> bool {
    if n < 2 { return false; }
    (2..=(n as f64).sqrt() as u64).all(|i| n % i != 0)
}
```

## Python Quick Start (Workers for Platforms)

```toml
# pyproject.toml
[project]
name = "my-worker"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
```

```python
# src/entry.py
from js import Response, Headers

async def on_fetch(request, env):
    url = request.url

    if "/compute" in url:
        result = heavy_computation()
        return Response.new(f"Result: {result}")

    return Response.new("Hello from Python!")

def heavy_computation():
    """CPU-intensive computation"""
    return sum(1 for n in range(2, 100000) if is_prime(n))

def is_prime(n):
    if n < 2:
        return False
    return all(n % i != 0 for i in range(2, int(n**0.5) + 1))
```

## WASM Module Integration

```typescript
// Load and use WASM module in TypeScript Worker
import wasmModule from './pkg/my_lib_bg.wasm';
import { init, process_data } from './pkg/my_lib';

let wasmInstance: WebAssembly.Instance;

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    // Initialize WASM once
    if (!wasmInstance) {
      wasmInstance = await WebAssembly.instantiate(wasmModule);
      init();
    }

    // Use WASM function
    const result = process_data(inputData);

    return Response.json({ result });
  },
};
```

## When to Load References

| Reference | Load When |
|-----------|-----------|
| `references/rust-workers.md` | Building Workers with Rust/WASM |
| `references/python-workers.md` | Using Python on Workers for Platforms |
| `references/wasm-integration.md` | Integrating WASM modules in any Worker |

## Performance Tips

1. **WASM Initialization**: Cache instance, use streaming
2. **Memory**: Use typed arrays for data transfer
3. **Bundle Size**: Enable LTO, strip debug info
4. **Cold Starts**: Keep WASM modules small
5. **Data Transfer**: Minimize JS/WASM boundary crossings

## See Also

- `workers-performance` - General optimization techniques
- `workers-testing` - Testing multi-language Workers
- `cloudflare-worker-base` - Basic Workers setup

© secondsky · MIT · secondsky/claude-skills

Similar skills

All skills for Backend and APIs →

From the same set138

The whole set →
cloudflare-workers-ci-cd cloudflare-workers-ci-cd — a skill that walks your agent through CI/CD for Cloudflare Workers on GitHub Actions or GitLab CI. Useful when a pipeline breaks or every pull request needs its own preview. CX Codex +1 326installs cloudflare-workers-dev-experience cloudflare-workers-dev-experience guides local Cloudflare Workers development using Wrangler and Miniflare. Helps fix broken bindings for KV, D1, or R2, configure HMR, and set up tsconfig. CX Codex +1 324installs cloudflare-workers-observability A skill for Cloudflare Workers observability: structured logging, Analytics Engine, Tail Workers, metrics and alerting. Useful when a worker fails in production and you can't see why. CX Codex +1 322installs xss-prevention The xss-prevention skill helps prevent XSS with input sanitization, output encoding, and CSP. Use it for user HTML, comments, rich text, and script injection issues. CX Codex +1 320installs cloudflare-r2 Skill for working with Cloudflare R2, an S3-compatible object storage. Manages buckets, uploads, CORS and presigned URLs — everything needed to handle files in the cloud. CX Codex +1 316installs cloudflare-workers-migration cloudflare-workers-migration — a skill for porting applications to Cloudflare Workers from AWS Lambda, Vercel, Express and Node.js. Adapts handlers, middleware and environment variables to Web APIs. CX Codex +1 316installs tanstack-query This skill guides Claude Code through TanStack Query v5 for fetching, caching, mutations, and v4 migration issues in React projects. CX Codex +1 314installs zustand-state-management zustand-state-management guides agent setup of Zustand v5 stores for React 18+ and TypeScript 5+. Fixes Next.js hydration mismatches and prevents selector re-render loops. CX Codex +1 301installs

Project sponsors

Companies that keep this analytics open