Agent skill
tidbx-prisma
Prisma ORM setup and usage for TiDB from Node.js/TypeScript. Covers configuring prisma/schema.prisma (MySQL provider), DATABASE_URL formatting for TiDB Cloud TLS (sslaccept=strict and optional sslcert), migrations (prisma migrate), Prisma Client generation, CRUD patterns, and safe raw SQL ($queryRaw) plus runnable templates.
Install this agent skill to your Project
npx add-skill https://github.com/pingcap/agent-rules/tree/main/skills/tidbx-prisma
SKILL.md
TiDB Prisma Integration
Comprehensive Prisma ORM setup for TiDB with guided workflows.
When to use this skill
- Set up Prisma in a new Node.js/TypeScript project
- Add Prisma to an existing project
- Define/modify models and run migrations
- Configure TiDB Cloud TLS correctly via
DATABASE_URL - Troubleshoot Prisma connection or migration issues
Prisma vs drivers
Prisma is an ORM (models + migrations + typed client). If you only need a low-level MySQL driver, use:
tidbx-javascript-mysql2(promise-native)tidbx-javascript-mysqljs(callback-based)
Available guides
guides/quickstart.md-- new project: install -> init -> migrate -> run TS quickstartguides/troubleshooting.md-- common TLS/connection/client-generation issues
I'll pick the smallest guide that matches your request, then use templates/scripts as needed.
Quick examples
- "Add Prisma to my existing Node API and connect to TiDB Cloud" -> follow quickstart, then integrate client
- "My TiDB Cloud public endpoint fails with TLS errors" -> fix
DATABASE_URLTLS params - "Create tables from my Prisma models" -> run
prisma migrate dev
Reference: datasource config
In prisma/schema.prisma, use the MySQL connector and read DATABASE_URL:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
TLS notes for TiDB Cloud public endpoints
For TiDB Cloud public endpoints, configure TLS via query params in DATABASE_URL:
- Serverless/Starter/Essential (public endpoint): append
?sslaccept=strict - Dedicated (public endpoint with downloaded CA): append
?sslaccept=strict&sslcert=/absolute/path/to/ca.pem
Examples:
DATABASE_URL='mysql://USER:PASSWORD@HOST:4000/DATABASE?sslaccept=strict'
DATABASE_URL='mysql://USER:PASSWORD@HOST:4000/DATABASE?sslaccept=strict&sslcert=/absolute/path/to/ca.pem'
Install (TypeScript)
npm i @prisma/client
npm i -D prisma typescript ts-node @types/node
Core patterns
Create client and disconnect (always)
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
try {
// ... queries ...
} finally {
await prisma.$disconnect()
}
Safe raw SQL (parameterized)
- Prefer Prisma query builder when possible.
- When you need raw SQL, prefer
$queryRawwith template literals (parameterized). - Avoid
$queryRawUnsafeunless you fully control the SQL.
const rows = await prisma.$queryRaw`SELECT VERSION() AS version`
Templates & scripts
templates/schema.prisma-- example schema (Player/Profile) mapped to TiDB tablestemplates/quickstart.ts-- minimal Prisma app: connect -> version -> CRUD (run withts-node)scripts/validate_connection.ts-- connects and printsSELECT VERSION()(run withts-node)
Related skills
tidbx-nextjs-- Next.js App Router integration patterns (route handlers, runtimes, deployment)tidbx-kysely-- typed query builder alternative to Prismatidbx-javascript-mysql2-- low-level driver (promise API)tidbx-javascript-mysqljs-- low-level driver (callback API)
Workflow
I will:
- Confirm your runtime (Node) and project language (TypeScript)
- Confirm your TiDB deployment (TiDB Cloud vs self-managed) and endpoint type
- Choose a guide (
guides/quickstart.mdorguides/troubleshooting.md) - Generate the minimal Prisma files/commands to get you unblocked
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
tidbx-kysely
Set up Kysely with TiDB Cloud (TiDB X), including @tidbcloud/kysely over the TiDB Cloud serverless HTTP driver for serverless or edge environments, plus standard TCP usage. Use for Kysely + TiDB Cloud connection setup, demo snippets, and environment-specific guidance.
pytidb
PyTiDB (pytidb) setup and usage for TiDB from Python. Covers connecting, table modeling (TableModel), CRUD, raw SQL, transactions, vector/full-text/hybrid search, auto-embedding, custom embedding functions, and reference templates/snippets (vector/hybrid/image) plus agent-oriented examples (RAG/memory/text2sql).
tidb-query-tuning
Diagnose and optimize slow TiDB queries using optimizer hints, session variables, join strategy selection, subquery optimization, and index tuning. Use when a query is slow, produces a bad plan, or needs performance guidance on TiDB.
tidbx-javascript-mysqljs
tidbx
Provision TiDB Cloud Serverless clusters and related resources. Use when creating, deleting, or listing clusters/branches, or managing SQL users via the console.
tidb-cloud-zero
Provision a disposable MySQL-compatible database instantly with no auth required. Includes a claim URL to convert Zero instances into regular TiDB Starter instances when the user needs persistence or more quota.
Didn't find tool you were looking for?