go-database

Provide idiomatic database access patterns for Go services using database/sql, sqlc, GORM, or ent.

64|9|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/eduardo-sl/go-agent-skills --skill go-database-eduardo-sl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-database
Source: https://github.com/eduardo-sl/go-agent-skills/tree/main/skills/%28data%29/go-database
Command: npx skills add https://github.com/eduardo-sl/go-agent-skills --skill go-database-eduardo-sl

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provide clear, production-ready patterns for database access in Go to avoid connection leaks, unsafe queries, improper transaction handling, and brittle migrations that cause outages or data corruption.

Core Features & Use Cases

  • Connection management: Explicit pool sizing, connection lifetimes, and proactive pinging to prevent overload and stale connections.
  • Query safety and patterns: Parameterized queries, proper row closing, QueryRow vs Query semantics, and strategies to avoid N+1 queries.
  • Transactions and helpers: Transaction wrapper patterns that guarantee rollback on errors and guidance on isolation levels for critical operations.
  • Tooling and workflows: Recommendations for sqlc for type-safe SQL, migration tooling best practices, and repository interface design for testability.
  • Use Case: Implement a Postgres-backed service that requires safe concurrent access, atomic money transfers, and reliable schema migrations.

Quick Start

Use the go-database skill to audit your repository and produce idiomatic connection pool configuration, transaction helpers, and sqlc-ready queries for a Postgres service.

Frequently Asked Questions about go-database

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

FAQPage Schema
How do I prevent connection pool leaks in a Go database service?

Prevent connection pool leaks in Go by explicitly setting maximum open connections, connection idle time, and lifetime limits. Proactively ping connections to clear stale states and ensure proper resource closure to avoid overload.

What is the best way to handle database transactions in Go to ensure rollback on errors?

Handle Go database transactions reliably by using wrapper patterns that guarantee rollback on errors. Configure appropriate isolation levels for critical operations to maintain atomicity and prevent partial data corruption.

How do I avoid N+1 queries and write safe SQL in Go applications?

Avoid N+1 queries and write safe SQL in Go by using parameterized queries, understanding QueryRow versus Query semantics, and properly closing rows. Adopt type-safe tooling like sqlc to enforce query safety at compile time.

Does the go-database Skill support GORM and ent for Go database access?

Yes, this Skill supports Go projects using GORM and ent. It provides idiomatic access patterns, enforces context propagation, and guides repository interface design for testability across these different ORM and query generation tools.

What are the best practices for database migrations in a Go Postgres service?

Database migration best practices for a Go Postgres service involve applying reliable schema migration tooling, handling nullable columns correctly, and enforcing context propagation to prevent brittle migrations that cause outages.

When should I use sqlc instead of standard database/sql in Go?

Use sqlc instead of standard database/sql when you need type-safe SQL generation and compile-time query validation. Standard database/sql remains suitable for lower-level control, while sqlc reduces boilerplate and prevents runtime query errors.