For a quick overview of what Prisma 8 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 8 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
- Middleware observes a tree of activities (statements, transactions, ORM calls) through the lifecycle events
activityStarted,activityEndedandactivityFinalized, and changes or stops statements, or supplies an activity's result, through the interceptorsbeforeCompile(SQL),beforeEncode,interceptandonRow;intercept.onActivityanswers client activities such as ORM calls (ADR 271) - Composable linting, telemetry, query budgets, and policy enforcement
- Extension packs for domain-specific capabilities (vector search, geospatial, etc.)
Prisma 8 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.
@internal/contract— Core contract types (ContractBase,Source)@internal/operations— Target-neutral operation registry and capability helpers@internal/contract-authoring— Shared authored storage descriptor types@internal/cli— CLI tooling for contract emission@internal/emitter— Contract emission engine@internal/runtime-executor— Target-agnostic execution engine (verification, plugin lifecycle, telemetry)
@internal/sql-contract-ts— SQL-specific TypeScript contract authoring surface@internal/sql-contract— SQL-specific contract types (SqlContract,SqlStorage,SqlModelStorage)@internal/sql-operations— SQL-specific operation definitions and assembly@internal/sql-contract-emitter— SQL emitter hook implementation@internal/sql-relational-core— Schema and column builders, operation attachment, and AST types@internal/sql-lane— Relational DSL and raw SQL helpers@internal/sql-runtime— SQL family runtime that composes runtime-executor with SQL adapters@internal/adapter-postgres— Postgres adapter implementation@internal/driver-postgres— Postgres driver (low-level connection)
@internal/postgres— Postgres target package (one-liner client entry point)
@internal/pgvector— pgvector extension pack for vector similarity search
Modern developer agents (Cursor, Windsurf, Claude Code) increasingly read, reason about, and modify codebases. Prisma 8 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 8 |
|---|---|---|
| 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 8:
- Write
schema.psl - Run
prisma 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