memory-service: Skill for Claude Code

.skills/gorm-query-patterns/SKILL.md

gorm-query-patterns is a skill for Claude Code, Codex from chirino/memory-service. It costs 96 tokens per session (806 once invoked), scanned A, original, Apache-2.0.

A set of rules for writing and reviewing Go database queries that use GORM, a Go library for working with databases. It explains how to handle lists, single-row lookups, ordering, and expected missing records.

In plain words
What is it for?
Use it when editing PostgreSQL or SQLite storage code, choosing between GORM query methods, or handling records that may be absent.
Why use it?
It helps prevent queries from reading unintended rows and keeps normal “not found” cases from becoming noisy errors.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

This is chirino/memory-service's own configuration. It tells Claude Code and Codex how to work on memory-service itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything memory-service configures →

Reuse

Borrowing it

Nothing to install: this file belongs to chirino/memory-service. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/chirino/memory-service/main/.skills/gorm-query-patterns/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/chirino/memory-service

Made for: Claude Code, Codex.

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 gorm-query-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/chirino/memory-service/gorm-query-patterns/github.svg)](https://agentmods.dev/skills/chirino/memory-service/gorm-query-patterns)
Your own site
<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/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 gorm-query-patterns

Your own site · 80×15
<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="Reviewed on agentmods" width="80" height="20"></a>
Per session 96 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 806 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.00096 $0.00806
Opus 5.5 $0.00038 $0.00322
Sonnet 5.5 $0.00019 $0.00161
Haiku 4.5 $0.00010 $0.00081

Measured 1mo ago against content hash 184dc57c458a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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 1mo 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/gorm-query-patterns/SKILL.md · 83 lines

How it starts

The opening of the file, as written. The whole thing — 83 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 on RowsAffected.
  • Do not use Find(&row) without Limit(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, or Last only when you want GORM to return ErrRecordNotFound.
  • Use First or Last only when the ordering is part of the behavior. Otherwise prefer Take for required single-row fetches.
  • When the store API returns a domain-level ErrNotFound or nil, nil for absence, do not route that control flow through gorm.ErrRecordNotFound; check RowsAffected instead.

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

  • GORM stores live in internal/plugin/store/postgres and internal/plugin/store/sqlite. Inside route-scoped transactions, get the handle with dbFor(ctx) / writeDBFor(ctx, ...), not s.db.
  • Example of the optional single-row pattern: internal/plugin/store/postgres/episodic_kind.go (Limit(1).Find(...) plus RowsAffected).
  • Prefer consistent query shapes within one file. If a helper uses the optional-single-row pattern, keep nearby helpers aligned.

Read the full file on GitHub · 83 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. 1mo ago Changed · -5 lines 184dc57c458a
  2. 2mo ago First seen · 88 lines · 96 tokens per session scan A 19453bf234be

Subscribe to this mod's changes

gorm-query-patterns is a skill published in the GitHub repository chirino/memory-service (12 stars, last pushed yesterday), licensed Apache-2.0. It adds 96 tokens to every session and 806 once invoked, about $0.0004 per session on Opus 5.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.