/dev10x-db:db-psqlfrom dev10x-db
Safe read-only psql wrapper for Claude Code with SQL validation hook. Executes auditable SELECT queries against configured PostgreSQL databases via db.sh.
Ships in dev10x-db. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill follows references/task-orchestration.md patterns.
Create a task at invocation, mark completed when done:
REQUIRED: Create a task at invocation. Execute at startup:
TaskCreate(subject="Execute safe database query", activeForm="Querying database")Mark completed when done: TaskUpdate(taskId, status="completed")
Safe read-only psql wrapper with two layers of protection:
hooks/scripts/validate-sql.py) — blocks
non-SELECT queries before they reach psqlSET default_transaction_read_only = on
and read-only DB users / read-replica endpoints${CLAUDE_PLUGIN_ROOT}/skills/db-psql/scripts/db.sh <database> "<SQL>"
${CLAUDE_PLUGIN_ROOT}/skills/db-psql/scripts/db.sh <database> -f <file>
${CLAUDE_PLUGIN_ROOT}/skills/db-psql/scripts/db.sh --list
# WRONG — -c flag is not supported, triggers safety hook block
db.sh pp -c "SELECT ..."
# WRONG — stdin piping is not supported
echo "SELECT ..." | db.sh pp
# CORRECT — SQL as second positional argument in quotes
db.sh pp "SELECT ..."
psql (PostgreSQL client)uv -- Python package manager used by parse-databases.py
(pip install uv or brew install uv)secret-tool (libsecret-tools) -- only needed for keyring backendCreate databases.yaml in one of the discovered locations. The
db.sh script searches for config files in this order:
$DB_CONFIG environment variable (explicit path)skills/db-psql/databases.yaml)~/.config/Dev10x/databases.yaml (XDG; preferred global location)~/.claude/memory/Dev10x/databases.yaml (deprecated fallback)skills/*/databases.yaml)~/.claude/skills/*/databases.yaml)~/.claude/plugins/marketplaces/*/skills/*/databases.yaml)Example YAML with both backends:
databases:
my-prod:
label: "My App production (read-only)"
aliases: [mp]
backend: env
env_var: DB_MY_PRODUCTION_RO
my-staging:
label: "My App staging (read-only)"
aliases: [ms]
backend: keyring
keyring_service: claude-db
keyring_account: my-staging
Configure the connection string using the backend specified in
databases.yaml:
env backend — set the environment variable in your shell profile:
export DB_MY_PRODUCTION_RO="postgres://user:pass@host:5432/db"
keyring backend — store the DSN in the system keyring:
secret-tool store --label "claude-db my-staging" \
service claude-db account my-staging
The SQL validation hook (validate-sql.py) is automatically
registered via hooks/hooks.json when this plugin is installed.
No manual configuration needed.
If the PreToolUse hook blocks a non-SELECT query, tell the user:
This query modifies data and cannot be run through the read-only tool. Here's the SQL to run manually:
-- Run against: <alias> (<label>) <the blocked query>
REQUIRED: Always prefix SQL snippets with a target database comment when outputting SQL for manual execution. This prevents copy-paste errors where SQL intended for staging runs against production. The comment format is:
-- Run against: bs (backend-staging)
Never attempt to bypass the safety checks.
For the full handoff — one statement per block, never SQL inside an
AskUserQuestion prompt, and a SELECT read-back after the user runs
it — follow dev10x-db:sql-handoff.
dev10x-db:db for query planning and schema discoverytt:db) provide databases.yaml
with aliases and schema referencesWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dev10x-guru/dev10x-claude --plugin dev10x-db4 skills in this plugin
/bqdev10x-db:bqRead-only BigQuery access through MCP tools that wrap the bq CLI — so an agent can explore datasets and run a SELECT against project.dataset.table without a blanket `Bash(bq query:*)` allow that would also approve DELETE, MERGE or a --destination_table write. TRIGGER when: reading BigQuery data, listing BigQuery datasets or tables, or checking a BigQuery table's columns. DO NOT TRIGGER when: querying Postgres (use dev10x-db:db-psql), or the statement writes (print it for the user, see dev10x-db:sql-handoff).
/dbdev10x-db:dbSafe database query planning for Claude Code. When querying any database, ensures schema-first construction and read-only safety so queries are accurate and never modify production data. TRIGGER when: code needs database queries, schema discovery, or SQL construction. DO NOT TRIGGER when: no database interaction needed, or user is writing application code that happens to mention SQL in comments.
/sql-handoffdev10x-db:sql-handoffUse when a write (UPDATE, INSERT, DELETE, DDL) must reach a database the agent can only read through dev10x-db:db-psql — so the supervisor gets one paste-safe statement aimed at the right database, and the agent proves the effect before building on it. TRIGGER when: the agent needs the user to run non-SELECT SQL by hand, or the db-psql hook just blocked a write. DO NOT TRIGGER when: the SQL is a SELECT (run it via dev10x-db:db-psql), or the change belongs in a migration file in the codebase.
Other plugins' skills for the same job