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/mcpCursor 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-stackSupports 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.
- MCP connection details
- HTTP API docs
- Short agent guide
- Public rules, lore, systems, and skills
- Lore wiki
- Systems
Four ideas
- Pieces. An Alchemy Layer carries its own infrastructure. A service tag is the product's API. A Layer is one vendor's implementation. Swapping vendors is a one-line change.
- Trust. Make the easy path the right path. The codebase and the compiler stop mistakes that rules and style guides can only ask about. Remove a binding and the code that uses it stops compiling.
- Floor. Raise the worst case. Small cuts to failure rates multiply how long an agent can run unattended.
- Range. Think wider. Building got fast and deploying did not. Layers that carry their own infrastructure close that gap. If it compiles, it deploys.
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 β
ββββββββββββββ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 WorkerWhat 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
- rat-stack-mode β Route non-trivial rat-stack code, data, design, investigation, and documentation tasks to every matching playbook and principle.
See how the pieces fit
- find-peers β Refresh public peers, exact stack versions, and usefulness tiers every week or two and after each shared-line bump. Study source before adopting patterns.
- learn-alchemy β Learn how Alchemy 2 turns an Effect program into a planned Cloudflare deployment.
- learn-rat-stack β Trace a capability through Effect, XState, five projections, the CLI, and Alchemy. Try hosted search and read.
Learn by building
- add-a-capability β Learn how one contract and its handler become a command, HTTP route, MCP tool, browser RPC, and sandbox call.
- add-a-lifecycle-machine β Learn how XState owns a lifecycle while Effect owns its work, errors, and services.
- add-a-store β Add persistence behind a job-shaped service with schema validation, vendor Layers, migrations, bounded reads, and shared backend tests.
- write-a-wiki-page β Write or revise public wiki pages with short prose, cited claims, meaningful visuals, and pinned code snippets.
Choose what you keep
- keep-or-cut β Learn which pieces depend on each other, then keep only the ones your project needs.
- uncomplect β Find what a rat-stack design braids together, separate it into capabilities, cartridges, machines, features, and clients, and fence the separation so the next change cannot braid it again. 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".
Keep the fence sharp
- gardener β Keep rat-stack current and clean. Bump the bleeding-edge pins, learn from repos on the same versions, and turn every bad pattern into a lint rule before cleaning it up.
Ship with evidence
- ship β Learn how to ship a change through merge, CI, release, stage deployment, rollout, verification, rollback and flags.
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
- Agent rules for rat-stack (AGENTS.md) β What you may change, which commands to run, and which changes need approval.
- Purpose and boundaries of rat-stack (VISION.md) β What this starter is for and what a useful copy should keep.
- Build and run rat-stack (README.md) β What is in the repo, how the example works, and how to run it.
- Dependency vendoring rules (vendor/README.md) β How to pin an unpublished package and when to remove the local copy.
- Exact workspace dependency pins (pins.md) β Exact dependency values declared by every workspace package.
- Change log β What changed in the files served here, newest first.
- Source change history (log.md) β The generated change log as Markdown.
- Lint and type escape ledger (debt.md) β A source-linked count of repo-owned lint and type escapes.
- Effect 4 study: September 2026 β Dated Effect 4 source studies from September 2026; current versions live in pins.md.
- 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.
- Oxlint rule limits β How the current lint rules draw their syntax boundaries.
- Effect + Alchemy peers β Public repositories that share rat-stack's prerelease lines.
- Effect + Alchemy peer patterns β Source-grounded patterns from repos on nearby Effect and Alchemy pins.