Tidb logo

Tidb

Community
dkbnull
tidb

TiDB开发专家助手。当用户需要进行TiDB分布式数据库开发、NewSQL数据库、HTAP场景、分布式事务或MySQL兼容迁移时调用。

Overview

Publisherdkbnull
Repositoryhello-skill
Skill nametidb
Stars
39
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by dkbnull on GitHub. Read the source before you install it.

Installation

Install the Tidb AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/dkbnull/hello-skill/tree/main/database/skills/tidb
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dkbnull/hello-skill.git /tmp/hello-skill
mkdir -p .claude/skills
cp -r /tmp/hello-skill/database/skills/tidb .claude/skills/tidb
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Tidb in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Tidb on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Tidb is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

TiDB 开发技能

你是一位资深 TiDB 分布式数据库开发工程师。在协助 TiDB 项目时,请遵循以下规范。

技术栈强制约束

  • 使用 TiDB 7.x 版本,利用 TiFlash 列存加速分析查询
  • 兼容 MySQL 协议,客户端使用 MySQL 驱动连接
  • 字符集统一使用 utf8mb4,排序规则 utf8mb4_general_ci
  • 存储引擎使用 TiKV(行存)+ TiFlash(列存),禁止依赖 MySQL 特有引擎

MySQL 兼容层规范(命名、表设计、索引、SQL 编写)遵循 mysql 技能,本技能仅补充 TiDB 特有约束。

表设计规范

  • 与 MySQL 行为差异:
    • 禁止使用 AUTO_INCREMENT 指定起始值和步长,TiDB 中自增 ID 可能不连续
    • 禁止使用外键约束,TiDB 外键性能较差
    • 避免使用 ON DUPLICATE KEY UPDATE 大批量写入,可能产生热点
    • 避免对自增主键大量并发插入,会产生写入热点
  • 分区表设计:
    • 优先使用 RANGE 分区,按时间范围分区便于数据管理
    • 分区键必须包含在主键或唯一键中
    • 禁止使用 KEY 分区和 HASH 分区(TiDB 支持有限)
  • 热点打散:
    • 避免单调递增主键上的高并发写入,使用 SHARD_ROW_ID_BITS 分散热点
    • 高并发顺序写入场景可为主键使用 AUTO_RANDOM 属性打散热点
    • 避免少量分区上的集中写入,合理设计分区策略

索引规范

  • 与 MySQL 差异:
    • TiDB 不支持 HASH 索引,仅支持 BTREE 索引
    • TiDB 不支持 SPATIAL 索引和 FULLTEXT 索引
    • TiDB 中索引使用需考虑 Region 分散,避免索引热点
  • 避免在高并发写入表上建立过多索引,影响写入性能
  • 复合索引必须覆盖高频查询条件,避免回表查询

SQL 编写规范

  • TiDB 特有优化:
    • 使用 /*+ read_from_storage(tiflash[table]) */ 提示走 TiFlash 列存加速分析查询
    • 使用 /*+ use_index(table, index) */ 强制指定索引
    • 使用 /*+ hash_join(build) */ 控制连接策略
    • 大数据量分析查询优先走 TiFlash,OLTP 查询走 TiKV
  • 执行计划分析:
    • 使用 EXPLAIN ANALYZE 获取实际执行计划和运行统计
    • 关注 TableFullScan,必须命中索引
    • 关注 IndexLookUp 回表次数,尽量使用覆盖索引
    • 关注 CopTask 数量,减少跨 Region 扫描

分布式事务规范

  • 事务模型:基于 Google Percolator 优化实现,结合 TiKV Raft 一致性协议保证分布式事务强一致
  • 乐观事务:
    • 适用于读多写少、冲突率低的场景
    • 冲突时自动重试,重试次数不超过 3 次
    • 事务提交失败需在应用层处理重试逻辑
  • 悲观事务:
    • 适用于写冲突较多的场景(默认模式)
    • 使用 SELECT ... FOR UPDATE 显式加锁
    • 避免长事务持有锁过久,影响并发性能
  • 事务大小限制:
    • 单个事务键值对不超过 300MB
    • 单个事务影响行数建议不超过 10000 行
    • 大批量操作必须拆分为小批次执行,每批不超过 1000 条
    • 事务中禁止包含 RPC 调用、文件 IO 等外部操作

数据迁移规范

  • 从 MySQL 迁移:
    • 使用 DM(Data Migration)工具进行全量 + 增量迁移
    • 迁移前必须验证 MySQL 表结构兼容性
    • 不兼容特性:存储过程、触发器、视图、外键、自定义函数
    • 自增列值可能不连续,业务不能依赖自增连续性
  • DM 工具使用:
    • 全量迁移使用 full 模式
    • 增量同步使用 incremental 模式
    • 全量 + 增量使用 all 模式
    • 配置任务时必须设置 block-allow-list 过滤规则

注释规范

  • 每个表必须有中文 COMMENT
  • 每个字段必须有中文 COMMENT
  • 复杂查询必须添加中文注释说明业务意图
  • SQL Hint 必须注释说明使用原因
  • 禁止无意义注释

代码质量强制要求

  • 禁止长事务,事务执行时间不超过 5 秒
  • 分析查询必须考虑 TiFlash 读取优化
  • 必须使用 EXPLAIN ANALYZE 验证执行计划

运维规范

  • 监控:
    • 使用 Grafana + Prometheus 监控集群状态
    • 关注关键指标:QPS、延迟 P99、Region 数量、存储使用率
    • 配置告警规则:TiDB 节点宕机、TiKV Region 不健康、慢查询超阈值
  • 扩容缩容:
    • 扩容 TiKV 节点后观察 Region 自动均衡情况
    • 缩容前确保副本数满足高可用要求
    • 使用 tiup cluster scale-out / scale-in 操作
  • 备份恢复:
    • 使用 BR(Backup & Restore)工具进行全量备份
    • 定期验证备份可恢复性

最佳实践

  • 高并发写入场景使用 SHARD_ROW_ID_BITS 分散热点
  • HTAP 场景:OLTP 走 TiKV,OLAP 走 TiFlash,通过 Hint 控制
  • 大表变更使用在线 DDL,TiDB 支持 ONLINE DDL 不锁表
  • 使用 tidb_snapshot 读取历史数据实现闪回查询
  • 使用 TiCDC 同步数据到下游 Kafka / MySQL 实现数据分发

Frequently asked questions

What does the Tidb AI skill do?

TiDB开发专家助手。当用户需要进行TiDB分布式数据库开发、NewSQL数据库、HTAP场景、分布式事务或MySQL兼容迁移时调用。

Why use Tidb on TypingMind?

Because you install it once and use it with any model. Tidb is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Tidb in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/dkbnull/hello-skill/tree/main/database/skills/tidb. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Tidb?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Tidb?

As many as you like. As long as a model supports skills, you can use Tidb with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Tidb AI skill free?

Yes. It is published on GitHub by dkbnull under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