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

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

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

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
  1. Very specific:

    No bool arguments: use WD_STRONG_BOOL for type safety and readability

    line 30
  2. Very specific:

    Use kj::Maybe for optional values: avoid null pointers and sentinel values

    line 31
  3. Very specific:

    StateMachine + KJ_SWITCH_ONEOF: does NOT acquire transition lock — UAF risk.

    line 39

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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

FileWhatNotes
state-machine.hType-safe kj::OneOf wrapper with transition lockingPrevents UAF in callbacks; 7 consumers in api/streams/
sqlite.h/c++Full SQLite wrapper with custom VFS over kj::DirectoryRegulator controls allowed SQL; Statement for prepared queries
sqlite-kv.hKV abstraction on SQLiteUsed by Durable Object storage
autogate.h/c++Runtime feature gatesAutogateKey enum; isEnabled() check
weak-refs.hWeakRef<T> / AtomicWeakRef<T>Non-owning refs; tryAddStrongRef() or runIfAlive(fn) pattern
ring-buffer.hAmortized O(1) dequeReplaces std::list in streams
small-weak-vector.hkj::OneOf-based weak vectorO(1) for 0–2 items, fallback to kj::Vector
batch-queue.hDouble-buffered cross-thread queueProducer/consumer with mutex swap
checked-queue.hSafe std::list wrapperpop() returns Maybe instead of UB on empty
strong-bool.hWD_STRONG_BOOL(Name) macroType-safe boolean; prevents implicit conversions
sentry.hLOG_EXCEPTION, LOG_ONCE, LOG_PERIODICALLYDEBUG_FATAL_RELEASE_LOG = debug assert + release warning
thread-scopes.hThread-local scope flagsSelf-described "horrible hacks"; AllowV8BackgroundThreadsScope, MultiTenantProcess
abortable.hnewAbortableInputStream/OutputStreamWraps KJ streams with disconnect capability
stream-utils.hNeuterableInputStream, newNullInputStreamDisconnectable I/O; null/identity stream factories
mimetype.hMIME type parser/serializerMimeType::extract() from content-type header
wait-list.hCross-request event subscriptionShared fulfiller list for signaling waiters

Guidelines

  • No bool arguments: use WD_STRONG_BOOL for type safety and readability
  • Use kj::Maybe for optional values: avoid null pointers and sentinel values
  • Prefer composition over inheritance: utilities should be standalone and reusable without complex class hierarchies
  • Use StateMachine for state management: original pattern has been to use kj::OneOf directly, and that's still acceptable for simple cases, but StateMachine provides 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; use whenState<T>(fn) instead
  • StateMachine deferTransitionTo(): first-wins semantics; second call silently ignored
  • SQLite: SQLITE_MISUSE always throws; virtual tables disallowed (except FTS5 and RTREE); ATTACH/DETACH forbidden; 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.

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.