sql-queries

sql-queries is a skill for Claude Code, Codex from killvxk/pm-skills-zh. It costs 73 tokens per session (885 once invoked), scanned A, original, MIT.

A tool that turns plain-language data questions into SQL, the language used to query databases. It can read a database structure and write queries for systems such as BigQuery, PostgreSQL, MySQL, Snowflake, and SQL Server.

In plain words
What is it for?
Use it to write reporting, filtering, aggregation, and analysis queries from a schema file or table description. It can also provide comments, performance suggestions, alternatives, and test queries.
Why use it?
It reduces the effort of remembering SQL syntax, table relationships, and database-specific details. It also explains the query and suggests ways to check or improve it.

Skill for Claude CodeCodex

Part of the pm-data-analytics plugin — 3 skills, 3 commands shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/killvxk/pm-skills-zh/sql-queries
Any agent
npx skills add killvxk/pm-skills-zh --skill sql-queries
Clone the repo
git clone --depth 1 https://github.com/killvxk/pm-skills-zh

Made for: Claude Code, Codex.

Or install pm-data-analytics, the plugin that ships this one along with the rest of its 3 skills, 3 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for sql-queries

README.md
[![agentmods](https://agentmods.dev/badge/skills/killvxk/pm-skills-zh/sql-queries.svg)](https://agentmods.dev/skills/killvxk/pm-skills-zh/sql-queries)
Your own site
<a href="https://agentmods.dev/skills/killvxk/pm-skills-zh/sql-queries"><img src="https://agentmods.dev/badge/skills/killvxk/pm-skills-zh/sql-queries.svg" alt="Measured on agentmods" height="20"></a>
Per session 73 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 885 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00073 $0.00885
Opus 5 $0.00036 $0.00443
Sonnet 5 $0.00015 $0.00177
Haiku 4.5 $0.00007 $0.00089

Measured 5d ago against content hash 2635dfeeb3e8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

sql-queries scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

pm-data-analytics/skills/sql-queries/SKILL.md · 87 lines

What it actually says

SQL 查询生成器

用途

将自然语言需求转化为经过优化的 SQL 查询,支持多种数据库平台。帮助产品经理、分析师和工程师准确生成查询语句,无需手动处理语法细节。

工作原理

第一步:理解数据库结构

  • 如果你提供了结构文件(SQL、文档或结构图描述),我将读取并分析
  • 提取表名、字段定义、数据类型及关联关系
  • 识别主键、外键和索引策略

第二步:处理查询需求

  • 明确你需要检索或分析的具体数据
  • 确认 SQL 方言(BigQuery、PostgreSQL、MySQL、Snowflake 等)
  • 询问额外要求(过滤条件、聚合方式、排序规则)

第三步:生成优化查询

  • 编写充分利用数据库结构的高效 SQL
  • 添加注释,解释复杂逻辑
  • 针对大数据集提供性能优化建议
  • 如有适用,提供替代实现方案

第四步:解释与测试

  • 用通俗语言解释查询逻辑
  • 建议如何测试或验证结果
  • 提供性能优化技巧
  • 如有需要,生成测试脚本或示例数据

使用示例

示例一:基于结构文件生成查询

上传你的 database_schema.sql 文件,并输入:
"生成一个查询,找出过去 30 天内注册且至少有 5 次活跃会话的用户"

示例二:基于结构描述生成查询

"我的数据库结构如下:Users 表(id, email, created_at),Sessions 表
(id, user_id, timestamp, duration)。生成一个查询,
统计 2026 年 1 月每位用户的平均会话时长。"

示例三:复杂分析查询

"创建一个 BigQuery 查询,按地区和客户等级分析营收,
包含同比增长率。"

核心能力

  • 多方言支持:兼容 BigQuery、PostgreSQL、MySQL、Snowflake、SQL Server
  • 文件读取:读取结构文件、SQL dump 及数据文档
  • 查询优化:建议索引、分区及性能改进方案
  • 解释说明:拆解查询逻辑,便于学习和文档化
  • 测试支持:可生成测试查询和示例数据脚本
  • 脚本执行:为你的数据库创建可执行的 SQL 脚本

最佳实践建议

  1. 提供背景信息:分享你的数据库结构或表结构
  2. 描述清晰:明确说明你需要的数据及过滤条件
  3. 注明数据库类型:指定你使用的 SQL 方言
  4. 说明限制条件:提及数据量、时间范围和性能要求
  5. 明确输出格式:如需特定格式的查询结果,请提前说明

输出格式

你将收到:

  • SQL 查询:带注释的生产可用 SQL 代码
  • 说明:查询的功能和运行逻辑
  • 性能备注:优化建议和注意事项
  • 测试脚本(如有需要):示例数据和验证查询

延伸阅读

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 87 lines · 73 tokens per session scan A 2635dfeeb3e8

Subscribe to this mod's changes

sql-queries is a skill published in the GitHub repository killvxk/pm-skills-zh (151 stars, last pushed 5mo ago), licensed MIT. It adds 73 tokens to every session and 885 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

schema-exploration

Lists tables, describes columns and data types, identifies foreign key relationships, and maps entity relationships in a database. Use when the user asks about database schema, table structure, column types, what tables exist, ERD, foreign keys, or how entities relate.

langchain-ai/deepagents · 57 tokens

ha-data-stores

Map of Hope Agent's local data stores and safe read-only query workflow. Use when the user asks where Hope Agent stores data, wants to inspect sessions/messages/memory/logs/background jobs/knowledge indexes/settings, asks the model to query local app data, or debugging requires checking persisted state. Trigger…

shiwenwen/hope-agent · 115 tokens

supabase

Supabase / PostgREST Row-Level-Security playbook — pull the anon (or leaked servicerole) key out of the frontend JS, map tables from the auto-generated OpenAPI spec, test anonymous RLS READ disclosures (PII/secret leaks), and anonymous RLS WRITE abuse (insert/update/delete — e.g. forging…

PentesterFlow/agent · 120 tokens

dsql

Build with Aurora DSQL — manage schemas, execute queries, handle migrations, diagnose query plans, diagnose cluster performance, load data, and develop applications with a serverless, distributed SQL database. Covers IAM auth, multi-tenant patterns, MySQL-to-DSQL and PostgreSQL-to-DSQL schema conversion, foreign key…

awslabs/agent-plugins · 229 tokens

nw-ddd-eventsourcing

Event Sourcing and CQRS as DDD implementation patterns — when to use, aggregate event streams, projections, snapshots, sagas, upcasting, conflict resolution.

nWave-ai/nWave · 38 tokens

sql-translate

Translate SQL queries between database dialects (Snowflake, BigQuery, PostgreSQL, MySQL, etc.).

AltimateAI/altimate-code · 26 tokens