Smart Query logo

Smart Query

Community
zrt-ai-lab
smart-query

智能数据库查询技能。通过SSH隧道连接线上数据库,支持自然语言转SQL、执行查询、表结构探索。当用户需要查询数据库、问数据、看表结构时使用此技能。

Overview

Publisherzrt-ai-lab
Repositoryopencode-skills
Skill namesmart-query
Stars
293
Forks
75
Bundled files
6
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.

  • 6 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by zrt-ai-lab on GitHub. Read the source before you install it.

Installation

Install the Smart Query 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/zrt-ai-lab/opencode-skills/tree/main/smart-query
  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/zrt-ai-lab/opencode-skills.git /tmp/opencode-skills
mkdir -p .claude/skills
cp -r /tmp/opencode-skills/smart-query .claude/skills/smart-query
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Smart Query 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 Smart Query 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 Smart Query 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.

Smart Query - 智能问数

通过 SSH 隧道安全连接线上数据库,支持自然语言查询和 SQL 执行。

触发场景

  • 用户问"查一下xxx数据"、"帮我看看xxx表"
  • 用户需要查询线上数据库
  • 用户问"有哪些表"、"表结构是什么"

快速使用

1. 测试连接

bash
python .opencode/skills/smart-query/scripts/db_connector.py

2. 执行SQL查询

bash
python .opencode/skills/smart-query/scripts/query.py "SELECT * FROM table_name LIMIT 10"
python .opencode/skills/smart-query/scripts/query.py "SHOW TABLES"
python .opencode/skills/smart-query/scripts/query.py "DESC table_name"

参数:

  • -n 50:限制返回行数
  • -f json:JSON格式输出
  • --raw:输出原始结果(含元信息)

3. 生成表结构文档

bash
python .opencode/skills/smart-query/scripts/schema_loader.py

生成 references/schema.md,包含所有表结构信息。

自然语言查询流程

  1. 理解用户意图:分析用户想查什么数据
  2. 查阅表结构:读取 references/schema.md 了解表结构
  3. 生成SQL:根据表结构编写正确的SQL
  4. 执行查询:使用 query.py 执行
  5. 解读结果:用通俗语言解释查询结果

配置说明

配置文件:config/settings.json

json
{
  "ssh": {
    "host": "SSH跳板机地址",
    "port": 22,
    "username": "用户名",
    "password": "密码",
    "key_file": null
  },
  "database": {
    "type": "mysql",
    "host": "数据库内网地址",
    "port": 3306,
    "database": "库名",
    "username": "数据库用户",
    "password": "数据库密码"
  }
}

分享给同事

  1. 复制整个 smart-query/ 目录
  2. 同事复制 config/settings.json.example 为 settings.json
  3. 填入自己的 SSH 和数据库连接信息
  4. 安装依赖:pip install paramiko sshtunnel pymysql

安全提示

  • config/settings.json 包含敏感信息,不要提交到 Git
  • 建议将 config/settings.json 加入 .gitignore
  • 只执行 SELECT 查询,避免 UPDATE/DELETE 操作

依赖安装

bash
pip install paramiko sshtunnel pymysql

脚本清单

脚本用途
scripts/db_connector.pySSH隧道+数据库连接,可单独运行测试连接
scripts/query.py执行SQL查询,支持表格/JSON输出
scripts/schema_loader.py加载表结构,生成 schema.md

参考文档

文档说明
references/schema.md数据库表结构(运行 schema_loader.py 生成)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Smart Query AI skill do?

智能数据库查询技能。通过SSH隧道连接线上数据库,支持自然语言转SQL、执行查询、表结构探索。当用户需要查询数据库、问数据、看表结构时使用此技能。

Why use Smart Query on TypingMind?

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

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/zrt-ai-lab/opencode-skills/tree/main/smart-query. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Smart Query?

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 Smart Query?

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

Is the Smart Query AI skill free?

It is published on GitHub by zrt-ai-lab. Check the repository for licensing terms. 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 👇