duckdb avatar

Attach Db

Hooks up a DuckDB database file so you can query it with the companion query skill. It resolves the path, validates the file, explores the schema (tables, columns, row counts), and writes everything to a shared state.sql init file that persists the session. The state file lives either in your project directory or home directory, your choice, and it's append-only so multiple databases and other skills can coexist. Worth noting it handles the entire discovery flow automatically, from checking if DuckDB is installed to asking if you want to gitignore the state directory. If you're jumping between DuckDB files or setting up a new analytics workflow, this saves you from writing the same ATTACH boilerplate every time.

skills.sh installs
1.1K
GitHub stars
616
last updated
Aug 21, 2026

Install

$ npx -y skills add duckdb/duckdb-skills --skill attach-db --agent claude-code

Installs into .claude/skills of the current project.

Files

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

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

Check the file exists:

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

command -v duckdb

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

Step 3 — Validate the database

duckdb "$RESOLVED_PATH" -c "PRAGMA version;"

Sponsors

Details

Repository
github.com/duckdb/duckdb-skills
Categories
Backend & APIs, Databases
First seen
Jun 3, 2026

More from duckdb/duckdb-skills

All 6
1kostja94 avatarsocial-share-generatorkostja94/marketing-skillsWhen the user wants to add, optimize, or audit social share buttons (share article to X, LinkedIn, Facebook, etc.). Also use when the user mentions "share butto1.1Kskills.sh installs
2inference-sh avatarpython-sdkinference-sh/skillsPython SDK for inference.sh - run AI apps, build agents, and integrate with all models. Package: inferencesh (pip install inferencesh). Supports sync/async, str1.1Kskills.sh installs
3heygen-com avatarvideo-understandheygen-com/skillsUnderstand video content locally using ffmpeg frame extraction and Whisper transcription. No API keys needed. Use when: (1) Understanding what a video contains,1.1Kskills.sh installs
4inference-sh avatarjavascript-sdkinference-sh/skillsJavaScript/TypeScript SDK for inference.sh - run AI apps, build agents, integrate with all models. Package: @inferencesh/sdk (npm install). Full TypeScript supp1.1Kskills.sh installs
5kostja94 avatardocs-page-generatorkostja94/marketing-skillsWhen the user wants to create, optimize, or structure a documentation site. Also use when the user mentions "docs," "documentation site," "docs subdomain," "doc1.1Kskills.sh installs
6vtex avatarmarketplace-rate-limitingvtex/skillsApply when implementing retry logic, rate limit handling, or resilience patterns in VTEX API integrations. Covers VTEX rate limit headers (X-RateLimit-Remaining1.1Kskills.sh installs