go-database

go-database is a skill for Claude Code from eduardo-sl/go-agent-skills. It costs 103 tokens per session (1,409 once invoked), scanned A, original, MIT.

Patterns for connecting Go services to databases, including connection pools, SQL queries, transactions, migrations, and repository code. A connection pool manages reusable database connections so each request does not open a new one.

In plain words
What is it for?
Use it when adding database access, writing queries, configuring pools, handling transactions, creating migrations, or working with database/sql, sqlc, GORM, or ent.
Why use it?
It helps avoid connection leaks, overloaded databases, inconsistent transactions, inefficient queries, and missing database changes between environments.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: positional $N argument; mentions Claude Code.

Part of the go-agent-skills plugin — 33 skills shipped together

Good fit Use it when adding database access, writing queries, configuring pools, handling transactions, creating migrations, or working with database/sql, sqlc, GORM, or ent.

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

Made for: Claude Code.

Or install go-agent-skills, the plugin that ships this one along with the rest of its 33 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 go-database

README.md
[![agentmods](https://agentmods.dev/badge/skills/eduardo-sl/go-agent-skills/go-database/github.svg)](https://agentmods.dev/skills/eduardo-sl/go-agent-skills/go-database)
Your own site
<a href="https://agentmods.dev/skills/eduardo-sl/go-agent-skills/go-database"><img src="https://agentmods.dev/badge/skills/eduardo-sl/go-agent-skills/go-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 go-database

Your own site · 80×15
<a href="https://agentmods.dev/skills/eduardo-sl/go-agent-skills/go-database"><img src="https://agentmods.dev/badge/skills/eduardo-sl/go-agent-skills/go-database.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 103 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,409 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
  • 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.00103 $0.01409
Opus 5 $0.00051 $0.00705
Sonnet 5 $0.00021 $0.00282
Haiku 4.5 $0.00010 $0.00141

Measured 10d ago against content hash 7330e6a2a73a, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, 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 10d 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/(data)/go-database/SKILL.md · 158 lines

How it starts

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

Go Database Patterns

Database access is where most Go services spend their complexity budget. Get connection management, transactions, and query patterns right.

Detailed reference material, loaded on demand:

  • references/query-patterns.md — full query/scan/rows patterns, null handling, N+1 avoidance, connection-leak examples.
  • references/tooling.md — repository pattern implementation, sqlc annotated queries, migration tooling and rules.

Read a reference file only when the summary below is not enough.

1. Connection Management

Configure the pool explicitly — the default is unbounded connections:

func OpenDB(dsn string) (*sql.DB, error) {
    db, err := sql.Open("postgres", dsn)
    if err != nil {
        return nil, fmt.Errorf("open db: %w", err)
    }

    db.SetMaxOpenConns(25)
    db.SetMaxIdleConns(10)
    db.SetConnMaxLifetime(5 * time.Minute)
    db.SetConnMaxIdleTime(1 * time.Minute)

    if err := db.PingContext(context.Background()); err != nil {
        return nil, fmt.Errorf("ping db: %w", err)
    }

    return db, nil
}
Setting Guideline
MaxOpenConns Match your DB's max connections / number of app instances
MaxIdleConns 40-50% of MaxOpenConns
ConnMaxLifetime 5-10 minutes (prevents stale connections behind load balancers)
ConnMaxIdleTime 1-2 minutes

2. Query Rules

  1. Parameterized queries only — string concatenation into SQL is an injection vulnerability, no exceptions.
  2. Always pass context — use the *Context variants (QueryContext, QueryRowContext, ExecContext) so queries respect cancellation and timeouts.
  3. defer rows.Close() immediately after the error check, and check rows.Err() after the iteration loop.
  4. Handle sql.ErrNoRows explicitly with errors.Is, mapping it to a domain error like ErrUserNotFound.
var user User
err := db.QueryRowContext(ctx,
    "SELECT id, name, email FROM users WHERE id = $1", id,
).Scan(&user.ID, &user.Name, &user.Email)

if errors.Is(err, sql.ErrNoRows) {
    return nil, ErrUserNotFound
}
if err != nil {
    return nil, fmt.Errorf("get user %s: %w", id, err)
}

Read the full file on GitHub · 158 lines

Files

What ships with it

2 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. 10d ago First seen · 158 lines · 103 tokens per session scan A 7330e6a2a73a

Subscribe to this mod's changes

go-database is a skill published in the GitHub repository eduardo-sl/go-agent-skills (71 stars, last pushed 23d ago), licensed MIT. It adds 103 tokens to every session and 1,409 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

golang-database

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…

samber/cc-skills-golang · 99 tokens

golang-samber-hot

In-memory caching in Golang using samber/hot — eviction algorithms (LRU, LFU, TinyLFU, W-TinyLFU, S3FIFO, ARC, TwoQueue, SIEVE, FIFO), TTL, cache loaders, sharding, stale-while-revalidate, missing key caching, and Prometheus metrics. Apply when using or adopting samber/hot, when the codebase imports…

samber/cc-skills-golang · 122 tokens

vendor-update

Upgrade Go/Node.js vendor dependencies and sync tool versions. Use whenever the user says "upgrade dependencies", "update vendors", "vendor update", "run vendor-upgrade", "bump dependencies", "update packages", or asks to run the vendor-update Make target. This skill also checks scripts/build/version.mk after…

apache/skywalking-banyandb · 95 tokens

compiling

Compile and build the SkyWalking BanyanDB project. Use when the user asks to compile, build, or generate code for this project.

apache/skywalking-banyandb · 31 tokens

neo4j-driver-go-skill

Covers the Neo4j Go Driver v6 — driver lifecycle, ExecuteQuery, managed and explicit transactions, session config, error handling, data type mapping, and connection tuning. Use when writing Go code that connects to Neo4j, setting up NewDriver or ExecuteQuery, debugging sessions/transactions/result handling, or working…

neo4j-contrib/neo4j-skills · 143 tokens

go-add-migration

Create properly named PostgreSQL migration files for GOB microservices.

JotJunior/cstk · 17 tokens