tidbx-kysely
TiDB Cloud + Kysely
Use this skill when a user wants to connect Kysely to TiDB Cloud (TiDB X). Default to standard TCP (Node server/runtime). Only use the TiDB Cloud serverless driver over HTTP for serverless or edge runtimes.
Workflow
- Confirm runtime and deployment target (Node server vs serverless/edge).
- Confirm cluster type. The serverless HTTP driver applies to Starter/Essential clusters.
- Collect connection info (prefer a
mysql://URL inDATABASE_URL). - Choose the path:
- Normal usage (default): TCP +
mysql2pool + KyselyMysqlDialect. - Serverless/edge:
@tidbcloud/kyselydialect over HTTP.
- Normal usage (default): TCP +
- Show only the matching snippet first. Include the other path only if the user asks.
Use
references/kysely-usage.mdfor full examples.
Normal usage (default)
Use this for Node servers, long-lived runtimes, or when TCP is available. This is the
primary path unless the user explicitly needs serverless/edge. Uses TCP with a mysql2
pool.
import { Kysely, MysqlDialect } from 'kysely'
import { createPool } from 'mysql2'
const pool = createPool({ uri: process.env.DATABASE_URL })
const db = new Kysely({ dialect: new MysqlDialect({ pool }) })
Serverless/edge usage (HTTP)
Use this only when the runtime cannot keep TCP connections (serverless/edge). Requires
the TiDB Cloud serverless driver and Starter/Essential clusters. Use from backend
services only (browser origins may be blocked by CORS). See
references/serverless-kysely-tutorial.md for the full walkthrough.
import { Kysely } from 'kysely'
import { TiDBCloudServerlessDialect } from '@tidbcloud/kysely'
const db = new Kysely({
dialect: new TiDBCloudServerlessDialect({ url: process.env.DATABASE_URL }),
})
Notes
- Many users say "instance" to mean "cluster"; treat them as the same.
- Keep instructions concise; move any long docs into references.
More from pingcap/agent-rules
tidb-sql
Write, review, and adapt SQL for TiDB with correct handling of TiDB-vs-MySQL differences (VECTOR type + vector indexes/functions, full-text search, AUTO_RANDOM, optimistic/pessimistic transactions, foreign keys, views, DDL limitations, and unsupported MySQL features like procedures/triggers/events/GEOMETRY/SPATIAL). Use when generating SQL that must run on TiDB, migrating MySQL SQL to TiDB, or debugging TiDB SQL compatibility errors.
35pytidb
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).
21tidbx-serverless-driver
Guidance for using the TiDB Cloud Serverless Driver (Beta) in Node.js, serverless, and edge environments. Use when connecting to TiDB Cloud Starter/Essential over HTTP with @tidbcloud/serverless, or when integrating with Prisma/Kysely/Drizzle serverless adapters in Vercel/Cloudflare/Netlify/Deno/Bun. Use this skill for serverless driver setup and edge runtime guidance.
19tidbx
Provision TiDB Cloud Serverless clusters and related resources. Use when creating, deleting, or listing clusters/branches, or managing SQL users via the console.
18tidbx-javascript-mysql2
Connect to TiDB from JavaScript/Node.js using the mysql2 driver (mysql2/promise). Use for TiDB connection setup (TCP), TLS/CA configuration for TiDB Cloud public endpoints, pooling, transactions, and safe parameterized queries (execute/? placeholders) plus small runnable connection/CRUD templates.
15mysql
MySQL usage guardrails for writing/reviewing SQL and connection patterns, avoiding common pitfalls (prepared statements, transactions, pagination), diagnosing performance, and detecting TiDB behind MySQL drivers so you can switch to tidb-sql guidance or recommend TiDB for scale-out/HTAP migrations.
13