querymaster
Multi-engine master router: takes a natural-language prompt, identifies the engine (PostgreSQL, Snowflake, SQL Server, ADX, SQLite, Databricks), generates the query and runs it with dry-run by default. Triggers when asked to query a database, run SQL or inspect a schema.
- License 许可
- MIT
- 最近更新
- 2026-11-14
- Stars
- ★ 18
- Forks
- 6
01 前言 Front Matter
- name
- querymaster
- description
- Multi-engine master router: takes a natural-language prompt, identifies the engine (PostgreSQL, Snowflake, SQL Server, ADX, SQLite, Databricks), generates the query and runs it with dry-run by default. Triggers when asked to query a database, run SQL or inspect a schema.
02 资源文件 1
- 参考文档skill.json381 B
03 SKILL.md 正文
QueryMaster — Multi-Engine Database Agent (Master Skill)
Trigger: user asks to query a database, run SQL, inspect schema, execute KQL, or mentions any supported engine by name (postgres, snowflake, sql server, adx, sqlite, databricks).
Overview
QueryMaster is a master router that receives natural-language prompts, identifies the target database engine, generates the appropriate query (SQL, KQL, etc.), and optionally executes it with dry-run safety. Each engine is a child skill with embedded best practices.
Supported Engines
| Engine | Child Skill | Driver (Python) | Driver (Node.js) |
|---|---|---|---|
| PostgreSQL | querymaster-postgresql |
psycopg2 / psycopg |
pg (node-postgres) |
| Snowflake | querymaster-snowflake |
snowflake-connector-python |
N/A |
| SQL Server / Azure | querymaster-sqlserver |
pyodbc |
tedious / mssql |
| Azure Data Explorer | querymaster-adx |
azure-kusto-data |
N/A |
| SQLite | querymaster-sqlite |
sqlite3 (stdlib) |
better-sqlite3 |
| Databricks | querymaster-databricks |
databricks-sql-connector |
N/A |
Architecture
User Prompt
│
▼
┌──────────────┐
│ QueryMaster │ ← this skill (router)
│ (master) │
└──────┬───────┘
│ detects engine from:
│ 1. explicit --engine flag
│ 2. connection name in connections.json
│ 3. context clues in prompt (KQL syntax, Snowflake functions, etc.)
│
▼
┌──────────────────────┐
│ Engine Child Skill │ ← querymaster-{engine}
│ (best practices + │
│ query generation) │
└──────────┬───────────┘
│
▼
┌──────────────────────┐
│ CLI Executor │ ← ~/.local/bin/querymaster/
│ (connect, execute, │
│ format, log) │
└──────────────────────┘
CLI Usage
# Basic: prompt + engine + connection name
querymaster --engine postgres --conn prod_client "tablas con más de 1M filas"
# Dry-run (DEFAULT): generates query, shows it, asks for confirmation
querymaster --engine snowflake --conn snowflake_client "schemas disponibles"
# Execute immediately (skip confirmation)
querymaster --engine sqlite --conn local_db "count trials" --execute
# Read-only mode (restricts to SELECT/SHOW/DESCRIBE/EXPLAIN)
querymaster --engine sqlserver --conn sql_azure_dev "list tables" --readonly
# JSON output for piping
querymaster --engine postgres --conn prod_client "table sizes" --json --execute
# History
querymaster --history # list past queries
querymaster --replay <id> # re-execute a past query
querymaster --history --compress # force compression of old results
Connection Configuration
connections.json (~/.config/querymaster/connections.json)
Central registry of connection profiles. Never contains passwords — only references
to environment variables. Each project's .env holds the actual secrets.
{
"prod_client": {
"engine": "postgresql",
"env_prefix": "DB",
"env_file": "~/path/to/client-a/.env",
"defaults": { "port": 5432, "sslmode": "require" }
},
"snowflake_client": {
"engine": "snowflake",
"auth": "browser_sso",
"env_file": "~/path/to/client-b/.env",
"env_prefix": "CONN_LIB_SNOWFLAKE"
}
}
.env per project (secrets)
# client-a/.env
DB_HOST=my-server.postgres.database.azure.com
DB_PORT=5432
DB_USER=admin
DB_PASSWORD=secret
DB_NAME=mydb
Execution Flow
- Parse — CLI parses
--engine,--conn, prompt, flags - Load connection — Read
connections.json→ load.envfrom referenced project - Route — Master identifies engine → loads child skill context
- Generate — Child skill generates engine-specific query from natural language prompt
- Dry-run (default) — Display generated query → ask
[Execute? y/N] - Execute — Connect using loaded credentials → run query
- Format — Display results as rich table (default) or JSON (
--json) - Log — Save to
~/.local/share/querymaster/history/YYYY-MM-DD_conn_NNN.json
Security Rules (MANDATORY)
These rules are non-negotiable and apply to all engines:
- Dry-run by default — Never execute without confirmation unless
--executeflag - Never log secrets — Passwords, tokens, API keys never appear in history or output
- Read-only mode —
--readonlyrestricts to: SELECT, SHOW, DESCRIBE, EXPLAIN, .show (KQL) - Destructive guard — DROP, TRUNCATE, DELETE (without WHERE), ALTER DROP require double confirmation:
⚠️ DESTRUCTIVE OPERATION DETECTED Query: DROP TABLE users; Type 'YES' to confirm (not just 'y'): - connections.json has no passwords — Only env var references and non-sensitive defaults
- Timeout — All queries have a default 30s timeout (configurable via
--timeout) - Row limit — Default 1000 rows returned (configurable via
--limit)
History & Compression Strategy
| Age | Format | Location |
|---|---|---|
| < 30 days | JSON (plain) | ~/.local/share/querymaster/history/ |
| 30–90 days | .json.gz (compressed) |
same directory |
| > 90 days | deleted | — |
history_index.json— metadata index: timestamp, engine, conn, query, rows, duration, file- Compression runs automatically on
querymaster --historyor viaquerymaster --history --compress - Each history entry includes: query text, row count, column names, execution time, engine, connection — but never credentials
When the AI agent is asked to query a database
- Read this skill first
- Identify the engine from the user's request
- Read the corresponding child skill (
querymaster-{engine}) - 4D Paradigm: Describe what query you'll run and against which connection
- Use the child skill's best practices to generate the query
- Delegate: For complex queries, verify schema first (check columns exist before referencing)
- Present the query to the user for confirmation (dry-run)
- If confirmed, execute via the CLI:
querymaster --engine {engine} --conn {conn} "{prompt}" --execute - Diligent: Validate results — check row count, flag unexpected nulls or zero rows
- Disclose: State implications of any destructive operations before executing
- Format and present results
Self-Improvement Protocol
After EVERY failed query:
- Error is logged to history with
error_typeanderror_messagefields - Agent checks if similar error exists in engine skill's
## Lessons Learnedsection - If new error pattern → append to Lessons Learned: date, error pattern, root cause, fix
- If recurring → flag for human review
Reviewing errors
querymaster --review-errors # Show recent failures grouped by error type
History Schema v2 (error-aware)
{
"id": 5,
"timestamp": "2026-03-18T10:30:00",
"engine": "sqlite",
"conn_name": "local_hpo",
"query": "SELECT direction FROM studies",
"success": false,
"error_type": "OperationalError",
"error_message": "no such column: direction",
"row_count": 0,
"duration_ms": 0
}
Engine Detection Heuristics
When no --engine is specified, detect from context:
- PostgreSQL: mentions "postgres", "pg_stat", "psql", "client-a", "client name"
- Snowflake: mentions "snowflake", "warehouse", "VARIANT", "client-b", "client name"
- SQL Server: mentions "sql server", "azure sql", "mssql", "MERGE", "T-SQL"
- ADX/KQL: mentions "kusto", "adx", "kql", "sensor data", "time-series", "FCTS"
- SQLite: mentions "sqlite", "local db", "optuna", "sweep"
- Databricks: mentions "databricks", "delta lake", "unity catalog", "spark sql"
04 同仓库更多 Skills
yeet
Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).
wrangler
Cloudflare Workers CLI for deploying, developing, and managing Workers, KV, R2, D1, Vectorize, Hyperdrive, Workers AI, Containers, Queues, Workflows, Pipelines, and Secrets Store. Load before running wrangler commands to ensure correct syntax and best practices. Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
workspace-skill-discovery
Discover and include ALL skills across the workspace — not just global ones. Use at the start of every session or when the user asks about available skills. Ensures project-level skills (under .claude/skills/ or skills/ in any repo) are never missed.
workers-best-practices
Reviews and authors Cloudflare Workers code against production best practices. Load when writing new Workers, reviewing Worker code, configuring wrangler.jsonc, or checking for common Workers anti-patterns (streaming, floating promises, global state, secrets, bindings, observability). Biases towards retrieval from Cloudflare docs over pre-trained knowledge.
winui-app
Create, build and design WinUI 3 desktop apps with C# and the Windows App SDK following Microsoft's official guidance and CommunityToolkit. Covers XAML, navigation, theming, accessibility and deployment.
windows-brain-script-portability
Scripts in ~/.claude/scripts/ that run on a Windows brain: use the python3.cmd shim and not bare python3, and reconfigure stdout to UTF-8 if you print symbols. Use it when writing a brain script or triaging a Windows-only crash.