masumi-network/sokosumi/prisma-driver-adapter-implementation
Claude Code and agent skill by masumi-network/sokosumi
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install masumi-network/sokosumi/prisma-driver-adapter-implementationSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as prisma/skills/prisma-driver-adapter-implementation.
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, orTransaction - 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
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.
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
Numericusing the representation expected by Prisma - binary to
Uint8Array/Bytes - date-only, time-only, and timestamp to
Date,Time, andDateTime - 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 transaction, apply the requested isolation level, and return a Transaction bound to that same connection. If setup fails, release it immediately.
Commit and rollback
Prisma coordinates the SQL COMMIT/ROLLBACK through executeRaw. The transaction object's commit() and rollback() methods are lifecycle hooks: detach listeners and release the dedicated connection exactly once. They must not issue a second SQL commit/rollback.
Implement the optional savepoint methods only where the provider supports them. Validate/quote savepoint identifiers. For providers whose savepoints are intentionally no-ops, document and test that limitation.
Never keep transaction depth on the shared adapter. Parallel transactions make adapter-global depth incorrect; nested state belongs to the returned transaction connection and Prisma's savepoint calls.
Error mapping
Wrap recognized driver failures in DriverAdapterError. Map known conditions to MappedError kinds such as constraint violations, authentication/reachability, missing table/column/database, timeouts, closed transactions, invalid input, value range, and write conflicts.
For database errors, preserve originalCode and originalMessage even when falling back to the provider-specific raw variant:
Prisma uses preserved original details when an unmapped driver error becomes P2039. Do not replace every unknown exception with a fabricated GenericJs id; rethrow genuinely unexpected non-driver errors so programming bugs remain visible.
Factory, ownership, and shadow database
connect()returns a fresh usable adapter connection/pool wrapper.- Track whether the factory created the pool.
dispose()closes owned pools and only detaches listeners from caller-owned pools unless an explicit option transfers ownership. - Implement
SqlMigrationAwareDriverAdapterFactoryonly whenconnectToShadowDb()can create an isolated shadow database, connect to it, and drop it during disposal/failure cleanup. - Never point the shadow adapter at the primary database. Quote generated identifiers and use cryptographically unique names.
getConnectionInfo()should accurately reportschemaName,maxBindValueswhen applicable, andsupportsRelationJoins.
Verification checklist
- [ ] Typecheck against the exact target
@prisma/driver-adapter-utilsversion - [ ]
queryRawpreserves column order, types, nulls, and precision - [ ]
executeRawreports affected rows correctly - [ ]
executeScripthandles provider-specific multi-statement syntax - [ ] Concurrent interactive transactions use distinct dedicated connections
- [ ] Success commits and releases once; failure rolls back and releases once
- [ ] Nested transaction tests exercise create/rollback/release savepoint hooks
- [ ] Unsupported isolation levels fail as
InvalidIsolationLevel - [ ] Known constraints map to structured errors
- [ ] Unmapped database errors retain original code/message and surface useful
P2039 - [ ] Dispose ownership is tested for internal and external pools
- [ ] Shadow database creation, use, failure cleanup, and disposal are isolated
- [ ] Run Prisma Client integration/E2E tests, not only adapter unit tests
Source references
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingpackages/database/.agents/skills/prisma-driver-adapter-implementation/SKILL.md
Popularity
- Repository stars
- 12
- Repository forks
- 8
- 7-day trend score
- 13
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 8 Sep 2026, 2 months ago.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/masumi-network/sokosumi/prisma-driver-adapter-implementation)