AgentSkillsCN

drizzle-core

Drizzle ORM 的核心架构定义模式与最佳实践。当您在 Drizzle ORM 中定义数据库架构、创建数据表、设置表间关系,或配置约束条件时,可使用此技能。触发条件包括涉及架构设计、表创建、外键、索引,或数据库建模的相关任务。

SKILL.md
--- frontmatter
name: drizzle-core
description: Core Drizzle ORM schema definition patterns and best practices. This skill should be used when defining database schemas, creating tables, setting up relationships, or configuring constraints in Drizzle ORM. Triggers on tasks involving schema design, table creation, foreign keys, indexes, or database modeling.
license: MIT
metadata:
  author: community
  version: "1.0.0"

Drizzle Core Schema Patterns

Comprehensive schema definition guide for Drizzle ORM, applicable across all supported databases (PostgreSQL, MySQL, SQLite, MSSQL). Contains 9 rules across 3 categories focused on building type-safe, well-structured database schemas.

When to Apply

Reference these guidelines when:

  • Defining new database tables with Drizzle ORM
  • Setting up primary keys (single or composite)
  • Creating foreign key relationships between tables
  • Adding indexes for query performance
  • Implementing constraints (unique, check, not null)
  • Configuring default values for columns
  • Setting up Drizzle relations for type-safe queries

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Schema DefinitionCRITICALschema-
2ConstraintsHIGHschema-
3PerformanceMEDIUMschema-

Quick Reference

1. Schema Definition (CRITICAL)

  • schema-table-definition - Define tables with proper structure and exports
  • schema-column-modifiers - Use .notNull(), .default(), .$type<>() correctly
  • schema-primary-keys - Single and composite primary key patterns

2. Constraints (HIGH)

  • schema-foreign-keys - Foreign key relationships and self-references
  • schema-unique-constraints - Single and composite unique constraints
  • schema-check-constraints - Data validation with check constraints
  • schema-default-values - Static, SQL expression, and function defaults

3. Performance & Relations (MEDIUM-HIGH)

  • schema-indexes - Index creation for query optimization
  • schema-relations - Drizzle relations for type-safe joins

How to Use

Read individual rule files for detailed explanations and code examples:

code
rules/schema-table-definition.md
rules/schema-primary-keys.md
rules/schema-foreign-keys.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and variations

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md