Rat Stack

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

The goal is to build the best Effect + Alchemy application we can. This is the reference for building an app and its cloud as one typed program. Effect owns the hard parts. Alchemy infers the infrastructure from the code. The fence raises the floor, so agents can build it and you can still trust it.

Vendor it like a library. Keep the bins you need and pull the rest.

Connect an agent

Paste this into your coding agent:

Read https://ratstack.sh/llms.txt and use rat-stack as the reference
for how we build: Effect for the hard parts, Alchemy for the
infrastructure, and a fence that makes the easy path the right
one. Search its rules and skills before you write code, follow
its patterns, and tell me when my code breaks them.

Or connect the MCP server directly:

# Claude Code
claude mcp add --transport http rat-stack https://ratstack.sh/mcp

# Codex
codex mcp add rat-stack --url https://ratstack.sh/mcp

Cursor reads ~/.cursor/mcp.json:

{ "mcpServers": { "rat-stack": { "url": "https://ratstack.sh/mcp" } } }

Install the skills into any agent that reads a skills folder:

npx skills add joelhooks/rat-stack

Supports MCP protocol versions 2026-07-28, 2025-11-25, 2025-06-18, 2025-03-26, and 2024-11-05. Clients on protocol 2026-07-28 are served without sessions; older clients get a session of their own, held by a Durable Object.

Four ideas

The vision has the sources and the reasoning.

The shelf

These packages have separate jobs. Follow the removal checklists before cutting a bin; a package name alone does not prove one-line removal.

  labeled Β· push in Β· pull out Β· self-contained Β· easy to trash

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ capability β”‚ β”‚ core       β”‚ β”‚ database   β”‚ β”‚ auth       β”‚
  β”‚ contracts  β”‚ β”‚ handlers   β”‚ β”‚ D1 Β· PG    β”‚ β”‚ Better Authβ”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ devtools   β”‚ β”‚ web        β”‚ β”‚ infra      β”‚ β”‚ fence      β”‚
  β”‚ call logs  β”‚ β”‚ TanStack   β”‚ β”‚ Alchemy    β”‚ β”‚ types Β· CI β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       in             in             in             in

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ events     β”‚ β”‚ lore       β”‚ β”‚ subscriber-delivery β”‚
  β”‚ analytics  β”‚ β”‚ graph      β”‚ β”‚ delivery adapter    β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ front door β”‚  coming: its own cartridge
  β”‚ REST Β· MCP β”‚
  β”‚ A2A Β· code β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
A shelf of current rat-stack bins: capability, core, database, auth, devtools, events, lore, subscriber-delivery, web, infra stack, and fence. The generic agent front door becoming its own cartridge is coming.

What to notice: these bins exist today. The hosted REST, MCP, A2A, and sandbox routes already run; extracting their generic front door into its own cartridge is coming.

Hexagonal architecture keeps job-shaped ports in core and provider adapters outside it. HATEOAS explains links that guide an agent's next action, including agent-only page guidance. Analytics is a running capture system; interest signup shows consent and confirmation across a delivery adapter.

One capability, every surface

              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  one contract + capability          β”‚
              β”‚  Effect Schema: input Β· output Β· errβ”‚
              β”‚  one Effect handler                 β”‚
              β”‚  XState when the work has states    β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚  defineContract β†’ implement
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β–Ό            β–Ό            β–Ό            β–Ό            β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ command  β”‚ β”‚   HTTP   β”‚ β”‚   MCP    β”‚ β”‚   RPC    β”‚ β”‚ sandbox  β”‚
  β”‚   line   β”‚ β”‚ + OpenAPIβ”‚ β”‚  tools   β”‚ β”‚ browser  β”‚ β”‚ code modeβ”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

  checked by  TypeScript 7 Β· Oxlint Β· Vitest Β· lefthook
  shipped by  pnpm Β· Turborepo Β· Alchemy β†’ Cloudflare Worker
One capability projected to the command line, HTTP with OpenAPI, MCP tools, browser RPC, and sandbox code mode

What to notice: all five projections share one contract and handler. RPC serves the browser; it is not an agent interface.

The pattern in code

This is the whole search capability. Every surface below calls it.

export const search = implement(searchContract, ({ limit, query }) =>
  ContentStore.use((store) => store.search(query, limit)).pipe(
    Effect.map((matches) => ({ matches, total: matches.length }))
  )
);

What to notice: the schemas and handler share one contract, so the command line, HTTP, MCP, RPC, and sandbox projections cannot quietly disagree. RPC serves the browser.

Learn the stack

Skills are short guides your agent can install (see above). You can also just read them here.

Start here

See how the pieces fit

Learn by building

Choose what you keep

Keep the fence sharp

Ship with evidence

These pieces are pre-release (Effect 4 rc, XState 6 alpha, TypeScript 7, Alchemy beta). APIs move; pins.md has the exact versions this repo builds against.

Source files