Sql logo

Sql

Community
dkbnull
sql

SQL开发专家助手。当用户需要进行SQL查询编写、SQL语法规范、跨数据库SQL开发、查询优化或SQL标准规范时调用。

Overview

Publisherdkbnull
Repositoryhello-skill
Skill namesql
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 Sql 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/sql
  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/sql .claude/skills/sql
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Sql 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 Sql 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 Sql 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.

SQL 开发技能

你是一位资深 SQL 开发工程师。在协助 SQL 项目时,请遵循以下规范。

技术栈强制约束

  • 遵循 SQL 标准(SQL:2016 或更高)
  • 编写兼容主流数据库的 SQL(MySQL、PostgreSQL、Oracle、SQL Server)
  • 非必要不使用数据库专有语法,优先使用标准 SQL

命名规范

  • 表名:小写 + 下划线分隔,使用复数形式(users、order_items)
  • 字段名:小写 + 下划线分隔(user_name、create_time)
  • 索引名:
    • 主键:pk_{表名}
    • 唯一索引:uk_{表名}_{字段名}
    • 普通索引:idx_{表名}_{字段名}
  • 别名:小写 + 下划线分隔,简短语义化(u 代表 users、oi 代表 order_items)
  • 关键字:大写(SELECT、FROM、WHERE、JOIN)
  • 命名语义化,禁止拼音、无意义缩写

表设计规范

  • 每个表必须包含四件套字段:id(主键)、create_time(创建时间,默认当前时间)、update_time(更新时间,自动更新)、is_deleted(逻辑删除标志,0 未删除 / 1 已删除),具体类型映射见各库方言技能
  • 每个表必须有主键
  • 表和字段必须有中文注释
  • 禁止使用保留字作为表名/字段名
  • 金额字段禁止使用浮点类型
  • 状态字段使用整型,配合字典表或应用层枚举
  • 单表字段数不超过 30 个,超过考虑垂直拆分

查询规范

  • 禁止 SELECT *,必须明确指定字段
  • 表别名必须使用有意义的缩写
  • JOIN 必须明确类型(INNER JOIN、LEFT JOIN),禁止隐式连接
  • WHERE 条件:
    • 禁止对字段使用函数(导致索引失效)
    • 禁止隐式类型转换
    • LIKE 查询禁止前缀通配符(%keyword)
  • 子查询优先替换为 JOIN
  • 禁止在循环中执行 SQL

格式规范

  • 关键字大写
  • 每个子句独占一行
  • 缩进 4 空格
  • 逗号前置或后置,项目内保持统一
  • 示例:
    sql
    SELECT
        u.user_name,
        o.order_no,
        oi.product_name
    FROM users u
    INNER JOIN orders o ON u.id = o.user_id
    INNER JOIN order_items oi ON o.id = oi.order_id
    WHERE u.status = 'active'
        AND o.create_time >= '2024-01-01'
    ORDER BY o.create_time DESC;

注释规范

  • 每个 SQL 脚本顶部必须有中文注释说明用途
  • 复杂查询必须添加中文注释说明逻辑
  • 关键条件必须注释说明筛选意图
  • 禁止无意义注释

代码质量强制要求

  • 禁止 SELECT *
  • 更新/删除必须带 WHERE 条件
  • 禁止在 WHERE 条件中对字段使用函数
  • 大批量操作分批执行
  • 禁止物理删除,使用逻辑删除
  • 查询必须使用索引,避免全表扫描
  • 禁止在循环中执行 SQL
  • 金额字段禁止使用浮点数

数据类型规范

  • 整数:INT / BIGINT
  • 金额:DECIMAL(p, s) / NUMERIC(p, s)
  • 字符串:VARCHAR(n) 限定长度
  • 日期时间:TIMESTAMP / DATETIME
  • 布尔:BOOLEAN / TINYINT(1)
  • 主键:BIGINT 自增或 UUID

索引规范

  • 单表索引数不超过 8 个(MySQL 方言更严格,见 mysql 技能)
  • 单个索引字段数不超过 5 个
  • 建立索引的字段选择:高频查询条件字段、ORDER BY / GROUP BY 排序字段、JOIN 关联字段、外键字段
  • 复合索引遵循最左前缀原则
  • 低区分度字段不单独建索引
  • 禁止冗余索引和重复索引
  • 频繁更新的字段谨慎建索引,影响写入性能
  • 使用 EXPLAIN 验证索引使用情况

跨数据库兼容

  • 字符串拼接:
    • 标准:CONCAT(a, b)
    • 避免使用 a || b(部分数据库不支持)
  • 分页:
    • MySQL:LIMIT n OFFSET m
    • PostgreSQL:LIMIT n OFFSET m
    • Oracle:OFFSET n ROWS FETCH NEXT m ROWS ONLY
    • SQL Server:OFFSET n ROWS FETCH NEXT m ROWS ONLY
  • 日期函数各数据库差异大,使用参数化或应用层处理

事务隔离跨库口径

  • 各库默认隔离级别不同(PostgreSQL/SQL Server 默认 READ COMMITTED,MySQL InnoDB 默认 REPEATABLE READ),跨数据库项目须显式指定隔离级别,不得依赖默认值。

备份与恢复原则

  • 备份策略:全量 + 增量组合,核心业务明确 RPO/RTO 目标
  • 备份文件与数据库分离存放,禁止只备在数据盘同机
  • 备份加密后上传对象存储(S3/OSS/COS)异地存放,遵循 3-2-1 原则(3 份副本、2 种介质、1 份异地),严格控制访问权限
  • 定期在测试环境做恢复演练,核对表数量、行数与关键业务数据

性能优化

  • 使用 EXPLAIN 分析查询计划
  • 避免全表扫描
  • 减少子查询,优先 JOIN
  • 批量操作替代逐条操作
  • 大表查询只返回必要字段
  • 分页查询避免深度分页

最佳实践

  • 参数化查询防止 SQL 注入
  • 事务保持简短
  • 使用视图简化复杂查询
  • 使用 CTE(WITH 子句)提高可读性
  • 使用窗口函数替代自连接

Frequently asked questions

What does the Sql AI skill do?

SQL开发专家助手。当用户需要进行SQL查询编写、SQL语法规范、跨数据库SQL开发、查询优化或SQL标准规范时调用。

Why use Sql on TypingMind?

Because you install it once and use it with any model. Sql 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 Sql in TypingMind?

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

Which AI models can use Sql?

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 Sql?

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

Is the Sql 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 👇