Bindings

Goal: connect a Worker60 to a resource it declares, and see what it gets back.

A binding is a declared connection. On Cloudflare, it lets a Worker60 use a platform resource such as a bucket, a queue, or a stream. Cloudflare bindings In Alchemy, the binding is declared in the same Effect35 program as the resource.

Worked example: the events cartridge writes to a stream

The events cartridge38 sends one row per request to a Pipelines stream. It binds the stream in two steps:

packages/events/src/basin.ts · a3f5a148 · Init: ask for a writer bound to the stream
      const saltValue = yield* salt.text;
      const writer = yield* Cloudflare.Pipelines.WriteStream(stream);
packages/events/src/basin.ts · a3f5a148 · Runtime: provide the binding implementation
  ).pipe(Layer.provide(Cloudflare.Pipelines.WriteStreamBinding));
  1. Cloudflare.Pipelines.WriteStream(stream) names the stream this code writes to. It returns a writer with a send method.
  2. Layer.provide(Cloudflare.Pipelines.WriteStreamBinding) gives the Layer21 what it needs: it supplies the implementation that talks to the bound stream at runtime.

Alchemy documents the same two steps for queues: WriteQueue in the init phase, and WriteQueueBinding in the runtime layer. Queue.ts

Why a binding carries permission and configuration

Sam says a binding includes both permissions and environment variables. A service30’s configuration and permissions can be declared together before the application runs. Happy Path 116, 37:09 37:33

He also describes deriving least-privilege policies: permissions limited to the methods an application uses. Effect Office Hours 27, 58:16 59:23

Next

Read Queues, Pipelines, Workflows and K2 do different jobs8 to choose what to bind. Read Workers answer requests; Durable Objects own named state60 to choose where state lives. Then read cartridges38 for how a package owns its resources and bindings.

See Happy Path 1168 and Effect Office Hours 278.

Sources

  1. #116 Infrastructure as Effects with Sam Goodwin - YouTube. Sam Goodwin. Binding explanation; used for permissions and environment configuration. Accessed 2026-10-01.
  2. Alchemy, Infrastructure as Effects | Office Hours 27 🔥 - YouTube. Sam Goodwin. Policy derivation discussion; used for least privilege from application methods. Accessed 2026-10-01.
  3. Bindings (env). Cloudflare. Bindings let a Worker interact with resources on the Cloudflare Developer Platform. Accessed 2026-11-08.
  4. Alchemy Queue resource at v2.0.0-beta.85. GitHub alchemy-run/alchemy. Use WriteQueue in the init phase and provide WriteQueueBinding in the runtime layer. Accessed 2026-11-08.
  5. Basin event sink. GitHub joelhooks/rat-stack. The events cartridge binds its Pipelines stream with WriteStream and WriteStreamBinding. Accessed 2026-11-08.

Last changed 2026-11-08 in fa39fa0. Source on GitHub. Change log.

