PluginBench
Skill
Review
Audit score 70

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
Prerequisites
  • 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
Claude Code
Cursor
Windsurf
Cline

How to use postgres-drizzle

  1. 1.Identify the task: schema design, query writing, migration, or performance diagnosis
  2. 2.Check the installed Drizzle version (0.x or v1) and PostgreSQL version from your project
  3. 3.Consult the relevant reference (SCHEMA.md, QUERIES.md, RELATIONS.md, MIGRATIONS.md, POSTGRES.md, or PERFORMANCE.md)
  4. 4.Provide the current schema, query, or migration context
  5. 5.Review the generated SQL or code; execute migrations only after authorization

Use cases

Good for
  • 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
Who it's for
  • 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

What's the difference between Drizzle 0.x relations() and v1 defineRelations()?

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.

Do I need to execute queries against a database to get help?

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.

How do I handle a slow query?

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.

Can this skill help with other databases like MySQL or MongoDB?

No. This skill is specific to PostgreSQL and Drizzle ORM. For other databases, use a different skill or consult the relevant database documentation.

What should I do before applying a migration?

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 ANALYZE as 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.

TaskReference
Tables, types, constraints, indexes, generated columnsSCHEMA.md
Reads, writes, joins, transactions, prepared queriesQUERIES.md
Relationships and version-specific relational query APIsRELATIONS.md
drizzle-kit configuration, migration generation and rolloutMIGRATIONS.md
PostgreSQL features, RLS, partitioning, JSONB, full-text searchPOSTGRES.md
Query plans, indexing, pooling, pagination, bulk workPERFORMANCE.md
Compact syntax or connection setup lookupCHEATSHEET.md

For APIs or support not established by the installed project and references, consult version-matched Drizzle and PostgreSQL documentation.