agentleFS
CloudflareKnown publishercloudflare/workerd/src/node/AGENTS.md

workerd / node

AGENTS.md8.8k starsChanged 9 months agoApache-2.0View on GitHub

TypeScript and JavaScript layer implementing Node.js compatible built-in modules for Workers. It is split across multiple layers: It is common, but not required, for top-level .ts files to re-export from internal/ via node-internal: specifiers. This allows for a clean separation between public API surface and internal implementation details. See README.md for 12 policy rules governing compat scope and philosophy. node:* modules are gated behind the nodejs_compat compatibility flag. The node:async_hooks module can be enabled individually via the nodejs_als compatibility flag.

Trending

Quiet since August.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the cloudflare/workerd repository that our weekly crawl found: only 12 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about cloudflare/workerd

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

1 more on GitHub

On Hacker News · 2

The file

Files
AGENTS.md

src/node/ — Node.js Compatibility (TypeScript)

OVERVIEW

TypeScript and JavaScript layer implementing Node.js compatible built-in modules for Workers.

It is split across multiple layers:

  1. An internal layer consisting of:
    • Non-user-importable TypeScript and JavaScript files in internal/ that implement core logic, utilities, and C++ JSG module declarations.
    • C++ JSG modules (src/workerd/api/node/) expose native ops via node-internal:* specifiers
    • Some native internal modules may be implemented in Rust
  2. A public layer of TypeScript files at the top-level that are user-importable.

It is common, but not required, for top-level .ts files to re-export from internal/ via node-internal: specifiers. This allows for a clean separation between public API surface and internal implementation details.

See README.md for 12 policy rules governing compat scope and philosophy.

MODULE GATING

node:* modules are gated behind the nodejs_compat compatibility flag.

The node:async_hooks module can be enabled individually via the nodejs_als compatibility flag.

Runtime compat flags checked via Cloudflare.compatibilityFlags['flag_name']:

FlagGuards
enable_nodejs_http_server_moduleshttp Server/createServer, https Server
nodejs_zlibzlib streaming classes (Deflate, Gzip, etc.)
enable_nodejs_process_v2Extended process/events functionality
remove_nodejs_compat_eol_v22/v23/v24EOL deprecation of specific API surfaces (crypto, util, tls, process)

Most modules require nodejs_compat + nodejs_compat_v2 flags (enforced by C++ side, not visible here).

ADDING NEW INTERNAL MODULES

New .ts and .js files in internal/ are auto-discovered by the build system via glob(["internal/*.ts", "internal/*.js"]) in BUILD.bazel. No explicit registration is needed — just create the file and it becomes importable via its node-internal: specifier.

For example, creating internal/internal_fs_glob.ts immediately makes node-internal:internal_fs_glob available as an import specifier. No changes to BUILD.bazel or any registration macro are required.

What does require explicit wiring:

  • New top-level node:* public modules need a corresponding .ts file in src/node/ and must be registered in the C++ module registry (src/workerd/api/node/node.h, the NODEJS_MODULES macro).
  • New C++ JSG native modules require a .d.ts declaration file in internal/ to declare the shape of the native module.

CONVENTIONS

  • internal/*.js (not .ts) = upstream Node.js ports (streams_readable.js, streams_writable.js, etc.); paired with .d.ts type declarations
  • internal/*.d.ts without matching .ts = declares C++ JSG module shape (crypto.d.ts → node-internal:crypto)
  • internal/*.d.ts with matching .js = types for ported JS (streams_readable.d.ts → streams_readable.js)
  • Top-level files are thin: import from node-internal:*, re-export with export { ... } / export * from
  • Feature-gated exports use if (!flag) { throw ... } or conditional class assignment patterns
  • Shared validators in internal/validators.ts; shared errors in internal/internal_errors.ts
  • _ prefix files (e.g., _http_agent.ts, _stream_readable.ts) = Node.js legacy internal module aliases
  • Some Node.js compat APIs are non-functional stubs that are either non-ops or throw when called

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.