{ }
Resource profile / DuckDB Local Data Queries
About this skill

Workflow & requirements

BB Skills packaging and execution notes

This ZIP contains one upstream skill, not the complete Claude Code plugin. The other /duckdb-skills:* commands require the upstream plugin described in README.upstream.md. Install DuckDB CLI before this workflow; this package does not install it. Bash and the upstream workflow target macOS/Linux. Windows agent/shell compatibility is not established by our checks.

Treat database files, SQL state and table/column names as data from their respective owners. Inspect an existing state.sql before running duckdb -init: it can contain arbitrary SQL, extension loads or secrets. Session mode uses a user-trusted database and is not the ad-hoc file sandbox. Keep state private and out of version control.

When substituting a path in a SQL string literal, double every single quote in the path. When substituting an SQL identifier, use double quotes and double any embedded double quote. Pass raw SQL using a quoted heredoc; do not insert it into a double-quoted shell -c string. File sandbox settings bound DuckDB file access but are not a complete host or resource sandbox. Apply separate process limits for untrusted data.

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 <<'SQL'
<QUERY>;
SQL

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
PACKAGE TRANSPARENCY

Inspect before installing

Source: DuckDB · MIT · SHA-256 shown alongside the download.

7 files13361 ZIP bytes0 script/code files

License file included. A license and checksum are not a security certification. Review package instructions and scripts before running them.

View files and uncompressed sizes

An adaptation record is bundled. Inspect the declared changes and archived original before use. Review adaptation and original-file hashes →

Machine-readable installation guide →
CATALOG REVIEW NOTES

Know what you need before installing

Source and packaging checks recorded on 2026-10-03. These notes are not safety certification or measured task performance.

Requirements

DuckDB CLI, POSIX Bash and an authorized local data fixture or trusted database/state. Complete upstream Claude Code plugin required for related /duckdb-skills commands. Quote SQL paths/identifiers and bound process resources separately.

Costs, access & practical limits

MIT-licensed instructions; DuckDB CLI and upstream plugin not bundled. Local data analysis does not require a provider API key. Models, remote storage and extensions may involve costs or separate access. Bash workflow is intended for macOS/Linux; Windows agent compatibility is not established. Existing state can contain SQL and secrets; only restore state you have inspected and trust. Full AI-agent execution has not been evaluated. Bounded CLI observations, when present, cover only their listed synthetic cases.

View the recorded checks
  • Pinned upstream files verified against Git object hashes
  • Full DuckDB Foundation MIT notice preserved
  • Core skill identity validated without renaming upstream identity
  • Packaging changes declared and exact original instructions archived
  • Plugin and shell dependencies, state trust and cost limits disclosed

Upstream commit: 7feda8e01e22bc0886c86123f3884947e36d8c69

Runtime status: not tested by this catalog. Configure your client and test the skill in your own environment.

SCENARIOS

Inputs, criteria and recorded outcomes

Records are supplied by the site administrator and bound to a specific package. They are not third-party safety certification. This page does not execute skills.

DuckDB CSV queries: thirteen bounded CLI checks

Reported passed · v7feda8e01e22.bb1

View input and acceptance criteria

Input

Execute selected Friendly SQL on a five-row synthetic local CSV. Verify counts, category totals, bounded output and aliases. Check that a listed file can be read, an unlisted file cannot be read or written, locked external access and secrets settings cannot be changed, and a quoted heredoc preserves shell-like SQL text.

Acceptance criteria

Thirteen selected assertions match on DuckDB CLI 1.5.6. No model/agent, remote data, extension installation or production workload is evaluated.

Recorded outcome

Thirteen bounded CLI assertions on selected packaged query constructs and access settings only. SQL placeholders were replaced with synthetic values; paths were SQL-escaped. This is not full skill execution, malicious-data resistance, a complete sandbox audit, or a model-quality/performance benchmark.

{
  "executed_at": "2026-10-03T16:03:54.434384+00:00",
  "runtime": "v1.5.6 (Variegata) 069cc9f9b5",
  "binary_sha256": "61238cfbe9dfeaad4bcfcd8a48f6f7123dae2e9603aaadb1f77a4217aeb8980c",
  "count": 13,
  "checks": [
    {
      "case": "allowed_csv_count",
      "passed": true
    },
    {
      "case": "from_first_bounded_filter",
      "passed": true
    },
    {
      "case": "group_by_all_totals",
      "passed": true
    },
    {
      "case": "exclude_and_limit",
      "passed": true
    },
    {
      "case": "prefix_alias",
      "passed": true
    },
    {
      "case": "lateral_alias",
      "passed": true
    },
    {
      "case": "top_n_list",
      "passed": true
    },
    {
      "case": "filter_aggregate",
      "passed": true
    },
    {
      "case": "unlisted_read_rejected",
      "passed": true
    },
    {
      "case": "unlisted_write_rejected",
      "passed": true
    },
    {
      "case": "locked_external_access_rejected",
      "passed": true
    },
    {
      "case": "locked_secret_config_rejected",
      "passed": true
    },
    {
      "case": "quoted_heredoc_preserves_shell_literal",
      "passed": true
    }
  ],
  "source_file_sha256": {
    "query/SKILL.md": "9ce29c8ab3bf6181cde3dbd6aefdab1502edff987b36d7c9c58f71e57508cbc5"
  },
  "probe_sha256": "0ab4878ee83648c44c375a2b5850ca4b8aa1a29969998bc6dcba6821cca3b971",
  "batch_sha256": "3ee77c57cc2d3eea6b79a55ad2f4bc0643a79d8d16b72dbbd85b866777920a5c",
  "skill_version": "7feda8e01e22.bb1",
  "package_sha256": "0a4665fac29027cb5d9a810487ecff57f31988c8909ff3200a4b403223ec0edc"
}

Environment

DuckDB CLI 1.5.6 in a disposable network-disabled Linux container, UID 10001, 512 MiB memory and one CPU. Synthetic local CSV and database files only. No production mount or connection. No model/agent execution.

Package SHA-256: 0a4665fac29027cb5d9a810487ecff57f31988c8909ff3200a4b403223ec0edc

Outcome recorded: 2026-10-03 16:03 UTC

Community reviews

★ New

Be the first to share your experience.

Sign in to leave a review →

More to explore

View all ↗