duckdb/duckdb-skills/attach-db
Claude Code and agent skill by duckdb/duckdb-skills
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install duckdb/duckdb-skills/attach-dbSKILL.md
The same SKILL.md was published earlier as kaalia0912/dsh-data-analysis-mode/attach-db.
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).
Check the file exists:
- 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
If not found, delegate to /duckdb-skills:install-duckdb and then continue.
Step 3 — Validate the database
- 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:
If the database has no tables, note that it is empty and skip to Step 5.
For each table discovered (up to 20), run:
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:
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:
Then ask: "Would you like to gitignore `.duckdb-skills/`?" If yes:
Option 2:
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:
If not already present, append:
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
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.sqlpath - 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.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/attach-db/SKILL.md
Popularity
- Repository stars
- 594
- Repository forks
- 35
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/duckdb/duckdb-skills/attach-db)