golang-database

golang-database is a skill for Claude Code from shennawardana23/skillme. It costs 160 tokens per session (1,919 once invoked), scanned A, original, Apache-2.0.

A guide to connecting Go programs to databases, with focus on connection pools, query cancellation, and turning database rows into Go values. A connection pool reuses a limited set of database connections instead of opening one for every query.

In plain words
What is it for?
Configuring database/sql or pgxpool, querying PostgreSQL or MySQL, scanning rows into structs, and handling database errors.
Why use it?
It prevents common production problems such as too many open connections, ignored request cancellations, and incorrect handling of missing rows.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Part of the skillme plugin — 137 skills, 2 commands shipped together

Good fit Configuring database/sql or pgxpool, querying PostgreSQL or MySQL, scanning rows into structs, and handling database errors.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/shennawardana23/skillme/golang-database
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 shennawardana23/skillme --skill golang-database
Clone the repo
git clone --depth 1 https://github.com/shennawardana23/skillme

Made for: Claude Code.

Or install skillme, the plugin that ships this one along with the rest of its 137 skills, 2 commands.

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/shennawardana23/skillme/golang-database/github.svg)](https://agentmods.dev/skills/shennawardana23/skillme/golang-database)
Your own site
<a href="https://agentmods.dev/skills/shennawardana23/skillme/golang-database"><img src="https://agentmods.dev/badge/skills/shennawardana23/skillme/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/shennawardana23/skillme/golang-database"><img src="https://agentmods.dev/badge/skills/shennawardana23/skillme/golang-database.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 160 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,919 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.
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.00160 $0.01919
Opus 5 $0.00080 $0.00959
Sonnet 5 $0.00032 $0.00384
Haiku 4.5 $0.00016 $0.00192

Measured 8d ago against content hash 2f81f86bc01e, 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 8d 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.

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

How it starts

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

Go Database Driver Mechanics

postgres-patterns/mysql-patterns decide what SQL to write; database-migrations decides how schema changes ship safely; this skill covers the layer between them and your Go code — connection pooling, context propagation into queries, and scanning results without silent bugs.

Connection pooling: database/sql

sql.DB is already a connection pool, not one connection — sql.Open doesn't even connect until the first use. Configure it explicitly; the zero-value defaults (unlimited open connections, unlimited idle connections, no connection lifetime) are wrong for production:

db.SetMaxOpenConns(25)          // cap total connections the pool can hold
db.SetMaxIdleConns(25)          // keep idle conns ready instead of reopening
db.SetConnMaxLifetime(5 * time.Minute)  // force rotation past a load balancer/DB restart
db.SetConnMaxIdleTime(1 * time.Minute)  // release idle conns the pool doesn't need

SetMaxOpenConns with no SetMaxIdleConns set can thrash — connections open under load then get closed immediately once idle because the idle limit defaults lower, then reopen on the next request. Set both, and size them against the database's actual max_connections, not just your app's guess at concurrency.

Connection pooling: pgxpool (jackc/pgx/v5)

pgxpool.New(ctx, connString) or pgxpool.NewWithConfig(ctx, cfg) parse their own equivalents of the settings above onto a *pgxpool.Config: MaxConns, MinConns, MaxConnLifetime, MaxConnIdleTime, HealthCheckPeriod. Prefer pgxpool over database/sql + a pgx driver shim when you're on Postgres exclusively and want pgx-native features (typed arrays, COPY, batch, native context cancellation mid-query) — reach for database/sql when the code must stay database-agnostic or already depends on a database/sql-based library.

Always pass context through to the call that does I/O

Every query, exec, and prepare has a *Context variant — QueryContext, ExecContext, QueryRowContext, PrepareContext (pgx: Query, Exec, QueryRow already take ctx as their first argument). Using the non-context variant (db.Query instead of db.QueryContext(ctx, ...)) means the caller's cancellation or timeout has no way to reach the database driver — the query runs to completion regardless of what upstream gave up on.

Read the full file on GitHub · 163 lines

Files

What ships with it

1 file 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. 8d ago First seen · 163 lines · 160 tokens per session scan A 2f81f86bc01e

Subscribe to this mod's changes

golang-database is a skill published in the GitHub repository shennawardana23/skillme (2 stars, last pushed 13d ago), licensed Apache-2.0. It adds 160 tokens to every session and 1,919 once invoked, about $0.0008 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-09-03.

Related

Other skills, from other repositories

supabase

Use when doing ANY task involving Supabase. Triggers: Supabase products (Database, Auth, Edge Functions, Realtime, Storage, Vectors, Cron, Queues); client libraries and SSR integrations (supabase-js, @supabase/ssr) in Next.js, React, SvelteKit, Astro, Remix; auth issues (login, logout, sessions, JWT, cookies…

supabase/agent-skills · 185 tokens

postgres-drizzle

Proactively apply when creating APIs, backends, or data models. Triggers on PostgreSQL, Postgres, Drizzle, drizzle-orm, drizzle-kit, database, schema, pgTable, tables, columns, indexes, queries, migrations, ORM, relations, relational queries, joins, transactions, SQL, connection pooling, PgBouncer, N+1, JSONB, RLS…

ccheney/robust-skills · 119 tokens

backend-setup-stack

Bootstraps a local Node.js backend development stack with Docker, PostgreSQL, and an ORM (Prisma or Sequelize). Use this skill whenever the user wants to: initialize a new backend project, set up a Dockerized database locally, wire up an ORM with automated migrations, scaffold an Express server with a health endpoint…

WESTsyre21/setup-backend-stack · 155 tokens

backend-setup-stack

Use this skill when the user wants to initialize a local development environment using Docker, PostgreSQL, an npm server, and an ORM (Prisma/Sequelize) with automated migration workflows, including detection of existing migration metadata and database readiness checks.

WESTsyre21/setup-backend-stack · 54 tokens

postgresql-development-cloudbase

Use when building, debugging, or evaluating CloudBase PostgreSQL / CloudBase PG / PG mode apps, including Postgres schema setup, queryPgDatabase/managePgDatabase, JS SDK v3 app.rdb() CRUD/RPC, PG HTTP API fallback, RLS-style permissions, username-password auth, and Web CMS/admin CRUD flows backed by CloudBase PG.

sutchan/Agent-Skills-Hub · 77 tokens

minimal-web-baas-demo

A quick setup path for a small CloudBase web application with a database. CloudBase is a backend service that provides hosting and data storage, while CRUD means creating, reading, updating, and deleting records.

sutchan/Agent-Skills-Hub · 144 tokens