database-postgresql
Skill1 starsChanged 3 months agoMITView on GitHub
PostgreSQL relational schema design, Prisma ORM and SQLAlchemy/Alembic migrations, indexes, transaction boundaries, and pool optimization.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- d-padmanabhan/agent-engineering-handbooktheir own version, first seen Sep 18, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- d-padmanabhan/agent-engineering-handbook★ 17same 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 repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adr-managementSkill
- agentic-developmentSkill
- ci-cdSkill
- code-architectureSkill
- data-engineeringSkill
- debuggingSkill
- deep-learningSkill
- dependency-managementSkill
- deploymentSkill
- dockerSkill
- documentation-orchestratorSkill
- documentationSkill
- environment-guardrailsSkill
- frontend-react-typescriptSkill
- git-githubSkill
- machine-learningSkill
- observabilitySkill
- performance-optimizationSkill
- portfolio-readinessSkill
- project-bootstrapSkill
- project-knowledgeSkill
- python-apiSkill
- python-environmentSkill
- rag-ocr-llmSkill
- release-engineeringSkill
- reusable-componentsSkill
- security-secretsSkill
- supply-chain-securitySkill
- testing-qualitySkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Use this skill when:
- Very specific: line 145
NEVER query records in a loop (N+1 query problem): Use eager loading (selectinload in SQLAlchemy or include: { user: true } in Prisma).
- Very specific: line 147
NEVER omit timezone in timestamp columns: Always use TIMESTAMP WITH TIME ZONE (DateTime(timezone=True)).
≈ “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
Database (PostgreSQL) Skill
1. When Should I Use This?
Use this skill when:
- Designing or modifying relational database tables, foreign key constraints, and indexes in PostgreSQL.
- Managing schema migrations using Prisma ORM (
schema.prisma) or SQLAlchemy 2.0 + Alembic. - Optimizing SQL queries, eliminating N+1 query bottlenecks, and managing transactional integrity.
- Configuring connection pools (Supabase transaction poolers, SQLAlchemy asyncpg pool sizes).
2. What Should I Inspect First?
- ORM Tooling:
- Prisma: Inspect
backend/schema.prismaandprisma/migrations/. - SQLAlchemy: Inspect
app/models/,alembic.ini, andalembic/versions/.
- Prisma: Inspect
- Connection Semantics:
- Inspect
DATABASE_URL(direct vs pooler port6543vs5432in Supabase/PgBouncer).
- Inspect
- Existing Schema & Indexes: Inspect primary key conventions (UUIDs vs BigInt) and foreign key relation maps.
3. What Workflow Should I Follow?
Inspect Existing Schema & Migration History
↓
Draft Schema Changes in Model / Prisma Schema
↓
Add Indexes on Foreign Keys and High-Frequency Query Filters
↓
Generate Migration File (Alembic / Prisma)
↓
Inspect Generated SQL Migration Script for Destructive Actions
↓
Apply Migration (alembic upgrade head / prisma migrate deploy)
↓
Verify with Integration TestPrisma ORM Workflow (TypeScript / Node)
// backend/schema.prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model User {
id String @id @default(uuid())
email String @unique
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
documents Document[]
transactions Transaction[]
@@index([email])
}
model Document {
id String @id @default(uuid())
userId String
title String
ocrText String @db.Text
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
@@index([createdAt])
}# Generate and apply migration locally
npx prisma migrate dev --name add_document_ocr_text
# Deploy migration in production (non-destructive)
npx prisma migrate deploySQLAlchemy 2.0 + Alembic Workflow (Python)
# app/models/document.py
from datetime import datetime, timezone
import uuid
from sqlalchemy import String, Text, DateTime, ForeignKey, Index
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
class Base(DeclarativeBase):
pass
class DocumentModel(Base):
__tablename__ = "documents"
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
user_id: Mapped[str] = mapped_column(String(36), ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
title: Mapped[str] = mapped_column(String(255), nullable=False)
content: Mapped[str] = mapped_column(Text, nullable=False)
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), default=lambda: datetime.now(timezone.utc))
# Explicit indexes
__table_args__ = (
Index("idx_documents_user_id", "user_id"),
Index("idx_documents_created_at", "created_at"),
)# Generate migration script automatically from model metadata
alembic revision --autogenerate -m "create documents table"
# Upgrade database to latest revision
alembic upgrade head4. What Decisions Should I Make?
| Database Requirement | Best Practice Decision |
| Primary Keys | Use UUIDv4 (String(36) / uuid) for distributed API resources to prevent sequential ID scraping. |
| Indexing Heuristic | Index every foreign key column (user_id, vendor_id) and fields used in WHERE, ORDER BY, or JOIN filters. |
| Transactions | Always wrap multi-table modifications (e.g. deduct balance + insert transaction record) in an atomic database transaction. |
| Pool Sizing | For serverless / Render free tiers: pool_size=5, max_overflow=10, pool_recycle=1800 to prevent exhausting PostgreSQL client connection limits. |
5. What Should I Avoid?
- NEVER run destructive resets (
prisma db push --force-resetoralembic downgrade base) on live databases. - NEVER query records in a loop (N+1 query problem): Use eager loading (
selectinloadin SQLAlchemy orinclude: { user: true }in Prisma). - NEVER store large binary blobs (PDFs, images) directly in PostgreSQL columns: Store files in object storage (S3 / Local storage) and save the file path or URI in the database.
- NEVER omit timezone in timestamp columns: Always use
TIMESTAMP WITH TIME ZONE(DateTime(timezone=True)).
6. How Should I Verify Success?
# 1. Verify migration status
alembic current
# Or Prisma
npx prisma migrate status
# 2. Run database integration test suite
pytest tests/integration/test_database.py -vDoes 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.

