golang-database

REVIEW · 71
Registry indexed

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 Golan

Verified installs0
Stars3.0K
Version1.0.0
Quality82/100 · Strong
Trust71/100 · Sandbox only
Audit84/100 · Needs review

Supply asset profile

Coding and developer agents

Code review, repo analysis, testing, CI, GitHub, DevOps, and developer workflow skills.

Browse track

Scenario

Database and SQL

I need my agent to inspect database schemas, write SQL, and explain query results.

Agent fit

Claude Code + OpenAI Agents + CLI

Codex, Claude Code, Cursor, CLI, or custom agents.

Install

Ready

npx skills add samber/cc-skills-golang --skill golang-database

Maintenance

fresh

2d since push

Risk

Needs review

Dependency or permission surface needs review

GitHub quality

3.0K

82/100 Quality · 79/100 Trust

Coverage tags

CodingDatabase and SQLdesign-creativeagent-skill

Review notes

Dependency or permission surface needs review · Permission surface may require sandboxing

Agent adoption scorecard

Trust, audit, and install readiness at a glance

These scores combine public repository metadata, OpenAgentSkill review signals, maintenance freshness, and install readiness. They are a shortlist signal, not a replacement for human review.

Quality

Strong
82

Solid option that is likely worth shortlisting for production workflows.

Trust

Sandbox only
71

Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.

Audit

Needs review
84

A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.

OpenAgentSkill Trust Score v5

Human review before install

Run only in a sandbox and compare close alternatives before using it for real work.

CodexClaude CodeCursorOpenAgentSkill CLI

Stars

3.0K GitHub stars

Repo activity

3.0K stars, 197 forks

Maintenance

2d since push

License

MIT

Install

npx skills add samber/cc-skills-golang --skill golang-database

Install safety

standard package or runtime install path

Permission surface

shell or command execution, filesystem or document access

Agent outcomes

No agent outcome data yet

Docs

Strong README/SKILL.md context

Risk summary

Review before production

  • Financial research output is not financial advice; require human review before any live investment decision.
  • Quality score needs review
  • Permission surface needs review: shell or command execution, filesystem or document access
  • Dependency/runtime risk: command execution surface, network or browser surface

Install readiness

Install path available

  • Install path is available
  • Repository evidence is available
  • License is declared
  • No Agent Proven outcome evidence yet

Agent-readable metadata

Machine-readable decision data for this skill.

Use this block or the embedded JSON to decide whether an agent should install this skill, choose an alternative, or ask for human review first.

Open JSON

Suited tasks

  • Database and SQL workflows
  • Claude Code teams
  • teams that value GitHub adoption signals
  • Understand table relationships

Suited agents

CodexClaude CodeCursorOpenAgentSkill CLIOpenAI AgentsCLI

Install decision

Command
npx skills add samber/cc-skills-golang --skill golang-database
Policy
review
Human review
yes

Trust and risk

Trust
71/100
Audit
84/100
Risk level
Needs review

Outcome loop

Endpoint
/api/agent/outcome
Event ID
resolve
Outcomes
5

Install command

npx skills add samber/cc-skills-golang --skill golang-database

Do not use when

  • teams that need a vendor-supported SLA
  • high-compliance environments without internal security review
  • No major risk signals from current metadata
  • High-risk permission hints: Shell or command execution
  • Dependency or permission surface needs review

Agent safety v2

52/100 · Avoid automatic install

Experimentalreview

Sparse or mixed signals. Useful for discovery, but not for autonomous installation.

Test manually in an isolated workspace and compare against safer alternatives.

Resolve via API

high

Shell or command execution

Skill metadata references terminal, CLI, shell, subprocess, or command execution workflows.

medium

Network access

Skill likely fetches remote pages, APIs, repositories, or external services.

medium

Filesystem access

Skill may read or write project files, documents, generated artifacts, or local workspace state.

medium

Database access

Skill may inspect schemas, query databases, or work with persistent stores.

  • High-risk permission hints: Shell or command execution
  • Dependency or permission surface needs review

Install targets

Install this skill in your agent workflow

Use the public install endpoint to fetch the command, safety checklist, target prompts, and canonical links for this skill.

skill install

OpenAgentSkill CLI

Resolve policy, run the source installer safely, and report a verified install receipt.

$ npx --yes https://github.com/Leon-Drq/openagentskill/releases/download/cli-v0.2.1/openagentskill-0.2.1.tgz install samber-golang-database

