db-context-postgres

db-context-postgres is a command for Claude Code from Mozurok/fhorja.dev. It costs 113 tokens per session (4,499 once invoked), scanned A, original, MIT.

A database inspection command for PostgreSQL, a relational database system. It checks whether the database can be reached and records selected schema details such as tables, columns, indexes, relationships, and optionally security policies and functions.

In plain words
What is it for?
Use it to capture context from PostgreSQL running in Cloud SQL, Kubernetes, a managed service, or your own infrastructure.
Why use it?
It gives a task a current, user-scoped view of the database before code or schema changes are planned. This reduces guesswork about the data structure and access rules.

Command for Claude Code

Written for Claude Code: a Claude Code command (commands/*.md). Also seen: reads .claude/ paths; reads ~/.codex paths; mentions Codex.

Good fit Use it to capture context from PostgreSQL running in Cloud SQL, Kubernetes, a managed service, or your own infrastructure.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/mozurok/fhorja.dev/db-context-postgres
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.

Clone the repo
git clone --depth 1 https://github.com/Mozurok/fhorja.dev

Made for: Claude Code.

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 db-context-postgres

README.md
[![agentmods](https://agentmods.dev/badge/commands/mozurok/fhorja.dev/db-context-postgres/github.svg)](https://agentmods.dev/commands/mozurok/fhorja.dev/db-context-postgres)
Your own site
<a href="https://agentmods.dev/commands/mozurok/fhorja.dev/db-context-postgres"><img src="https://agentmods.dev/badge/commands/mozurok/fhorja.dev/db-context-postgres/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 db-context-postgres

Your own site · 80×15
<a href="https://agentmods.dev/commands/mozurok/fhorja.dev/db-context-postgres"><img src="https://agentmods.dev/badge/commands/mozurok/fhorja.dev/db-context-postgres.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 113 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,499 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.00113 $0.04499
Opus 5.5 $0.00045 $0.01800
Sonnet 5.5 $0.00023 $0.00900
Haiku 4.5 $0.00011 $0.00450

Measured 13d ago against content hash ec136e4051da, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

db-context-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 13d 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.

commands/db-context-postgres.md · 178 lines

How it starts

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

db-context-postgres

Act as a senior/staff engineering database context capture for the active task, scoped to a generic Postgres deployment (GCP Cloud SQL, GKE Autopilot Postgres, self-hosted, AWS RDS, etc.) accessed via psql or pg_dump.

Goal: Validate that connection params resolve to a reachable Postgres instance, introspect a user-scoped subset of the schema (extensions, tables, columns, indexes, foreign keys, and optionally RLS policies and functions), and persist the result as DB_CONTEXT.md inside the active task folder so the task has a grounded, point-in-time schema reference for planning, implementation, and review.

This command is opt-in. It is not part of the default task initialization flow; run it after task-init only when the task actually touches Postgres data, schema, or RLS.

Mandatory context bootstrap (before any output):

  • Read these sections in WORKFLOW_OPERATING_SYSTEM.md first:
    • ## LLM execution contract
    • ## Editor mode policy (mode definitions only; the tool mapping table is lazy-loaded in wos/editor-mode-mappings.md and needed only for non-Claude-Code tools)
    • ## Global output contract (including Adaptive handoff and Mode selection rule)
    • ## Cross-cutting workflow guardrails
  • Bootstrap tiers: the light-weight commands (branch-commit, what-next, where-we-at, slice-closure, compact-task-memory) plus the high-frequency implement-approved-slice and sync-task-state (v3 wave1 item D) read the four sections above with two subsections of ## Cross-cutting workflow guardrails skipped: ### External web access (centralized) and ### Sequencing heuristics (by phase). Everything else is read at every tier, including ### Proposal vs approved persistence and ### Substrate peer ownership (per ADR-0034), since all seven write substrate sections and reason about PROPOSED (state-reconcile stays on the full tier for cross-artifact judgment). The full tier is measured at 12109 tokens, the four always-read sections combined; the two skipped subsections are 1,034 of those (measured 2026-09-28), so the reduced tier is about 11,074. The leaf-reviewer tier (verify-against-rubric, ADR-0226) reads only ## Global output contract, measured at 5215 tokens, plus its rubric.
  • Session bootstrap reuse (skip-if-unchanged; v3 wave1 item D): WHEN this conversation already read the bootstrap sections in an earlier turn still VISIBLE in the context window AND WORKFLOW_OPERATING_SYSTEM.md has not changed since, the command MAY skip the re-read and cite the earlier one, emitting one Command transcript line: Bootstrap: reusing turn <N> read, WOS unchanged. Scoped exception to the context-budget re-fetch rule (wos/context-budget.md, "The re-fetch rule"), because these sections are one large, static, byte-identical read repeated every turn; every other tool result still re-fetches. VISIBLE means the section text itself is still present and quotable now, not merely that a record of the earlier read exists: a harness that clears a tool result while the record survives (ADR-0114) has not satisfied VISIBLE, and self-declared memory after a compaction never qualifies. A stateless-per-turn harness is excluded. The transcript line is mandatory; a silent skip is invalid output.
  • Resolving the spec and wos/<topic>.md: canonical repository FIRST. Otherwise use active-adapter docs: ~/.claude/workflow-docs (CLAUDE_WORKFLOW_DOCS_DIR), ~/.cursor/workflow-docs (WORKFLOW_DOCS_DIR; project .cursor/workflow-docs on project installs), ~/.codex/workflow-docs (CODEX_WORKFLOW_DOCS_DIR), or <kimi-home>/workflow-docs (KIMI_WORKFLOW_DOCS_DIR). Nonempty overrides win. Kimi home: KIMI_CODE_HOME, else existing ~/.kimi-code, else existing ~/.kimi, default ~/.kimi-code. Use one root for both paths; try other adapters if absent or unknown. Report resolved root, fallback to other adapters, or missing mandatory context in ### Command transcript. Installed snapshots refresh and prune retired topics only on sync.
  • Read additional sections only when relevant to this command's role.
  • Align all routing recommendations and next-command suggestions with the current command set.
  • Official next-command names only: recommendations, including Run now, use registered names from commands/<name>.md or commands/<name>/SKILL.md; installed mode uses the available Fhorja command or skill inventory. No invented aliases. Run now: none with Mode: N/A ends only if no honest next step exists, defined under ### Official command names (routing integrity) (ADR-0126). Required inputs:
  • active task path (or enough context to resolve projects/<client>__<project>/active/YYYY-MM-DD_<task-slug>/)
  • connection params, provided via one of:
    • environment variables PGHOST, PGPORT, PGUSER, PGDATABASE, PGPASSWORD (or PGSSLMODE)
    • a DATABASE_URL (postgres://user:pass@host:port/dbname?sslmode=...)
    • a ~/.pgpass entry plus host/db identifiers
  • scope of introspection, supplied by the user as one or more of:
    • list of table names (qualified schema.table or unqualified for the default public schema)
    • list of schemas to include in full (use sparingly; large schemas should be narrowed)
  • depth flag (one of):
    • tables-only: tables, columns with types, primary keys, not-null flags, indexes, foreign keys
    • tables+rls (default): tables-only plus row-level security policies for each in-scope table when RLS is in use
    • full: tables+rls plus relevant functions, triggers, extensions, and server version metadata
  • optional: refresh flag (refresh to regenerate; default is to fail with NO_OP_TRACE if a non-stale DB_CONTEXT.md already exists for the same scope)

Read the full file on GitHub · 178 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. 13d ago Changed · -62 tokens per session ec136e4051da
  2. 16d ago Changed · -1 lines 625b34ad10c0
  3. 23d ago Changed · -1 lines 3c23089ba2f7
  4. 24d ago Changed · +1 lines · +89 tokens per session c3f6e0538102
  5. 1mo ago First seen · 179 lines · 86 tokens per session scan A 7657b6e2b341

Subscribe to this mod's changes

db-context-postgres is a command published in the GitHub repository Mozurok/fhorja.dev (10 stars, last pushed 13d ago), licensed MIT. It adds 113 tokens to every session and 4,499 once invoked, about $0.0005 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-09-03.