golang-database

レビュー · 71
Registry に収録

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
スター3.0K
バージョン1.0.0
品質82/100 · 強い
信頼71/100 · サンドボックス限定
監査84/100 · 要レビュー

供給アセットの概要

コーディングと開発 Agent

コードレビュー、リポジトリ分析、テスト、CI、GitHub、DevOps、開発ワークフロー向けのスキルです。

カテゴリを見る

シナリオ

Database and SQL

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

Agent 適合

Claude Code + OpenAI Agents + CLI

Codex、Claude Code、Cursor、CLI、またはカスタム Agent に対応します。

インストール

準備完了

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

メンテナンス

新しい

最終プッシュから 2 日

リスク

要レビュー

Dependency or permission surface needs review

GitHub 品質

3.0K

82/100 品質 · 79/100 信頼

対象タグ

コーディングDatabase and SQLデザイン・クリエイティブagent-skill

レビュー注記

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

Agent 導入スコアカード

信頼、監査、インストール準備状況を一目で確認

公開リポジトリのメタデータ、OpenAgentSkill のレビューシグナル、保守の鮮度、インストール準備状況を組み合わせたスコアです。候補選定の目安であり、人によるレビューの代替ではありません。

品質

強い
82

本番ワークフローの候補に値する堅実な選択肢です。

信頼

サンドボックス限定
71

信頼シグナルが不足または混在する有用な候補です。結果ループがタスク適合を示すまで、隔離されたワークスペースで使用してください。

監査

要レビュー
84

インストール準備、安全メタデータ、保守、採用リスクの機械可読なレビュー。

OpenAgentSkill Trust Score v5

インストール前に人のレビュー

実作業で使う前に、サンドボックスでのみ実行し、近い代替と比較してください。

CodexClaude CodeCursorOpenAgentSkill CLI

スター

GitHub スター 3.0K

リポジトリ活動

スター 3.0K、フォーク 197

メンテナンス

最終プッシュから 2 日

ライセンス

MIT

インストール

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

インストール安全性

標準パッケージまたはランタイムのインストールパス

権限範囲

shell or command execution, filesystem or document access

Agent の成果

Agent の成果データはまだありません

ドキュメント

README/SKILL.md の文脈が十分です

リスク概要

本番前にレビュー

  • 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

インストール準備状況

インストールパスを利用可能

  • インストールパスを利用できます
  • リポジトリの根拠を利用できます
  • ライセンスが明示されています
  • Agent-Proven の成果エビデンスはまだありません

Agent 可読メタデータ

このスキルの機械可読な判断データ。

このブロックまたは埋め込み JSON を使い、Agent がこのスキルをインストールすべきか、代替を選ぶべきか、先に人のレビューを求めるべきかを判断できます。

JSON を開く

適したタスク

  • Database and SQL ワークフロー
  • Claude Code チーム
  • GitHub 採用シグナルを重視するチーム
  • Understand table relationships

適した Agent

CodexClaude CodeCursorOpenAgentSkill CLIOpenAI AgentsCLI

インストール判断

コマンド
npx skills add samber/cc-skills-golang --skill golang-database
ポリシー
レビュー
人によるレビュー
はい

信頼とリスク

信頼
71/100
監査
84/100
リスクレベル
要レビュー

成果ループ

エンドポイント
/api/agent/outcome
イベント ID
resolve
成果
5

インストールコマンド

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

使わない場合

  • ベンダー提供の SLA が必要なチーム
  • 内部セキュリティレビューのない高コンプライアンス環境
  • OpenAgentSkill の利用フィードバックはまだありません
  • 高リスク権限のヒント: Shell またはコマンド実行
  • Dependency or permission surface needs review
近い代替スキルはまだ登録されていません。

Agent セーフティ v2

52/100 · 自動インストールを避ける

実験的レビュー

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

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

API で解決

Shell またはコマンド実行

Skill メタデータに端末、CLI、Shell、サブプロセス、またはコマンド実行のワークフローが含まれます。

ネットワークアクセス

Skill はリモートページ、API、リポジトリ、外部サービスにアクセスする可能性があります。

ファイルシステムアクセス

Skill はプロジェクトファイル、ドキュメント、生成物、ローカルワークスペース状態を読み書きする可能性があります。

データベースアクセス

Skill はスキーマを確認し、データベースを照会し、永続ストアを扱う可能性があります。

  • 高リスク権限のヒント: Shell またはコマンド実行
  • Dependency or permission surface needs review

インストール先

Agent ワークフローにこのスキルをインストール

公開インストールエンドポイントからコマンド、安全チェックリスト、対象プロンプト、正規リンクを取得します。

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 解決プラン

インストール前に Agent に適合性を検証させます。

Resolve API は第一候補、代替、安全ポリシー、監査メモ、インストール先、Agent がそのまま使えるプロンプトを返します。

テキストプランを開く

Agent が確認すべきこと

  • Resolve API でタスク適合と代替を確認。
  • 監査・信頼スコアと安全ポリシーの警告を確認。
  • Codex、Claude Code、Cursor、CLI のインストール先互換性を確認。

プロンプトをコピー

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 引き継ぎ

別のディレクトリではなく、インストール経路を Agent に渡します。

公開インストールエンドポイントからコマンド、安全チェックリスト、対象プロンプト、正規リンクを取得します。

Install API を開く

Agent プロンプト

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 メタデータ

自動スキル選択用の Agent 可読プロファイル。

Registry API 経由で判断、信頼、監査、ユースケース、インストールのシグナルを提供し、UI をスクレイピングせずに Agent が順位付けできます。

Manifest を開く

Agent 適合

93/100

Database and SQL