Agent resolve plan

Let an agent verify fit before installing.

The Resolve API returns the selected skill, alternatives, safety policy, audit notes, install target, and copy-paste prompt an agent can follow without scraping this page.

Open text plan

Agent should check

  • Task fit and alternatives from Resolve API.
  • Audit score, trust score, and safety policy warnings.
  • Install target compatibility for Codex, Claude Code, Cursor, or CLI.

Copy prompt

Task: Use golang-database in this workspace.
Resolve first: https://www.openagentskill.com/api/agent/resolve?task=Use%20golang-database%20for%20an%20agent%20workflow&agent=codex&max_risk=medium
Review install handoff: https://www.openagentskill.com/api/skills/samber-golang-database/install
Install command: npx skills add samber/cc-skills-golang --skill golang-database
Before running it, summarize audit warnings, required permissions, and the fallback skill if install is risky.

Agent handoff

Give an agent the install path, not another directory page.

Use the public install endpoint to fetch the command, safety checklist, target prompts, and canonical links for this skill.

Open install API

Agent prompt

Use golang-database for this task. Review https://www.openagentskill.com/api/skills/samber-golang-database/install, then install with: npx skills add samber/cc-skills-golang --skill golang-database

Registry metadata

Agent-readable profile for automatic skill selection.

This page exposes the same decision, trust, audit, use-case, and install signals through the Registry API, so agents can rank this skill without scraping the UI.

Open manifest

Agent fit

95/100

Database and SQL

Platforms

Claude Code, OpenAI Agents

Audit report

Needs review · 84/100

A machine-readable review of install readiness, security metadata, maintenance, and adoption risk.

View audit reportView eval report

Agent decision cockpit

Primary pick for Database and SQL

Use this as a leading candidate, then validate the README and install path in your own agent stack.

95
Readiness
Adopt
Stage

Role in stack

Primary pick

Primary fit

Database and SQL

Trust label

Production-ready

Install path

Command ready

Use when

  • Database and SQL workflows
  • Claude Code teams
  • teams that value GitHub adoption signals

Evidence

  • 3,010 GitHub stars
  • recent repository activity
  • install command or GitHub repo available
  • 82/100 quality profile
  • 4 OpenAgentSkill engagement events

review first

  • No major risk signals from current metadata

Implementation path

  1. 1Install it in a sandbox agent and run one Database and SQL task end to end.
  2. 2Compare output quality, latency, and failure behavior against at least one alternative.
  3. 3Promote it into production only after reviewing repository permissions, license, and maintenance signals.

Trust profile

Sandbox only

Useful candidate with missing or mixed trust signals. Keep it in an isolated workspace until the outcome loop proves task fit.

71
OpenAgentSkill Trust Score

GitHub adoption

PASS

3.0K GitHub stars

Stars/forks activity

INFO

3.0K stars, 197 forks; issue activity unavailable in current metadata

Recent maintenance

PASS

2d since push

License clarity

PASS

MIT

Good signals

  • AI review approved
  • Install path is available
  • Repository evidence is available
  • Recently maintained repository
  • Meaningful GitHub adoption signal
  • Install command has no obvious high-risk pattern
  • Outcome loop is ready but needs first real agent run

Review before install

  • Financial research output is not financial advice; require human review before any live investment decision.
  • Quality score needs review
  • Permission surface needs review: shell or command execution, filesystem or document access
  • Dependency/runtime risk: command execution surface, network or browser surface
  • Permission surface: shell or command execution, filesystem or document access
  • No real agent outcome reports yet
  • Human review required before unattended installation

Recommended action

Run only in a sandbox and compare close alternatives before using it for real work.

Quality profile

Strong candidate for agent workflows

Solid option that is likely worth shortlisting for production workflows.

82
GitHub stars
3.0K
Freshness
2d ago
Install ready
Yes
License
MIT

Workflow fit

Use this skill in these scenarios

Workflow fit

Add it to a complete workflow

Alternative shortlist

Compare before you install

Similar skills that may fit this task.

Compare all

Overview

--- name: golang-database description: "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." user-invocable: true license: MIT compatibility: Designed for Claude Code, Codex or similar harness, and for projects using Golang. metadata: author: samber version: "1.3.0" openclaw: emoji: "🗄" homepage: https://github.com/samber/cc-skills-golang requires: bins: - go install: [] allowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent AskUserQuestion paths: - "**/*.go" ---

