Builds backends with @alchemy.run/domain using domain-driven design on Effect. Guides modeling aggregates, commands, events, sagas, projections, and queries in a monorepo, with hosting on Durable Objects and a foldkit frontend.
Ships in alchemy. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
@alchemy.run/domain models a backend as typed messages and pure state transitions. Commands are decided by aggregates, which record events. Views fold events into read models. Policies react to events. Sagas run long processes. Projections write outside the model, and queries serve what they wrote. The same model runs in memory for tests and on Cloudflare, Rivet or Effect Cluster Durable Objects in production.
Docs: https://alchemy.run/domain, with every page listed in https://alchemy.run/llms.txt. Every section here and in the reference files ends with a More link to the docs page that covers it in depth. A complete reference project: examples/cloudflare-domain in the alchemy repo (a bank with a foldkit app).
Work in this order. Each step has a reference file with templates.
Verify checks. See references/testing.md.alchemy-ai skill, which builds on this model and returns here for the front end.More: Tutorial, part 1.
Read the requirements as a story of facts, and name each kind of thing you find:
MoneyWithdrawn): an Event.<Verb><Noun> (WithdrawMoney): a Command.InsufficientFunds): a Rejection.yield* Triage, and a session reports back by sending the model's commands. Domain knows nothing more of it. Use the alchemy-ai skill (packages/ai/skills/alchemy-ai, or https://alchemy.run/ai) for the process itself.decide, a view or stream in its Layer's validate, a query in its handler.A rule that spans aggregates needs an aggregate for each thing it's about. Give an invariant with no owner its own aggregate, keyed by what it protects (UsernameClaim keyed by username), and implement the command with a decision that reads every instance involved. A process that takes time, waits, or calls an external system is a saga, with a deadline for anything that waits.
For history that grows or has to change, pick a pattern from references/modeling.md.
More: What is Domain-Driven Design?, Domain Model, Decision.
<Noun>.<kind>.ts. The kinds are .aggregate, .command, .decision, .view, .policy, .saga, .projection, .stream, .query, .external, .api and .model. Plus .middleware, .context and .rejection. An aggregate's id lives in <Aggregate>.id.ts next to it. Plain values (Money.ts) and helpers keep plain names.TransferExecutionLive in TransferExecution.policy.ts), unless it touches infrastructure. Then it lives in the server package.Account/, Transfer/). The model, Apis, middleware and request context sit at the package root.@alchemy.run/domain and effect. Cloudflare, Stripe, databases and HTTP session handling belong to the server package.() => ({ ... }): Domain.Model, Domain.View, Domain.Aggregate, Domain.Projection, Domain.Stream, Domain.Policy, Domain.Saga, Domain.Query, Domain.Decision and Domain.Api take one, with the same type. Events, commands and rejections are schemas and never do. More: Break an import cycle.More: Project layout.
decide is pure, or an Effect.fn that reads only what its command's middleware provides (yield* CurrentActor). It returns events or a rejection; it never performs I/O.evolve only applies an event to state. It never decides anything. It and reply are total: they cover every state and never fail, because decide already refused what can't happen. Keep a state the event can't follow (s._tag === "Open" ? { ...s, balance: e.balanceAfter } : s), never a guard that throws.decide worked out (balanceAfter), so evolve copies it instead of repeating a rule.rejects. Callers handle each one with Effect.catchTag.Domain.Query on an Api, never a hand-written route: its handler checks the caller and scopes the rows it reads.yield* Account then accounts.get(ref).stream:seq.start it, keyed by the aggregate it's about, and react to the events its steps record.toLayer. Per call it requires nothing but the runtime it runs in (RuntimeContext), which the platform provides.Layer.mergeAll, Layer.provide). Never chain Effect.provide.throw. Fail with tagged errors (Domain.Rejection, Schema.TaggedError).Effect.annotateCurrentSpan in a handler: it lands on the engine's span for that handler. Make secrets Schema.Redacted, so they never reach a trace or a log.More: Domain Model: The aggregate decides, and everything commits at once, Cloudflare: Count on these guarantees.
<Command>.command.ts with its events and rejections.commands, whose input carries the id field the aggregate's keyOf reads, a decide branch for it and an evolve branch for each event.{ description } as its last argument.tsc -b) and run the server and web tests.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/alchemy:alchemy-domainfrom alchemy
npx claudepluginhub alchemy-run/alchemy --plugin alchemyOther plugins' skills for the same job