golang-database
Comprehensive guide for Go database access — parameterized queries, struct scanning, NULLable columns, transactions, isolation levels, SELECT FOR UPDATE, connection pool, batch processing, context propagation, and migration tooling. Use when writing, reviewing, or debugging Golang code that interacts with PostgreSQL, MariaDB, MySQL, or SQLite; for database testing; or for questions about database/sql, sqlx, or pgx. Does NOT generate database schemas or migration SQL.
Install
git clone https://github.com/samber/cc-skills-golang /tmp/cc-skills-golang && ln -s /tmp/cc-skills-golang/skills/golang-database ~/.claude/skills/golang-database
From README
Go Database Best Practices Go's database/sql provides a solid foundation for database access. Use sqlx or pgx on top of it for ergonomics — never an ORM. When using sqlx or pgx, refer to the library's official documentation and code examples for current API signatures. Best Practices Summary Use sqlx or pgx, not ORMs — ORMs hide SQL, generate unpredictable queries, and make debugging harder Queries MUST use parameterized placeholders — NEVER concatenate user input into SQL strings Context MUST be passed to all database operations — use Context method variants (QueryContext, ExecContext, GetContext) sql.ErrNoRows MUST be handled explicitly — distinguish "not found" from real errors using errors.Is Rows MUST be closed after iteration — defer rows.Close() immediately after QueryContext calls NEVER use db.Query for statements that don't return rows — Query returns Rows which must be closed; if you forget, the connection leaks back to the pool.
More from this repo
golang-google-wire
Compile-time dependency injection in Golang using google/wire — wire.NewSet, wire.Build, wire.Bind...
golang-gopls
Golang semantic code intelligence via `gopls`, the official Go language server — go-to-definition, find references,...
golang-how-to
Golang skills orchestrator — always active on any Golang coding, review, debug, or setup task.
