Overview
Use this skill for repository adapters backed by PostgreSQL and GORM. It focuses on explicit schema control, predictable transactions, and clean mapping between domain models and persistence models.
When To Use
- Adding or refactoring GORM repositories.
- Designing tables, indexes, and migrations for a Go service.
- Investigating slow queries, transaction issues, or N+1 behavior.
- Reviewing whether ORM models have leaked across boundaries.
Implementation Rules
- Keep persistence structs in infrastructure packages unless there is a conscious shared-model tradeoff.
- Use explicit transactions in application services or unit-of-work helpers for multi-write flows.
- Create indexes and unique constraints based on domain lookup patterns, not only foreign keys.
- Prefer repository methods named by business intent, such as
FindAvailableInventoryBySKU, over generic ORM helpers.
- Use migrations as source of truth for schema evolution. Do not rely on auto-migrate in production workflows.