Token导航 LogoToken导航TokenDH.com
研究检索执行命令github未标认证来源可访问许可证需确认审计异常

query查询工具

Agent Skill

query 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,288

周安装

137

GitHub Stars

435

下载量

1,096
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:query(查询工具)
来源仓库:https://github.com/duckdb/duckdb-skills
仓库路径:skills/query
安装命令:
npx skills add https://github.com/duckdb/duckdb-skills --skill query
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/duckdb/duckdb-skills --skill query

简介

用于通过 DuckDB 查询本地或远程数据源。

  • 支持 CSV、Parquet、JSON 等格式的直接 SQL 分析。
  • 可创建临时数据库状态文件来保存查询上下文。
  • 使用时需确认数据文件路径和查询权限。query 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 适用于数据探索、临时分析和快速原型验证。

SKILL.md

You are helping the user query data using DuckDB.

Input: $@

Follow these steps in order.

Step 1 — Resolve state and determine the mode

Look for an existing state file in either location:

STATE_DIR=""
test -f .duckdb-skills/state.sql && STATE_DIR=".duckdb-skills"
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")"
PROJECT_ID="$(echo "$PROJECT_ROOT" | tr '/' '-')"
test -f "$HOME/.duckdb-skills/$PROJECT_ID/state.sql" && STATE_DIR="$HOME/.duckdb-skills/$PROJECT_ID"

If found, verify the databases it references are still accessible:

duckdb -init "$STATE_DIR/state.sql" -c "SHOW DATABASES;"

Now determine the mode:

  • Ad-hoc mode if: the --file flag is present, or the SQL references file paths/literals (e.g. FROM 'data.csv'), or STATE_DIR is empty.
  • Session mode if: STATE_DIR is set and the input references table names, is natural language, or is SQL without file references.

If no state file exists and no file is referenced, fall back to ad-hoc mode against :memory: — the user must reference files directly in their SQL.

If the state file exists but any ATTACH in it fails, warn the user and fall back to ad-hoc mode.

Step 2 — Check DuckDB is installed

command -v duckdb

If not found, delegate to /duckdb-skills:install-duckdb and then continue.

Step 3 — Generate SQL if needed

If the input is natural language (not valid SQL), generate SQL using the Friendly SQL reference below.

In session mode, first retrieve the schema to inform query generation:

duckdb -init "$STATE_DIR/state.sql" -csv -c "
SELECT table_name FROM duckdb_tables() ORDER BY table_name;
"

Then for relevant tables:

duckdb -init "$STATE_DIR/state.sql" -csv -c "DESCRIBE <table_name>;"

Use the schema context and the Friendly SQL reference to generate the most appropriate query.

Step 4 — Estimate result size

Before executing, estimate whether the query could produce a very large result that would consume excessive tokens when returned to this conversation.

Session mode — check row counts for the tables involved:

duckdb -init "$STATE_DIR/state.sql" -csv -c "
SELECT table_name, estimated_size, column_count
FROM duckdb_tables()
WHERE table_name IN ('<table1>', '<table2>');
"

Ad-hoc mode — probe the source:

duckdb :memory: -csv -c "
SET allowed_paths=['FILE_PATH'];
SET enable_external_access=false;
SET allow_persistent_secrets=false;
SET lock_configuration=true;
SELECT count() AS row_count FROM 'FILE_PATH';
"

Evaluate:

  • If the query already has a LIMIT, count(), or other aggregation that bounds the output -> safe, proceed.
  • If the source has >1M rows and the query has no LIMIT or aggregation -> tell the user: *"This query would return a very large result set. Displaying it here would consume a lot of tokens and increase cost. I'd recommend adding LIMIT 1000 or an aggregation to keep the output manageable."* Ask for confirmation before running as-is.
  • If the data size is >10 GB -> additionally warn: *"This table is over 10 GB — the query may take a while to complete."* Proceed if the user confirms.

Skip this step for queries that are intrinsically bounded (e.g. DESCRIBE, SUMMARIZE, aggregations, count()).

Step 5 — Execute the query

Ad-hoc mode (sandboxed — only the referenced file is accessible):

duckdb :memory: -csv <<'SQL'
SET allowed_paths=['FILE_PATH'];
SET enable_external_access=false;
SET allow_persistent_secrets=false;
SET lock_configuration=true;
<QUERY>;
SQL

Replace FILE_PATH with the actual file path extracted from the query or --file argument. If multiple files are referenced, include all paths in the allowed_paths list.

