attach-db
Attach a DuckDB database file for use with /duckdb-skills:query.
Skill by duckdb
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/duckdb-attach-db
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/attach-db
Tools it pre-approves 1
From allowed-tools in SKILL.md: the agent may use these without asking you each time.
Bash
What's inside
- Skill 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.
- License
- MIT
- Allowed tools
- Bash
- Instructions
- 150 lines in SKILL.md · view on GitHub
Before installing
- Pre-approves any shell command
Files (1)
- SKILL.md
SKILL.md (first lines)
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" ``` ## 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:
From duckdb/duckdb-skills, MIT.
More from duckdb/duckdb-skills
- 0.638score
spatial
duckdb
Answer questions about spatial data using DuckDB.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
read-file
duckdb
Read any data file (CSV, JSON, Parquet, Avro, Excel, spatial, SQLite) or remote URL (S3, HTTPS).
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
read-memories
duckdb
Search past Claude Code session logs to recall prior decisions, patterns, or unresolved work.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
s3-explore
duckdb
Explore and query data on S3, Cloudflare R2, GCS, MinIO, or any S3-compatible storage.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
convert-file
duckdb
Convert any data file to another format: CSV, Parquet, JSON, Excel, GeoJSON, and more.
SkillDFreshness: D★ 610Claude Code +9 - 0.547score
install-duckdb
duckdb
Install or update DuckDB extensions.
SkillDFreshness: D★ 610Claude Code +9 - 0.547score
duckdb-docs
duckdb
Search DuckDB and DuckLake documentation and blog posts.
SkillDFreshness: D★ 610Claude Code +9 - 0.547score
query
duckdb
Run SQL queries against the attached DuckDB database or ad-hoc against files.
SkillDFreshness: D★ 610Claude Code +9
Signals
- Stars
- 610
- Forks
- 37
- Open issues
- 4
- Last commit (this folder)
- Mar 19, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/duckdb/duckdb-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from duckdb
- 0.638score
spatial
duckdb
Answer questions about spatial data using DuckDB.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
read-file
duckdb
Read any data file (CSV, JSON, Parquet, Avro, Excel, spatial, SQLite) or remote URL (S3, HTTPS).
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
read-memories
duckdb
Search past Claude Code session logs to recall prior decisions, patterns, or unresolved work.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
s3-explore
duckdb
Explore and query data on S3, Cloudflare R2, GCS, MinIO, or any S3-compatible storage.
SkillDFreshness: D★ 610Claude Code +9 - 0.632score
convert-file
duckdb
Convert any data file to another format: CSV, Parquet, JSON, Excel, GeoJSON, and more.
SkillDFreshness: D★ 610Claude Code +9 - 0.547score
install-duckdb
duckdb
Install or update DuckDB extensions.
SkillDFreshness: D★ 610Claude Code +9
Cite this page
attach-db skill. Agent Mart. https://agentmart.dev/skills/duckdb-attach-db (last updated 2026-10-24)