go-db

Configure pgx connection pools, queries, migrations, and transactions in Go.

1|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/anicdh/agstack --skill go-db-anicdh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-db
Source: https://github.com/anicdh/agstack/tree/main/.claude/skills/go/go-db
Command: npx skills add https://github.com/anicdh/agstack --skill go-db-anicdh

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Go developers writing database interactions with pgx need clear patterns for connection pooling, safe queries, migrations, and transaction handling; this skill provides practical Go pgx usage patterns and examples.

Core Features & Use Cases

  • Connection Pool Setup: configure a global pool with min/max conns and lifecycle.
  • Query Patterns & Scanning: parameterized queries, proper scanning, and context propagation.
  • Transactions & Migrations: multi-step operations with rollback, and SQL migrations as files.
  • Null Handling & Error Wrapping: robust handling of nullable columns and wrapped errors for clarity.
  • Use Case: building a backend service that performs CRUD and complex transactions against PostgreSQL using pgx.

Quick Start

Create a Go module and implement the pgx-based DB layer following the patterns and examples provided.

Frequently Asked Questions about go-db

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

FAQPage Schema
How do I set up a PostgreSQL connection pool in Go using pgx?

Configure a global PostgreSQL connection pool in Go using pgx by defining min and max connections and managing the pool lifecycle for efficient database access. This ensures safe backend service operations.

What is the best way to handle database transactions and rollbacks in Go pgx?

Handle database transactions in Go pgx by executing multi-step operations with proper rollback mechanisms on failure. This pattern ensures reliable complex query execution and data integrity.

How do I run SQL migrations in a Go project with pgx?

Run SQL migrations in a Go pgx project by organizing migration files in a dedicated migrations folder. This approach maintains version control over PostgreSQL schema changes across microservices.

How do I handle nullable columns and wrap errors when querying PostgreSQL in Go?

Handle nullable PostgreSQL columns and wrap query errors in Go by using proper scanning patterns and error wrapping for clarity. This ensures robust context-aware database operations.

Does pgx support context-aware parameterized queries for Go backend services?

Yes, pgx supports context-aware parameterized queries for Go backend services. It enables safe PostgreSQL data access by propagating context and using parameterized statements to prevent injection.

When should I use pgx over other database libraries for Go microservices?

Use pgx for Go microservices when you need reliable PostgreSQL access with advanced connection pooling, complex transaction handling, and organized migrations for data pipelines and API servers.