go-database

go-database is a skill for Claude Code, Codex from muratmirgun/gophers. It costs 98 tokens per session (2,256 once invoked), scanned A, original, MIT.

A guide to connecting Go programs to SQL databases such as PostgreSQL, MySQL, MariaDB, and SQLite.

In plain words
What is it for?
Use it when writing or debugging queries, scanning results, passing cancellation deadlines, managing transactions, and choosing a Go database library.
Why use it?
It helps avoid SQL injection, stuck database calls, leaked connections, incorrect handling of missing rows, and poorly limited connection pools.

Skill for Claude CodeCodex

Part of the gophers plugin — 26 skills, 4 agents shipped together

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.

agentmods
npx agentmods add skills/muratmirgun/gophers/go-database
Any agent
npx skills add muratmirgun/gophers --skill go-database
Clone the repo
git clone --depth 1 https://github.com/muratmirgun/gophers

Made for: Claude Code, Codex.

Or install gophers, the plugin that ships this one along with the rest of its 26 skills, 4 agents.

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 go-database

README.md
[![agentmods](https://agentmods.dev/badge/skills/muratmirgun/gophers/go-database.svg)](https://agentmods.dev/skills/muratmirgun/gophers/go-database)
Your own site
<a href="https://agentmods.dev/skills/muratmirgun/gophers/go-database"><img src="https://agentmods.dev/badge/skills/muratmirgun/gophers/go-database.svg" alt="Measured on agentmods" height="20"></a>
Per session 98 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,256 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00098 $0.02256
Opus 5 $0.00049 $0.01128
Sonnet 5 $0.00020 $0.00451
Haiku 4.5 $0.00010 $0.00226

Measured 4d ago against content hash e5e2acd03d62, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

go-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 4d 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.

.claude-plugin/skills/go-database/SKILL.md · 203 lines

How it starts

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

Go Database

Go's database/sql is a thin, driver-pluggable foundation. Most projects layer one of sqlx, sqlc, or pgx on top for ergonomics. ORMs (GORM, ent) trade SQL visibility for one less line of code — a bad trade in production.

Core Rules

  1. SQL is the source of truth. It is reviewed, version-controlled, and explained in code. Magic ORM queries are the opposite.
  2. Always parameterize. $1/? placeholders, never string concatenation. The driver handles escaping; you cannot.
  3. Every I/O call takes ctx. QueryContext, ExecContext, GetContext. No context = no timeout = a stuck handler.
  4. Distinguish "not found" from "error". errors.Is(err, sql.ErrNoRows) is a domain signal, not a failure.
  5. Close rows. defer rows.Close() immediately after QueryContext. Forgetting it leaks a pool connection.
  6. Configure the pool. Default MaxOpenConns is unlimited — a runaway request rate exhausts the DB.

Library Decision

Library Best for Struct scanning Code-gen
database/sql Minimal deps, multi-driver portability Manual Scan No
sqlx Sweetens database/sql ergonomics StructScan, Get, Select No
sqlc Type-safe queries derived from .sql files Generated structs and funcs Yes
pgx (v5) PostgreSQL-only, 30-50% faster, native types pgx.RowToStructByName No
GORM / ent Avoid in new code Reflection Yes

Why not ORMs.

  • Generated queries are unpredictable; N+1 problems are invisible at the call site.
  • Hooks (BeforeCreate, AfterUpdate) create implicit state machines.
  • Schema migrations entangle with application code.
  • Learning the ORM API is harder than learning SQL, and the abstraction leaks at every interesting query.

Read references/library-tradeoffs.md when picking between sqlx, sqlc, and pgx for a new project.

Parameterized Queries

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

// Good — placeholder, driver-escaped.
err := db.GetContext(ctx, &u, "SELECT id, email FROM users WHERE email = $1", email)

Read the full file on GitHub · 203 lines

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. 4d ago First seen · 203 lines · 98 tokens per session scan A e5e2acd03d62

Subscribe to this mod's changes

go-database is a skill published in the GitHub repository muratmirgun/gophers (8 stars, last pushed 23d ago), licensed MIT. It adds 98 tokens to every session and 2,256 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-31.

Related

Other skills, from other repositories

convex

Build and operate Convex backends: functions (queries/mutations/actions/http actions), schemas, auth patterns, scheduling (cron/scheduled/workflows), file storage, components, migrations, performance, testing, and debugging. Triggers: "convex", "query", "mutation", "action", "httpAction", "schema", "validator"…

bntvllnt/agent-skills · 160 tokens

django-safe-migration

Write, review, and rewrite Django migrations for PostgreSQL with zero-downtime guarantees. Use this skill whenever the user mentions migrations, Django schema changes, or deployment safety — even if they don't say "zero downtime" explicitly. Trigger on: "review this migration", "is this migration safe?", "write a…

vintasoftware/django-ai-plugins · 156 tokens

agent-platform-rag-engine-management

Manage and query Agent Platform RAG Engine Corpora and retrieve grounded contexts using the Google GenAI SDK. Use when listing RAG corpora or files, inspecting a corpus, retrieving contexts, or generating content grounded in a RAG corpus. Do not use for standard database queries (use SQL/Spanner skills), Google…

google/skills · 85 tokens

alloydb-basics

Manages clusters, instances, and backups for AlloyDB for PostgreSQL, and integrates with AlloyDB Model Context Protocol (MCP) tools for automated database operations. Use when creating, configuring, or administering AlloyDB databases. Do NOT use for general PostgreSQL instances (e.g. Cloud SQL) or other GCP databases.

google/skills · 72 tokens

cloud-databases-onboarding

Guides users through discovering their database requirements, recommends a Google Cloud database based on a recommendation matrix, and assists in database creation. Use when a user asks 'What database service should I use?', 'Help me pick a database', or when a user wants to create a new database on Google Cloud.…

google/skills · 83 tokens

cloud-monitoring-metric-selection

Retrieve, query, and identify relevant Google Cloud Monitoring metric descriptors for a GCP service or resource (such as Compute Engine, Spanner, BigQuery, Cloud Run, Cloud SQL, Pub/Sub, Cloud Storage, etc.). Use when asked to find, list, search, or discover GCP metric types, names, kind/value schemas, or descriptors.

google/skills · 78 tokens