CodeVetter
← All unpacks
CodeVetter · Repo Unpack evidence

prisma/prisma

Scanned commit dd867230cd dated 2026-09-22 — last upstream commit. Generated by codevetter 1.12.0 on 2026-09-22.

github.com/prisma/prisma ↗ · 4000 files · 25.9 MB · scan capped

Docs | Discord | X | Blog Post | Architecture --- Using Prisma 7? It remains fully supported.

Deep analysis by cli:grok via the grok CLI on 2026-09-22 (477s) — every claim below links to its cited source files.

Overview

Prisma 8 (root package @internal/monorepo at 8.0.0-rc.11) is a contract-first TypeScript data layer for application developers and coding agents. A schema is emitted as contract.json plus contract.d.ts; queries are a composable DSL compiled at runtime, not a generated client of findMany methods. The same contract gates migrations (control plane) and execution (runtime plane). Postgres and MongoDB are first-class targets, SQLite is a proof of concept, and dialect behavior is added as extension packs rather than branches in the core.

System map

The repo is a pnpm/Turbo workspace that requires Node >=24. Framework code lives under packages/1-framework, SQL and Mongo families under packages/2-*, concrete adapters under packages/3-targets and packages/3-mongo-target, and user-facing facades under packages/3-extensions with publishable shells in packages/9-public/@prisma. architecture.config.json assigns every glob a domain, layer, and plane; dependency-cruiser enforces those edges. The in-repo prisma binary is a stand-in that mounts the ORM command family; the published host is the separate prisma-cli repo. Local Postgres is docker-compose on port 5433; CI and npm publish run from GitHub Actions.

Feature catalog

User-facing surface is the prisma CLI command family plus three database facades (postgres, mongo, sqlite) and extension packs. Contract commands are offline; db commands need a live connection; migration commands manage on-disk contract-to-contract edges and named refs. The language server speaks LSP over stdio. A Vite plugin re-emits the contract during dev. The Postgres client exposes sql, orm, raw, enums, transactions, and prepared statements, with a separate serverless entry that returns a connectable runtime.

Data flow

Authoring starts in prisma.config.ts, where defineConfig binds a family, target, adapter, driver, and extensions to a contract source. Emit loads that source, enriches it with component descriptors, round-trips it through the target serializer, and writes a canonical JSON document plus a generated contract.d.ts. At runtime the Postgres client revalidates that JSON into a typed contract, and the SQL runtime lowers a query plan to SQL, encodes parameters, checks the marker, and decodes rows. Schema changes are a separate pipeline: introspect the database, plan a contract-space aggregate, and apply operations under a class policy. CLI telemetry is a side channel that forks a sender after the command settles.

Behavior traces

Three flows dominate. Process startup wires telemetry, a CLI engine, and a host runtime, then dispatches one mounted command. Contract emit is offline: config, source provider, enrichment, canonical JSON, and a dts pair. A Postgres query stays lazy until first use, then compiles middleware, lowers SQL, encodes codecs, checks the marker, and streams decoded rows. db update is the persistence path: prepare a control client, pre-plan destructive work, and only then introspect, plan, and apply.

Testing signals

Vitest is the package, integration, and e2e runner. The root config discovers every package vitest.config.ts, forces telemetry off, and on CI caps workers at 50% because PGlite plus Postgres oversubscribes the runner. Package tests are sharded four ways with v8 coverage; integration tests are also sharded but, until about 2026-08-21, do not run in merge queue. A large scorecard separates features proven by a database integration test from features that are only unit-tested. Fixture drift is a git diff of emitted contract files, not an ad-hoc snapshot.

Risk map

The sharp edges are warn-only marker checks, a contract loader that bundles and imports user TypeScript from the temp directory, package-manager and telemetry child processes, and a destructive migration consent flow that can be satisfied non-interactively. Supply-chain controls exist (frozen lockfile, release-age cooldown, OIDC publish, least-privilege CI tokens) but several trust exclusions are intentional. SQLite is not at parity, integration tests do not block the merge queue during the launch window, and the in-repo CLI can drift from the external prisma-cli host.

Extension points

New behavior is supposed to arrive as a composed descriptor, not a core branch. The control stack orders extension packs and merges authoring contributions, codecs, aggregates, and capabilities. The same extensions array is accepted by defineConfig and by the postgres() runtime options. CLI commands are a record passed to defineCommandFamily, with a factory injection point for the control client. Public npm names are thin shells over internal packages. pgvector is the concrete pattern: a pack meta id, authoring types, a codec registry, and SQL lowering templates.

Contributor handoff

Agents should treat this as a layered contract compiler plus a runtime, not as a Next.js app. Start from Agents.md, the architecture overview, and architecture.config.json. Use pnpm on Node 24, rebuild before typecheck, and do not bypass lint:deps. Tests are written first and run with Vitest; name the Contract type at every JSON boundary; never use any, zod, or a bare cast. Skills and rules have one canonical directory each. The traps that waste a session are stale dist types, plane violations, fixture drift, warn-only marker checks, and editing a gitignored symlink tree.

Languages

LanguageFilesShare of source
TypeScript469497%
Markdown1214docs/config
JSON992docs/config
JavaScript1052%
SQL411%
YAML30docs/config
CSS4docs/config
HTML3docs/config

Start reading here

Probable source entrypoint: packages/ — inferred from the directory tree and manifest, not the upstream docs.

Source roots

packages/ (981 files)

Repository structure

Top-level pathFiles
packages/981
test/980
examples/851
projects/391
docs/292
skills/96
.agents/90
scripts/79

Docs found: AGENTS.mdARCHITECTURE.mdCLAUDE.mdCONTRIBUTING.mdREADME.mddocs/Architecture Overview.mddocs/CLI Style Guide.mddocs/Error Handling.mddocs/README.mddocs/Serverless Deployment Guide.md

Package

package.json — @internal/monorepo v8.0.0-rc.11, 22 declared dependencies.

@biomejs/biome@cursor/sdk@internal/cli@internal/framework-components@internal/migration-tools@repo/tsconfig@types/node@vitest/coverage-v8arktypedependency-cruiseres-module-lexergray-matter

CI & config entrypoints

Structural health signals

Average score 5.6/10 across 96 analyzed source files; 90 hotspots surfaced.

These are deterministic review leads — size, churn, and structural signals — not proof of a bug in this project.

Recent history