GORM ORM

Define GORM models and perform database operations in Go.

Updated Feb 25, 2026
One-click install
npx skills add https://github.com/futuretea/x-project --skill gorm-orm
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: GORM ORM
Source: https://github.com/futuretea/x-project/tree/main/.claude/skills/gorm-orm
Command: npx skills add https://github.com/futuretea/x-project --skill gorm-orm

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Go developers avoid repetitive, error-prone SQL by providing patterns and instructions to define models, initialize connections, run migrations, and perform reliable CRUD and association operations using GORM.

Core Features & Use Cases

  • Model Definitions & Struct Tags: Guides on designing models, primary keys, timestamps, soft deletes, and JSON/db tags for predictable schema mapping.
  • Connection Management: Initialization patterns for SQLite, MySQL, and PostgreSQL with sensible logger and configuration examples.
  • CRUD, Queries & Preloading: Examples for common create, read, update, delete flows, filtered queries, ordering, pagination, and eager loading of associations.
  • Associations, Transactions & Hooks: Best practices for one-to-one, one-to-many, nested preloads, transactional workflows, and lifecycle hooks.
  • Migrations & Schema Operations: AutoMigrate usage, checking/creating tables, adding columns and indexes, and recommendations for production migrations.
  • Use Case: Build a user management system with profiles and orders, ensure referential integrity with cascading deletes, and implement transactional order creation with rollback on failure.

Quick Start

Use the GORM ORM skill to initialize a database connection, auto-migrate User, Profile, and Order models, and perform a basic create-and-query cycle for a User record.

Frequently Asked Questions about GORM ORM

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define Go struct models and run database migrations using GORM?

Define Go struct models and run database migrations using GORM by applying struct tags for schema mapping and executing AutoMigrate to automatically create or update database tables for your application.

Does GORM support eager loading associations and nested preloads in Go?

GORM supports eager loading associations and nested preloads in Go by utilizing its preloading features to fetch related one-to-one and one-to-many records efficiently in a single query.

How do I manage database transactions and rollback on failure in a Go ORM?

Manage database transactions and rollback on failure in a Go ORM by applying GORM transactional workflows that ensure data integrity and automatically revert operations if an error occurs.

What is the best way to initialize PostgreSQL and MySQL connections in a Go application?

The best way to initialize PostgreSQL and MySQL connections in a Go application is using GORM connection patterns that configure sensible loggers and database parameters for reliable operations.

How do soft deletes and lifecycle hooks work in a Go ORM?

Soft deletes and lifecycle hooks work in a Go ORM by tagging model fields for soft deletion and implementing GORM hooks to trigger custom logic during record creation, updates, or deletion.

Can I implement cascading deletes and referential integrity with GORM associations?

You can implement cascading deletes and referential integrity with GORM associations by configuring foreign key constraints and relationship tags to automatically remove dependent child records.