workerd / util
AGENTS.md8.8k starsChanged 9 months agoApache-2.0View on GitHub
Shared utility library: data structures, SQLite wrapper, feature gating, logging, thread-local scopes. No workerd-specific API dependencies — consumed across api/, io/, server/.
Trending
Quiet since August.thin dataabout the whole repository
Who's talking about cloudflare/workerd
- A Hacker News story“OS Workerd, Cloudflare's JavaScript/WASM Runtime”Hacker News · Sep 27, 2022 · 27 points
- withastro/astro“Cloudflare adapter returning [object Object]”GitHub · Oct 10, 2025 · 18 reactions
- supabase/supabase-js“The 'cache' field on 'RequestInitializerDict' is not implemented - Cloudflare Workers”GitHub · Mar 28, 2024 · 16 reactions
- nodejs/node“src: improve buffer.transcode performance”GitHub · Aug 1, 2024 · 13 reactions
- NixOS/nixpkgs“Package request: workerd”GitHub · Nov 12, 2024 · 12 reactions
The biggest 5 of 12 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 12
Talked about on GitHub, Bluesky and Hacker News (12 times).
On GitHub · 6
- Oct 10, 2025Cloudflare adapter returning [object Object] — withastro/astro18 reactions · 15 comments
- Mar 28, 2024The 'cache' field on 'RequestInitializerDict' is not implemented - Cloudflare Workers — supabase/supabase-js16 reactions · 24 comments
- Aug 1, 2024src: improve buffer.transcode performance — nodejs/node13 reactions · 26 comments
- Nov 12, 2024Package request: workerd — NixOS/nixpkgs12 reactions · 8 comments
- Feb 19, 2024Add Curve25519 — w3c/webcrypto9 reactions · 16 comments
1 more on GitHub
- Nov 3, 2025Optimize TextEncoder::encode — nodejs/performance7 reactions · 33 comments
On Bluesky · 4
- Mar 24, 2026workerd : le runtime JavaScript/Wasm open source de Cloudflare Workers — @news.humancoders.com4 likes and reposts
- Aug 22, 2026Current status: trying to build github.com/cloudflare/w... on various sandbox providers — @jeremymorrell.dev1 likes and repost
- Mar 24, 2026workerd : le runtime JavaScript/Wasm qui propulse Cloudflare Workers est maintenant open source. Basé sur les standards web, il permet… — @humancoders.com1 likes and repost
- Nov 5, 2024Technically workers are open source github.com/cloudflare/w... — @userops.bsky.social1 likes and repost
On Hacker News · 2
- Sep 27, 2022OS Workerd, Cloudflare's JavaScript/WASM Runtime27 points · 2 comments
- Oct 5, 2023Cloudflare workers is adopting Ada URL parser2 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository61 other files it gives its agents.
- AGENTS.mdAGENTS.md
- build/AGENTS.mdAGENTS.md
- src/cloudflare/AGENTS.mdAGENTS.md
- src/node/AGENTS.mdAGENTS.md
- src/per_isolate/AGENTS.mdAGENTS.md
- src/per_isolate/crypto/AGENTS.mdAGENTS.md
- src/per_isolate/webfs/AGENTS.mdAGENTS.md
- src/per_isolate/webstreams/AGENTS.mdAGENTS.md
- src/pyodide/AGENTS.mdAGENTS.md
- src/rust/AGENTS.mdAGENTS.md
- src/rust/cxx/AGENTS.mdAGENTS.md
- src/tests/node/AGENTS.mdAGENTS.md
- src/tests/node/http-client/AGENTS.mdAGENTS.md
- src/tests/node/http-server/AGENTS.mdAGENTS.md
- src/tests/node/net/AGENTS.mdAGENTS.md
- src/tests/node/stream/AGENTS.mdAGENTS.md
- src/tests/streams/AGENTS.mdAGENTS.md
- src/tests/streams/cache/AGENTS.mdAGENTS.md
- src/tests/streams/compression/AGENTS.mdAGENTS.md
- src/tests/streams/digest/AGENTS.mdAGENTS.md
- src/tests/streams/encoding/AGENTS.mdAGENTS.md
- src/tests/streams/formdata/AGENTS.mdAGENTS.md
- src/tests/streams/htmlrewriter/AGENTS.mdAGENTS.md
- src/tests/streams/identity/AGENTS.mdAGENTS.md
- src/tests/streams/inspect/AGENTS.mdAGENTS.md
- src/tests/streams/iocontext/AGENTS.mdAGENTS.md
- src/tests/streams/piping/AGENTS.mdAGENTS.md
- src/tests/streams/r2-patterns/AGENTS.mdAGENTS.md
- src/tests/streams/readable/AGENTS.mdAGENTS.md
- src/tests/streams/readable-byte/AGENTS.mdAGENTS.md
- src/tests/streams/scaling/AGENTS.mdAGENTS.md
- src/tests/streams/sockets/AGENTS.mdAGENTS.md
- src/tests/streams/strategies/AGENTS.mdAGENTS.md
- src/tests/streams/transform/AGENTS.mdAGENTS.md
- src/tests/streams/writable/AGENTS.mdAGENTS.md
- src/workerd/api/AGENTS.mdAGENTS.md
- src/workerd/api/crypto/AGENTS.mdAGENTS.md
- src/workerd/api/node/AGENTS.mdAGENTS.md
- src/workerd/api/streams/AGENTS.mdAGENTS.md
- src/workerd/io/AGENTS.mdAGENTS.md
- src/workerd/jsg/AGENTS.mdAGENTS.md
- src/workerd/server/AGENTS.mdAGENTS.md
- types/AGENTS.mdAGENTS.md
- bazel-test-hygieneSkill
- commit-categoriesSkill
- dad-jokesSkill
- find-and-run-testsSkill
- identify-reviewerSkill
- investigation-notesSkill
- kj-styleSkill
- markdown-draftsSkill
- parent-project-skillsSkill
- pr-review-guideSkill
- receiving-code-reviewSkill
- rust-reviewSkill
- ts-styleSkill
- update-v8Skill
- wd-test-formatSkill
- workerd-api-reviewSkill
- workerd-safety-reviewSkill
- The first 60 shown.
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
No bool arguments: use WD_STRONG_BOOL for type safety and readability
- Very specific: line 31
Use
kj::Maybefor optional values: avoid null pointers and sentinel values - Very specific: line 39
StateMachine +
KJ_SWITCH_ONEOF: does NOT acquire transition lock — UAF risk.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
src/workerd/util/
OVERVIEW
Shared utility library: data structures, SQLite wrapper, feature gating, logging, thread-local scopes. No workerd-specific API dependencies — consumed across api/, io/, server/.
KEY UTILITIES
| File | What | Notes |
state-machine.h | Type-safe kj::OneOf wrapper with transition locking | Prevents UAF in callbacks; 7 consumers in api/streams/ |
sqlite.h/c++ | Full SQLite wrapper with custom VFS over kj::Directory | Regulator controls allowed SQL; Statement for prepared queries |
sqlite-kv.h | KV abstraction on SQLite | Used by Durable Object storage |
autogate.h/c++ | Runtime feature gates | AutogateKey enum; isEnabled() check |
weak-refs.h | WeakRef<T> / AtomicWeakRef<T> | Non-owning refs; tryAddStrongRef() or runIfAlive(fn) pattern |
ring-buffer.h | Amortized O(1) deque | Replaces std::list in streams |
small-weak-vector.h | kj::OneOf-based weak vector | O(1) for 0–2 items, fallback to kj::Vector |
batch-queue.h | Double-buffered cross-thread queue | Producer/consumer with mutex swap |
checked-queue.h | Safe std::list wrapper | pop() returns Maybe instead of UB on empty |
strong-bool.h | WD_STRONG_BOOL(Name) macro | Type-safe boolean; prevents implicit conversions |
sentry.h | LOG_EXCEPTION, LOG_ONCE, LOG_PERIODICALLY | DEBUG_FATAL_RELEASE_LOG = debug assert + release warning |
thread-scopes.h | Thread-local scope flags | Self-described "horrible hacks"; AllowV8BackgroundThreadsScope, MultiTenantProcess |
abortable.h | newAbortableInputStream/OutputStream | Wraps KJ streams with disconnect capability |
stream-utils.h | NeuterableInputStream, newNullInputStream | Disconnectable I/O; null/identity stream factories |
mimetype.h | MIME type parser/serializer | MimeType::extract() from content-type header |
wait-list.h | Cross-request event subscription | Shared fulfiller list for signaling waiters |
Guidelines
- No bool arguments: use
WD_STRONG_BOOLfor type safety and readability - Use
kj::Maybefor optional values: avoid null pointers and sentinel values - Prefer composition over inheritance: utilities should be standalone and reusable without complex class hierarchies
- Use
StateMachinefor state management: original pattern has been to usekj::OneOfdirectly, and that's still acceptable for simple cases, butStateMachineprovides additional safety guarantees and should be preferred for more complex state management
ANTI-PATTERNS
- StateMachine
forceTransitionTo(): bypasses terminal state protection — use only for error recovery - StateMachine
underlying(): bypasses ALL safety (transition lock, terminal states) — last resort only - StateMachine +
KJ_SWITCH_ONEOF: does NOT acquire transition lock — UAF risk; usewhenState<T>(fn)instead - StateMachine
deferTransitionTo(): first-wins semantics; second call silently ignored - SQLite:
SQLITE_MISUSEalways throws; virtual tables disallowed (except FTS5 and RTREE);ATTACH/DETACHforbidden; callbacks must not write - ThreadScopes: thread-local state crossing module boundaries — acknowledged hack, do not proliferate
- RingBuffer: moves on grow invalidating references; iterators invalidated on push/pop; intentionally not thread-safe.
setup-async-io (the kj::setupAsyncIo() seam)
setup-async-io.c++ defines a tokio-backed kj::setupAsyncIo() and an inert kj::UnixEventPort.
It is sound only while kj-async-os is absent from the link -- see the I/O section in
src/workerd/server/AGENTS.md for the rule (no :kj-async umbrella deps) and the gates that
enforce it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

