PostgreSQL Connection Assistant
Paste the following prompt into your AI chat to install this skill:
Please install @user_2ea0925b/postgresql according to https://skillhub.cn/install/skillhub.md.
About this skill
Problem: read-only MCP is not enough
LLM tooling often treats PostgreSQL as a read-only query target, leaving out safe INSERT, UPDATE, DELETE, and DDL paths. When an agent needs to backfill data, repair rows, or migrate test tables, a read-only interface does not close the loop. Running writes directly also risks missing a WHERE clause, dropping the wrong table, or treating a production database like a test environment.
How it works
The skill provides a local CLI built with Python 3 and psycopg2-binary:
- pg_query.py: runs SELECT, WITH, and EXPLAIN, adding LIMIT 100 by default.
- pg_execute.py: runs writes with dry-run and ROLLBACK by default, committing only with explicit --confirm.
- pg_schema.py / pg_list.py: inspect columns, primary keys, indexes, foreign keys, and row estimates.
- pg_init.py: creates credentials.json, requiring the password file to live in a fixed user directory.
Connection details such as host, port, and database can be overridden via command-line arguments, avoiding ad hoc connection strings. High-risk operations such as DROP TABLE, TRUNCATE, UPDATE/DELETE without WHERE, updates affecting more than a threshold, and any production write must enter a human confirmation flow: dry-run first, pause for explicit approval, then add --confirm. Program-level safeguards include --force, --confirm-prod, Ctrl+C rollback, password masking, and explicit exit codes.
Boundaries
It fits controlled database work in local or trusted agent environments, not bypassing database permissions, audit controls, or release processes. The scripts reject mismatched SQL types and point to the correct entry point. Credentials must not be written into repos, scripts, or chat context; production changes should still follow DBA review and backup policy.
Use Cases
- Before local API debugging, inspect the test database schema and sample rows with read-only queries.
- Before a data repair, preview a risky no-WHERE UPDATE with dry-run and estimated affected rows.
- When exposing database tools to an agent, restrict writes with default dry-run and explicit confirmation.
- Before migration, verify target tables, indexes, and foreign keys using pg_list and pg_schema.
Best For
- Engineers debugging local databases: need safe queries and repairs in a test environment.
- Developers adding DB tools to LLM agents: want to constrain writes and keep human confirmation.
- Engineers performing data migration: quickly verify target schemas, indexes, and foreign keys.
- Backend engineers maintaining test data: preview affected rows before batch updates.
Related Skills
A one-shot coding agent built on Claude Code CLI that runs non-interactively, supports a specified workdir, and can be monitored in the foreground or background.
Preview and confirm file sorting by extension, with recursive cleanup, ignore rules, and transactional rollback.
An engineering assistant for static HTML/CSS/JS pages, design-token extraction, IE8-compatible review, and structured delivery.
An engineering workflow for requirement analysis, scenario modeling, risk planning, quality gates, testing, and knowledge capture, with lightweight, standard, and full modes.