postgres-drizzle
ccheney/robust-skills
Write, review, and optimize PostgreSQL schemas, queries, and Drizzle ORM code.
What is postgres-drizzle?
This skill handles PostgreSQL database design, SQL queries, migrations, and Drizzle ORM code for Node.js projects. Use it when working with Postgres schemas, relations, indexing, query performance, or Drizzle-specific patterns—not for other databases or generic backend work.
- Author and review PostgreSQL schemas, constraints, indexes, and generated columns
- Write and diagnose SQL queries, joins, transactions, and prepared statements
- Generate and manage Drizzle migrations with drizzle-kit
- Define and work with Drizzle relations (both 0.x and v1 APIs)
- Analyze query plans and optimize indexing and pooling strategies
- Handle PostgreSQL-specific features like JSONB, full-text search, RLS, and partitioning
How to install postgres-drizzle
npx skills add https://github.com/ccheney/robust-skills --skill postgres-drizzle- Node.js project with drizzle-orm and drizzle-kit installed
- PostgreSQL database (version 17/18 recommended for latest features)
- Access to schema files, migration history, and lockfile to verify installed versions
How to use postgres-drizzle
- 1.Identify the task: schema design, query writing, migration, or performance diagnosis
- 2.Check the installed Drizzle version (0.x or v1) and PostgreSQL version from your project
- 3.Consult the relevant reference (SCHEMA.md, QUERIES.md, RELATIONS.md, MIGRATIONS.md, POSTGRES.md, or PERFORMANCE.md)
- 4.Provide the current schema, query, or migration context
- 5.Review the generated SQL or code; execute migrations only after authorization
Use cases
- Design a normalized schema with foreign keys and indexes for a new feature
- Optimize a slow query by analyzing EXPLAIN ANALYZE output and adding missing indexes
- Migrate an existing schema change using drizzle-kit and review the generated SQL
- Define Drizzle relations and verify they match the actual database constraints
- Set up connection pooling and pagination for bulk data operations
- Backend developers using Node.js with PostgreSQL and Drizzle ORM
- Database architects designing or reviewing Postgres schemas
- Teams optimizing query performance and database indexing strategies
- Developers managing database migrations in a Drizzle project
postgres-drizzle FAQ
The 0.x API uses relations() to define ORM relationships separately from schema; v1 uses defineRelations(). Do not mix them. Check your installed version in package.json or package-lock.json before writing relation code.
No. Authoring, reviewing, and analyzing SQL does not require execution. Use EXPLAIN ANALYZE only on a test target if you need a real query plan; otherwise, the skill can diagnose based on schema and workload context.
Provide the query, EXPLAIN output (if available), and schema. The skill will evaluate indexes on referencing columns, suggest missing indexes, and recommend query rewrites based on PostgreSQL's query planner.
No. This skill is specific to PostgreSQL and Drizzle ORM. For other databases, use a different skill or consult the relevant database documentation.
Generate the migration with drizzle-kit, inspect the SQL, verify it matches your intent, and confirm the target database. The skill will prepare the migration; you authorize execution.
Full instructions (SKILL.md)
Source of truth, from ccheney/robust-skills.
name: postgres-drizzle description: Write or review PostgreSQL schemas, queries, migrations, and Drizzle ORM code. Use for Postgres/Drizzle relations, indexing, pooling, or query performance; not for unrelated databases or generic backend work.
PostgreSQL and Drizzle ORM
Match database work to the project's installed API and deployment context. The user's explicit instructions take precedence over this skill's guidelines.
Establish the database contract
Use the relevant schema/query, migration history, and requested behavior as input. For Drizzle code, inspect installed drizzle-orm/drizzle-kit versions and the driver; for SQL, establish the PostgreSQL version when a version-specific feature matters.
The references cover PostgreSQL 17/18 and distinguish Drizzle's 0.x relations() API from the v1 defineRelations() API. Do not mix them or infer the installed API from an npm dist-tag. When the version is unknown, use imports/lockfiles or ask for the missing version before giving version-dependent code.
Keep changes consistent
- Declare database foreign keys separately from ORM relation metadata. Match nullability, uniqueness, and delete behavior to the actual relationship.
- Use the transaction handle for every statement in that transaction; a query through the outer connection can escape it.
- Diagnose slow queries from plans and workload evidence. Evaluate indexes on referencing columns; PostgreSQL does not create them automatically.
- Generate and inspect migration SQL for schema changes. Preserve applied migration history; use a new migration for subsequent changes.
- Establish the target before applying migrations or
push. Authoring or reviewing SQL does not itself require executing it against a database. Continue execution when the user has already authorized that target and action. - Treat
EXPLAIN ANALYZEas query execution, including writes. Use a suitable test target or non-executing plan when execution is outside the task.
Deliver the requested SQL/code, migration, or diagnosis, with compatibility assumptions and relevant verification. If execution is requested but the target is missing, prepare the change and ask only for that missing target.
References
Read the topic required for the current operation.
| Task | Reference |
|---|---|
| Tables, types, constraints, indexes, generated columns | SCHEMA.md |
| Reads, writes, joins, transactions, prepared queries | QUERIES.md |
| Relationships and version-specific relational query APIs | RELATIONS.md |
| drizzle-kit configuration, migration generation and rollout | MIGRATIONS.md |
| PostgreSQL features, RLS, partitioning, JSONB, full-text search | POSTGRES.md |
| Query plans, indexing, pooling, pagination, bulk work | PERFORMANCE.md |
| Compact syntax or connection setup lookup | CHEATSHEET.md |
For APIs or support not established by the installed project and references, consult version-matched Drizzle and PostgreSQL documentation.
Related skills
More from ccheney/robust-skills and the wider catalog.

clean-ddd-hexagonal
Design backend domain boundaries using DDD, Clean Architecture, and hexagonal ports/adapters.

news-aggregator-skill
Fetch and analyze real-time news from 44+ sources with deep insights in Chinese.
ccxt-python
CCXT cryptocurrency exchange library for Python—REST and WebSocket APIs for trading, market data, and real-time monitoring.
cmm-api
Agent skill from cdn-cmm-ai-open.chanmama.com.

best-minds
模拟器思维:不问"你怎么看",而是问"世界上谁最懂这个?TA 会怎么说?"。触发词:最强大脑、顶级专家、世界级、best minds、谁最懂这个
building-apis
Agent skill from celigo/ai.