Use this skill whenever the user wants to query, explore, or modify a PostgreSQL database using the psql command-line tool. This includes: running SQL queries against a Postgres database, exploring database schemas (listing tables, describing columns, checking indexes), inserting or updating data, running DDL statements, or any task where the user mentions psql, PostgreSQL, Postgres, or a database connection string starting with postgresql://. Trigger whenever the user mentions a database table, asks to 'check the database', 'run a query', 'look at the data', or references a Postgres connection — even casually. Do NOT trigger if the user is working with the pgedge-postgres MCP server (which has its own guardrails and knowledgebase), or if they're writing application code that uses a Postgres driver/ORM rather than the psql CLI directly.
This skill guides you through using the psql command-line tool to interact with PostgreSQL databases efficiently. The core principles are: minimize token usage by using compact output formats, default to read-only access unless the user explicitly needs writes, and always discover the schema before writing queries against unfamiliar tables.
psql supports several connection methods. Ask the user how they connect if it's not clear from context.
psql "postgresql://user:password@host:5432/dbname"
This is the most portable format. If the user provides a connection string, use it directly.
psql -h hostname -p 5432 -U username -d dbname
The user may have these set already — check before asking for connection details:
echo $PGHOST $PGPORT $PGUSER $PGDATABASE
The standard libpq environment variables are: PGHOST, PGPORT, PGUSER, PGDATABASE, PGPASSWORD (though .pgpass is preferred over PGPASSWORD for security).
If the user has a ~/.pgpass file, psql will authenticate automatically without prompting. The file format is:
Spring Boot中的JPA/Hibernate模式,用于实体设计、关系处理、查询优化、事务管理、审计、索引、分页和连接池。