gorm-generics

Enable type-safe generic CRUD and advanced queries for GORM models.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-generics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: gorm-generics
Source: https://github.com/liurida/gorm-development-skill/tree/main/gorm-generics
Command: npx skills add https://github.com/liurida/gorm-development-skill --skill gorm-generics

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

GORM's Generics API provides enhanced type safety and a fluent interface for database operations, reducing boilerplate and runtime errors when working with multiple model types.

Core Features & Use Cases

  • Type-safe CRUD operations using generics across models
  • Advanced queries with joins, preloads, and upserts using a single generic API
  • Seamless integration with existing GORM contexts and error handling across apps

Quick Start

Start by selecting a model type and wrapping your DB handle with the generics API to perform CRUD operations using the GT pattern.

Frequently Asked Questions about gorm-generics

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

FAQPage Schema
How do I perform type-safe CRUD operations with GORM in Go?

Type-safe CRUD operations with GORM are performed by wrapping your DB handle using the G[T](db) pattern to execute generic database queries. This provides a fluent interface that reduces boilerplate and runtime errors across multiple model types.

Can I use GORM generics for advanced queries like preloading associations and upserts?

Yes, GORM generics support advanced queries including preloading associations and upserts. The typed API wrapper handles heterogeneous model types using a single generic API for complex data access operations.

Does this generic GORM API integrate with existing context and error handling?

The generic GORM API integrates seamlessly with existing GORM contexts and error handling. It implements context support within the typed wrapper to ensure safe and predictable data access across applications.

What is the best way to reduce boilerplate when managing multiple Go database models?

The best way to reduce boilerplate for multiple Go database models is using GORM's generics API. It provides enhanced type safety and a fluent interface, standardizing heterogeneous model operations through a single typed wrapper.

How do I start using the generics API for my GORM models?

To start using the generics API, select your target model type and wrap your existing DB handle with the generics API. You can then immediately perform type-safe CRUD operations using the G[T](db) pattern.