Golang database

From HoangNguyen0403/agent-skills-standard · View interactive version

Golang database is an AI agent skill from the GitHub repository HoangNguyen0403/agent-skills-standard. Implement Go database access with context, pool tuning, transaction boundaries, and repository seams. Use when building repositories, tuning `sql.DB` or `pgx`, or reviewing DB transaction flow in Go.

How to use this skill

Skill file

Golang Database

**Priority: P0 (CRITICAL)**

Rules

Recipe

  1. Choose the access layer: database/sql, pgx, sqlx, sqlc, or ORM only if standardized.
  2. Tune the pool: max open, max idle, connection lifetime, and idle lifetime.
  3. Hide storage details behind repository methods or query services.
  4. Close rows and inspect rows.Err().
  5. Wrap multi-step writes in one transaction using a withTx helper with defer tx.Rollback().
  6. Chunk large slice lookups: partition slices into batches of ≤ 1,000 before running IN queries.

Verify

Anti-Patterns

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.