Attach Db
Attach a DuckDB file, map its schema, and persist a session state file for later queries.
- CCM score
- 65 of 100
- skills.sh installs
- 1.2K
- GitHub stars
- 623
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers attaching a DuckDB database for
/duckdb-skills:query, with schema exploration of tables, columns, and row counts - Writes an accumulative
state.sqlinit file, stored per project in.duckdb-skills/or~/.duckdb-skills/, that is never overwritten - Checks that DuckDB is installed and validates the file with
PRAGMA version, offering to create a new database when the path is missing - Designed for analysts who want repeat
duckdb -initsessions to restore the attached database automatically
Install
$ npx -y skills add duckdb/duckdb-skills --skill attach-db -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
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;"
Details
- Repository
- github.com/duckdb/duckdb-skills
- Categories
- Databases, Data Science & Analytics
- First seen
- Jun 3, 2026
Questions
What does the attach-db skill do?
attach-db attaches a DuckDB database file for use with /duckdb-skills:query. It explores the schema, listing tables, columns and row counts, and writes a SQL state file so later queries restore the session automatically via duckdb -init.
How do I install attach-db?
Run npx -y skills add duckdb/duckdb-skills --skill attach-db -y in a project to install attach-db. Once installed, attach-db lets the agent attach a DuckDB file and record its session state for later queries.
Where does attach-db store its session state?
attach-db asks whether to store state in the project directory at .duckdb-skills/state.sql or in the home directory under ~/.duckdb-skills/. It appends to a shared state.sql file and never overwrites other skills' macros, secrets or ATTACH statements.
Which skills does attach-db sit beside in the Databases category?
attach-db is in the Databases category on Claude Marketplaces, next to supabase-postgres-best-practices and the prisma skills. Unlike those, attach-db works with local DuckDB database files and sets up a session that the query skill reuses.
More from duckdb/duckdb-skills
All 6Similar to Attach Db
More DatabasesquerySkillduckdb/duckdb-skills1.7K installsRun SQL or natural-language questions against an attached DuckDB database or ad-hoc against local files.
duckdb-skillsPluginduckdb/duckdb-skills623 starsDuckDB-powered skills for Claude Code: read any data file, attach and query DuckDB databases, search DuckDB/DuckLake docs, search past session logs, and install
DbxMCP servert8y231.8K starsRead and write access to DBX-configured databases: list connections, tables, and schemas, and run SQL.
database-schemaSkillalinaqi/maggy275 installsSchema-first guardrail that makes Claude read and verify database schemas before writing queries.