Official agent skill

Attach DB

by duckdb in duckdb/duckdb-skills

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

OfficialMITAuto-check: notesDatabases

Install Attach DB

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

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

GitHub CLI
$ gh skill install duckdb/duckdb-skills attach-db --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/attach-db .claude/skills/attach-db && 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
attach-db
GitHub stars
599
Used in
1 other repo
Token cost
~1.2k tokens
SKILL.md length
454 words
Files
1
Skills in repo
8
Repo updated
First seen
Licence
MIT

At a glance

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

  • Works in 8 steps: Resolve the database path → Check DuckDB is installed → Validate the database → …
  • Tasks that involve SQL
  • SKILL.md covers Step 1 — Resolve the database…, Step 2 — Check DuckDB is…, Step 3 — Validate the database and Step 4 — Explore the schema, plus 4 more sections
  • Calls duckdb and git

What it does

Attach DB is an agent skill from duckdb/duckdb-skills, published by the product's own GitHub organization. Attach a DuckDB database file for use with /duckdb-skills:query. Explores the schema (tables, columns, row counts) and writes a SQL state file so subsequent queries can restore this session automatically via duckdb -init.

Its SKILL.md is about 1.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 DuckDB and SQL. The licence is MIT.

When your agent uses it

  • Tasks that involve SQL

Example prompts

  • “/attach-db”

Requirements

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

Workflow steps

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

  1. Resolve the database path
  2. Check DuckDB is installed
  3. Validate the database
  4. Explore the schema
  5. Resolve the state directory
  6. Append to the state file
  7. Verify the state file works
  8. Report

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

Attach DB loads about 1.2k tokens when it runs. Until then it costs about 58 tokens; SKILL.md has 454 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~58
When it runs · the whole SKILL.md, loaded when a task matches
~1.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). 454 words, ~1,195 tokens.

Download SKILL.mdSave it as .claude/skills/attach-db/SKILL.md (or your agent's skills folder).
name
attach-db
description
Attach a DuckDB database file for use with /duckdb-skills:query. Explores the schema (tables, columns, row counts) and writes a SQL state file so subsequent queries can restore this session automatically via duckdb -init.
allowed-tools
Bash
argument-hint
<path-to-database.duckdb>

You are helping the user attach a DuckDB database file for interactive querying.

Database path given: $0

Follow these steps in order, stopping and reporting clearly if any step fails.

State file convention: see the "Resolve state directory" section below. All skills share a single state.sql file per project. Once resolved, any skill can use it with duckdb -init "$STATE_DIR/state.sql" -c "<QUERY>".

Step 1 — Resolve the database path

If $0 is a relative path, resolve it against $PWD to get an absolute path (RESOLVED_PATH).

bash
RESOLVED_PATH="$(cd "$(dirname "$0")" 2>/dev/null && pwd)/$(basename "$0")"

Check the file exists:

bash
test -f "$RESOLVED_PATH"
  • File exists -> continue to Step 2.
  • File not found -> ask the user if they want to create a new empty database (DuckDB creates the file on first write). If yes, continue. If no, stop.

Step 2 — Check DuckDB is installed

bash
command -v duckdb

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

Step 3 — Validate the database

bash
duckdb "$RESOLVED_PATH" -c "PRAGMA version;"
  • Success -> continue.
  • Failure -> report the error clearly (e.g. corrupt file, not a DuckDB database) and stop.

Step 4 — Explore the schema

First, list all tables:

bash
duckdb "$RESOLVED_PATH" -csv -c "
SELECT table_name, estimated_size
FROM duckdb_tables()
ORDER BY table_name;
"

If the database has no tables, note that it is empty and skip to Step 5.

For each table discovered (up to 20), run:

bash
duckdb "$RESOLVED_PATH" -csv -c "
DESCRIBE <table_name>;
SELECT count() AS row_count FROM <table_name>;
"

Collect the column definitions and row counts for the summary.

Step 5 — Resolve the state directory

Check if a state file already exists in either location:

bash
# Option 1: in the project directory
test -f .duckdb-skills/state.sql && STATE_DIR=".duckdb-skills"

# Option 2: in the home directory, scoped by project root path
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 neither exists, ask the user:

Where would you like to store the DuckDB session state for this project?

  1. In the project directory (.duckdb-skills/state.sql) — colocated with the project, easy to find. You can choose to gitignore it.
  2. In your home directory (~/.duckdb-skills/<project-id>/state.sql) — keeps the project directory clean.

Based on their choice:

Option 1:

bash
STATE_DIR=".duckdb-skills"
mkdir -p "$STATE_DIR"

Then ask: "Would you like to gitignore .duckdb-skills/?" If yes:

bash
echo '.duckdb-skills/' >> .gitignore

Option 2:

bash
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")"
PROJECT_ID="$(echo "$PROJECT_ROOT" | tr '/' '-')"
STATE_DIR="$HOME/.duckdb-skills/$PROJECT_ID"
mkdir -p "$STATE_DIR"
Show full SKILL.md (170 more words)Show less

Step 6 — Append to the state file

state.sql is a shared, accumulative init file used by all duckdb-skills. It may already contain macros, LOAD statements, secrets, or other ATTACH statements written by other skills. Never overwrite it — always check for duplicates and append.

Derive the database alias from the filename without extension (e.g. my_data.duckdb → my_data). Check if this ATTACH already exists:

bash
grep -q "ATTACH.*RESOLVED_PATH" "$STATE_DIR/state.sql" 2>/dev/null

If not already present, append:

bash
cat >> "$STATE_DIR/state.sql" <<'STATESQL'
ATTACH IF NOT EXISTS 'RESOLVED_PATH' AS my_data;
USE my_data;
STATESQL

Replace RESOLVED_PATH and my_data with the actual values. If the alias would conflict with an existing one in the file, ask the user for a name.

Step 7 — Verify the state file works

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

If this fails, fix the state file and retry.

Step 8 — Report

Summarize for the user:

  • Database path: the resolved absolute path
  • Alias: the database alias used in the state file
  • State file: the resolved STATE_DIR/state.sql path
  • Tables: name, column count, row count for each table (or note the DB is empty)
  • Confirm the database is now active for /duckdb-skills:query

If the database is empty, suggest creating tables or importing data.

© 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/attach-db 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

Attach DB 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.

Attach DB compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Attach DB this skillduckdb/duckdb-skills5991 repos~1.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
  • 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
  • Query

    duckdb/duckdb-skills

    Official

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

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

Works with

Categories

Questions about Attach DB

What does Attach DB do?

Attach a DuckDB database file for use with /duckdb-skills:query. Attach DB is an agent skill from duckdb/duckdb-skills, published by the product's own GitHub organization. Attach a DuckDB database file for use with /duckdb-skills:query.

When should I use Attach DB?

Attach DB fits situations like: tasks that involve SQL.

How do I install Attach DB in Claude Code?

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

How do I install Attach DB in Codex?

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

Can I use Attach DB 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 attach-db -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/attach-db, .gemini/skills/attach-db, .github/skills/attach-db and .opencode/skills/attach-db in your project.

What does Attach DB need to run?

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

Does Attach DB 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 Attach DB 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 Attach DB use?

Attach DB 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 Attach DB use?

About 1.2k tokens (SKILL.md is roughly 4.8k 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 Attach DB?

Skills that share tags, products or a category with Attach DB: 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 Attach DB?

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.