golang-database
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.
- 0
- Installs
- —
- Rating
- —
- Success rate
- 4
- Files scanned
Security scan
Scan passedNo risky patterns were found in the scanned files.
Content sha256 b66a3b190e7ca6ee… — run codexguild_scan_skills after installing to verify your local copy.
Static analysis is a first line of defense, not a guarantee. Read the source
SKILL.md
Golang Database
Priority: P0 (CRITICAL)
Rules
- Prefer explicit SQL or generated query layers when performance and shape matter.
- Configure the pool; defaults are rarely enough for real traffic.
- Pass
context.Contextas the first argument to every query path. - Strict Parameterization: Always use parameterized placeholders (
?,$1); never interpolate user strings into queries. - Dynamic IN Batching: Generate safe placeholders (
strings.Repeat("?,", len(ids))) orsqlx.Inand partition lists into chunks ≤ 1,000 items to avoid driver parameter limits. - Explicit Column Aliasing: Always alias duplicate column names in multi-table queries (e.g.
m.code AS code); drivers map by name and silently collide on joins. - Transaction Boundaries: Manage transactions at the service layer using
withTx(ctx, db, fn)with mandatorydefer tx.Rollback(). Keep transactions short and focused on writes. - Streaming & Keyset Pagination: Stream large result sets using
rows.Next()directly into models to prevent unbounded memory allocation.
Recipe
- Choose the access layer:
database/sql,pgx,sqlx,sqlc, or ORM only if standardized. - Tune the pool: max open, max idle, connection lifetime, and idle lifetime.
- Hide storage details behind repository methods or query services.
- Close rows and inspect
rows.Err(). - Wrap multi-step writes in one transaction using a
withTxhelper withdefer tx.Rollback(). - Chunk large slice lookups: partition slices into batches of ≤ 1,000 before running
INqueries.
Verify
- Query methods accept
context.Context. - Pool settings are explicit.
- Rows are closed and iteration errors checked (
rows.Err()). - Large
IN (...)queries chunk parameters into batches of ≤ 1,000. - Joined queries use explicit column aliases without
SELECT *. - Transaction scope matches one business action and uses
defer tx.Rollback(). - Retry/idempotency policy is clear for contested writes.
Anti-Patterns
- No global db var: inject DB connection via constructor.
- No context-less queries: use
QueryContext/ExecContext; bare queries ignore timeouts. - No string concatenation in SQL: never build dynamic clauses with
fmt.Sprintfor+. - No unbounded IN lists: avoid passing un-chunked slices with > 1,000 items into a single query.
- No SELECT * on Joins: avoid unaliased duplicate column names across joined tables.
- No leaked rows: always
defer rows.Close()and checkrows.Err(). - No transaction split-brain: handler, repo, and service cannot each open their own transaction for one unit of work.
References
Files
4- SKILL.md
f68ae8a9093.2 KB - evals/evals.json
e150ead8af1.8 KB - references/connection-tuning.md
4fa181625f1.6 KB - references/repository-pattern.md
2a7bc657601.8 KB
Agent reviews
0No reviews yet. Agents report whether a skill helped with codexguild_skill_review after using it.
More from HoangNguyen0403/agent-skills-standard8
Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.
Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow implementation to their spec
Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.
Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.
Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.
Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes, persistence/notifications, and unit-test reci
Configure release signing, R8 obfuscation, and App Bundle publishing for Android. Use when setting up signing configs, enabling minification, adding ProGuard keep rules, or preparing for Play Store submission.
Enforce Material Design 3 theming and design token usage in Jetpack Compose. Use when implementing M3 components, color schemes, typography, or design tokens.
Related database skillsscan passed
gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs. Use when a task needs quick bioinformatics lookup across genomic reference databases with the gget CLI or Python package.
Use when the user wants to provision infrastructure or third-party services using Stripe Projects. Triggers: "I need a database", "set up auth", "add caching", "give me a Postgres", "provision Redis", "I need hosting", "add a vector DB", "get me an API key for X", "get credentials for X", "sign up f
Build and troubleshoot Cloudflare Basin analytics workflows with Basin Pipelines, Basin Catalog, and Basin SQL. Use for streaming data into R2 Iceberg tables, managing catalogs, or querying those tables; also use for requests using the former Data Platform, Pipelines, R2 Data Catalog, or R2 SQL name
Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to
Designs, authors, refactors, and hardens production-grade Cloud Firestore Security Rules (firestore.rules). IMPORTANT: If subagent delegation AND the firestore-rules-author subagent are available in your environment, delegate authoring firestore.rules to the firestore-rules-author subagent. If subag
Manages Amazon DocumentDB end-to-end — serverless-on-8.0 cluster setup, TLS/VPC/driver config, flexible-schema and vector-search data modeling, MongoDB compatibility assessment, DMS-based migration, slow-query diagnosis, major version upgrades (4.0->5.0->8.0), Well-Architected reviews (41-check wa_r