This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Install dependencies
npm ci
# Build (both ESM and CJS outputs)
npm run build
# Run tests (automatically runs `prisma db push` first to set up the SQLite test DB)
npm test
# Run a single test file
npx vitest run path/to/test.spec.ts
# Watch mode
npm run test:watch
# Lint and format check (Biome)
npm run check
# Lint and format auto-fix
npm run check:writeCommits must follow Conventional Commits — enforced by commitlint. Use npm run commit for an interactive prompt.
The library is a Prisma Client Extension that bridges Kysely's query builder to Prisma's raw query execution. It has three source files in src/:
- src/index.ts — Entry point. Exports the extension factory function. Uses
Prisma.defineExtensionto attach$kyselyto the client. Wraps$transactionvia aProxyso that interactive transactions get a freshPrismaDriver/PrismaConnectionbound to the transaction client (not the original client). - src/driver.ts —
PrismaDriverimplements Kysely'sDriverinterface. Transaction methods intentionally throw — Kysely's own transaction API is unsupported; users must useprisma.$transactioninstead. - src/connection.ts —
PrismaConnectionimplements Kysely'sDatabaseConnection. Routes SELECT queries through$queryRawUnsafeand mutation queries (INSERT/UPDATE/DELETE) without a RETURNING clause through$executeRawUnsafe(returning affected row count as a BigInt).
The package is published as a dual ESM/CJS package:
- tsconfig.json compiles to
dist/esm(ES2022 modules) - tsconfig.cjs.json compiles to
dist/cjs(CommonJS) tsconfig-to-dual-packagegenerates thepackage.jsonmarkers for each output directory
Tests use Vitest (vitest.config.ts). The test database is SQLite at prisma/dev.db, set up via prisma db push (the pretest script). The Prisma schema at prisma/schema.prisma also generates Kysely types via prisma-kysely to generated/kysely/types.ts.
Runnable examples live in examples/ (basic, camel-case, esm, logging, read-replica). Each is a self-contained project with its own package.json and Prisma schema. They are run in CI but are not part of the main test suite.
- Transaction reliability (Issue #71) — Reports that
tx.$kyselyinsideprisma.$transactiondoesn't always use the transaction client. The current Proxy-based implementation is covered by 30 integration tests (all passing). Monitor for new reproduction cases.
- ✅ Prisma 7 support (Issue #292) — Prisma 7 introduces a driver adapter architecture as a breaking change. Updated the extension and all examples to use driver adapters. Bumped to v4.0.0.
@prisma/extension-read-replicas@^0.5.0included. - ✅ Migrate tests from Jest to Vitest — Replaced jest + ts-jest with vitest for native ESM/TypeScript support.
- ✅ Fix Prisma client import path (Issue #245) —
src/index.tsnow importsPrismafrom@prisma/client/extension, consistent withdriver.tsandconnection.ts. Fixes failures when a custom Prisma output path is configured. - ✅ Pin peer dependency version (Issue #289) —
peerDependenciesnow specifies"@prisma/client": "^5.0.0 || ^6.0.0". - ✅ Kysely ^0.27 + ^0.28 both supported —
peerDependenciesanddevDependenciesupdated. - ✅ Publishing overhauled — Replaced release-please + npm token with semantic-release + npm OIDC trusted publishing (
workflow_dispatchtrigger, no long-lived secrets). See.github/workflows/release.ymland.releaserc.json. - ✅ Renovate replaced with Dependabot — Weekly grouped updates via
.github/dependabot.yml. - ✅ Dependency hygiene — commitlint v20, Biome v2.