agentleFS
saifoellohsaifoelloh/golang-best-practices-skill/postgresql-syntax/SKILL.md

gorm-sql-postgresql-syntax

Skill15 starsChanged 9 months agoMITView on GitHub

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.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 22

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

PostgreSQL Syntax

Expert-level review of raw PostgreSQL SQL syntax in GORM/Go projects. Ensures correct Postgres-specific usage, idiomatic SQL, and avoids common runtime errors.

When to Apply

Use this skill when:

  • Writing raw SQL in db.Raw(), db.Exec(), or migration files
  • Debugging syntax error or operator does not exist PostgreSQL errors
  • Reviewing SQL expressions involving JSONB, UUID, timestamps, or reserved keywords
  • Using RETURNING, CTEs, window functions, or ILIKE

Rule Categories

PriorityCountFocus
Critical1Placeholder style mismatch
High4Identifier quoting, RETURNING, ILIKE, type casting
Medium4CTE readability, JSONB operators, INTERVAL, select redundancy

Rules Covered (9 total)

Critical Issues (1)

  • critical-placeholder-style — Use ? with GORM, $N only with pgx/pq directly

High-Impact Patterns (4)

  • high-identifier-quoting — Quote reserved keywords (order, user, group) in raw SQL
  • high-returning-clause — Use RETURNING for generated values after INSERT/UPDATE
  • high-ilike-search — Use ILIKE for case-insensitive search, not LOWER(col) LIKE
  • high-explicit-cast — Cast types explicitly (::uuid, ::bigint) to avoid operator does not exist

Medium Improvements (4)

  • medium-cte-readability — Use CTEs instead of nested subqueries for complex queries
  • medium-jsonb-operators — Use correct @>, ->>, -> operators for JSONB queries
  • medium-interval-arithmetic — Use INTERVAL for date math, not manual second calculations
  • medium-select-redundancy — Don't manually quote plain column names in .Select() (GORM handles it)

Trigger Phrases

  • "Check this raw SQL"
  • "db.Raw / db.Exec"
  • "SQL syntax error"
  • "operator does not exist"
  • "reserved keyword"
  • "JSONB query"
  • "PostgreSQL compatibility"

Cross-Reference with golang-best-practices-skill

Two rules in this skill directly extend rules from the companion database-repository skill in golang-best-practices-skill:

This skillgolang-best-practices-skillRelationship
high-identifier-quotinghigh-gorm-identifier-quotingExpanded — more Postgres examples, full reserved word list
medium-select-redundancymedium-gorm-select-redundancyMirror — same rule, cross-referenced

Related Skills

  • gorm-query-patterns — For ORM-level query patterns
  • query-performance — For index-related syntax (CONCURRENTLY, partial indexes)
  • migration-safety — For DDL SQL in migration files

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.