database-postgres

Project guidance for using PostgreSQL, a relational database, with Drizzle, repositories, migrations, row-level security, and application database clients.

In plain words
What is it for?
Use it when changing database schemas, repositories, migrations, platform adapters, or organization-aware PostgreSQL access.
Why use it?
It keeps database access consistent and ensures queries are scoped to the correct organization.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/latitude-dev/latitude-llm/database-postgres
Any agent
npx skills add latitude-dev/latitude-llm --skill database-postgres
Clone the repo
git clone --depth 1 https://github.com/latitude-dev/latitude-llm

Made for: Claude Code, Codex.

Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,128 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00039 $0.03128
Opus 5 $0.00019 $0.01564
Sonnet 5 $0.00008 $0.00626
Haiku 4.5 $0.00004 $0.00313

Measured 2d ago against content hash 3fc6b32ed2c8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

database-postgres 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 2d 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.

.agents/skills/database-postgres/SKILL.md · 279 lines

How it starts

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

Postgres, SqlClient, schema, migrations, mappers

When to use: Drizzle schema, repositories, RLS, SqlClient wiring, Postgres migrations, psql / reset, or platform mappers (toDomain* / toInsertRow).

Database patterns (Postgres)

  • Postgres adapter stack uses Drizzle ORM in packages/platform/db-postgres
  • Domain models are independent from table/row shapes
  • Mapping from DB rows to domain objects belongs in platform adapters
  • Apps use SqlClient for all DB access: Boundaries provide SqlClientLive with organization context for RLS enforcement

SqlClient and row-level security (RLS)

All Postgres access flows through SqlClient—a domain-level service that abstracts database operations and enforces organization scoping via RLS.

Architecture:

  • Domain Layer (@domain/shared): SqlClient interface with transaction() and query() methods
  • Platform Layer (@platform/db-postgres): SqlClientLive implementation with automatic RLS context setting
  • App Layer (apps/*): Boundaries provide SqlClientLive with the request's organization context

Key behaviors:

  • Every transaction automatically sets app.current_organization_id session variable
  • RLS policies filter all queries by this organization ID at the database level
  • Nested transactions share the same connection (pass-through proxy—no nested transaction overhead)
  • Domain errors propagate through Effect error channel; database errors become RepositoryError
  • On effect failure, SqlClientLive still awaits the Drizzle transaction promise so the connection returns to the pool; if the driver surfaces a different error than the Effect failure (for example rollback/commit), that secondary error is logged via @repo/observability while the original failure remains the propagated error

Usage in boundaries (apps):

// packages/operations/src/operations/projects.ts
import { SqlClientLive } from "@platform/db-postgres"
import { ProjectRepositoryLive } from "@platform/db-postgres"

app.openapi(createProjectRoute, async (c) => {
  const project = await Effect.runPromise(
    createProjectUseCase(input).pipe(
      Effect.provide(ProjectRepositoryLive),
      Effect.provide(SqlClientLive(c.var.postgresClient, c.var.organization.id)),
    ),
  )
  return c.json(toProjectResponse(project), 201)
})

Read the full file on GitHub · 279 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. 2d ago First seen · 279 lines · 39 tokens per session scan A 3fc6b32ed2c8

Subscribe to this mod's changes

database-postgres is a skill published in the GitHub repository latitude-dev/latitude-llm (4,611 stars, last pushed today), licensed MIT. It adds 39 tokens to every session and 3,128 once invoked, about $0.0002 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.