---
name: "gorm-developer-friendly-orm"
description: "Model database entities, auto-migrate schemas, and manage relationships using Go GORM."
metadata:
  author: "Jinzhu"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "automigrate gorm"
  - "preload associations gorm"
  - "gorm transaction block"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# GORM Developer-Friendly Object Relational Mapping for Go

Configures GORM v2: defining models with gorm.Model, AutoMigrate, associations (hasMany, belongsTo, many2many), hooks (BeforeCreate), query preloading (Preload), transactions, and connection pool tuning.

## When to Invoke
Invoke this skill whenever you need to:
- automigrate gorm
- preload associations gorm
- gorm transaction block

## Execution SOP & Rules
1. Connect database: db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{}).
2. Auto-migrate: db.AutoMigrate(&User{}, &Order{}).
3. Execute CRUD: db.Create(&user); db.First(&user, 1); db.Model(&user).Update('Name', 'Alex').
4. Preload relations: db.Preload('Profile').Where('active = ?', true).Find(&users).

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
