MCPInstall

smart-query

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

Installs
69
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/zrt-ai-lab/opencode-skills --skill smart-query
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads smart-query automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Smart Query - 智能问数

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

触发场景

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

快速使用

1. 测试连接

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

2. 执行SQL查询

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. 生成表结构文档

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

{
  "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 操作

依赖安装

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 生成)

FAQ

What does the smart-query skill do?

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

How do I install smart-query?

Run npx skills add https://github.com/zrt-ai-lab/opencode-skills --skill smart-query in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/smart-query/ (personal) or .claude/skills/smart-query/ (project).

Which AI agents can use smart-query?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is smart-query safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains smart-query?

It is published by zrt-ai-lab in zrt-ai-lab/opencode-skills. It has 69 recorded installs.

More from zrt-ai-lab/opencode-skills

View all →

videocut-subtitle

zrt-ai-lab/opencode-skills

字幕生成与烧录。转录→词典纠错→审核→烧录。触发词:加字幕、生成字幕、字幕

531 installs

auto-douyin

zrt-ai-lab/opencode-skills

抖音视频自动发布技能。当用户需要发布视频到抖音时使用这个技能。技能包含:获取登录Cookie、上传视频、设置标题话题、定时发布等功能。

512 installs

videocut-clip

zrt-ai-lab/opencode-skills

Open the skill to read its SKILL.md instructions.

301 installs

videocut-clip-oral

zrt-ai-lab/opencode-skills

口播视频转录和口误识别。生成审查稿和删除任务清单。触发词:剪口播、处理视频、识别口误

234 installs

videocut-install

zrt-ai-lab/opencode-skills

环境准备。安装依赖、下载模型、验证环境。触发词:安装、环境准备、初始化

207 installs

auto-weixin-video

zrt-ai-lab/opencode-skills

Open the skill to read its SKILL.md instructions.

Media & Creative198 installs

Popular data & databases skills

View category →

Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.

OfficialData & Databases462.2K installs

prisma-client-api

prisma/skills

Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".

OfficialData & Databases393.5K installs

Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.

OfficialData & Databases392.3K installs

prisma-cli

prisma/skills

Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.

OfficialData & Databases390.8K installs

prisma-postgres

prisma/skills

Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.

OfficialData & Databases384.4K installs

Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.

OfficialData & Databases378.9K installs