Metakit / @doeixd/metakit

metakit

Effect Schema turns your data shapes into inspectable ASTs: one Schema gives you TypeScript types, decoding, encoding, JSON Schema, and Arbitrary generators. That stops the moment you write a business rule in Schema.makeFilter(a => a.reserved <= a.balance) or a state update in a plain TypeScript function. JavaScript closures are opaque, so you end up rewriting the same rule in SQL CHECK/WHERE clauses, again in UI disabled checks, and again in tests—and nothing proves an update cannot break an invariant.

@doeixd/metakit is the natural extension of Effect and Effect Schema for inspectable rules and single-step transitions. Replace only the opaque closure with a typed expression tree (Expr.refine) and a declarative Transition; your Schema, Result, Option, and Effect pipelines stay untouched while every consumer reads the same rule—validation, SQL/Drizzle, UI & agent affordances, form specs, SSR pruning, and Zone/Z3 proofs.

See it

Run the live end-to-end example in examples/metakit/src/demo.ts (pnpm --filter foldkit-example-metakit demo), or read Why Effect Schema needs inspectable expressions for the full breakdown of what changes when rules become data.

Install

bash
pnpm add @doeixd/metakit effect

Install optional peers only for the subpaths you use:

bash
pnpm add drizzle-orm      # only for @doeixd/metakit/drizzle
pnpm add -D z3-solver     # only for @doeixd/metakit/prove's Z3 escalation