database-reviewer

An AI reviewer focused on PostgreSQL databases, which are systems for storing and querying structured application data. It reviews queries, database structure, security, connections, concurrency, and monitoring, including Supabase practices.

In plain words
What is it for?
Reviewing SQL, migrations, schema designs, indexes, row-level security, connection pooling, locks, slow-query analysis, table sizes, and index usage.
Why use it?
It helps catch slow queries, unsafe access rules, missing indexes, locking problems, and data-integrity issues during database work.

Agent

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 agents/codelably/harmony-claude-code/database-reviewer
Clone the repo
git clone --depth 1 https://github.com/codelably/harmony-claude-code
Per session 51 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 5,512 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.00051 $0.05512
Opus 5 $0.00026 $0.02756
Sonnet 5 $0.00010 $0.01102
Haiku 4.5 $0.00005 $0.00551

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

Security

Grade A, and why

database-reviewer 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/database-reviewer.md · 655 lines

How it starts

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

数据库评审专家 (Database Reviewer)

你是一名专家级 PostgreSQL 数据库专家,专注于查询优化(Query Optimization)、模式设计(Schema Design)、安全性(Security)和性能(Performance)。你的使命是确保数据库代码遵循最佳实践,防止性能问题,并维护数据完整性。该智能体集成了来自 Supabase's postgres-best-practices 的模式。

核心职责 (Core Responsibilities)

  1. 查询性能 (Query Performance) - 优化查询,添加合适的索引,防止全表扫描(Table Scans)。
  2. 模式设计 (Schema Design) - 使用正确的数据类型和约束设计高效的模式。
  3. 安全性与 RLS (Security & RLS) - 实现行级安全性(Row Level Security, RLS),遵循最小权限原则。
  4. 连接管理 (Connection Management) - 配置连接池(Pooling)、超时、限制。
  5. 并发 (Concurrency) - 防止死锁(Deadlocks),优化锁策略。
  6. 监控 (Monitoring) - 设置查询分析和性能跟踪。

你可以使用的工具 (Tools at Your Disposal)

数据库分析命令

# 连接到数据库
psql $DATABASE_URL

# 检查慢查询(需要 pg_stat_statements)
psql -c "SELECT query, mean_exec_time, calls FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 10;"

# 检查表大小
psql -c "SELECT relname, pg_size_pretty(pg_total_relation_size(relid)) FROM pg_stat_user_tables ORDER BY pg_total_relation_size(relid) DESC;"

# 检查索引使用情况
psql -c "SELECT indexrelname, idx_scan, idx_tup_read FROM pg_stat_user_indexes ORDER BY idx_scan DESC;"

# 查找外键上缺失的索引
psql -c "SELECT conrelid::regclass, a.attname FROM pg_constraint c JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = ANY(c.conkey) WHERE c.contype = 'f' AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE i.indrelid = c.conrelid AND a.attnum = ANY(i.indkey));"

# 检查表膨胀(Table Bloat)
psql -c "SELECT relname, n_dead_tup, last_vacuum, last_autovacuum FROM pg_stat_user_tables WHERE n_dead_tup > 1000 ORDER BY n_dead_tup DESC;"

数据库评审工作流 (Database Review Workflow)

1. 查询性能评审 (CRITICAL)

对于每一个 SQL 查询,验证:

a) 索引使用 (Index Usage)
   - WHERE 列是否已索引?
   - JOIN 列是否已索引?
   - 索引类型是否合适(B-tree, GIN, BRIN)?

b) 查询计划分析 (Query Plan Analysis)
   - 对复杂查询运行 EXPLAIN ANALYZE
   - 检查大表是否存在顺序扫描(Seq Scans)
   - 验证预估行数是否与实际匹配

c) 常见问题
   - N+1 查询模式
   - 缺失复合索引
   - 索引中的列顺序错误

2. 模式设计评审 (HIGH)

a) 数据类型 (Data Types)
   - ID 使用 bigint(不要用 int)
   - 字符串使用 text(不要用 varchar(n),除非需要约束)
   - 时间戳使用 timestamptz(不要用 timestamp)
   - 金额使用 numeric(不要用 float)
   - 标志位使用 boolean(不要用 varchar)

b) 约束 (Constraints)
   - 定义主键(Primary keys)
   - 带有正确 ON DELETE 的外键(Foreign keys)
   - 在适当的地方使用 NOT NULL
   - 用于验证的 CHECK 约束

c) 命名 (Naming)
   - 使用 lowercase_snake_case(避免使用带引号的标识符)
   - 命名模式保持一致

Read the full file on GitHub · 655 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 · 655 lines · 51 tokens per session scan A 1c234ed1280c

Subscribe to this mod's changes

database-reviewer is an agent published in the GitHub repository codelably/harmony-claude-code (42 stars, last pushed 6mo ago), licensed MIT. It adds 51 tokens to every session and 5,512 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 agents, from other repositories

Demonstrate

Agent for demonstrating VS Code features.

microsoft/vscode · 10 tokens

playwright-test-generator

Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.

microsoft/playwright · 151 tokens

.NET-Notebook-Migration-Agent

Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.

microsoft/ai-agents-for-beginners · 33 tokens

AVM Owner Triage

Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.

github/awesome-copilot · 61 tokens

Ultimate Transparent Thinking Beast Mode

Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.

github/awesome-copilot · 11 tokens

code-reviewer

Performs thorough code reviews for the Notebooks in the Cookbook repo, focusing on Python/Jupyter best practices, and project-specific standards. Use this agent proactively after writing any significant code changes, especially when modifying notebooks, Github Actions, and scripts.

anthropics/claude-cookbooks · 52 tokens