Cloudflare workers
Unju fork of everything-claude-code — curated agent harness for unju-vmFrom the repository description
npx -y skills add unju-ai/ecc --skill cloudflare-workersAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.9 KB, as published. Nobody here has run it
Skill: Cloudflare Workers
When to Use
When working with Cloudflare Workers, Wrangler, Hono, Durable Objects, D1, KV, R2, Service Bindings, or Queues. Use this skill before writing any Worker code to avoid the most common pitfalls.
Wrangler.toml
Routes MUST be an array:
# ✓ CORRECT
[[routes]]
pattern = "api.unju.ai/*"
zone_name = "unju.ai"
# ✗ WRONG (breaks every deploy)
[routes]
pattern = "api.unju.ai/*"
D1 database binding:
[[d1_databases]]
binding = "UNJU_DB"
database_name = "unju"
database_id = "your-actual-d1-id"
Service bindings (for inter-worker calls):
[[services]]
binding = "WALLET"
service = "unju-wallet"
Verify config before pushing:
bun run build # runs: wrangler deploy --dry-run --outdir dist
Hono patterns
import { Hono } from 'hono'
import type { Env } from '../index'
// Always type the bindings
export const myRouter = new Hono<{ Bindings: Env }>()
myRouter.get('/path', async (c) => {
const db = c.env.UNJU_DB // D1 binding
return c.json({ ok: true })
})
D1 with Kysely
import { Kysely } from 'kysely'
import { D1Dialect } from 'kysely-d1'
import type { DB } from './generated-types'
export function getDb(env: { UNJU_DB: D1Database }): Kysely<DB> {
return new Kysely<DB>({ dialect: new D1Dialect({ database: env.UNJU_DB }) })
}
// Column names come from generated-types.ts — never guess
// If you get a type error on a column, check generated-types.ts first
Node.js compatibility
Some packages need nodejs_compat flag:
compatibility_flags = ["nodejs_compat"]
If you see "package X wasn't found on the file system but is built into node" — add this flag.
Durable Objects
export class MyDO implements DurableObject {
state: DurableObjectState
constructor(state: DurableObjectState, env: Env) {
this.state = state
}
async fetch(request: Request): Promise<Response> { ... }
}
// Register in wrangler.toml:
// [[durable_objects.bindings]]
// name = "MY_DO"
// class_name = "MyDO"
Secrets
# Set in production (never commit)
wrangler secret put SECRET_NAME
# In code: c.env.SECRET_NAME
Size limits
- Workers: 10MB (after gzip ≈ 1MB limit for free tier)
- D1: 2GB max, 10MB per row
- KV: 25MB max value
- If bundle too large: split into multiple workers with Service Bindings
Testing locally
wrangler dev # local dev with live reload
wrangler dev --remote # dev against remote D1/KV bindings
bun run build # dry-run deploy check (no actual deploy)
Common mistakes
[routes]instead of[[routes]]— breaks every deploy- Missing
nodejs_compatflag for Node builtins - Using
process.envinstead ofc.envin Workers - Blocking I/O — Workers are async-only, use
await - Importing Node.js modules that aren't CF-compatible
- Hand-editing
openapi.json— always regenerate from the script