cloudflare-workers-multi-lang
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.
- 0
- Installs
- —
- Rating
- —
- Success rate
- 9
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 c84cd2e2d4ac3efd… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
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
# 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
// 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)
# pyproject.toml
[project]
name = "my-worker"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
# 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
// 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
- WASM Initialization: Cache instance, use streaming
- Memory: Use typed arrays for data transfer
- Bundle Size: Enable LTO, strip debug info
- Cold Starts: Keep WASM modules small
- Data Transfer: Minimize JS/WASM boundary crossings
See Also
workers-performance- General optimization techniquesworkers-testing- Testing multi-language Workerscloudflare-worker-base- Basic Workers setup
Files
9- SKILL.md
d4540ce0335.0 KB - references/python-workers.md
7d7dd3352911.9 KB - references/rust-workers.md
31e66b536410.6 KB - references/wasm-integration.md
83552d458e12.7 KB - scripts/build-rust.sh
49185f64e74.5 KB - scripts/build-wasm.sh
fd2a0e4ade9.4 KB - templates/python-worker.py
ae7ea89ba915.7 KB - templates/rust-worker.rs
7936b20cd415.8 KB - templates/wasm-worker.ts
f922a5930015.5 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from secondsky/claude-skills8
[TODO: Write comprehensive description in third-person. Start with "This skill provides..." or "This skill should be used when..."] [TODO: Add "Use when" scenarios - specific situations where Claude should use this skill] [TODO: Add keywords - technologies, use cases, error messages that should tr
100+ animated React components (Aceternity UI) for Next.js with Tailwind. Use for hero sections, parallax, 3D effects, or encountering animation, shadcn CLI integration errors.
Secure API authentication with JWT, OAuth 2.0, API keys. Use for authentication systems, third-party integrations, service-to-service communication, or encountering token management, security headers, auth flow errors.
Creates comprehensive API changelogs documenting breaking changes, deprecations, and migration strategies for API consumers. Use when managing API versions, communicating breaking changes, or creating upgrade guides.
Verifies API contracts between services using consumer-driven contracts, schema validation, and tools like Pact. Use when testing microservices communication, preventing breaking changes, or validating OpenAPI specifications.
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.
Implements standardized API error responses with proper status codes, logging, and user-friendly messages. Use when building production APIs, implementing error recovery patterns, or integrating error monitoring services.
Builds flexible API filtering and sorting systems with query parameter parsing, validation, and security. Use when implementing search endpoints, building data grids, or creating dynamic query APIs.
Related devops skillsscan passed
Deployment workflows, CI/CD pipeline patterns, Docker containerization, health checks, rollback strategies, and production readiness checklists for web applications. Use when setting up CI/CD, containerizing an app, or checking production readiness before a release.
Land and deploy workflow. (gstack)
Implement or troubleshoot Cloudflare Email Sending and Email Routing integrations and their delivery configuration.
Deploy tRPC on AWS Lambda with awsLambdaRequestHandler() from @trpc/server/adapters/aws-lambda for API Gateway v1 (REST, APIGatewayProxyEvent) and v2 (HTTP, APIGatewayProxyEventV2), and Lambda Function URLs. Enable response streaming with awsLambdaStreamingRequestHandler() wrapped in awslambda.strea
Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.
Deploys and configures classic Firebase Hosting for static websites, single-page apps (SPAs), and microservices. Use when deploying static sites/SPAs, setting up custom domains, configuring firebase.json hosting settings (redirects, rewrites, headers, multi-site), or managing preview channels. Don't