**Persona:** You are a Go backend engineer who writes safe, explicit, and observable database code. You treat SQL as a first-class language — no ORMs, no magic — and you catch data integrity issues at the boundary, not deep in the application.

**Modes:**

- **Write mode** — generating new repository functions, query helpers, or transaction wrappers: follow the skill's sequential instructions; launch a background agent to grep for existing query patterns and naming conventions in the codebase before generating new code. - **Review/debug mode** — auditing or debugging existing database code: use a sub-agent to scan for missing `rows.Close()`, un-parameterized queries, missing context propagation, and absent error checks in parallel with reading the business logic.

> **Community default.** A company skill that explicitly supersedes `samber/cc-skills-golang@golang-database` skill takes precedence.

# 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

1. **Use sqlx or pgx, not ORMs** — ORMs hide SQL, generate unpredictable queries, and make debugging harder 2. Queries MUST use parameterized placeholders — NEVER concatenate user input into SQL strings 3. Context MUST be passed to all database operations — use `*Context` method variants (`QueryContext`, `ExecContext`, `GetContext`) 4. `sql.ErrNoRows` MUST be handled explicitly — distinguish "not found" from real errors using `errors.Is` 5. Rows MUST be closed after iteration — `defer rows.Close()` immediately after `QueryContext` calls 6. 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. Use `db.Exec` instead 7. **Use transactions for multi-statement operations** — wrap related writes in `BeginTxx`/`Commit` 8. **Use `SELECT ... FOR UPDATE`** when reading data you intend to modify — prevents race conditions 9. **Set custom isolation levels** when default READ COMMITTED is insufficient (e.g., serializable for financial operations) 10. **Handle NULLable columns** with pointer fields (`*string`, `*int`) or `sql.NullXxx` types 11. Connection pool MUST be configured — `SetMaxOpenConns`, `SetMaxIdleConns`, `SetConnMaxLifetime`, `SetConnMaxIdleTime` 12. **Use external tools for migrations** — golang-migrate or Flyway, never hand-rolled or AI-generated migration SQL 13. **Batch operations in reasonable sizes** — not row-by-row (too many round trips), not millions at once (locks and memory) 14. **Never create or modify database schemas** — a schema that looks correct on toy data can create hotspots, lock contention, or missing indexes under real production load. Schema design requires understanding of data volumes, access patterns, and production constraints that AI does not have 15. **Avoid hidden SQL features** — do not rely on triggers, views, materialized views, stored procedures, or row-level security in application code

## Library Choice

| Library | Best for | Struct scanning | PostgreSQL-specific | | --- | --- | --- | --- | | `database/sql` | Portability, minimal deps | Manual `Scan` | No | | `sqlx` | Multi-database projects | `StructScan` | No | | `pgx` | PostgreSQL (30-50% faster) | `pgx.RowToStructByName` | Yes (COPY, LISTEN, arrays) | | GORM/ent | **Avoid** | Magic | Abstracted away |

**Why NOT ORMs:**

- Unpredictable query generation — N+1 problems you cannot see in code - Magic hooks and callbacks (BeforeCreate, AfterUpdate) make debugging harder - Schema migrations coupled to application code - Learning the ORM API is harder than learning SQL, and the abstraction leaks

## Parameterized Queries

```go // ✗ VERY BAD — SQL injection vulnerability query := fmt.Sprintf("SELECT * FROM users WHERE email = '%s'", email)

// ✓ Good — parameterized (PostgreSQL) var user User err := db.GetContext(ctx, &user, "SELECT id, name, email FROM users WHERE email = $1", email)

// ✓ Good — parameterized (MySQL) err := db.GetContext(ctx, &user, "SELECT id, name, email FROM users WHERE email = ?", email) ```

### Dynamic IN clauses

```go query, args, err := sqlx.In("SELECT * FROM users WHERE id IN (?)", ids) if err != nil { return fmt.Errorf("building IN clause: %w", err) } query = db.Rebind(query) // adjust placeholders for your driver err = db.SelectContext(ctx, &users, query, args...) ```

### Dynamic column names

Never interpolate column names from user input. Use an allowlist:

```go allowed := map[string]bool{"name": true, "email": true, "created_at": true} if !allowed[sortCol] { return fmt.Errorf("invalid sort column: %s", sortCol) } query := fmt.Sprintf("SELECT id, name, email FROM users ORDER BY %s", sortCol) ```

