go-repository-pattern

Implement a cloud-agnostic Go persistence layer with sqlc and in-memory backends.

Updated Jan 18, 2026
One-click install
npx skills add https://github.com/333-333-333/agents --skill go-repository-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-repository-pattern
Source: https://github.com/333-333-333/agents/tree/main/skills/go-repository-pattern
Command: npx skills add https://github.com/333-333-333/agents --skill go-repository-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

Cloud-agnostic persistence layer for Go services, combining sqlc-based repositories with clear domain ports, in-memory paths for tests, and migration conventions to keep data access consistent across backends.

Core Features & Use Cases

  • Provides a domain-driven repository interface and sqlc-backed adapters for Postgres, plus an in-memory implementation for local development and unit tests.
  • Includes migrations and a wired configuration to switch between backends without changing domain logic.
  • Designed for scalable data access layers across services, enabling easy swapping of storage backends.

Quick Start

Create a new skill under skills/go-repository-pattern following the provided template and wire it to switch between memory and Postgres backends as demonstrated in wiring.go.

Frequently Asked Questions about go-repository-pattern

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

FAQPage Schema
How do I implement a repository pattern in Go with sqlc and PostgreSQL?

Implement the repository pattern in Go with sqlc by defining domain port interfaces and generating PostgreSQL database adapters. This Skill provides the wiring mechanism to seamlessly switch between Postgres and in-memory backends for your data access layer.

How do I test Go data access layers without connecting to a PostgreSQL database?

Test Go data access layers without PostgreSQL by using an in-memory repository implementation. This Skill provides a memory backend that fulfills your domain interfaces, enabling fast local unit tests without a live database connection.

What is the best way to switch between in-memory and PostgreSQL backends in a Go service?

The best way to switch between in-memory and PostgreSQL backends is an environment-aware wiring mechanism. This Skill provides a configuration that swaps storage repositories without requiring changes to your domain logic.

How do I manage PostgreSQL migrations in a Go repository pattern architecture?

Manage PostgreSQL migrations within a Go repository architecture by applying consistent migration conventions. This Skill includes migration practices that keep your database schema aligned with your sqlc adapters and domain interfaces.

Does this repository pattern template require sqlc to function?

Yes, the template requires sqlc to generate the PostgreSQL database adapters for the repository pattern. The Skill combines sqlc-generated code with domain ports and an in-memory implementation to enable backend switching.

Why define domain ports when building a Go persistence layer with sqlc?

Define domain ports when building a Go persistence layer to decouple core business logic from sqlc database adapters. This Skill uses these interfaces to ensure your domain remains cloud-agnostic and compatible with the in-memory backend.