← ClaudeAtlas

golang-databaselisted

Implement or review Go relational-database code using database/sql, pgx, sqlx, or an existing data layer. Use for query safety, scanning and nullability, transactions, pools, migrations, performance, and database tests while preserving the project's selected datastore and library.
reagin/agent-skills · ★ 0 · API & Backend · score 63
Install: claude install-skill reagin/agent-skills
# Go Database Engineering Prioritize correctness at transaction and trust boundaries. Match the project's database, driver, migration system, generated code, and error conventions. ## Establish context Before changing code: 1. Read go.mod and the existing database initialization, repository/query layer, schema, migrations, and tests. 2. Identify the database engine and version, driver placeholder syntax, transaction semantics, and deployment migration policy. 3. Trace the requested operation from validated input through query execution and result mapping. 4. Determine whether the public behavior includes not-found, conflict, retry, or idempotency guarantees. Do not switch between database/sql, pgx, sqlx, generated queries, or an ORM merely to apply a preferred style. ## Query safety and correctness - Pass data values through driver parameters. Never concatenate untrusted values into SQL. - Placeholders cannot represent identifiers, keywords, sort direction, or whole clauses. Map those choices from a fixed allowlist to known SQL fragments. - Build dynamic filters so each generated clause and argument stays paired. Test empty and multi-value cases. - Propagate context to query and transaction calls, with deadlines set at an appropriate request or job boundary. - Close rows, then check rows.Err after iteration. Check errors from scanning, commit, rollback when relevant, and affected-row expectations. - Model SQL NULL deliberately with nullable types, pointers, or domain-s