schema-exploration
Installation
SKILL.md
Explore a PostgreSQL database
Start with the user's question, not a full-database audit unless that is the explicit ask. Use the database connection already available to you; if none is available, ask for access or work from provided schema files. Stay within the database and schemas the user has authorized. Catalog metadata can reveal sensitive names or source code: do not export it unnecessarily.
Workflow
- Establish the current database, server version, role, and scope. Use overview for a small inventory. Choose relevant schemas; do not assume
publiccontains the application. - Pick the most promising object(s) and read only the matching drill-down reference: tables, partitioning/inheritance, foreign tables, views, routines, triggers, security/RLS, or extensions. Follow cross-references only when the question requires them.
- Corroborate meaning with comments, definitions, keys, and known dependencies. Names are clues, not proof of business meaning. If data-derived values would help, use data-derived values only after obtaining approval for the specific columns and access method. Ask the user when semantics remain ambiguous.
- If the user wants SQL, follow query authoring: establish join keys and grain, then validate a vetted read-only query with plain
EXPLAINwhere authorized. Do not mistake a valid plan for proof of business semantics. - Stop once you can answer. Report the specific schema-qualified objects and evidence, distinguish observations from inferences, and state limitations (permissions, stale statistics, missing dependencies, unknown application logic).
Example finding
Illustrative only; report facts verified in the target database:
- Observed:
sales.ordershas a primary key onorder_idand a foreign key fromaccount_idtosales.accounts.account_id. - Inferred:
sales.orderslikely records one row per order; the keys support this, but do not establish what the business calls an “order.” - Unresolved: The catalog does not show whether canceled orders remain in this table. Confirm with the application owner before assuming they do.