public-postgres-expert-base
Skill25 starsChanged 4 months agoApache-2.0View on GitHub
PostgreSQL 知识基座。覆盖 Schema Design、Indexing(B-Tree/GIN/GiST/BRIN)、JSONB、Partitioning、Extensions。供 devlab-postgres-usage 通过 extends 继承。
In this repository57 other files it gives its agents.
- base-cn-registry-mirror-strategySkill
- base-manual-captureSkill
- devlab-ai-agent-engineeringSkill
- devlab-ai-kit-minerSkill
- devlab-cicd-onboardSkill
- devlab-contract-web-serverSkill
- devlab-dao-sql-compatSkill
- devlab-db-data-migrationSkill
- devlab-eval-driven-agentSkill
- devlab-integration-fullstackSkill
- devlab-srv-test-apiSkill
- devlab-tech-debt-opsSkill
- devlab-test-expertSkill
- devlab-test-onboardSkill
- devlab-web-contextSkill
- devlab-web-deep-acceptanceSkill
- devlab-web-echarts-usageSkill
- devlab-web-engineeringSkill
- devlab-web-extension-bootstrapSkill
- devlab-web-skywalking-rum-usageSkill
- devlab-web-test-e2eSkill
- devlab-web-visual-opsSkill
- devlab-web-xyflow-usageSkill
- diag-container-oomSkill
- diag-k8s-node-pressureSkill
- diag-k8s-pod-crashloopSkill
- diag-mysql-deadlockSkill
- diag-mysql-replicationSkill
- diag-mysql-slow-querySkill
- diag-network-port-unreachSkill
- infra-dify-opsSkill
- infra-harbor-opsSkill
- infra-jenkins-pipeline-opsSkill
- infra-nexus-opsSkill
- infra-ragflow-opsSkill
- infra-sonarqube-opsSkill
- infra-system-env-opsSkill
- infra-woodpecker-pipeline-opsSkill
- markitdownSkill
- patent-disclosure-workflowSkill
- patent-reviewSkill
- patent-specification-writerSkill
- public-git-workflow-expert-baseSkill
- public-kafka-expert-baseSkill
- public-mongodb-expert-baseSkill
- public-mysql-expert-baseSkill
- public-nl2sql-expert-baseSkill
- public-oracle-expert-baseSkill
- public-rabbitmq-expert-baseSkill
- public-redis-expert-baseSkill
- work-convertSkill
- work-exportSkill
- work-markitdownSkill
- work-sc-document-sop-builderSkill
- work-sc-docx-comment-replySkill
- work-sc-patent-specification-writerSkill
- work-sc-software-copyright-writerSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Prefer BIGSERIAL or BIGINT GENERATED ALWAYS AS IDENTITY for PKs.
- Very specific: line 12
Use TIMESTAMPTZ (with timezone) over TIMESTAMP.
- Very specific: line 14
Use NUMERIC for money, never FLOAT/REAL.
- Distinctive: line 51
Use connection pooling (PgBouncer) — PostgreSQL connections are expensive (~5-10 MB each).
- Very specific: line 53
Use prepared_statements for parameterized queries.
- Very specific: line 57
Always use TIMESTAMPTZ, not TIMESTAMP.
- Very specific: line 58
Prefer TEXT over VARCHAR(N) unless length limit is meaningful.
- Very specific: line 59
Use CONCURRENTLY when creating indexes on production tables.
- Distinctive: line 61
Use PgBouncer for connection pooling in production.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
PostgreSQL Knowledge Base
Source: Adapted from planetscale/database-skills (PostgreSQL skill).
Schema Design
- Prefer
BIGSERIALorBIGINT GENERATED ALWAYS AS IDENTITYfor PKs. - Use
TIMESTAMPTZ(with timezone) overTIMESTAMP. TEXTandVARCHARhave similar performance in PostgreSQL — preferTEXTunless length constraint is meaningful.- Use
NUMERICfor money, neverFLOAT/REAL. JSONB(binary) overJSON(text) for structured data.
Indexing
| Type | Use for |
| B-Tree (default) | Equality, range, sorting |
| GIN | JSONB, fulltext, arrays, containment |
| GiST | Geometry, range types, nearest-neighbor |
| BRIN | Sequential data (timestamps, IDs) on large tables |
| Hash | Equality only (rarely needed) |
- Partial indexes:
CREATE INDEX ... WHERE condition— index only relevant rows. - Expression indexes:
CREATE INDEX ... ON t (lower(name)). - Covering indexes:
INCLUDE (col1, col2)for index-only scans. CONCURRENTLYfor creating indexes without blocking writes.
JSONB
- Store structured, semi-structured, or variable-schema data.
- Index with GIN:
CREATE INDEX ... USING GIN (data jsonb_path_ops). - Query:
data->>'key'(text),data->'key'(jsonb),data @> '{"key": "val"}'(containment). - Generated columns for frequently queried JSONB paths.
Partitioning
- Declarative partitioning (range, list, hash) for large tables.
- Partition key must be part of every unique/PK constraint.
ATTACH PARTITION/DETACH PARTITIONfor maintenance.- Partition pruning: queries automatically skip irrelevant partitions.
Extensions
pg_trgm: trigram similarity for fuzzy search.pgvector: vector similarity search (AI/embeddings).pg_stat_statements: query performance analysis.uuid-ossp: UUID generation.postgis: geospatial data.
Connection Management
- Use connection pooling (PgBouncer) — PostgreSQL connections are expensive (~5-10 MB each).
- Pool sizing: start with
2 * CPU cores + 1. - Use
prepared_statementsfor parameterized queries. - Set
statement_timeoutto prevent runaway queries.
Guardrails
- Always use
TIMESTAMPTZ, notTIMESTAMP. - Prefer
TEXToverVARCHAR(N)unless length limit is meaningful. - Use
CONCURRENTLYwhen creating indexes on production tables. - Set
statement_timeoutat connection or session level. - Use PgBouncer for connection pooling in production.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

