Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
prisma avatar

Prisma Client Api Client Methods

  • 14 installs
  • 8 repo stars
  • Updated February 9, 2026
  • prisma/cursor-plugin

prisma-client-api-client-methods documents PrismaClient $connect, $extends, and events.

About

The prisma-client-api-client-methods skill documents PrismaClient lifecycle and extension APIs. $connect and $disconnect manage explicit connections and graceful shutdown including SIGTERM handlers and test afterAll cleanup. $on subscribes to query and log events when log emit is event. $extends adds client, model, query, and result extensions with chainable soft-delete and computed field patterns. Cross-references $transaction and raw query docs. Type utilities cover Prisma namespace input and output types plus Prisma.validator for reusable select fragments. v7 examples assume required driver adapters on construction. Documents $connect, $disconnect, and shutdown handlers. Covers $on query and log event subscriptions. Shows $extends client, model, query, and result patterns. Includes Prisma.validator typed select fragments. Links transactions and raw query companion skills. Correct use of connect, extensions, and typed query helpers. User implements $extends, logging, or connection lifecycle hooks.

  • Documents $connect, $disconnect, and shutdown handlers.
  • Covers $on query and log event subscriptions.
  • Shows $extends client, model, query, and result patterns.
  • Includes Prisma.validator typed select fragments.
  • Links transactions and raw query companion skills.

Prisma Client Api Client Methods by the numbers

  • 14 all-time installs (skills.sh)
  • Ranked #604 of 911 Databases skills by installs in the Skillselion catalog
  • Data as of Aug 4, 2026 (Skillselion catalog sync)
At a glance

prisma-client-api-client-methods capabilities & compatibility

Capabilities
$extends chain examples · graceful shutdown patterns · prisma namespace type utilities
Works with
postgres
Use cases
database · api development
From the docs

What prisma-client-api-client-methods says it does

Add extensions for custom behavior
SKILL.md
Graceful shutdown
SKILL.md
npx skills add https://github.com/prisma/cursor-plugin --skill prisma-client-api-client-methods

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs14
repo stars8
Last updatedFebruary 9, 2026
Repositoryprisma/cursor-plugin

What Prisma Client instance methods are available?

Reference Prisma Client instance methods for connect, disconnect, events, extensions, and type utilities.

Who is it for?

Backend developers extending Prisma Client behavior.

Skip if: Skip for basic CRUD without extensions or events.

When should I use this skill?

User implements $extends, logging, or connection lifecycle hooks.

What you get

Correct use of connect, extensions, and typed query helpers.

Files

SKILL.mdMarkdownGitHub ↗

Client Methods

Prisma Client instance methods.

$connect()

Explicitly connect to the database:

const prisma = new PrismaClient({ adapter })

// Explicit connection
await prisma.$connect()

When to use

Usually not needed - Prisma connects automatically on first query. Use for:

  • Fail fast on startup
  • Health checks
  • Pre-warming connections
async function main() {
  try {
    await prisma.$connect()
    console.log('Database connected')
  } catch (e) {
    console.error('Failed to connect:', e)
    process.exit(1)
  }
}

$disconnect()

Close database connection:

await prisma.$disconnect()

Graceful shutdown

process.on('beforeExit', async () => {
  await prisma.$disconnect()
})

// Or with SIGTERM
process.on('SIGTERM', async () => {
  await prisma.$disconnect()
  process.exit(0)
})

In tests

afterAll(async () => {
  await prisma.$disconnect()
})

$on()

Subscribe to events:

Query events

const prisma = new PrismaClient({
  adapter,
  log: [{ level: 'query', emit: 'event' }]
})

prisma.$on('query', (e) => {
  console.log('Query:', e.query)
  console.log('Params:', e.params)
  console.log('Duration:', e.duration, 'ms')
})

Log events

const prisma = new PrismaClient({
  adapter,
  log: [
    { level: 'info', emit: 'event' },
    { level: 'warn', emit: 'event' },
    { level: 'error', emit: 'event' }
  ]
})

prisma.$on('info', (e) => console.log(e.message))
prisma.$on('warn', (e) => console.warn(e.message))
prisma.$on('error', (e) => console.error(e.message))

$extends()

Add extensions for custom behavior:

Add custom methods

const prisma = new PrismaClient({ adapter }).$extends({
  client: {
    $log: (message: string) => console.log(message)
  }
})

prisma.$log('Hello!')

Add model methods

const prisma = new PrismaClient({ adapter }).$extends({
  model: {
    user: {
      async findByEmail(email: string) {
        return prisma.user.findUnique({ where: { email } })
      }
    }
  }
})

const user = await prisma.user.findByEmail('alice@prisma.io')

Query extensions

const prisma = new PrismaClient({ adapter }).$extends({
  query: {
    user: {
      async findMany({ args, query }) {
        // Add default filter
        args.where = { ...args.where, deletedAt: null }
        return query(args)
      }
    }
  }
})

Result extensions

const prisma = new PrismaClient({ adapter }).$extends({
  result: {
    user: {
      fullName: {
        needs: { firstName: true, lastName: true },
        compute(user) {
          return `${user.firstName} ${user.lastName}`
        }
      }
    }
  }
})

const user = await prisma.user.findFirst()
console.log(user.fullName) // Computed field

Chain extensions

const prisma = new PrismaClient({ adapter })
  .$extends(loggingExtension)
  .$extends(softDeleteExtension)
  .$extends(computedFieldsExtension)

$transaction()

See transactions.md for details.

$queryRaw() / $executeRaw()

See raw-queries.md for details.

Type utilities

Prisma namespace

import { Prisma } from '../generated/client'

// Input types
type UserCreateInput = Prisma.UserCreateInput
type UserWhereInput = Prisma.UserWhereInput

// Output types
type User = Prisma.UserGetPayload<{}>
type UserWithPosts = Prisma.UserGetPayload<{
  include: { posts: true }
}>

Prisma.validator

Type-safe query fragments:

import { Prisma } from '../generated/client'

const userSelect = Prisma.validator<Prisma.UserSelect>()({
  id: true,
  email: true,
  name: true
})

const user = await prisma.user.findUnique({
  where: { id: 1 },
  select: userSelect
})

Related skills

FAQ

What does prisma-client-api-client-methods do?

prisma-client-api-client-methods documents PrismaClient $connect, $extends, and events.

When should I use prisma-client-api-client-methods?

User implements $extends, logging, or connection lifecycle hooks.

Is this skill safe to install?

Review the Security Audits panel on this page before installing in production.

Databasesdatabases

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.