Official agent skill

Query

by duckdb in duckdb/duckdb-skills

Run SQL queries against the attached DuckDB database or ad-hoc against files.

OfficialMITAuto-check: notesDatabases

Install Query

skills CLI
$ npx skills add duckdb/duckdb-skills --skill query -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install duckdb/duckdb-skills query --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/duckdb/duckdb-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/query .claude/skills/query && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
query
GitHub stars
599
Used in
1 other repo
Token cost
~2k tokens
SKILL.md length
887 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
MIT

At a glance

Run SQL queries against the attached DuckDB database or ad-hoc against files.

  • Works in 7 steps: Resolve state and determine the mode → Check DuckDB is installed → Generate SQL if needed → …
  • Tasks that involve SQL
  • SKILL.md covers Step 1 — Resolve state and…, Step 2 — Check DuckDB is…, Step 3 — Generate SQL if needed and Step 4 — Estimate result size, plus 4 more sections
  • Calls duckdb and git

What it does

Query is an agent skill from duckdb/duckdb-skills, published by the product's own GitHub organization. Run SQL queries against the attached DuckDB database or ad-hoc against files. Accepts raw SQL or natural language questions. Uses DuckDB Friendly SQL idioms.

Its SKILL.md is about 2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Databases, covering SQL. It works with SQL and DuckDB. The licence is MIT.

When your agent uses it

  • Tasks that involve SQL

Example prompts

  • “/query”

Requirements

  • Pre-approved tools (allowed-tools): Bash

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Resolve state and determine the mode
  2. Check DuckDB is installed
  3. Generate SQL if needed
  4. Estimate result size
  5. Execute the query
  6. Handle errors
  7. Present results

What it can do on your machine

Read from SKILL.md and the folder at commit 7feda8e. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Bash

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • duckdb
    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Query loads about 2k tokens when it runs. Until then it costs about 41 tokens; SKILL.md has 887 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~41
When it runs · the whole SKILL.md, loaded when a task matches
~2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Bash

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from duckdb/duckdb-skills at commit 7feda8e, republished under its MIT licence (© duckdb). 887 words, ~1,983 tokens.

Download SKILL.mdSave it as .claude/skills/query/SKILL.md (or your agent's skills folder).
name
query
description
Run SQL queries against the attached DuckDB database or ad-hoc against files. Accepts raw SQL or natural language questions. Uses DuckDB Friendly SQL idioms.
allowed-tools
Bash
argument-hint
<SQL or question> [--file path]

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:

bash
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:

bash
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

bash
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:

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

Then for relevant tables:

bash
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:

bash
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:

bash
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):

bash
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):

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

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

bash
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.


Show full SKILL.md (336 more words)Show less

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

© duckdb, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/query of duckdb/duckdb-skills.

Open the folder on GitHubat commit 7feda8e

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in duckdb/duckdb-skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Query next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Query compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Query this skillduckdb/duckdb-skills5991 repos~2kAutomated safety check: NotesMIT
Modelersidequery/sidemantic129—~4.2kAutomated safety check: PassApache-2.0
Semantic Analystsidequery/sidemantic129—~982Automated safety check: PassAGPL-3.0
Ops Telemetry Queryboundless-xyz/boundless193—~3.8kAutomated safety check: PassApache-2.0
Matlab Use Databasematlab/matlab-agentic-toolkit1.1k—~3.1kAutomated safety check: PassCustom licence
Matlab Use Duckdbmatlab/matlab-agentic-toolkit1.1k—~3.9kAutomated safety check: PassCustom licence

