prisma/prisma
internals
Active contributors: jacek-prisma, Oleksii Orlenko, Søren Bramer Schmidt
Purpose
@prisma/internals is the kitchen sink of CLI ↔ engine glue. It exports the helpers Prisma's own CLI, Migrate, and generators all depend on: schema loading, DMMF retrieval, configuration parsing, generator orchestration, error rendering, and platform detection.
It's intentionally a single package rather than several smaller ones because the boundaries between these helpers were drawn before the workspace had today's level of structure. New abstraction belongs in dedicated packages (e.g., client-common, client-runtime-utils, client-generator-registry); @prisma/internals is preserved for back-compat and for the orchestration glue that doesn't fit anywhere else.
What it exports
From AGENTS.md and the export map:
arg— argument parsing helper (re-exported from the upstreamargpackage)getDMMF— calls@prisma/prisma-schema-wasmto compute a DMMF AST from a schemagetConfig— calls the same Wasm to extractdatasource/generatorblocksgetGenerators— orchestrates running each generator in a Prisma projectloadSchemaContext— locates and loads the project's Prisma schema (less used post-Prisma 7;prisma.config.tsis the new entry)- Error rendering helpers used by
prisma formatandprisma validate - Engine resolution helpers (delegated to
@prisma/engines) - Prompt and terminal output utilities
Directory layout
packages/internals/src/
├── ... # CLI utilities, schema loading, generator orchestration,
└── __tests__/ # Snapshot-heavy tests for getDMMF, getConfig, introspectionHow it's used
graph LR
CLI[packages/cli] --> INT[internals]
MIG[packages/migrate] --> INT
GENERATORS[client-generator-*] --> INT
INT --> WASM[prisma-schema-wasm]
INT --> ENG[engines]
INT --> CONFIG[config]A representative chain: prisma generate calls getDMMF and getGenerators from @prisma/internals. getDMMF invokes the Wasm parser; getGenerators shells out (via JSON-RPC over stdio) to each registered generator using @prisma/generator-helper as the IPC contract.
Snapshot tests
packages/internals/src/__tests__/ is heavy on snapshots — getDMMF output for many schemas, getConfig output, introspection results. From AGENTS.md:
Usually, dmmf changes are also visible in the tests of the
@prisma/internalspackage … If there is a change in the snapshots, only accept them if you're 100% certain that these changes are expected. If not, please always ping the Rust team.
A snapshot diff in internals after upgrading @prisma/engines is the most common signal that something changed in the schema parser or DMMF shape.
Integration points
@prisma/prisma-schema-wasm— Wasm PSL parser@prisma/engines— engine binary resolution@prisma/config—prisma.config.tsloader@prisma/generator-helper— IPC for external generators- Used by
packages/cli,packages/migrate, allpackages/client-generator-*
Entry points for modification
- Schema parsing changes: usually
getDMMF/getConfiginsrc/. If the change is in the parser itself, it's inprisma-engines(Rust), not here. - New CLI helper: add it under
src/, export fromindex.ts. Keep the API minimal — there's a known appetite for shrinking this package over time. - Snapshot updates after engine bumps: review carefully, never accept blindly.
See also
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.