プラットフォーム

Claude Code, OpenAI Agents

監査レポート

要レビュー · 84/100

インストール準備、安全メタデータ、保守、採用リスクの機械可読なレビュー。

監査レポートを見る評価レポートを見る

Agent 判断パネル

Database and SQL 向けの第一候補

有力候補として扱い、自分の Agent スタックで README とインストール経路を検証してください。

93
準備状況
採用
段階

スタック内の役割

第一候補

主な適合

Database and SQL

信頼ラベル

本番対応

インストールパス

コマンド準備済み

使う場面

  • Database and SQL ワークフロー
  • Claude Code チーム
  • GitHub 採用シグナルを重視するチーム

根拠

  • GitHub スター 3,010
  • 最近のリポジトリ活動
  • インストールコマンドまたは GitHub リポジトリが利用可能
  • 品質プロファイル 82/100

先にレビュー

  • OpenAgentSkill の利用フィードバックはまだありません

実装パス

  1. 1サンドボックスの Agent にインストールし、Database and SQL タスクを一度最初から最後まで実行します。
  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.

信頼プロファイル

サンドボックス限定

信頼シグナルが不足または混在する有用な候補です。結果ループがタスク適合を示すまで、隔離されたワークスペースで使用してください。

71
OpenAgentSkill Trust Score

GitHub 採用度

合格

GitHub スター 3.0K

スター/フォーク活動

情報

スター 3.0K、フォーク 197; 現在のメタデータでは Issue 活動を利用できません

最近のメンテナンス

合格

最終プッシュから 2 日

ライセンスの明確さ

合格

MIT

良いシグナル

  • AI レビュー承認済み
  • インストールパスを利用できます
  • リポジトリの根拠を利用できます
  • 最近保守されたリポジトリ
  • 意味のある GitHub 採用シグナル
  • インストールコマンドに明確な高リスクパターンはありません
  • 成果ループは準備済みですが、最初の実行が必要です

インストール前にレビュー

  • 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
  • 実際の Agent 成果レポートはまだありません
  • 無人インストールの前に人によるレビューが必要です

推奨アクション

実作業で使う前に、サンドボックスでのみ実行し、近い代替と比較してください。

品質プロファイル

強い Agent ワークフロー向けの候補

本番ワークフローの候補に値する堅実な選択肢です。

82
GitHub スター
3.0K
鮮度
2 日前
インストール準備完了
はい
ライセンス
MIT

ワークフロー適合

このスキルを使うシナリオ

ワークフロー適合

完全なワークフローに追加

概要

--- 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)

技術詳細

バージョン
1.0.0
ライセンス
MIT
最終更新
2026年8月20日
公開日
2026年8月20日

判断の要約

第一候補

93
準備完了
採用
段階

GitHub スター 3,010

監査

インストールレビュー

インストールと採用のレビュー

84
要レビュー
セキュリティ
79/100
メンテナンス
100/100
インストール
92/100
完全な監査を開く評価レポートを見る

Agent 実証エビデンス

Agent 実証エビデンス

Resolve、レビュー、インストール、限定実行後の成果レポート。

0
実証済み
Needs first agent run自動インストール: 先にレビュー最新: 不明
成功率
直近の失敗
成果
0
出力品質
失敗
0
非該当
0
インストール数
0
リスクによりブロック
0
設定が必要
0
本番
0

Agent の実行結果はまだありません。最初の実行では /api/agent/outcome を通じて成功、設定要件、リスクによるブロック、失敗、非該当を報告できます。

インストール

Agent ワークフローに追加

無料・オープンソース. 本番 Agent にインストールする前にレポートを確認してください。

成長ループ

共有キット

X

golang-database 用のシナリオベース草案です。X へ手動投稿できます。

キュレーターノート
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
X 下書きを開く
任意:インストールコマンド付きの返信
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
返信の下書きを開く

掲載元

Registry により登録

申請可能

この掲載は公開ソースから登録されており、メンテナー申請が承認されるまで公式として表示されません。

作成者
samber
インデックス作成者
OpenAgentSkill コミュニティインデックス

帰属は公開リポジトリまたは作成者プロフィールにリンクされています。作成者は掲載を申請して所有権シグナルを更新できます。

このスキルを申請

所有者の申請

このスキル掲載を申請

この Registry により登録 掲載は samber に帰属していますが、まだ公式として表示されていません。申請すると、確認済み所有者シグナルが追加され、今後の公開、インストール、監査更新の信頼性が高まります。

クリエイター被リンクキット

README にエビデンスバッジを追加

開発者がリポジトリを評価する場所で、正規掲載、現在の信頼・監査シグナル、実際の Agent-Proven エビデンスを表示します。

[![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)

作者

S

samber

@samber

プラットフォーム適合

健全性シグナル

GitHub スター
3.0K
品質スコア
47/100
最終 GitHub プッシュ
2026年8月20日
フレームワークのヒント
不明
OpenAgentSkill 閲覧数
0
インストールコピー数
0
外部クリック
0

コミュニティシグナル

このスキルが Agent ワークフローに役立つかを共有してください。集約されたフィードバックがランキングを改善します。

信頼と安全性

サンドボックス限定

71
  • GitHub 採用度GitHub スター 3.0K合格
  • スター/フォーク活動スター 3.0K、フォーク 197; 現在のメタデータでは Issue 活動を利用できません情報
  • 最近のメンテナンス最終プッシュから 2 日合格
  • ライセンスの明確さMIT合格
  • README/SKILL.md の完全性メタデータには十分な利用・ワークフロー文脈があります合格
  • 依存関係/ランタイムのリスクcommand execution surface, network or browser surface確認