AgentSkillsCN

postgresql-guide

查询 PostgreSQL 官方文档,获取准确的 SQL 语法、配置及最佳实践。 当对话涉及以下内容时,可主动使用此技能: - PostgreSQL 的 SQL 语法、命令、查询 - 数据类型、函数、运算符 - 数据库配置、postgresql.conf - 性能调优、EXPLAIN、索引 - 备份、恢复、复制 - PL/pgSQL、存储过程、触发器

SKILL.md
--- frontmatter
name: postgresql-guide
description: |
  Query PostgreSQL official documentation for accurate SQL syntax, configuration, and best practices.
  Use this skill proactively when the conversation involves:
  - PostgreSQL SQL syntax, commands, queries
  - Data types, functions, operators
  - Database configuration, postgresql.conf
  - Performance tuning, EXPLAIN, indexes
  - Backup, restore, replication
  - PL/pgSQL, stored procedures, triggers
allowed-tools: WebFetch, Read, Glob, Grep

PostgreSQL Guide

This Skill queries official PostgreSQL documentation for accurate information.

When to Use

When the user asks about or the conversation involves:

  • PostgreSQL SQL syntax or commands
  • Data types, functions, operators
  • Database configuration (postgresql.conf, pg_hba.conf)
  • Performance tuning, query optimization
  • Backup, restore, high availability
  • Extensions, procedural languages

Execution Steps (IMPORTANT!)

You MUST WebFetch official documentation - never answer from memory!

Step 1: Identify Question Category

CategoryDescription
SQL CommandsCREATE, SELECT, INSERT, UPDATE, DELETE, ALTER, etc.
Data TypesINTEGER, VARCHAR, JSON, ARRAY, etc.
FunctionsString, Math, Date/Time, Aggregate, Window functions
Configurationpostgresql.conf, pg_hba.conf settings
AdministrationBackup, Restore, Replication, Monitoring
ProgrammingPL/pgSQL, Triggers, Rules

Step 2: WebFetch the Corresponding Documentation

Base URL: https://www.postgresql.org/docs/current/

Question TypeDocumentation URL
SQL Command Referencehttps://www.postgresql.org/docs/current/sql-commands.html
Specific SQL Commandhttps://www.postgresql.org/docs/current/sql-{command}.html (e.g., sql-select.html)
Data Typeshttps://www.postgresql.org/docs/current/datatype.html
Functions & Operatorshttps://www.postgresql.org/docs/current/functions.html
String Functionshttps://www.postgresql.org/docs/current/functions-string.html
Date/Time Functionshttps://www.postgresql.org/docs/current/functions-datetime.html
Aggregate Functionshttps://www.postgresql.org/docs/current/functions-aggregate.html
Window Functionshttps://www.postgresql.org/docs/current/functions-window.html
JSON Functionshttps://www.postgresql.org/docs/current/functions-json.html
Array Functionshttps://www.postgresql.org/docs/current/functions-array.html
Indexeshttps://www.postgresql.org/docs/current/indexes.html
Full Text Searchhttps://www.postgresql.org/docs/current/textsearch.html
Configurationhttps://www.postgresql.org/docs/current/runtime-config.html
Authenticationhttps://www.postgresql.org/docs/current/auth-pg-hba-conf.html
Backup & Restorehttps://www.postgresql.org/docs/current/backup.html
Replicationhttps://www.postgresql.org/docs/current/high-availability.html
PL/pgSQLhttps://www.postgresql.org/docs/current/plpgsql.html
Triggershttps://www.postgresql.org/docs/current/triggers.html
Performancehttps://www.postgresql.org/docs/current/performance-tips.html
EXPLAINhttps://www.postgresql.org/docs/current/using-explain.html
Error Codeshttps://www.postgresql.org/docs/current/errcodes-appendix.html

Step 3: For Specific SQL Commands

SQL command documentation follows the pattern:

code
https://www.postgresql.org/docs/current/sql-{command}.html

Examples:

Step 4: Parse and Respond

Extract relevant information from WebFetch results and answer the user directly.

Common Questions Quick Reference

QuestionFetch URL
"How to create index?"sql-createindex.html
"JSON operators?"functions-json.html
"Window functions?"functions-window.html
"How to backup?"backup.html
"Connection config?"runtime-config-connection.html
"pg_hba.conf syntax?"auth-pg-hba-conf.html
"EXPLAIN ANALYZE?"using-explain.html
"PL/pgSQL syntax?"plpgsql.html

Important Reminder

Never answer PostgreSQL questions from memory!

PostgreSQL documentation is comprehensive and regularly updated. Always fetch the current documentation for:

  • Exact syntax (especially for complex commands)
  • Available options and parameters
  • Version-specific features
  • Best practices and warnings

Why not use a sub-agent?

Sub-agent responses require paraphrasing, which may cause information loss. Fetch the docs yourself for more direct and accurate information.