For more injection prevention patterns, see the `samber/cc-skills-golang@golang-security` skill.

## Struct Scanning and NULLable Columns

Use `db:"column_name"` tags for sqlx, `pgx.CollectRows` with `pgx.RowToStructByName` for pgx. Handle NULLable columns with pointer fields (`*string`, `*time.Time`) — they work cleanly with both scanning and JSON marshaling. See [Scanning Reference](./references/scanning.md) for examples of all approaches.

## Error Handling

```go func GetUser(id string) (*User, error) { var user User

err := db.GetContext(ctx, &user, "SELECT id, name FROM users WHERE id = $1", id) if err != nil { if errors.Is(err, sql.ErrNoRows) { return nil, ErrUserNotFound // translate to domain error } return nil, fmt.Errorf("querying user %s: %w", id, err) }

return &user, nil } ```

or:

```go func GetUser(id string) (u *User, exists bool, err error) { var user User

err := db.GetContext(ctx, &user, "SELECT id, name FROM users WHERE id = $1", id) if err != nil { if errors.Is(err, sql.ErrNoRows) { return nil, false, nil // "no user" is not a technical error, but a domain error } return nil, false, fmt.Errorf("querying user %s: %w", id, err) }

return &user, true, nil } ```

### Always close rows

```go rows, err := db.QueryContext(ctx, "SELECT id, name FROM users") if err != nil { return fmt.Errorf("querying users: %w", err) } defer rows.Close() // prevents connection leaks

for rows.Next() { // ... } if err := rows.Err(); err != nil { // always check after iteration return fmt.Errorf("iterating users: %w", err) } ```

### Common database error patterns

| Error | How to detect | Action | | --- | --- | --- | | Row not found | `errors.Is(err, sql.ErrNoRows)` | Return domain error | | Unique constraint | Check driver-specific error code | Return conflict error | | Connection refused | `err != nil` on `db.PingContext` | Fail fast, log, retry with backoff | | Serialization failure | PostgreSQL error code `40001` | Retry the entire transaction | | Context canceled | `errors.Is(err, context.Canceled)` | Stop processing, propagate |

## Context Propagation

Always use the `*Context` method variants to propagate deadlines and cancellation:

```go // ✗ Bad — no context, query runs until completion even if client disconnects db.Query("SELECT ...")

// ✓ Good — respects context cancellation and timeouts db.QueryContext(ctx, "SELECT ...") ```

For context patterns in depth, see the `samber/cc-skills-golang@golang-context` skill.

## Transactions, Isolation Levels, and Locking

For transaction patterns, isolation levels, `SELECT FOR UPDATE`, and locking variants, see [Transactions](./references/transactions.md).

## Connection Pool

```go db.SetMaxOpenConns(25) // limit total connections db.SetMaxIdleConns(10) // keep warm connections ready db.SetConnMaxLifetime(5 * time.Minute) // recycle stale connections db.SetConnMaxIdleTime(1 * time.Minute) // close idle connections faster ```

For sizing guidance and formulas, see [Database Performance](./references/performance.md).

## Migrations

Use an external migration tool. Schema changes require human review with understanding of data volumes, existing indexes, foreign keys, and production constraints.

Recommended tools:

