database-postgresql
Skill17 starsChanged 55 days agoMITView on GitHub
PostgreSQL database design patterns, naming conventions, schema design, migrations, performance optimization, and security best practices. Use when designing database schemas, writing migrations, optimizing queries, or working with PostgreSQL-specific features like JSONB, full-text search, or RLS.
- Deletes or force-pushes
1 other project uses a version of this.
Adopted by
Most recently taken up by
- SwastikPandey1024/agentic-engineering-ostheir own version, first seen Oct 20, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- SwastikPandey1024/agentic-engineering-os★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository53 other files it gives its agents.
- agents-sdkSkill
- agent-workflowSkill
- api-designSkill
- aws-iamSkill
- bash-shell-scriptingSkill
- cicd-github-actionsSkill
- cloudflare-email-serviceSkill
- cloudflareSkill
- cloudflare-waf-authorSkill
- cloudflare-workers-authorSkill
- cloud-platformsSkill
- codebase-security-auditSkill
- containers-orchestrationSkill
- core-engineeringSkill
- databricksSkill
- data-engineeringSkill
- distributed-transactionsSkill
- documentation-standardsSkill
- domain-driven-designSkill
- durable-objectsSkill
- frontend-engineeringSkill
- git-workflowSkill
- go-rust-systemsSkill
- iam-security-advisorSkill
- independent-verificationSkill
- infrastructure-iacSkill
- kubernetes-containersSkill
- kubernetes-operator-developmentSkill
- mcp-developmentSkill
- memory-architectureSkill
- multi-perspective-reviewSkill
- networking-transportSkill
- observabilitySkill
- oktaSkill
- pdf-exportSkill
- python-developmentSkill
- reactflow-architecture-diagramsSkill
- sandbox-sdkSkill
- scripting-automationSkill
- security-testingSkill
- service-resilienceSkill
- single-file-dashboardSkill
- skills-compositionSkill
- skills-continuous-improvementSkill
- snowflakeSkill
- system-designSkill
- typescript-javascriptSkill
- web-perfSkill
- web-research-kb-refreshSkill
- workers-best-practicesSkill
- workload-identitySkill
- wranglerSkill
- zero-trustSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
"Consistency is king": - Follow naming conventions consistently across all tables and columns
- Distinctive: line 11
"Explicit over implicit": - Use explicit constraints, types, and defaults
- Distinctive: line 13
"Security by default": - Use parameterized queries, RLS, least privilege
- Distinctive: line 16
"Test your migrations": - Test migrations in staging before production
- Distinctive: line 17
"Backup before changes": - Always backup before destructive operations
- Very specific: line 25
Primary Keys: Always named id (BIGSERIAL)
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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 Database Engineering
Core Principles
- "Consistency is king" - Follow naming conventions consistently across all tables and columns
- "Explicit over implicit" - Use explicit constraints, types, and defaults
- "Performance by design" - Index foreign keys and frequently queried columns
- "Security by default" - Use parameterized queries, RLS, least privilege
- "Migrations are code" - Version control migrations, make them reversible
- "Documentation matters" - Comments explain why, not just what
- "Test your migrations" - Test migrations in staging before production
- "Backup before changes" - Always backup before destructive operations
Quick Reference
Naming Conventions
- Tables: Plural snake_case (
users,order_items) - Columns: Singular snake_case (
first_name,email) - Primary Keys: Always named
id(BIGSERIAL) - Foreign Keys:
table_name_idpattern (user_id,product_id) - Indexes:
idx_table_columnpattern (idx_users_email) - Constraints: Named with descriptive pattern (
users_email_unique)
Essential Patterns
Timestamps:
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULLSoft Deletes:
deleted_at TIMESTAMP WITH TIME ZONE NULL
CREATE INDEX idx_users_deleted_at ON users(deleted_at) WHERE deleted_at IS NULL;Enums:
CREATE TYPE user_status AS ENUM ('active', 'inactive', 'suspended');
status user_status DEFAULT 'active' NOT NULLForeign Keys:
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE RESTRICTCommon Patterns
Basic Table Structure
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL,
first_name VARCHAR(100) NOT NULL,
last_name VARCHAR(100) NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL,
CONSTRAINT users_email_unique UNIQUE (email)
);
CREATE INDEX idx_users_email ON users(email);Migration Pattern
-- migrations/20250115120000_create_users_table.sql
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email VARCHAR(255) NOT NULL UNIQUE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() NOT NULL
);
-- Always provide down migration
-- migrations/20250115120000_create_users_table.down.sql
DROP TABLE IF EXISTS users;Security Essentials
Always use parameterized queries:
# GOOD
cursor.execute("SELECT * FROM users WHERE email = %s", (email,))
# BAD - SQL injection risk
cursor.execute(f"SELECT * FROM users WHERE email = '{email}'")Row-Level Security for multi-tenant:
ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
CREATE POLICY orders_user_policy ON orders
FOR ALL USING (user_id = current_setting('app.user_id')::bigint);Performance Basics
Index foreign keys:
CREATE INDEX idx_orders_user_id ON orders(user_id);Partial indexes for filtered queries:
CREATE INDEX idx_users_active ON users(email) WHERE deleted_at IS NULL;Composite indexes for common patterns:
CREATE INDEX idx_orders_user_created ON orders(user_id, created_at DESC);When to Use This Skill
- Designing database schemas
- Writing SQL migrations
- Optimizing database queries
- Implementing database security (RLS, parameterized queries)
- Working with PostgreSQL-specific features (JSONB, full-text search, arrays)
- Performance tuning (indexes, query plans, partitioning)
- Database testing and migrations
References
For detailed guidance, see:
- references/schema-design.md - Naming conventions, table design patterns
- references/migrations.md - Migration best practices, reversible migrations
- references/performance.md - Indexing strategies, query optimization
- references/security.md - RLS, parameterized queries, connection pooling
- references/sql-safety.md - SQL categories (DQL/DML/DDL/DCL/TCL) and destructive-operation guardrails
- references/advanced-patterns.md - JSONB, full-text search, CTEs, partitioning
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

