workerd / types
AGENTS.md8.8k starsChanged 9 months agoApache-2.0View on GitHub
Generates @cloudflare/workers-types .d.ts files from C++ RTTI (via jsg/rtti.capnp) + hand-written defines/*.d.ts. A workerd-hosted Worker extracts RTTI at runtime per compat-date; TypeScript transforms post-process into ambient and importable outputs. CI validates generated-snapshot/ matches. Types in this project come from three layers. Changes must be made in the correct layer: Do not edit files in generated-snapshot/ directly — they are overwritten by just generate-types. If the generated output looks wrong, fix the source layer (C++ RTTI, JSG_TS_OVERRIDE, or defines/). Types in…
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
- src/workerd/util/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, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 39
Do not edit files in generated-snapshot/ directly — they are overwritten by just generate-types.
- Very specific: line 65
After any change that affects types (C++ API changes, JSG_TS_OVERRIDE edits, defines/ modifications), regenerate the snapshot:
- Distinctive: line 77
When adding new types or changing existing ones, add or update type tests to cover the new shapes.
≈ “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
types/
OVERVIEW
Generates @cloudflare/workers-types .d.ts files from C++ RTTI (via jsg/rtti.capnp) + hand-written defines/*.d.ts. A workerd-hosted Worker extracts RTTI at runtime per compat-date; TypeScript transforms post-process into ambient and importable outputs. CI validates generated-snapshot/ matches.
PIPELINE
- RTTI extraction:
src/worker/runs inside workerd, imports binary RTTI viaworkerd:rtti+ param names fromparam-extractor.rs - Generation:
src/generator/converts Cap'n Proto structures to TS AST nodes (walks types, members, methods recursively viacollectIncluded) - Transforms (ordered, in
src/index.ts): iterators -> overrides/defines -> global scope extraction -> class-to-interface -> comments -> onmessage declaration; then second pass: import-resolve -> ambient. Importable variant runs separately. - Defines concatenation:
defines/*.d.tsappended after transforms (AI, D1, R2, RPC, Vectorize, etc.) - Build:
scripts/build-types.tsiterates compat-date entrypoints (oldest through experimental), type-checks output against TS libs
KEY DIRECTORIES
| Directory | Purpose |
src/generator/ | RTTI-to-TS-AST: structure.ts (classes/interfaces), type.ts (type mapping) |
src/transforms/ | 11 post-processing TS transformer factories |
src/worker/ | Workerd-hosted entry; imports RTTI binary + virtual modules |
defines/ | Hand-written .d.ts for APIs not expressible via C++ RTTI (~25 files) |
generated-snapshot/ | Checked-in latest/ + experimental/ output; CI diff-checked |
scripts/ | build-types.ts (full generation), build-worker.ts (worker bundle) |
test/ | Vitest specs for generator, transforms, print; type-check tests in test/types/ |
ADDING OR UPDATING TYPES
Where type changes belong
Types in this project come from three layers. Changes must be made in the correct layer:
| Layer | Location | When to use |
| C++ RTTI | src/workerd/api/*.h (JSG macros) | Types derived from C++ classes — the generator extracts these automatically |
JSG_TS_OVERRIDE | Same .h files, inside JSG_RESOURCE_TYPE blocks | When the auto-generated TS signature needs adjustment (e.g., conditional properties, union narrowing) |
| Hand-written defines | types/defines/*.d.ts | Types for APIs not expressible via C++ RTTI (Cloudflare product bindings like AI, D1, R2, Vectorize, etc.) |
Do not edit files in generated-snapshot/ directly — they are overwritten by just generate-types. If the generated output looks wrong, fix the source layer (C++ RTTI, JSG_TS_OVERRIDE, or defines/).
Naming conventions
Types in defines/*.d.ts become top-level ambient declarations visible to every Worker project. Generic names will collide or confuse.
- Prefix types with the product or feature name. For example:
D1Meta,AiSearchConfig,VectorizeVector— notMeta,Config, orVector. - Follow the existing convention for the relevant product. Check the existing
defines/file for that product (e.g.,cf.d.tsusesIncomingRequestCfProperties*,d1.d.tsusesD1*,ai-search.d.tsusesAiSearch*). - When in doubt, be more specific. A name like
TracePreviewInfois better thanPreview. The cost of a verbose name is low; the cost of a naming collision in every user's project is high.
Interface design
- Never use bare
objectas a type.type Foo = objectprevents all property access without casting, providing no value to users. Use a proper interface with known fields instead. - Use interfaces with known fields + index signature for types where the shape is partially known but extensible. Follow the
IncomingRequestCfPropertiesBasepattern:interface CloudflareAccessIdentity extends Record<string, unknown> { email?: string; name?: string; // ... other known fields } - Index signatures (
[key: string]: unknown) need justification. Only add them when forward-compatibility is genuinely required (e.g., the API frequently adds new fields across releases). Document the reason in a JSDoc comment. Do not add index signatures by default. - Add JSDoc comments to interfaces and their fields, especially for types used in
defines/. These comments appear in users' IDEs.
Snapshot regeneration
After any change that affects types (C++ API changes, JSG_TS_OVERRIDE edits, defines/ modifications), regenerate the snapshot:
just generate-typesCI will fail if generated-snapshot/ does not match the generated output. Always commit the updated snapshot alongside your source changes.
Type tests
Type-level tests live in test/types/ (e.g., test/types/rpc.ts). These are compile-time checks — they verify that type expressions are accepted or rejected by the TypeScript compiler.
- When adding new types or changing existing ones, add or update type tests to cover the new shapes.
- Review type test changes carefully — a test that compiles successfully may still be asserting the wrong thing.
PR hygiene for type changes
- Do not include unrelated formatting changes in PRs that modify types. If formatting needs fixing, do it in a separate commit or PR.
- Type changes in feature PRs need review from someone familiar with the types system. The Wrangler team typically reviews type changes that affect
@cloudflare/workers-types.
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.

