attach-db
Skill598 starsChanged 8 months agoMITView on GitHub
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.
3 other projects use a version of this; 2 new projects in the last 4 weeks, against 0 the 4 before.
Adopted by
Surging: 2 new projects took it in the last 4 weeks, none the 4 weeks before.thin data
Most recently taken up by
- justmytwospence/strava-mcpword for word, first seen Nov 8, 2026
- prdlk/skillsword for word, first seen Nov 1, 2026
- Kaalia0912/dsh-data-analysis-modeword for word, first seen Aug 20, 2026
Other versions3 projects use a version of this.
Word for word · 3
- Kaalia0912/dsh-data-analysis-mode★ 2100% same
- prdlk/skills★ 1100% same
- justmytwospence/strava-mcp★ 0100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository8 other files it gives its agents.
- convert-fileSkill
- duckdb-docsSkill
- install-duckdbSkill
- querySkill
- read-fileSkill
- read-memoriesSkill
- s3-exploreSkill
- spatialSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Follow these steps in order, stopping and reporting clearly if any step fails.
- Very specific: line 21
If $0 is a relative path, resolve it against $PWD to get an absolute path (RESOLVED_PATH).
- Distinctive: line 27
Check the file exists:
- Very specific: line 42
If not found, delegate to /duckdb-skills:install-duckdb and then continue.
- Distinctive: line 65
If the database has no tables, note that it is empty and skip to Step 5.
- Distinctive: line 80
Check if a state file already exists in either location:
- Distinctive: line 92
If neither exists, ask the user:
- Distinctive: line 129
If not already present, append:
- Distinctive: line 146
If this fails, fix the state file and retry.
- Distinctive: line 158
If the database is empty, suggest creating tables or importing data.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
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 duckdbIf not found, delegate to /duckdb-skills:install-duckdb and then continue.
Step 3 — Validate the database
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:
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:
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:
# 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?
- In the project directory (
.duckdb-skills/state.sql) — colocated with the project, easy to find. You can choose to gitignore it.- In your home directory (
~/.duckdb-skills/<project-id>/state.sql) — keeps the project directory clean.
Based on their choice:
Option 1:
STATE_DIR=".duckdb-skills"
mkdir -p "$STATE_DIR"Then ask: "Would you like to gitignore .duckdb-skills/?" If yes:
echo '.duckdb-skills/' >> .gitignoreOption 2:
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:
grep -q "ATTACH.*RESOLVED_PATH" "$STATE_DIR/state.sql" 2>/dev/nullIf not already present, append:
cat >> "$STATE_DIR/state.sql" <<'STATESQL'
ATTACH IF NOT EXISTS 'RESOLVED_PATH' AS my_data;
USE my_data;
STATESQLReplace 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
duckdb -init "$STATE_DIR/state.sql" -c "SHOW TABLES;"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.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

