golang-database

REVIEW · 62
Registry indexed

Comprehensive guide for Go database access. Covers parameterized queries, struct scanning, NULLable column handling, error patterns, transactions, isolation levels, SELECT FOR UPDATE, connection pool, batch processing, context propagation, and migration tooling. Use this skill wh

Verified installs0
Stars12
Version1.0.0
Quality58/100 · Promising
Trust62/100 · Sandbox only
Audit74/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 + CLI + Codex

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

Install

Ready

npx skills add yzfly/skills --skill golang-database

Maintenance

fresh

Pushed today

Risk

Needs review

Dependency or permission surface needs review

GitHub quality

12

58/100 Quality · 70/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

Promising
58

Useful candidate, but compare it with alternatives before adopting.

Trust

Sandbox only
62

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

Audit

Needs review
74

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

12 GitHub stars

Repo activity

12 stars, 2 forks

Maintenance

Pushed today

License

MIT

Install

npx skills add yzfly/skills --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.
  • Low GitHub adoption signal
  • Quality score needs review
  • Permission surface needs review: shell or command execution, filesystem or document access

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
  • builders willing to evaluate younger projects
  • Understand table relationships

Suited agents

CodexClaude CodeCursorOpenAgentSkill CLICLI

Install decision

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

Trust and risk

Trust
62/100
Audit
74/100
Risk level
Needs review

Outcome loop

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

Install command

npx skills add yzfly/skills --skill golang-database

Do not use when

  • teams that need a vendor-supported SLA
  • production agents without a repository review
  • Low GitHub adoption signal
  • No OpenAgentSkill engagement data yet
  • High-risk permission hints: Shell or command execution

Agent safety v2

42/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 yzfly-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/yzfly-golang-database/install
Install command: npx skills add yzfly/skills --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/yzfly-golang-database/install, then install with: npx skills add yzfly/skills --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

57/100

Database and SQL

Platforms

Claude Code

Audit report

Needs review · 74/100

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

View audit reportView eval report

Agent decision cockpit

Needs validation for Database and SQL

Do a manual repository review before adding this to an agent workflow.

57
Readiness
Review
Stage

Role in stack

Needs validation

Primary fit

Database and SQL

Trust label

Needs manual review

Install path

Command ready

Use when

  • Database and SQL workflows
  • Claude Code teams
  • builders willing to evaluate younger projects

Evidence

  • recent repository activity
  • install command or GitHub repo available
  • 58/100 quality profile

review first

  • Low GitHub adoption signal
  • No OpenAgentSkill engagement data yet

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.

62
OpenAgentSkill Trust Score

GitHub adoption

FIX

12 GitHub stars

Stars/forks activity

FIX

12 stars, 2 forks; issue activity unavailable in current metadata

Recent maintenance

PASS

Pushed today

License clarity

PASS

MIT

Good signals

  • AI review approved
  • Install path is available
  • Repository evidence is available
  • Recently maintained repository
  • 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.
  • Low GitHub adoption signal
  • Quality score needs review
  • Permission surface needs review: shell or command execution, filesystem or document access
  • GitHub adoption: 12 GitHub stars
  • Stars/forks activity: 12 stars, 2 forks; issue activity unavailable in current metadata
  • 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

Promising candidate for agent workflows

Useful candidate, but compare it with alternatives before adopting.

58
GitHub stars
12
Freshness
Today
Install ready
Yes
License
MIT
Review before install: Low GitHub adoption signal

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. Covers parameterized queries, struct scanning, NULLable column handling, error patterns, transactions, isolation levels, SELECT FOR UPDATE, connection pool, batch processing, context propagation, and migration tooling. Use this skill whenever writing, reviewing, or debugging Golang code that interacts with PostgreSQL, MariaDB, MySQL, or SQLite. Also triggers for database testing or any question about database/sql, sqlx, pgx, or SQL queries in Golang. This skill explicitly does NOT generate database schemas or migration SQL." user-invocable: true license: MIT compatibility: Designed for Claude Code or similar AI coding agents, and for projects using Golang. metadata: author: samber version: "1.1.2" 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 ---

**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 23, 2026
Published
Aug 23, 2026

Decision snapshot

Needs validation

57
Ready
Review
Stage

recent repository activity

Audit

Install review

Install and adoption review

74
Needs review
Security
77/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. Covers parameterized queries, struct scanning, NULLable column handling, error...

12 stars

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

Install: npx skills add yzfly/skills --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
yzfly
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 yzfly 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/yzfly-golang-database?metric=listed&label=Listed)](https://www.openagentskill.com/skills/yzfly-golang-database)
[![OpenAgentSkill Trust](https://www.openagentskill.com/api/badge/yzfly-golang-database?metric=trust&label=Trust)](https://www.openagentskill.com/skills/yzfly-golang-database)
[![OpenAgentSkill Audit](https://www.openagentskill.com/api/badge/yzfly-golang-database?metric=audit&label=Audit)](https://www.openagentskill.com/skills/yzfly-golang-database/audit)
[![Agent Proven](https://www.openagentskill.com/api/badge/yzfly-golang-database?metric=proven&label=Agent%20Proven)](https://www.openagentskill.com/skills/yzfly-golang-database)

Author

Y

yzfly

@yzfly

Platform fit

Health signals

GitHub stars
12
Quality score
32/100
Last GitHub push
Aug 23, 2026
Framework hints
Unknown
OpenAgentSkill views
0
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

62
  • GitHub adoption12 GitHub starsFIX
  • Stars/forks activity12 stars, 2 forks; issue activity unavailable in current metadataFIX
  • Recent maintenancePushed todayPASS
  • License clarityMITPASS
  • README/SKILL.md completenessMetadata includes enough usage and workflow contextPASS
  • Dependency/runtime riskcommand execution surface, network or browser surfaceCHECK