raw-sql-querybuilder-testing-patterns

raw-sql-querybuilder-testing-patterns is a skill for Claude Code from shennawardana23/skillme. It costs 87 tokens per session (1,582 once invoked), scanned A, original, Apache-2.0.

A guide for Go repositories that use the built-in database/sql package with a small custom query builder and mock database interfaces. Repositories are the code that reads and writes application data.

In plain words
What is it for?
Use it when adding or reviewing Go repository methods, SQL queries, transactions, and mock-based unit tests.
Why use it?
It explains how to keep this specific database layer easy to unit-test without using a full ORM or generated database code.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

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

Good fit Use it when adding or reviewing Go repository methods, SQL queries, transactions, and mock-based unit tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/shennawardana23/skillme/raw-sql-querybuilder-testing-patterns
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 raw-sql-querybuilder-testing-patterns
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 raw-sql-querybuilder-testing-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/shennawardana23/skillme/raw-sql-querybuilder-testing-patterns.svg)](https://agentmods.dev/skills/shennawardana23/skillme/raw-sql-querybuilder-testing-patterns)
Your own site
<a href="https://agentmods.dev/skills/shennawardana23/skillme/raw-sql-querybuilder-testing-patterns"><img src="https://agentmods.dev/badge/skills/shennawardana23/skillme/raw-sql-querybuilder-testing-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 87 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,582 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.00087 $0.01582
Opus 5 $0.00044 $0.00791
Sonnet 5 $0.00017 $0.00316
Haiku 4.5 $0.00009 $0.00158

Measured 4d ago against content hash 2f045c232a66, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-07, from the pricing page.

Security

Grade A, and why

raw-sql-querybuilder-testing-patterns 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.

skills/raw-sql-querybuilder-testing-patterns/SKILL.md · 143 lines

How it starts

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

Raw database/sql + Query Builder + Mock-Generated Repositories

A common Go data-access shape that isn't an ORM (GORM), a codegen tool (sqlc), or a fluent third-party builder (squirrel): a small, in-house query builder wrapping database/sql directly, plus interfaces over *sql.DB/ *sql.Tx specifically so mockgen-generated mocks can stand in for the database in unit tests. Distinct from postgres-patterns (which assumes pgx/idiomatic Postgres tooling) and database-migrations (which assumes a specific migration framework) — this skill is about the repository/ data-access layer itself when the stack is exactly this shape.

Interfaces exist for testability, not abstraction for its own sake

type Q interface {
    QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
    QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
    ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

//go:generate mockgen -destination=mocks/mock_db.go -package=mocks . Q

The point of wrapping *sql.DB/*sql.Tx behind a narrow interface like this is exclusively to let a repository be unit-tested against a generated mock instead of a real database — it is not a general abstraction layer to extend for its own sake. Keep the interface as narrow as the repository actually needs (the specific *Context methods it calls), not the full *sql.DB surface.

Translate driver errors at the repository boundary

func (r *RoomRepository) FindByID(ctx context.Context, id int64) (*Room, error) {
    row := r.db.QueryRowContext(ctx, "SELECT ... FROM rooms WHERE id = ?", id)
    var room Room
    if err := row.Scan(&room.ID, &room.Name /* ... */); err != nil {
        return nil, translateDBError(ctx, err)
    }
    return &room, nil
}

Callers above the repository layer should see a consistent, translated error type — not a raw driver error (sql.ErrNoRows, a MySQL-specific error code, a Postgres-specific error code) leaking upward. Centralize the translation once, at the boundary, rather than letting each repository method interpret driver errors its own way.

Read the full file on GitHub · 143 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. 4d ago First seen · 143 lines · 87 tokens per session scan A 2f045c232a66

Subscribe to this mod's changes

raw-sql-querybuilder-testing-patterns is a skill published in the GitHub repository shennawardana23/skillme (2 stars, last pushed 10d ago), licensed Apache-2.0. It adds 87 tokens to every session and 1,582 once invoked, about $0.0004 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

test-provenance-guard

Detects tests that pass by construction — tests that define a private copy of the function under test instead of importing the production module — and self-heals by extracting the inline logic to an exported function, updating production callers, and rewriting the test to import the export. Two checks: (1) static …

mthines/agent-skills · 207 tokens

test-auto-fix

Diagnoses failing tests across any project, classifies each failure as a test-bug, prod-bug, or unsure, confidence-gates the fix (auto-apply at >=90%, 80-89 ask, <80 escalate), applies it, and re-runs until green. Surface-driven: reads per-project configuration from a surface file keyed by normalised git remote URL.…

mthines/agent-skills · 166 tokens

dart-generate-test-mocks

A Dart testing workflow for creating generated mock objects with Mockito and build_runner. A mock is a controllable stand-in for an external service such as an API or database.

sutchan/Agent-Skills-Hub · 27 tokens

dart-add-unit-test

Organize test files to mirror the lib directory structure to maintain predictability.

sutchan/Agent-Skills-Hub · 23 tokens

flutter-add-widget-test

A guide for writing Flutter widget tests, which check individual interface components and their user interactions. Flutter is a toolkit for building apps from one Dart codebase.

sutchan/Agent-Skills-Hub · 25 tokens

diagnosing-bugs

A method for investigating difficult software bugs and performance slowdowns by building a repeatable feedback loop and testing possible causes.

sutchan/Agent-Skills-Hub · 32 tokens