query
Run SQL queries against the attached DuckDB database or ad-hoc against files.
Skill by duckdb
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/duckdb-query
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend, marketing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/query
Tools it pre-approves 1
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
Bash
What's inside
- Skill 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.
- License
- MIT
- Allowed tools
- Bash
- Instructions
- 201 lines in SKILL.md · view on GitHub
Before installing
- Pre-approves any shell command
Files (1)
- SKILL.md
SKILL.md (first lines)
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):
```bashFrom duckdb/duckdb-skills, MIT.
More from duckdb/duckdb-skills
- 0.638score
spatial
duckdb
Answer questions about spatial data using DuckDB.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
convert-file
duckdb
Convert any data file to another format: CSV, Parquet, JSON, Excel, GeoJSON, and more.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
read-file
duckdb
Read any data file (CSV, JSON, Parquet, Avro, Excel, spatial, SQLite) or remote URL (S3, HTTPS).
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
read-memories
duckdb
Search past Claude Code session logs to recall prior decisions, patterns, or unresolved work.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
s3-explore
duckdb
Explore and query data on S3, Cloudflare R2, GCS, MinIO, or any S3-compatible storage.
SkillDFreshness: D★ 610Claude Code +9 - 0.547score
duckdb-docs
duckdb
Search DuckDB and DuckLake documentation and blog posts.
SkillDFreshness: D★ 610Claude Code +9 - 0.547score
install-duckdb
duckdb
Install or update DuckDB extensions.
SkillDFreshness: D★ 610Claude Code +9 - 0.547score
attach-db
duckdb
Attach a DuckDB database file for use with /duckdb-skills:query.
SkillDFreshness: D★ 610Claude Code +9
Signals
- Stars
- 610
- Forks
- 37
- Open issues
- 4
- Last commit (this folder)
- Mar 19, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/duckdb/duckdb-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from duckdb
- 0.638score
spatial
duckdb
Answer questions about spatial data using DuckDB.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
convert-file
duckdb
Convert any data file to another format: CSV, Parquet, JSON, Excel, GeoJSON, and more.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
read-file
duckdb
Read any data file (CSV, JSON, Parquet, Avro, Excel, spatial, SQLite) or remote URL (S3, HTTPS).
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
read-memories
duckdb
Search past Claude Code session logs to recall prior decisions, patterns, or unresolved work.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
s3-explore
duckdb
Explore and query data on S3, Cloudflare R2, GCS, MinIO, or any S3-compatible storage.
SkillDFreshness: D★ 610Claude Code +9 - 0.547score
duckdb-docs
duckdb
Search DuckDB and DuckLake documentation and blog posts.
SkillDFreshness: D★ 610Claude Code +9
Cite this page
query skill. Agent Mart. https://agentmart.dev/skills/duckdb-query (last updated 2026-10-24)