Session mode (user-trusted database):

duckdb -init "$STATE_DIR/state.sql" -csv -c "<QUERY>"

For multi-line queries, use a heredoc with -init:

duckdb -init "$STATE_DIR/state.sql" -csv <<'SQL'
<QUERY>;
SQL

Always use heredocs (<<'SQL') for multi-line queries to avoid shell quoting issues.

Step 6 — Handle errors

  • Syntax error: show the error, suggest a corrected query, and re-run.
  • Missing extension (e.g. Extension "X" not loaded): delegate to /duckdb-skills:install-duckdb <ext>, then retry.
  • Table not found (session mode): list available tables with FROM duckdb_tables() and suggest corrections.
  • File not found (ad-hoc mode): use find "$PWD" -name "<filename>" 2>/dev/null to locate the file and suggest the corrected path.
  • Persistent or unclear DuckDB error: use /duckdb-skills:duckdb-docs <error message or relevant keywords> to search the documentation for guidance, then apply the fix and retry.

Step 7 — Present results

Show the query output to the user. If the result has more than 100 rows, note the truncation and suggest adding LIMIT to the query.

For natural language questions, also provide a brief interpretation of the results.


DuckDB Friendly SQL Reference

When generating SQL, prefer these idiomatic DuckDB constructs:

Compact clauses

  • FROM-first: FROM table WHERE x > 10 (implicit SELECT *)
  • GROUP BY ALL: auto-groups by all non-aggregate columns
  • ORDER BY ALL: orders by all columns for deterministic results
  • **SELECT * EXCLUDE (col1, col2)**: drop columns from wildcard
  • **SELECT * REPLACE (expr AS col)**: transform a column in-place
  • UNION ALL BY NAME: combine tables with different column orders
  • Percentage LIMIT: LIMIT 10% returns a percentage of rows
  • Prefix aliases: SELECT x: 42 instead of SELECT 42 AS x
  • Trailing commas allowed in SELECT lists

Query features

  • count(): no need for count(*)
  • Reusable aliases: use column aliases in WHERE / GROUP BY / HAVING
  • Lateral column aliases: SELECT i+1 AS j, j+2 AS k
  • **COLUMNS(*)**: apply expressions across columns; supports regex, EXCLUDE, REPLACE, lambdas
  • FILTER clause: count() FILTER (WHERE x > 10) for conditional aggregation
  • GROUPING SETS / CUBE / ROLLUP: advanced multi-level aggregation
  • Top-N per group: max(col, 3) returns top 3 as a list; also arg_max(arg, val, n), min_by(arg, val, n)
  • DESCRIBE table_name: schema summary (column names and types)
  • SUMMARIZE table_name: instant statistical profile
  • PIVOT / UNPIVOT: reshape between wide and long formats
  • SET VARIABLE x = expr: define SQL-level variables, reference with getvariable('x')

Data import

  • Direct file queries: FROM 'file.csv', FROM 'data.parquet'
  • Globbing: FROM 'data/part-*.parquet' reads multiple files
  • Auto-detection: CSV headers and schemas are inferred automatically

Expressions and types

  • Dot operator chaining: 'hello'.upper() or col.trim().lower()
  • List comprehensions: [x*2 FOR x IN list_col]
  • List/string slicing: col[1:3], negative indexing col[-1]
  • **STRUCT.* notation**: SELECT s.* FROM (SELECT {'a': 1, 'b': 2} AS s)
  • Square bracket lists: [1, 2, 3]
  • format(): format('{}->{}', a, b) for string formatting

Joins

  • ASOF joins: approximate matching on ordered data (e.g. timestamps)
  • POSITIONAL joins: match rows by position, not keys
  • LATERAL joins: reference prior table expressions in subqueries

Data modification

  • CREATE OR REPLACE TABLE: no need for DROP TABLE IF EXISTS first
  • CREATE TABLE... AS SELECT (CTAS): create tables from query results
  • INSERT INTO... BY NAME: match columns by name, not position
  • INSERT OR IGNORE INTO / INSERT OR REPLACE INTO: upsert patterns

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

34.59%
按下载量换算379

Claude

30.9%
按下载量换算339

Cursor

17.41%
按下载量换算191

Gemini CLI

10.17%
按下载量换算111

安全审计

Gen Agent Trust Hub

未通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/duckdb/duckdb-skills --skill query 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills