golang-database

golang-database is a skill for Claude Code from samber/cc-skills-golang. It costs 99 tokens per session (2,721 once invoked), scanned A, original, MIT.

A guide to writing Go code that reads and changes data in databases such as PostgreSQL. It covers queries, transactions, handling missing values, connection reuse, batches, and database migrations.

In plain words
What is it for?
Use it when building, reviewing, or debugging Go database access and transaction code.
Why use it?
It helps prevent unsafe queries, missed errors, leaked database resources, and incorrect data changes.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: mentions subagents; names the AskUserQuestion tool; positional $N argument.

Part of the cc-skills-golang plugin — 46 skills shipped together

Good fit Use it when building, reviewing, or debugging Go database access and transaction code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/samber/cc-skills-golang/golang-database
About the project

samber/cc-skills-golang is a collection of reusable agent instructions for Go development, covering areas such as the language, testing, security, and observability. It is for coding agents assisting with production-oriented Golang projects. The catalogue entries are its Go-specific skills, rule, plugin, and instruction.

samber/cc-skills-golang · 3,223 stars · on GitHub · skills.sh

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add samber/cc-skills-golang --skill golang-database
Clone the repo
git clone --depth 1 https://github.com/samber/cc-skills-golang

Made for: Claude Code.

Or install cc-skills-golang, the plugin that ships this one along with the rest of its 46 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for golang-database

README.md
[![agentmods](https://agentmods.dev/badge/skills/samber/cc-skills-golang/golang-database/github.svg)](https://agentmods.dev/skills/samber/cc-skills-golang/golang-database)
Your own site
<a href="https://agentmods.dev/skills/samber/cc-skills-golang/golang-database"><img src="https://agentmods.dev/badge/skills/samber/cc-skills-golang/golang-database/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for golang-database

Your own site · 80×15
<a href="https://agentmods.dev/skills/samber/cc-skills-golang/golang-database"><img src="https://agentmods.dev/badge/skills/samber/cc-skills-golang/golang-database.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 99 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,721 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • Socket pass 29 May 2026
  • Snyk pass 29 May 2026
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00099 $0.02721
Opus 5 $0.00049 $0.01360
Sonnet 5 $0.00020 $0.00544
Haiku 4.5 $0.00010 $0.00272

Measured 7d ago against content hash 34889bcf13c1, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

golang-database scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

2 near-identical copies found in the catalogue:

skills/golang-database/SKILL.md · 246 lines

How it starts

The opening of the file, as written. The whole thing — 246 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

Read the full file on GitHub · 246 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago Changed 34889bcf13c1
  2. 9d ago Changed cdee27b15737
  3. 12d ago First seen · 246 lines · 99 tokens per session scan A 3ebfcf48cdb5

Subscribe to this mod's changes

golang-database is a skill published in the GitHub repository samber/cc-skills-golang (3,223 stars, last pushed 4d ago), licensed MIT. It adds 99 tokens to every session and 2,721 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

Azure Cosmos Db Py

Build Azure Cosmos DB NoSQL services with Python/FastAPI following production-grade patterns. Use when implementing database client setup with dual auth (DefaultAzureCredential + emulator), service...

mayurrathi/awesome-agent-skills · 40 tokens

Azure Cosmos Ts

Azure Cosmos DB JavaScript/TypeScript SDK (@azure/cosmos) for data plane operations. Use for CRUD operations on documents, queries, bulk operations, and container management. Triggers: "Cosmos DB", "@azure/cosmos", "CosmosClient", "document CRUD", "NoSQL queries", "bulk operations", "partition key", "container.items".

mayurrathi/awesome-agent-skills · 78 tokens

Azure Data Tables Java

Build table storage applications with Azure Tables SDK for Java. Use when working with Azure Table Storage or Cosmos DB Table API for NoSQL key-value data, schemaless storage, or structured data at...

mayurrathi/awesome-agent-skills · 45 tokens

Azure Cosmos Java

Azure Cosmos DB SDK for Java. NoSQL database operations with global distribution, multi-model support, and reactive patterns. Triggers: "CosmosClient java", "CosmosAsyncClient", "cosmos database java", "cosmosdb java", "document database java".

mayurrathi/awesome-agent-skills · 58 tokens

Azure Cosmos Py

Azure Cosmos DB SDK for Python (NoSQL API). Use for document CRUD, queries, containers, and globally distributed data. Triggers: "cosmos db", "CosmosClient", "container", "document", "NoSQL", "partition key".

mayurrathi/awesome-agent-skills · 55 tokens

Azure Data Tables Py

Azure Tables SDK for Python (Storage and Cosmos DB). Use for NoSQL key-value storage, entity CRUD, and batch operations. Triggers: "table storage", "TableServiceClient", "TableClient", "entities", "PartitionKey", "RowKey".

mayurrathi/awesome-agent-skills · 57 tokens