Linked from

  1. Agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.

    Bindings — Sam Goodwin describes bindings as the place where runtime permissions and configuration meet infrastructure.

  2. Analytics. One event per HTTP request, stored unchanged for queries to select and interpret later.

    A Worker binding, a declared connection to a resource, sends the event to an unstructured Cloudflare Pipelines stream.¶

  3. AT Protocol separates identity, data, and application schemas. AT Protocol connects persistent account identifiers, signed public repositories, hosting services, and shared schemas.

    It distinguishes public profile records, private runtime bindings, and mailbox procedures.

  4. Auth. Email and password sign-in through Better Auth, with the signed-in person provided to each RPC call.

    It calls the private LearnFeedbackAuth Worker through a Worker binding.

  5. Cartridges. A cartridge owns one job and brings the infrastructure its service needs.

    Declare the bindings that give it access to its resources.¶

  6. Change log. What changed in the files served here, newest first.

    Bindings — new page: Initial commit from joelhooks/rat-stack template

  7. Effect + Alchemy peer patterns. Source-grounded patterns from repos on nearby Effect and Alchemy pins.

    Our private RPC binding remains the supported browser path; no implementation changes follow.

  8. Effect Office Hours 27: Alchemy, infrastructure as effects. Sam Goodwin presents Alchemy as a system built with Effect for planning, testing, and deploying infrastructure.

    He explains bindings as application capabilities that can inform least-privilege policies, which limit permissions to the application methods in use.

  9. Feature flags. Typed feature flags with owners, removal dates, and stable subject rollouts.

    The operator layer adds the ledger DO and its KV write binding.¶

  10. Full agent guide. An Effect stack so pure (aspirational) Kit Langton will blush.
  11. Infrastructure as effects. Sam Goodwin relates application operations to infrastructure requirements in one typed program.

    Sam describes bindings as permissions and environment variables together at 37:09.

  12. Learn mode presents concepts at useful depths. An agent presents source-derived concepts during real work and keeps learning events in a private local log.

    On adds Better Auth table migrations and the Worker bindings that use them.¶

  13. learn-alchemy. Learn how Alchemy 2 turns an Effect program into a planned Cloudflare deployment.

    One program declares resources, bindings, deployment state, and the Worker that uses them.¶

  14. Lint and type escape ledger (debt.md). A source-linked count of repo-owned lint and type escapes.

    Reason: Alchemy types the Worker environment as a dictionary, so the declared bindings need one boundary cast.

  15. onboard-a-list. Analyze or migrate an email list. Measure sanitation rules, preserve stops, choose a cohort, and verify an authorized import or sending cutover.

    Verify real bindings with authorized synthetic recipients.

  16. Oxlint rule limits. How the current lint rules draw their syntax boundaries.
    Link context

    Residual limit and why: Mutation behind const, static fields, imported shared state, and block-scoped bindings that escape through closures are not binding-level let/var findings.

  17. Queues, Pipelines, Workflows and K2 do different jobs. Pick a Cloudflare product for work outside a request by the unit you track: a message, a row, a step, or a record in a log.

    A stream receives events over HTTP or a Worker binding.¶

  18. Rat Stack lore | rat-stack. Short, source-grounded notes on the ideas and decisions behind rat-stack.

    Bindings — Sam Goodwin describes bindings as the place where runtime permissions and configuration meet infrastructure.

  19. Sam Goodwin on Alchemy. Sam Goodwin explains Alchemy's Effect model, plans, bindings, and cloud-library idea.

    He explains how bindings connect runtime needs to infrastructure.

  20. Schema projections: 2026-09-18 history. Historical Effect rc.115 proposal and implementation receipts from 2026-09-18; use the one-capability-every-surface lore page for the current pattern.
    Link context

    The MCP or OpenAPI schema becomes a typed TypeScript API with doc comments; the model writes TS against it; it runs in an isolated Worker with no network, only bindings.

  21. security-audit. Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

    Resource owners declare their own Alchemy resources and binding layers:¶

  22. Source change history (log.md). The generated change log as Markdown.

    Bindings — new page: Initial commit from joelhooks/rat-stack template

  23. Trace operations where they mean something. Name useful operations, add safe context, and distinguish creating a span from delivering it to a backend.

    D1 and Durable Object SQL: SQL text; Durable Object SQL also records query bindings¶

  24. uncomplect. Find responsibilities that a rat-stack design combines, separate them into capabilities, cartridges, machines, features, and clients, and enforce that separation through types and checks. Use when asked to simplify, review, or replace a design, "what would Rich Hickey do", "optimize for deletion", or "define this error out of existence".

    Binding: A connection that gives runtime code access to a resource.¶

  25. Worker init runs twice. Alchemy Worker initialization runs in deploy and runtime contexts, so resource declarations need a boundary.

    ts sets the runtime flag and provides only runtime bindings.

Unlinked mentions (8)
  • Build and run rat-stack (README.md) → ts also composes Website and the WEBSITE binding.
  • Cartridges → Sam describes test or development Layers for infrastructure and a type error when code still requires a removed binding.
  • Effect + Alchemy peer patterns → D1 uses a runtime Worker binding and a separate deploy-time migration connection; Hyperdrive accepts the origin URL for migrations because its runtime connection is minted per invocation, and the integration scopes auth/database work to that execution.
  • Infrastructure as effects → What the program checks: Relationships before deployment; code that requires a removed binding¶
  • learn-alchemy → Binding is a typed runtime value attached to a Worker.
  • Lint and type escape ledger (debt.md) → Reason: Alchemy types the test Worker environment as a dictionary, so the binding needs one boundary cast.
  • Oxlint rule limits → Residual limit and why: Mutation behind const, static fields, imported shared state, and block-scoped bindings that escape through closures are not binding-level let/var findings.
  • uncomplect → Look for a database or queue declared separately from the Layer that consumes its binding.¶