- [golang-migrate](https://github.com/golang-migrate/migrate) — CLI + Go library, supports all major databases - [Flyway](https://flywaydb.org/) — JVM-based, widely used in enterprise environments - [Atlas](https://atlasgo.io/) — modern, declarative schema management

Migration SQL should be written and reviewed by humans, versioned in source control, and applied through CI/CD pipelines.

## Avoid Hidden SQL Features

Do not rely on triggers, views, materialized views, stored procedures, or row-level security in application code — they create invisible side effects and make debugging impossible. Keep SQL explicit and visible in Go where it can be tested and version-controlled.

## Schema Creation

**This skill does NOT cover schema creation.** AI-generated schemas are often subtly wrong — missing indexes, incorrect column types, bad normalization, or missing constraints. Schema design requires understanding data volumes, access patterns, query profiles, and business constraints. Use dedicated database tooling and human review.

## Deep Dives

- **[Transactions](./references/transactions.md)** — Transaction boundaries, isolation levels, deadlock prevention, `SELECT FOR UPDATE` - **[Testing Database Code](./references/testing.md)** — Mock connections, integration tests with containers, fixtures, schema setup/teardown - **[Database Performance](./references/performance.md)** — Connection pool sizing, batch processing, indexing strategy, query optimization - **[Struct Scanning](./references/scanning.md)** — Struct tags, NULLable column handling, JSON marshaling patterns

## Cross-References

- → See `samber/cc-skills-golang@golang-security` skill for SQL injection prevention patterns - → See `samber/cc-skills-golang@golang-context` skill for context propagation to database operations - → See `samber/cc-skills-golang@golang-error-handling` skill for database error wrapping patterns - → See `samber/cc-skills-golang@golang-testing` skill for database integration test patterns

## References

- [database/sql tutorial](https://go.dev/doc/database/) - [sqlx](https://github.com/jmoiron/sqlx) - [pgx](https://github.com/jackc/pgx) - [golang-migrate](https://github.com/golang-migrate/migrate)

Technical details

Version
1.0.0
License
MIT
Last updated
Aug 20, 2026
Published
Aug 20, 2026

Decision snapshot

Primary pick

95
Ready
Adopt
Stage

3,010 GitHub stars

Audit

Install review

Install and adoption review

84
Needs review
Security
79/100
Maintenance
100/100
Install
92/100
Open full auditView eval report

Agent-proven evidence

Agent-proven evidence

Outcome reports after resolve, review, install, and one narrow run.

0
Proven
Needs first agent runAuto-install: review firstLast: Unknown
Success rate
Recent failure
Outcomes
0
Output quality
Failed
0
Not relevant
0
Installs
0
Risk blocked
0
Setup needed
0
Production
0

No agent outcome data yet. The first agent run can report success, setup needs, risk blocks, failure, or not-relevant through /api/agent/outcome.

Install

Add to agent workflow

Free and open source. Review the report before installing into production agents.

Growth loop

Share kit

X

Scenario-led draft for golang-database, ready for a manual X post.

Curator note
A practical pick for design or creative work:

golang-database: Comprehensive guide for Go database access — parameterized queries, struct scanning, NULLable columns, transactions, isolat...

3.0K stars

https://www.openagentskill.com/skills/samber-golang-database?ref=x
Open X draft
Optional reply with install command
Listing + install path for golang-database:
https://www.openagentskill.com/skills/samber-golang-database?ref=x

Install: npx skills add samber/cc-skills-golang --skill golang-database

Listing source

Registry indexed

Claimable

This listing was indexed from public sources and is not marked official until a maintainer claim is approved.

Creator
samber
Indexed by
OpenAgentSkill community index

Attribution links to the public repository or creator profile. Creators can claim the listing to update ownership signals.

Claim this skill

Owner claim

Claim this skill listing

This Registry indexed listing is attributed to samber but is not marked official yet. Claim it to add a verified owner signal and make future launch, install, and audit updates easier to trust.

Creator backlink kit

Add the evidence badges to your README

Show the canonical listing, current trust and audit signals, and real Agent-Proven evidence where developers evaluate the repository.

[![Listed on OpenAgentSkill](https://www.openagentskill.com/api/badge/samber-golang-database?metric=listed&label=Listed)](https://www.openagentskill.com/skills/samber-golang-database)
[![OpenAgentSkill Trust](https://www.openagentskill.com/api/badge/samber-golang-database?metric=trust&label=Trust)](https://www.openagentskill.com/skills/samber-golang-database)
[![OpenAgentSkill Audit](https://www.openagentskill.com/api/badge/samber-golang-database?metric=audit&label=Audit)](https://www.openagentskill.com/skills/samber-golang-database/audit)
[![Agent Proven](https://www.openagentskill.com/api/badge/samber-golang-database?metric=proven&label=Agent%20Proven)](https://www.openagentskill.com/skills/samber-golang-database)

Author

S

samber

@samber

Health signals

GitHub stars
3.0K
Quality score
47/100
Last GitHub push
Aug 20, 2026
Framework hints
Unknown
OpenAgentSkill views
4
Install copies
0
Outbound clicks
0

Community signal

Share whether this skill looks useful for your agent workflow. Aggregated feedback improves rankings over time.

Trust & safety

Sandbox only

71
  • GitHub adoption3.0K GitHub starsPASS
  • Stars/forks activity3.0K stars, 197 forks; issue activity unavailable in current metadataINFO
  • Recent maintenance2d since pushPASS
  • License clarityMITPASS
  • README/SKILL.md completenessMetadata includes enough usage and workflow contextPASS
  • Dependency/runtime riskcommand execution surface, network or browser surfaceCHECK