workerd / cxx
AGENTS.md8.8k starsChanged 9 months agoApache-2.0View on GitHub
This directory contains workerd's in-tree fork of cxx-rs. It was imported from the former cloudflare/workerd-cxx repository. Changes to the fork and its workerd consumers should use the in-tree Bazel labels and land atomically. The fork adds KJ exceptions, smart pointers, data types, and bidirectional async interop. Do not assume stock cxx-rs behavior when changing bridge generation or runtime code. Run commands from the workerd repository root: Important targets: Dependencies come from workerd's @crates_vendor repository and @capnp-cpp; do not add a…
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/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
- src/workerd/util/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
5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
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 14
Run commands from the workerd repository root:
- Very specific: line 50
Follow the parent src/rust/AGENTS.md and repository AGENTS.md.
- Distinctive: line 51
Prefer KJ C++ types over STL types unless required by the cxx ABI.
- Very specific: line 53
Every unsafe Rust block needs a // Safety: explanation.
- Distinctive: line 57
Run formatting and the full component tests after changing generated ABI behavior.
≈ “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/rust/cxx/
Overview
This directory contains workerd's in-tree fork of cxx-rs. It was imported from the former
cloudflare/workerd-cxx repository. Changes to the fork and its workerd consumers should use the
in-tree Bazel labels and land atomically.
The fork adds KJ exceptions, smart pointers, data types, and bidirectional async interop. Do not assume stock cxx-rs behavior when changing bridge generation or runtime code.
Build and test
Run commands from the workerd repository root:
bazel build //src/rust/cxx/...
bazel test //src/rust/cxx/...Important targets:
//src/rust/cxx:cxx— Rust runtime crate//src/rust/cxx:core— C++ runtime and public header//src/rust/cxx:codegen— C++ bridge generator//src/rust/cxx/kj-rs— KJ integration crate and C++ support library
Dependencies come from workerd's @crates_vendor repository and @capnp-cpp; do not add a nested
Bazel module, Cargo workspace, toolchain configuration, or external workerd-cxx repository.
Architecture
src/andinclude/— cxx Rust and C++ runtimessyntax/,gen/, andmacro/— bridge parser and code generatorskj-rs/— KJ promises/futures, exceptions, ownership, refcounting, dates, andMaybekj-rs-tokio/—TokioEventPort: akj::EventPortbacked by a per-thread tokiocurrent_threadruntime, plussetupTokioAsyncIo()(no I/O providers) andkj_rs_tokio::spawn()kj-rs-io/— tokio-backedkj::AsyncIoStream/kj::Network/kj::LowLevelAsyncIoProvider(the I/O providers for the tokio loop,kj_rs_io::setupTokioAsyncIo()),loopback:addresses (in-process connections forworkerd test), the--watchfile watcher (Rust overnotify), and signals. C++ there is interface adaptation only; the one policy object that stays C++ isPeerFilter, a wrapper over KJ's ownkj::_::NetworkFilter, which Rust consults through a bridgedshould_allowtests/andkj-rs/tests/— Rust and C++ bridge integration teststools/bazel/— Bazel bridge-generation macro used by this component's tests
Conventions
- Follow the parent
src/rust/AGENTS.mdand repositoryAGENTS.md. - Prefer KJ C++ types over STL types unless required by the cxx ABI.
- Preserve cancellation when converting between KJ promises and Rust futures.
- Every unsafe Rust block needs a
// Safety:explanation. KjOwn<T>requiresT: kj_rs::OwnTarget, generated per bridge for every declared type held in aKjOwn(seekj-rs/README.md). A type that is only aliased into a bridge gets no implementation there; addimpl KjOwn<T> {}to the bridge that declaresT.- Run formatting and the full component tests after changing generated ABI behavior.
kj-rs-io ownership and reactor rules
kj-rs-io/lib.rs is the canonical statement of these rules; this is the summary for people editing the crate. Two kinds of guarantee are in play and must not be confused: what the Rust handles guarantee by type, and what the C++ adapters guarantee by construction.
- Rust handles:
Send + Syncby type, operations own their state. Shared state isArc, atomics andMutex; lib.rs assertsSend + Syncfor every handle type at compile time, so anRcor aCellin one fails the build. Every bridged operation captures a share of its object's state, never a borrow (fn -> impl Future + use<..>), so arust::Boxdestroyed or carried to another thread is never a memory-safety question. - Two port checks, at registration and at the wait. A
TokioEventPortthread is a tokio runtime thread for its whole life (kj-rs-tokio/port.rs), so tokio's constructors register with the loop's driver as they are; do not add steering (entering handles, wrapper constructors) or lints around them.ensure_loop_thread()goes before every registration;ensure_owner_loop()(the resource's recorded owner runtime) goes at the point an operation is about to wait for readiness, never on the fast path -- a read whose syscall completes at once pays nothing. Accept always waits, so it checks up front. The file watcher is runtime-independent (notify delivers from its own thread;tokio::sync::Notifyneeds no runtime) and checks nothing. - Raw handles and buffers become typed at the bridge.
ffi.rsis the crate's only module allowed to writeunsafe. An fd/SOCKET arrives as an integer and becomes asocket2::Socket/OwnedFdin oneunsafeblock naming the C++ contract; atryReadbuffer arrives as pointer + length and becomes&mut [MaybeUninit<u8>], never&mut [u8]. Those helpers areunsafe fns: never make them safe, never pass integers or pointers pastffi.rs. - Addresses are typed on the bridge.
SocketAddress(ffi.rs) is the only form an address takes between Rust and C++; Rust converts it to and fromstd's address types (safe), and async-io.c++ is the only place astruct sockaddris decoded or encoded -- at the KJ interfaces that speak them. Do not reintroduce sockaddr byte blobs on either side. - C++ adapters: KJ's contracts, KJ's structure. The adapters implement KJ interfaces and keep
KJ's own shape where KJ has one: the connect and accept loops with
restrictPeersfiltering (KJ's ownkj::_::NetworkFilterbehind akj::Arc<PeerFilter>, atomic because KJ allows an address to be cloned on another thread), fd-flag handling, accept-retry sets, socket options, backlog, and the operation-start policy (every returned I/O promise is started inside the call). The one KJ behavior deliberately not mirrored is when the syscall happens: reads and writes are tokio'stry_*+ readiness loops (stream.rs, "When the syscall happens"); do not add direct-syscall-first paths. Buffer validity until a promise settles and fd ownership underTAKE_OWNERSHIPremain KJ's documented contracts, named at the// Safety:comments. - kj-rs-io is workerd's provider, not a general KJ provider. lib.rs, "Scope: workerd's provider", lists what is left out and the rule: no consumer in workerd's production code or its configuration surface (workerd.capnp's documented address grammar counts -- check it before declaring a feature unused), and hand-written libc/sockaddr/fd code to keep.
--config=asanand thetsanconfigs instrument both C++ and Rust. Rust is built with nightly rustc,-Zsanitizer=<address|thread>, and a standard library instrumented the same way (//build/rust);//src/rust/asanand//src/rust/tsanverify the instrumentation is active.
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.

