skill

Prisma Driver Adapter Implementation

Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.

prisma300,037+ installsVetted

About

# Prisma SQL Driver Adapter Implementation

Use this guide with the exact `@prisma/driver-adapter-utils` version installed by the target Prisma release. Driver adapters are a protocol boundary: type-compatible code can still corrupt values, leak connections, or break transactions.

## When to Apply

- Implementing `SqlDriverAdapterFactory`, `SqlMigrationAwareDriverAdapterFactory`, `SqlDriverAdapter`, or `Transaction` - Adding nested-transaction/savepoint support - Mapping driver values, column metadata, bind arguments, or database errors - Debugging `P2039`, transaction leaks, shadow-database failures, or adapter-specific query behavior

## Contract snapshot

```typescript interface SqlDriverAdapterFactory extends AdapterInfo { connect(): Promise<SqlDriverAdapter> }

interface SqlMigrationAwareDriverAdapterFactory extends SqlDriverAdapterFactory { connectToShadowDb(): Promise<SqlDriverAdapter> }

interface SqlDriverAdapter extends AdapterInfo { queryRaw(query: SqlQuery): Promise<SqlResultSet> executeRaw(query: SqlQuery): Promise<number> executeScript(script: string): Promise<void> startTransaction(isolationLevel?: IsolationLevel): Promise<Transaction> getConnectionInfo?(): ConnectionInfo dispose(): Promise<void> }

interface Transaction extends AdapterInfo { readonly options: { usePhantomQuery: boolean } queryRaw(query: SqlQuery): Promise<SqlResultSet> executeRaw(query: SqlQuery): Promise<number> commit(): Promise<void> rollback(): Promise<void> createSavepoint?(name: string): Promise<void> rollbackToSavepoint?(name: string): Promise<void> releaseSavepoint?(name: string): Promise<void> } ```

`IsolationLevel` currently includes `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, `SNAPSHOT`, and `SERIALIZABLE`; validate what the concrete database supports.

## Priority rules

| Priority | Rule | Impact | |----------|------|--------| | CRITICAL | One dedicated connection per transaction | Prevents interleaving and leaks | | CRITICAL | `commit`/`rollback` are lifecycle cleanup hooks | Prevents duplicate COMMIT/ROLLBACK | | CRITICAL | Savepoints live on `Transaction`, not adapter-global depth | Makes nested scopes connection-local | | CRITICAL | Preserve original database error code/message | Enables useful `P2039` fallback | | HIGH | Map arguments and result metadata exactly | Prevents silent value corruption | | HIGH | Shadow databases are isolated and always cleaned up | Makes Migrate safe | | HIGH | Dispose only resources the adapter owns | Prevents shutting down caller-owned pools |

## Query implementation

`SqlQuery` contains `sql`, `args`, and parallel `argTypes`. Map each argument using both value and `ArgType`; do not discard type/arity information. Execute in the driver's array/tuple row mode so column order is stable.

```typescript class ExampleQueryable { readonly provider = 'postgres' as const readonly adapterName = '@acme/adapter-example'

constructor(protected readonly connection: DriverConnection) {}

async queryRaw(query: SqlQuery): Promise<SqlResultSet> { try { const result = await this.connection.query({ text: query.sql, values: query.args.map((value, index) => mapArg(value, query.argTypes[index]), ), rowMode: 'array', })

return { columnNames: result.fields.map((field) => field.name), columnTypes: result.fields.map(mapColumnType), rows: result.rows, } } catch (error) { throwAdapterError(error) } }

async executeRaw(query: SqlQuery): Promise<number> { try { const result = await this.connection.execute( query.sql, query.args.map((value, index) => mapArg(value, query.argTypes[index])), ) return result.rowsAffected ?? 0 } catch (error) { throwAdapterError(error) } } } ```

### Result mapping

Return `columnNames`, `columnTypes`, and `rows` with identical lengths/order. Map driver metadata to `ColumnTypeEnum` deliberately:

- signed integer widths to `Int32`/`Int64`; preserve 64-bit values without JS number truncation - decimal/numeric to `Numeric` using the representation expected by Prisma - binary to `Uint8Array`/`Bytes` - date-only, time-only, and timestamp to `Date`, `Time`, and `DateTime` - UUID, JSON, enum, arrays, and provider-specific unknown values to their explicit types - unsupported native types to `DriverAdapterError({ kind: 'UnsupportedNativeDataType', type })`

Test `null`, empty arrays, array element types, big integers, decimals, byte arrays, JSON, dates, and user-defined/unknown native types.

### Script execution

`executeScript` must execute a migration script as the provider expects. Prefer the driver's native multi-statement/script facility or a real SQL parser. Naively splitting on `;` breaks functions, triggers, quoted strings, and dialect-specific blocks.

## Transaction protocol

`startTransaction` must acquire one dedicated connection, start the database tran

Install

Run this command

npx skills add prisma/skills

Works with

claude appclaude codeclaude apicursorcodexwindsurfclinezed

Manual steps

Install with `npx skills add prisma/skills`, or clone the repository and copy the `prisma-driver-adapter-implementation` folder into your Claude skills directory.

View source
License: MITBy prisma

Frequently asked questions

What is the Prisma Driver Adapter Implementation skill?

Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.

How do I install Prisma Driver Adapter Implementation?

Run this in your terminal:

npx skills add prisma/skills
Which AI tools does Prisma Driver Adapter Implementation work with?

It works with claude_app, claude_code, claude_api, cursor, codex, windsurf, cline, zed.

Who made Prisma Driver Adapter Implementation?

prisma, released under the MIT license.

Is Prisma Driver Adapter Implementation free?

Yes, it is free to use under the MIT license.

Related assets

More curated picks in Data & Analytics.

All Prisma Driver Adapter Implementation alternatives →
skillclaude_appclaude_codeclaude_api
npx skills add google/agents-cli
Google Agents Cli Observability
This skill should be used when the user wants to "set up tracing", "monitor my agent", "configure logging", "add observability", "debug production tra…357,631+
skillclaude_appclaude_codeclaude_api
npx skills add neondatabase/agent-skills
Neon Postgres
Guides and best practices for working with Lakebase Postgres on Neon: connections, pooled vs direct, schema migrations, branching, autoscaling, scale-…187,765+
skillclaude_appclaude_codeclaude_api
npx skills add firebase/agent-skills
Firebase Basics
Provides foundational Firebase CLI setup, CLI installation, version checks (`firebase-tools@latest --version`), CLI login (including --no-localhost),…158,802+
skillclaude_appclaude_codeclaude_api
npx skills add firebase/agent-skills
Firebase Auth Basics
Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data acce…157,711+
skillclaude_appclaude_codeclaude_api
npx skills add firebase/agent-skills
Firebase Hosting Basics
Deploys and configures classic Firebase Hosting for static websites, single-page apps (SPAs), and microservices. Use when deploying static sites/SPAs,…153,880+
skillclaude_appclaude_codeclaude_api
npx skills add neondatabase/agent-skills
Neon
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, and the AI Gateway. Start here…141,316+

Audit before you install

Run any source through our checks - AI visibility, security, performance, and stack detection.

More in Data & Analytics