For a quick overview of what Prisma Next is, see the README.
Prisma's current ORM architecture tightly couples three layers — the Prisma Schema Language (PSL), the generated client, and runtime execution. This coupling introduces rigidity, rebuild cost, and conceptual opacity.
Prisma Next rethinks Prisma's data layer around a contract-first model, where the schema is a stable, versioned artifact describing the database structure — not fuel for codegen, but a data contract.
- Deterministic JSON contract plus TypeScript types replace heavy runtime codegen
- Open, inspectable artifacts; no opaque generated methods
- Contract includes a
contractHashto cryptographically tie all artifacts to a specific schema version
- Write queries inline with a minimal DSL (
sql().from(...).select(...)) - Plans are verifiable and transparent; no hidden multi-query behaviors
- Only PSL to IR to types emission happens at build time — query compilation happens at runtime
- Contract JSON is consumable by tools and agents
- Hashes enable verification and drift detection
- Structured Plans include AST, referenced columns, and contract hash
- First-class hook system for Plan lifecycle events (
beforeCompile,afterExecute,onError) - Composable linting, telemetry, query budgets, and policy enforcement
- Extension packs for domain-specific capabilities (vector search, geospatial, etc.)
Prisma Next organizes packages using a three-dimensional architecture.
| Domain | Description | Location |
|---|---|---|
| Framework | Target-agnostic core (contracts, operations, runtime-executor) | packages/framework/ |
| SQL Family | SQL-specific implementations (operations, lanes, runtime) | packages/sql/ |
| Targets | Concrete adapters and drivers (postgres-adapter, postgres-driver) | packages/targets/ |
| Extensions | Optional capability packs (pgvector) | packages/extensions/ |
Dependencies flow downward (toward core); lateral dependencies within the same layer are permitted:
Core → Authoring → Targets → Lanes → Runtime Core → Family Runtime → Adapters
graph LR
Core[Core] --> Authoring
Authoring --> Targets
Targets --> Lanes
Lanes --> RuntimeCore[Runtime Core]
RuntimeCore --> FamilyRuntime[Family Runtime]
FamilyRuntime --> Adapters
style Core fill:#e1f5ff,stroke:#01579b,stroke-width:2px
style Authoring fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
style Targets fill:#fff3e0,stroke:#e65100,stroke-width:2px
style Lanes fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px
style RuntimeCore fill:#fce4ec,stroke:#880e4f,stroke-width:2px
style FamilyRuntime fill:#fff9c4,stroke:#f57f17,stroke-width:2px
style Adapters fill:#e0f2f1,stroke:#004d40,stroke-width:2px
- Shared: Code usable by both migration and runtime
- Migration: Build-time authoring, emission, and planning (CLI, emitter, control plane)
- Runtime: Execution-time query building and execution (DSL, executor, adapters)
See architecture.config.json for the complete domain/layer/plane mappings and pnpm lint:deps to validate boundaries.
@prisma-next/contract— Core contract types (ContractBase,Source)@prisma-next/operations— Target-neutral operation registry and capability helpers@prisma-next/contract-authoring— Shared authored storage descriptor types@prisma-next/cli— CLI tooling for contract emission@prisma-next/emitter— Contract emission engine@prisma-next/runtime-executor— Target-agnostic execution engine (verification, plugin lifecycle, telemetry)
@prisma-next/sql-contract-ts— SQL-specific TypeScript contract authoring surface@prisma-next/sql-contract— SQL-specific contract types (SqlContract,SqlStorage,SqlModelStorage)@prisma-next/sql-operations— SQL-specific operation definitions and assembly@prisma-next/sql-contract-emitter— SQL emitter hook implementation@prisma-next/sql-relational-core— Schema and column builders, operation attachment, and AST types@prisma-next/sql-lane— Relational DSL and raw SQL helpers@prisma-next/sql-lane-query-builder— Query builder lane@prisma-next/sql-runtime— SQL family runtime that composes runtime-executor with SQL adapters@prisma-next/adapter-postgres— Postgres adapter implementation@prisma-next/driver-postgres— Postgres driver (low-level connection)
@prisma-next/postgres— Postgres target package (one-liner client entry point)
@prisma-next/pgvector— pgvector extension pack for vector similarity search
Modern developer agents (Cursor, Windsurf, Claude Code) increasingly read, reason about, and modify codebases. Prisma Next is designed to be natively accessible to these tools:
- PSL as explicit contract — The IR is a deterministic JSON artifact: machine-readable, diffable, and stable
- Stable query DSL — Queries are typed, composable ASTs that agents can statically analyze or synthesize
- Runtime integration surface — Structured hooks around compile/execute events for verification, profiling, and policy enforcement
- Structured plans — Every query results in a Plan object with AST, referenced columns, and contract hash
Agents can read the schema (IR), generate valid queries (DSL), and verify them (runtime) — all through open, structured artifacts with no black-box client to reverse engineer.
| Feature | Prisma ORM | Prisma Next |
|---|---|---|
| Schema Model | Codegen for runtime client | Contract IR + TypeScript types |
| Code Generation | Heavy, runtime-bound | Minimal, build-time only |
| Query Interface | Generated methods | Composable DSL |
| Machine Readability | Opaque client code | Structured IR JSON |
| Verification | None | Contract hash + runtime checks |
| Extensibility | Monolithic client | Plugin and hook system |
| Migration Logic | Sequential scripts | Contract-based, deterministic |
Prisma ORM:
- Write
schema.prisma - Run
prisma generate— generates executable client code - Write application code using generated methods:
prisma.user.findMany()
Prisma Next:
- Write
schema.psl - Run
prisma-next contract emit— generates lightweight types + contract JSON - Write application code using composable DSL:
sql().from(t.user).select(...)
- Architecture Overview — High-level design principles
- Package Layering Guide — Layer details and dependencies
- ADR Index — Architecture Decision Records (140+)
- Subsystem Specifications — Detailed design docs for major components