> golang-database
Standards for database interaction, connection pooling, and repository patterns in Golang. Use when implementing database access, connection pools, or repositories in Go. (triggers: internal/adapter/repository/**, database, sql, postgres, gorm, sqlc, pgx)
curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/golang-database?format=md"Golang Database Standards
Priority: P0 (CRITICAL)
Principles
- Prefer Raw SQL/Builders over ORMs: Go structs map well to SQL. ORMs (GORM) can obscure performance. Recommended:
sqlc(type-safe SQL generation). - Repository Pattern: Abstract DB access behind interfaces in
internal/port/(e.g.,UserRepository). - Connection Pooling: Always configure
SetMaxOpenConns,SetMaxIdleConns,SetConnMaxLifetime. - Transactions: Logic requiring ACID MUST use transactions. Pass
context.Contexteverywhere.
Drivers
- PostgreSQL:
jackc/pgx(Preferpgx/v5for performance and features). - MySQL:
go-sql-driver/mysql. - SQLite:
mattn/go-sqlite3ormodernc.org/sqlite(pure Go).
Anti-Patterns
- Global DB Connection: Do not use global
var db *sql.DB. Inject it. - Ignoring Context: Always use
db.QueryContextordb.ExecContextto handle timeouts. - Leaking Rows: ALWAYS
defer rows.Close()and checkrows.Err().
References
> related_skills --same-repo
> typescript-tooling
Development tools, linting, and build config for TypeScript. Use when configuring ESLint, Prettier, Jest, Vitest, tsconfig, or any TS build tooling. (triggers: tsconfig.json, .eslintrc.*, jest.config.*, package.json, eslint, prettier, jest, vitest, build, compile, lint)
> typescript-security
Secure coding practices for TypeScript. Use when validating input, handling auth tokens, sanitizing data, or managing secrets and sensitive configuration. (triggers: **/*.ts, **/*.tsx, validate, sanitize, xss, injection, auth, password, secret, token)
> typescript-language
Modern TypeScript standards for type safety and maintainability. Use when working with types, interfaces, generics, enums, unions, or tsconfig settings. (triggers: **/*.ts, **/*.tsx, tsconfig.json, type, interface, generic, enum, union, intersection, readonly, const, namespace)
> typescript-best-practices
Idiomatic TypeScript patterns for clean, maintainable code. Use when writing or refactoring TypeScript classes, functions, modules, or async logic. (triggers: **/*.ts, **/*.tsx, class, function, module, import, export, async, promise)