gorm-sql-gorm-query-patterns

gorm-sql-gorm-query-patterns is a skill for Claude Code, Codex from saifoelloh/golang-best-practices-skill. It costs 63 tokens per session (781 once invoked), scanned A, original, MIT.

A review guide for Go code that uses GORM, a library that maps Go data structures to database tables, with PostgreSQL. It covers query correctness, related records, transactions, errors, updates, and request context.

In plain words
What is it for?
Use it when writing, reviewing, or debugging GORM repository code, especially queries, relationship loading, transactions, pagination, and updates.
Why use it?
It helps prevent unsafe queries, missing errors, inefficient repeated database calls, and partially completed multi-step writes.

Skill for Claude CodeCodex

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

Good fit Use it when writing, reviewing, or debugging GORM repository code, especially queries, relationship loading, transactions, pagination, and updates.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/saifoelloh/golang-best-practices-skill/gorm-query-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 saifoelloh/golang-best-practices-skill --skill gorm-query-patterns
Clone the repo
git clone --depth 1 https://github.com/saifoelloh/golang-best-practices-skill

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

README.md
[![agentmods](https://agentmods.dev/badge/skills/saifoelloh/golang-best-practices-skill/gorm-query-patterns/github.svg)](https://agentmods.dev/skills/saifoelloh/golang-best-practices-skill/gorm-query-patterns)
Your own site
<a href="https://agentmods.dev/skills/saifoelloh/golang-best-practices-skill/gorm-query-patterns"><img src="https://agentmods.dev/badge/skills/saifoelloh/golang-best-practices-skill/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-sql-gorm-query-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/saifoelloh/golang-best-practices-skill/gorm-query-patterns"><img src="https://agentmods.dev/badge/skills/saifoelloh/golang-best-practices-skill/gorm-query-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 781 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.00063 $0.00781
Opus 5 $0.00032 $0.00391
Sonnet 5 $0.00013 $0.00156
Haiku 4.5 $0.00006 $0.00078

Measured 11d ago against content hash 088e57e33316, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

gorm-sql-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 11d 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.

gorm-query-patterns/SKILL.md · 87 lines

How it starts

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

GORM Query Patterns

Expert-level review of GORM ORM usage in Go services backed by PostgreSQL. Covers correctness, safety, and idiomatic patterns.

When to Apply

Use this skill when:

  • Writing or reviewing repository layer code using GORM
  • Debugging unexpected query behavior (wrong results, wrong ORDER, missing data)
  • Reviewing association loading (Preload, Joins)
  • Auditing multi-step write operations for transaction safety

Rule Categories

Priority Count Focus
Critical 3 SQL injection, silent errors, partial writes
High 5 N+1, First vs Find, Save vs Updates, context, column selection
Medium 3 Scopes, pagination, association upserts

Rules Covered (11 total)

Critical Issues (3)

  • critical-sql-injection — Never concatenate user input into SQL strings
  • critical-error-check — Always check .Error after every GORM operation
  • critical-transaction-wrap — Wrap multi-step operations in db.Transaction()

High-Impact Patterns (5)

  • high-preload-vs-joins — Preload for loading, Joins for filtering
  • high-first-vs-find — First for single record, Find for lists
  • high-save-vs-updates — Use Updates with map for partial updates, not Save
  • high-with-context — Always pass context via db.WithContext(ctx)
  • high-select-columns — Select only required columns, never SELECT *

Medium Improvements (3)

  • medium-scopes — Extract reusable WHERE logic into GORM scopes
  • medium-pagination-order — Always include ORDER BY in paginated queries
  • medium-omit-associations — Use Omit to prevent unintended association upserts

Trigger Phrases

  • "Review this GORM query"
  • "Check repository layer"
  • "db.Find / db.First / db.Create / db.Where"
  • "Preload / Joins"
  • "GORM transaction"
  • "Is this GORM code correct?"
  • postgresql-syntax — For raw SQL correctness and Postgres-specific syntax
  • query-performance — For index usage and N+1 detection
  • error-handling — For GORM and PostgreSQL error handling patterns
  • golang-best-practices-skill database-repository — Companion Go skill covering identifier quoting and select redundancy

Read the full file on GitHub · 87 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. 11d ago First seen · 87 lines · 63 tokens per session scan A 088e57e33316

Subscribe to this mod's changes

gorm-sql-gorm-query-patterns is a skill published in the GitHub repository saifoelloh/golang-best-practices-skill (15 stars, last pushed 6mo ago), licensed MIT. It adds 63 tokens to every session and 781 once invoked, about $0.0003 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

multitenant

Architecture multitenant avec approche tiered (Shared/Dedicated Schema/DB), RBAC/ABAC, field-level encryption. Use when working with multitenant applications, tenant isolation, data segregation.

TheBeardedBearSAS/claude-craft · 46 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

azure-postgres-ts

Connect to Azure Database for PostgreSQL Flexible Server from Node.js/TypeScript using the pg (node-postgres) package. Use for PostgreSQL queries, connection pooling, transactions, and Microsoft Entra ID (passwordless) authentication. Triggers: "PostgreSQL", "postgres", "pg client", "node-postgres", "Azure PostgreSQL…

microsoft/skills · 94 tokens

butterbase

AI-native, open-source backend-as-a-service with a built-in Model Context Protocol server. Postgres, auth, storage, functions, AI gateway.

butterbase-ai/butterbase · 34 tokens

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

supabase-cli

This skill should be used when user asks to "use supabase CLI", "supabase init", "supabase start", "run migrations", "deploy edge functions", "manage Supabase project", or works with the supabase command-line tool for local development and project management.

fcakyon/claude-codex-settings · 60 tokens