Agent skill

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.

Stars 22
Forks 11

Install this agent skill to your Project

npx add-skill https://github.com/pingcap/agent-rules/tree/main/skills/tidbx-kysely

SKILL.md

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

  1. Confirm runtime and deployment target (Node server vs serverless/edge).
  2. Confirm cluster type. The serverless HTTP driver applies to Starter/Essential clusters.
  3. Collect connection info (prefer a mysql:// URL in DATABASE_URL).
  4. Choose the path:
    • Normal usage (default): TCP + mysql2 pool + Kysely MysqlDialect.
    • Serverless/edge: @tidbcloud/kysely dialect over HTTP.
  5. Show only the matching snippet first. Include the other path only if the user asks. Use references/kysely-usage.md for 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.

ts
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.

ts
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.

Expand your agent's capabilities with these related and highly-rated skills.

pingcap/agent-rules

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).

22 11
Explore
pingcap/agent-rules

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.

22 11
Explore
pingcap/agent-rules

tidbx-javascript-mysqljs

22 11
Explore
pingcap/agent-rules

tidbx

Provision TiDB Cloud Serverless clusters and related resources. Use when creating, deleting, or listing clusters/branches, or managing SQL users via the console.

22 11
Explore
pingcap/agent-rules

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.

22 11
Explore
pingcap/agent-rules

tidbx-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.

22 11
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results