agentsclimarketplace

Attach db

Skill Jylhis/skills/skills/services/attach-db

Curated Agent Skills marketplace for Claude Code, Codex, and Google Antigravity.

Install
npx -y skills add Jylhis/skills --skill attach-db

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

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.

SKILL.md

4.6 KB, as published. Nobody here has run it

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;"
  • 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

Resolve existing state in either location:

STATE_DIR=""
PROJECT_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo "$PWD")"
PROJECT_ID="$(echo "$PROJECT_ROOT" | tr '/' '-')"
HOME_STATE_DIR="$HOME/.duckdb-skills/$PROJECT_ID"
PROJECT_STATE_DIR=".duckdb-skills"

test -f "$HOME_STATE_DIR/state.sql" && STATE_DIR="$HOME_STATE_DIR"
test -z "$STATE_DIR" && test -f "$PROJECT_STATE_DIR/state.sql" && STATE_DIR="$PROJECT_STATE_DIR"

If STATE_DIR is still empty, ask where to store state:

  1. Home directory (recommended): ~/.duckdb-skills/<project-id>/state.sql
  2. Project directory: .duckdb-skills/state.sql

If user picks home directory:

STATE_DIR="$HOME_STATE_DIR"
mkdir -p "$STATE_DIR"

If user picks project directory, require an explicit warning/confirmation that project-local SQL can be repository-controlled. Then:

STATE_DIR="$PROJECT_STATE_DIR"
mkdir -p "$STATE_DIR"
: > "$STATE_DIR/TRUSTED_BY_USER"

If project state is used, recommend adding .duckdb-skills/ to .gitignore and confirm the marker must stay untracked.

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.duckdbmy_data). Check if this ATTACH already exists:

grep -q "ATTACH.*RESOLVED_PATH" "$STATE_DIR/state.sql" 2>/dev/null

If not already present, append:

cat >> "$STATE_DIR/state.sql" <<'STATESQL'
ATTACH IF NOT EXISTS 'RESOLVED_PATH' AS my_data;
USE my_data;
STATESQL

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

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.sql path
  • 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.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.