
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-codeInstalls 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