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.
npx agentmods add skills/chirino/memory-service/gorm-query-patternsnpx skills add chirino/memory-service --skill gorm-query-patternsgit clone --depth 1 https://github.com/chirino/memory-serviceWrote 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.
[](https://agentmods.dev/skills/chirino/memory-service/gorm-query-patterns)<a href="https://agentmods.dev/skills/chirino/memory-service/gorm-query-patterns"><img src="https://agentmods.dev/badge/skills/chirino/memory-service/gorm-query-patterns.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00096 | $0.00820 |
| Opus 5 | $0.00048 | $0.00410 |
| Sonnet 5 | $0.00019 | $0.00164 |
| Haiku 4.5 | $0.00010 | $0.00082 |
Grade A, and why
gorm-query-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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.
GORM Query Patterns
Use this skill when touching GORM-backed persistence code in this repo.
Base the query shape on whether "no row" is expected control flow or an exceptional condition.
Rules
- For slice reads, use
Find(&rows). An empty result set is normal. - For a single-row lookup where "not found" is expected, use
Limit(1).Find(&row)and branch onRowsAffected. - Do not use
Find(&row)withoutLimit(1)for a single struct destination. GORM's query docs warn that it can read more than one row and is not deterministic without a limit. - Use
Take,First, orLastonly when you want GORM to returnErrRecordNotFound. - Use
FirstorLastonly when the ordering is part of the behavior. Otherwise preferTakefor required single-row fetches. - When the store API returns a domain-level
ErrNotFoundornil, nilfor absence, do not route that control flow throughgorm.ErrRecordNotFound; checkRowsAffectedinstead.
Preferred Patterns
Expected absence, returning a domain ErrNotFound:
var row SomeRecord
result := tx.Where("user_id = ? AND external_id = ?", companyID, externalID).
Limit(1).
Find(&row)
if result.Error != nil {
return nil, result.Error
}
if result.RowsAffected == 0 {
return nil, ErrNotFound
}
return &row, nil
Expected absence, returning no result:
var row SomeRecord
result := tx.Where("user_id = ? AND status = ?", companyID, "running").
Order("started_at desc").
Limit(1).
Find(&row)
if result.Error != nil {
return nil, result.Error
}
if result.RowsAffected == 0 {
return nil, nil
}
return &row, nil
Required row, missing row is exceptional:
var row SomeRecord
if err := tx.Where("id = ? AND user_id = ?", id, companyID).Take(&row).Error; err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return ErrNotFound
}
return err
}
Repo Notes
- The noisy log pattern in this repo comes from optional lookups implemented with
Take(...)and then translated fromgorm.ErrRecordNotFound. - When reviewing
internal/store/gormstore, inspect helper methods first. A single helper often drives many log lines. - Prefer consistent query shapes within one file. If a helper uses the optional-single-row pattern, keep nearby helpers aligned.
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.
- 5d ago First seen · 88 lines · 96 tokens per session scan A 19453bf234be
gorm-query-patterns is a skill published in the GitHub repository chirino/memory-service (11 stars, last pushed yesterday), licensed Apache-2.0. It adds 96 tokens to every session and 820 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.
Other skills, from other repositories
encore-go-database
Work with PostgreSQL in Encore Go using sqldb.NewDatabase from encore.dev/storage/sqldb — schema migrations and SQL queries.
go-add-migration
Create properly named PostgreSQL migration files for GOB microservices.
mfd
MFD Generator — генерация Go-кода из PostgreSQL-схемы (модели, репозитории, фабрики тестов). Используй при правке .mfd файла, запуске make generate/make mfd, добавлении search-полей или db-test фабрик.
golang-fullstack-error-handling
Unified Go + GORM + PostgreSQL error handling review. Covers error wrapping, context propagation, PostgreSQL error codes (23505, 40001), errors.Is/As mapping, and retry logic. Ensures proper error chains and robust database failure recovery.
gorm-sql-postgresql-syntax
PostgreSQL SQL syntax review for Go/GORM projects. Use when writing or reviewing raw SQL used via db.Raw(), db.Exec(), or migrations. Covers placeholder style, reserved keyword quoting, RETURNING, ILIKE, JSONB operators, and type casting. Don't use for MySQL or SQLite.
azure-resource-manager-postgresql-dotnet
Azure PostgreSQL Flexible Server SDK for .NET. Database management for PostgreSQL Flexible Server deployments. Use for creating servers, databases, firewall rules, configurations, backups, and high availability. Triggers: "PostgreSQL", "PostgreSqlFlexibleServer", "PostgreSQL Flexible Server", "Azure Database for…