Similar skills

  • Modeler

    sidequery/sidemantic

    Build, validate, and manage semantic models using Sidemantic.

    129 GitHub stars~4.2k tokensUpdated today
    DatabasesAuto-check passed
  • Semantic Analyst

    sidequery/sidemantic

    Answer analytical, KPI, metric, trend, cohort, and business-performance questions through a Sidemantic semantic layer.

    129 GitHub stars~982 tokensUpdated today
    DatabasesAuto-check passed
  • Ops Telemetry Query

    boundless-xyz/boundless

    Internal — for Boundless team members only. An agent skill from boundless-xyz/boundless.

    193 GitHub stars~3.8k tokensUpdated 1 mo ago
    DatabasesAuto-check passed
  • Matlab Use Database

    matlab/matlab-agentic-toolkit

    Reads from, writes to, and manages relational databases using MATLAB Database Toolbox.

    1.1k GitHub stars~3.1k tokensUpdated 7 days ago
    DatabasesAuto-check passed
  • Matlab Use Duckdb

    matlab/matlab-agentic-toolkit

    Use DuckDB from MATLAB via Database Toolbox (R2026a+) as a non-math operations engine on large tabular files (CSV/Parquet/JSON) and as a zero-config embedded database.

    1.1k GitHub stars~3.9k tokensUpdated 7 days ago
    DatabasesAuto-check passed
  • SQL

    ericrisco/rsc-harness

    A skill your agent uses when writing or reviewing advanced SQL query logic independent of any one engine — multi-table joins, window functions, CTEs including recursive ones, GROUP BY and GROUPING…

    156 GitHub stars~3.8k tokensUpdated today
    DatabasesAuto-check passed

More from duckdb/duckdb-skills

All 8 skills in this repo
  • Spatial

    duckdb/duckdb-skills

    Official

    Answer questions about spatial data using DuckDB. An agent skill from duckdb/duckdb-skills.

    599 GitHub starsUsed in 1 repo~1k tokens
    Auto-check: notes
  • Convert File

    duckdb/duckdb-skills

    Official

    Convert any data file to another format: CSV, Parquet, JSON, Excel, GeoJSON, and more.

    599 GitHub starsUsed in 1 repo~720 tokens
    Auto-check: notes
  • S3 Explore

    duckdb/duckdb-skills

    Official

    Explore and query data on S3, Cloudflare R2, GCS, MinIO, or any S3-compatible storage.

    599 GitHub starsUsed in 1 repo~848 tokens
    Auto-check: notes
  • Read File

    duckdb/duckdb-skills

    Official

    Read any data file (CSV, JSON, Parquet, Avro, Excel, spatial, SQLite) or remote URL (S3, HTTPS).

    599 GitHub starsUsed in 1 repo~917 tokens
    Auto-check: notes
  • Attach DB

    duckdb/duckdb-skills

    Official

    Attach a DuckDB database file for use with /duckdb-skills:query.

    599 GitHub starsUsed in 1 repo~1.2k tokens
    Auto-check: notes
  • Duckdb Docs

    duckdb/duckdb-skills

    Official

    Search DuckDB and DuckLake documentation and blog posts. An agent skill from duckdb/duckdb-skills.

    599 GitHub starsUsed in 1 repo~1.4k tokens
    Auto-check: notes

Works with

Categories

Questions about Query

What does Query do?

Run SQL queries against the attached DuckDB database or ad-hoc against files. Query is an agent skill from duckdb/duckdb-skills, published by the product's own GitHub organization. Run SQL queries against the attached DuckDB database or ad-hoc against files.

When should I use Query?

Query fits situations like: tasks that involve SQL.

How do I install Query in Claude Code?

Run `npx skills add duckdb/duckdb-skills --skill query -a claude-code`. Or copy the skill folder (skills/query in duckdb/duckdb-skills) into .claude/skills/query in your project. Claude Code loads it when a task matches its description.

How do I install Query in Codex?

Run `npx skills add duckdb/duckdb-skills --skill query -a codex`. Or copy the skill folder (skills/query in duckdb/duckdb-skills) into .agents/skills/query in your project. Codex loads it when a task matches its description.

Can I use Query in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add duckdb/duckdb-skills --skill query -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/query, .gemini/skills/query, .github/skills/query and .opencode/skills/query in your project.

What does Query need to run?

Going by SKILL.md and its folder, Query needs the command-line tools its instructions call (duckdb and git). Its frontmatter pre-approves these tools: Bash.

Does Query access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Query safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Query use?

Query is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Query use?

About 2k tokens (SKILL.md is roughly 7.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Query?

Skills that share tags, products or a category with Query: Modeler (sidequery/sidemantic, 129 stars), Semantic Analyst (sidequery/sidemantic, 129 stars), Ops Telemetry Query (boundless-xyz/boundless, 193 stars) and Matlab Use Database (matlab/matlab-agentic-toolkit, 1.1k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Query?

duckdb (a GitHub organization, an official publisher) maintains it in duckdb/duckdb-skills, which has 599 GitHub stars. The repository holds 8 skills in this directory. The repository was last updated on April 23, 2026.

Source: duckdb/duckdb-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.